forked from HariSekhon/Nagios-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_hbase_regionservers.pl
More file actions
executable file
·102 lines (84 loc) · 3.03 KB
/
check_hbase_regionservers.pl
File metadata and controls
executable file
·102 lines (84 loc) · 3.03 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/perl -T
# nagios: -epn
#
# Author: Hari Sekhon
# Date: 2013-07-28 23:39:55 +0100 (Sun, 28 Jul 2013)
#
# http://github.com/harisekhon
#
# License: see accompanying LICENSE file
#
$DESCRIPTION = "Nagios Plugin to check the number of RegionServers that are dead or alive using HBase Stargate Rest API (Thrift API doesn't support this information at time of writing)
Checks the number of dead RegionServers against warning/critical thresholds and lists the dead RegionServers";
$VERSION = "0.2";
use strict;
use warnings;
BEGIN {
use File::Basename;
use lib dirname(__FILE__) . "/lib";
}
use HariSekhonUtils;
use LWP::Simple '$ua';
$ua->agent("Hari Sekhon $progname $main::VERSION");
my $default_port = 20550;
$port = $default_port;
my $default_warning = 0;
my $default_critical = 0;
$warning = $default_warning;
$critical = $default_critical;
%options = (
"H|host=s" => [ \$host, "HBase Stargate Rest API server address to connect to" ],
"P|port=s" => [ \$port, "HBase Stargate Rest API server port to connect to (defaults to $default_port)" ],
"w|warning=s" => [ \$warning, "Warning threshold or ran:ge (inclusive) for dead regionservers (defaults to $default_warning)" ],
"c|critical=s" => [ \$critical, "Critical threshold or ran:ge (inclusive) for dead regionservers (defaults to $default_critical)" ],
);
@usage_order = qw/host port warning critical/;
get_options();
$host = validate_host($host);
$host = validate_resolvable($host);
$port = validate_port($port);
my $url = "http://$host:$port/status/cluster";
vlog_options "url", $url;
validate_thresholds();
vlog2;
set_timeout();
set_http_timeout($timeout - 1);
my $content = curl $url, "HBase Stargate";
$status = "OK";
my $live_servers;
my $dead_servers;
my $average_load;
if($content =~ /(\d+) live servers, (\d+) dead servers, (\d+(?:\.\d+)?) average load/){
$live_servers = $1;
$dead_servers = $2;
$average_load = $3;
} else {
quit "CRITICAL", "didn't find live/dead server count line in output from HBase Stargate, try rerunning with -vvv. If the Rest API output has changed plugin may need updating";
}
plural $live_servers;
$msg .= "$live_servers live regionserver$plural, ";
plural $dead_servers;
$msg .= "$dead_servers dead regionserver$plural";
check_thresholds($dead_servers);
$msg .= ", $average_load average load";
my $dead_servers_section = 0;
my @dead_servers;
my $dead_server;
foreach(split("\n", $content)){
if(/^\d+ dead servers/){
$dead_servers_section = 1;
}
next unless $dead_servers_section;
if(/^ {4}([^\s,]+)/){
$dead_server = $1;
$dead_server =~ s/:\d+$//;
push(@dead_servers, $dead_server);
}
}
if(@dead_servers){
@dead_servers = uniq_array @dead_servers;
plural scalar @dead_servers;
$msg .= ". Dead regionserver$plural: " . join(",", @dead_servers);
}
$msg .= " | live_regionservers=$live_servers dead_regionservers=$dead_servers;" . get_upper_thresholds() . ";0 hbase_load_average=$average_load";
quit $status, $msg;