-
Notifications
You must be signed in to change notification settings - Fork 503
/
check_ibm_biginsights_console_version.pl
executable file
·66 lines (50 loc) · 1.79 KB
/
check_ibm_biginsights_console_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
#!/usr/bin/perl -T
# nagios: -epn
#
# Author: Hari Sekhon
# Date: 2014-04-22 21:40:03 +0100 (Tue, 22 Apr 2014)
#
# https://github.com/HariSekhon/Nagios-Plugins
#
# License: see accompanying LICENSE file
#
# http://www-01.ibm.com/support/knowledgecenter/SSPT3X_2.1.2/com.ibm.swg.im.infosphere.biginsights.admin.doc/doc/rest_access_version.html
$DESCRIPTION = "Nagios Plugin to check IBM BigInsights Console version
Tested on IBM BigInsights Console 2.1.2.0";
$VERSION = "0.2";
use strict;
use warnings;
BEGIN {
use File::Basename;
use lib dirname(__FILE__) . "/lib";
}
use HariSekhonUtils;
use HariSekhon::IBM::BigInsights;
$ua->agent("Hari Sekhon $progname version $main::VERSION");
%options = (
%biginsights_options,
%expected_version_option,
);
get_options();
$host = validate_host($host);
$port = validate_port($port);
$user = validate_user($user);
$password = validate_password($password);
$expected_version = validate_regex($expected_version, "expected version") if defined($expected_version);
validate_ssl();
vlog2;
set_timeout();
my $url_prefix = "$protocol://$host:$port";
$status = "OK";
my $url = "$url_prefix/$api/configuration/getVersion";
# curl_biginsights expects json and version is returned as plain html
my $html = curl $url, "IBM BigInsights Console", $user, $password;
my $biginsights_version = trim($html);
$msg = $biginsights_version;
my $version_format_regex = qw/IBM.+BigInsights.+\d+\.\d+\.\d+/;
$biginsights_version =~ $version_format_regex or quit "UNKNOWN", "version string did not match expected regex ($version_format_regex), returned version: $msg";
if(defined($expected_version) and $biginsights_version !~ $expected_version){
critical;
$msg .= " (expected: $expected_version)";
}
quit $status, $msg;