forked from HariSekhon/Nagios-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_cloudera_manager_version.pl
executable file
·73 lines (55 loc) · 1.74 KB
/
check_cloudera_manager_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
#!/usr/bin/perl -T
# nagios: -epn
#
# Author: Hari Sekhon
# Date: 2014-04-11 20:11:15 +0100 (Fri, 11 Apr 2014)
#
# http://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 Cloudera Manager version via 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 4.8.2 and 5.0.0";
$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_options_tls,
"e|expected=s" => [ \$expected, "Expected version regex (optional)" ],
);
@usage_order = qw/host port user password tls ssl-CA-path tls-noverify expected/;
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);
vlog2;
set_timeout();
$status = "OK";
$url = "$api/cm/version";
cm_query();
check_cm_field("version");
$msg = "Cloudera Manager version '" . $json->{"version"} . "'";
if(defined($expected_regex)){
unless($json->{"version"} =~ $expected_regex){
critical;
$msg .= " (expected: '$expected')";
}
}
quit $status, $msg;