forked from HariSekhon/Nagios-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_cloudera_manager_cluster_version.pl
executable file
·78 lines (59 loc) · 1.91 KB
/
check_cloudera_manager_cluster_version.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/perl -T
# nagios: -epn
#
# Author: Hari Sekhon
# Date: 2014-04-11 20:11:15 +0100 (Fri, 11 Apr 2014)
#
# https://github.com/harisekhon/nagios-plugins
#
# License: see accompanying LICENSE file
#
# still calling v1 for compatability with older CM versions
#
# http://cloudera.github.io/cm_api/apidocs/v1/index.html
$DESCRIPTION = "Nagios Plugin to check given CDH Hadoop cluster major release version via Cloudera Manager Rest API
You may need to upgrade to Cloudera Manager 4.6 for the Standard Edition (free) to allow the API to be used, but it should work on all versions of Cloudera Manager Enterprise Edition
This is still using v1 of the API for compatability purposes
Tested on Cloudera Manager 5.0.0, 5.7.0 with CDH 4.6 and CDH 5.x clusters";
$VERSION = "0.1";
use strict;
use warnings;
BEGIN {
use File::Basename;
use lib dirname(__FILE__) . "/lib";
}
use HariSekhonUtils;
use HariSekhon::ClouderaManager;
$ua->agent("Hari Sekhon $progname version $main::VERSION");
my $expected;
%options = (
%hostoptions,
%useroptions,
%cm_option_cluster,
"list-clusters" => $cm_options_list{"list-clusters"},
%cm_options_tls,
"e|expected=s" => [ \$expected, "Expected cluster version regex (optional)" ],
);
get_options();
$host = validate_host($host);
$port = validate_port($port);
$user = validate_user($user);
$password = validate_password($password);
my $expected_regex = validate_regex($expected) if defined($expected);
validate_thresholds();
vlog2;
set_timeout();
$status = "OK";
list_cm_components();
$cluster = validate_cm_cluster();
$url = "$api/clusters/$cluster";
cm_query();
check_cm_field("version");
$msg = "cluster '$cluster' version '" . $json->{"version"} . "'";
if(defined($expected_regex)){
unless($json->{"version"} =~ $expected_regex){
critical;
$msg .= " (expected: '$expected')";
}
}
quit $status, $msg;