├── README.md ├── check_cisco_nexus ├── check_cisco_nexus_cpu.pl ├── check_cisco_nexus_hardware.pl └── check_cisco_nexus_mem.pl ├── check_diskstat ├── check_all_diskstat.sh └── check_diskstat.sh ├── check_mirapoint ├── check_mirapoint_connections.pl ├── check_mirapoint_cpu.pl ├── check_mirapoint_inboxes.pl ├── check_mirapoint_io.pl ├── check_mirapoint_kb.pl ├── check_mirapoint_lat.pl ├── check_mirapoint_mailqueue.pl ├── check_mirapoint_raid-health.pl └── check_mirapoint_storage.pl ├── check_msa_hardware └── check_msa_hardware.pl └── check_netapp_perf ├── check_netapp_allvols.pl └── check_netapp_nfsops.pl /README.md: -------------------------------------------------------------------------------- 1 | Here you can find my Nagios (and compatible) monitoring plug-ins. 2 | 3 | check_cisco_nexus : monitor Cisco datacenter switch (CPU, memory and sensors)
4 | check_msa_hardware : monitor HP MSA 2xxx storage bays sensors (Voltage, temperature, capacity and overall status)
5 | check_mirapoint : monitor Mirapoint messaging system, tested with Razorgate and Messaging backends. 6 | check_diskstat : monitor linux IO activity 7 | -------------------------------------------------------------------------------- /check_cisco_nexus/check_cisco_nexus_cpu.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : david.barbion@adeoservices.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Switch; 21 | use List::Util qw[min max]; 22 | use Net::SNMP qw(:snmp); 23 | use FindBin; 24 | use lib "$FindBin::Bin"; 25 | use lib "/usr/local/nagios/libexec"; 26 | 27 | #use utils qw($TIMEOUT %ERRORS &print_revision &support); 28 | use Nagios::Plugin qw(%ERRORS); 29 | use Data::Dumper; 30 | 31 | use vars qw($PROGNAME); 32 | use Getopt::Long; 33 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u $opt_d $opt_i $opt_authproto $opt_priv $opt_privproto); 34 | use constant true => "1"; 35 | use constant false => "0"; 36 | $PROGNAME = $0; 37 | my $version = 1; 38 | my $release = 0; 39 | sub print_help (); 40 | sub print_usage (); 41 | sub verbose; 42 | sub get_nexus_table; 43 | sub get_nexus_entries; 44 | sub get_nexus_component_location; 45 | sub evaluate_sensor; 46 | my $opt_d = 0; 47 | Getopt::Long::Configure('bundling'); 48 | GetOptions( 49 | "h" => \$opt_h, 50 | "help" => \$opt_h, 51 | "u=s" => \$opt_u, 52 | "username=s" => \$opt_u, 53 | "p=s" => \$opt_p, 54 | "password=s" => \$opt_p, 55 | "authprotocol=s" => \$opt_authproto, 56 | "k=s" => \$opt_k, 57 | "key=s" => \$opt_k, 58 | "priv=s" => \$opt_priv, 59 | "privprotocol=s" => \$opt_privproto, 60 | "V" => \$opt_V, 61 | "version" => \$opt_V, 62 | "v=s" => \$opt_v, 63 | "snmp=s" => \$opt_v, 64 | "C=s" => \$opt_C, 65 | "community=s" => \$opt_C, 66 | "w=s" => \$opt_w, 67 | "warning=s" => \$opt_w, 68 | "c=s" => \$opt_c, 69 | "critical=s" => \$opt_c, 70 | "H=s" => \$opt_H, 71 | "hostname=s" => \$opt_H, 72 | "d=s" => \$opt_d, 73 | "debug=s" => \$opt_d, 74 | "i" => \$opt_i, 75 | "sysdescr" => \$opt_i 76 | ); 77 | 78 | if ($opt_V) { 79 | print($PROGNAME. ': $Revision: ' . $version . '.' . $release . "\n"); 80 | exit $ERRORS{'OK'}; 81 | } 82 | 83 | if ($opt_h) { 84 | print_help(); 85 | exit $ERRORS{'OK'}; 86 | } 87 | 88 | $opt_H = shift unless ($opt_H); 89 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 90 | 91 | my $snmp = "1"; 92 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 93 | $snmp = $opt_v; 94 | } 95 | 96 | if ($snmp eq "3") { 97 | if (!$opt_u) { 98 | print "Option -u (--username) is required for snmpV3\n"; 99 | exit $ERRORS{'OK'}; 100 | } 101 | if (!$opt_p && !$opt_k) { 102 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 103 | exit $ERRORS{'OK'}; 104 | } 105 | elsif ($opt_p && $opt_k) { 106 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 107 | exit $ERRORS{'OK'}; 108 | } 109 | } 110 | 111 | $opt_C ||= 'public'; 112 | $opt_w ||= '80,70,60'; 113 | $opt_c ||= '90,80,70'; 114 | 115 | my $name = $0; 116 | $name =~ s/\.pl.*//g; 117 | 118 | #=== create a SNMP session ==== 119 | 120 | my ($session, $error); 121 | if ($snmp eq "1" || $snmp eq "2") { 122 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp, -maxmsgsize => "5000"); 123 | } 124 | elsif ($opt_p && $opt_priv && $opt_authproto && $opt_privproto) { 125 | ($session, $error) = Net::SNMP->session( 126 | -hostname => $opt_H, 127 | -version => $snmp, 128 | -username => $opt_u, 129 | -authpassword => $opt_p, 130 | -authprotocol => $opt_authproto, 131 | -privpassword => $opt_priv, 132 | -privprotocol => $opt_privproto, 133 | -maxmsgsize => "5000" 134 | ); 135 | } 136 | elsif ($opt_p && $opt_priv) { 137 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -privpassword => $opt_priv, -maxmsgsize => "5000"); 138 | } 139 | elsif ($opt_p && $opt_authproto) { 140 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -authprotocol => $opt_authproto, -maxmsgsize => "5000"); 141 | } 142 | elsif ($opt_p) { 143 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -maxmsgsize => "5000"); 144 | } 145 | elsif ($opt_k) { 146 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k, -maxmsgsize => "5000"); 147 | } 148 | 149 | # check that session opened 150 | if (!defined($session)) { 151 | print("UNKNOWN: SNMP Session : $error\n"); 152 | exit $ERRORS{'UNKNOWN'}; 153 | } 154 | 155 | # Here we go ! 156 | my $loglevel = $opt_d; 157 | my $result; 158 | my $key; 159 | my $value; 160 | my @perfparse; 161 | 162 | # parse sysDescr 163 | my $outlabel_oid; 164 | if ($opt_i) { 165 | 166 | # sysdescr 167 | $outlabel_oid = ".1.3.6.1.2.1.1.1.0"; 168 | } 169 | else { 170 | # sysname 171 | $outlabel_oid = ".1.3.6.1.2.1.1.5.0"; 172 | } 173 | verbose("get sysdescr ($outlabel_oid)", "5"); 174 | my $sysdescr = $session->get_request(-varbindlist => [$outlabel_oid]); 175 | if (!defined($sysdescr)) { 176 | print("UNKNOWN: SNMP get_request : " . $session->error() . "\n"); 177 | exit $ERRORS{'UNKNOWN'}; 178 | } 179 | verbose(" sysdescr is " . $sysdescr->{$outlabel_oid}, "5"); 180 | my $outlabel = $sysdescr->{$outlabel_oid} . ": "; 181 | 182 | my @nagios_return_code = ("OK", "WARNING", "CRITICAL", "UNKNOWN"); 183 | 184 | # prepare warning and critical thresholds 185 | my @warning_threshold = split(',', $opt_w) if (defined($opt_w)); 186 | my @critical_threshold = split(',', $opt_c) if (defined($opt_c)); 187 | 188 | use constant THRESHOLD_5_SECONDS => "0"; 189 | use constant THRESHOLD_1_MINUTE => "1"; 190 | use constant THRESHOLD_5_MINUTES => "2"; 191 | 192 | # define some useful constants 193 | 194 | #################### 195 | # cpmCPUTotalTable # 196 | #################### 197 | # base oid 198 | use constant cpmCPUTotalTable => ".1.3.6.1.4.1.9.9.109.1.1.1"; 199 | 200 | use constant cpmCPUTotalIndex => ".1.3.6.1.4.1.9.9.109.1.1.1.1.1"; 201 | use constant cpmCPUTotal5secRev => ".1.3.6.1.4.1.9.9.109.1.1.1.1.6"; 202 | use constant cpmCPUTotal1minRev => ".1.3.6.1.4.1.9.9.109.1.1.1.1.7"; 203 | use constant cpmCPUTotal5minRev => ".1.3.6.1.4.1.9.9.109.1.1.1.1.8"; 204 | 205 | ##################### RETRIEVE DATA ####################### 206 | ###### get the cpmCPU table 207 | verbose("get cpu statistics table", "5"); 208 | my %nexus_cpu = get_nexus_table(cpmCPUTotalTable, false); 209 | 210 | ########################################################################################### 211 | # 212 | ########################################################################################### 213 | my $cpu; 214 | my $label; 215 | my $cpu_data; 216 | my $return_code = $ERRORS{'OK'}; 217 | while ((my $id, $cpu) = each(%nexus_cpu)) { 218 | if (defined($cpu)) { 219 | my %cpu_data = %{$cpu}; 220 | my $five_sec = $cpu_data{&cpmCPUTotal5secRev}; 221 | my $one_min = $cpu_data{&cpmCPUTotal1minRev}; 222 | my $five_min = $cpu_data{&cpmCPUTotal5minRev}; 223 | 224 | if (($five_sec > $warning_threshold[&THRESHOLD_5_SECONDS]) || ($one_min > $warning_threshold[&THRESHOLD_1_MINUTE]) || ($five_min > $warning_threshold[&THRESHOLD_5_MINUTES])) { 225 | if (($five_sec > $critical_threshold[&THRESHOLD_5_SECONDS]) || ($one_min > $critical_threshold[&THRESHOLD_1_MINUTE]) || ($five_min > $critical_threshold[&THRESHOLD_5_MINUTES])) 226 | { 227 | $return_code = $ERRORS{'CRITICAL'}; 228 | } 229 | else { 230 | $return_code = $ERRORS{'WARNING'}; 231 | } 232 | } 233 | $label .= "cpu${id}-5_seconds=$five_sec%,cpu${id}-1_minute=$one_min%,cpu${id}-5_minutes=$five_min% "; 234 | push(@perfparse, 235 | "cpu${id}-5_seconds=$five_sec%;$warning_threshold[&THRESHOLD_5_SECONDS];$critical_threshold[&THRESHOLD_5_SECONDS];0;100 cpu${id}-1_minute=$one_min%;$warning_threshold[&THRESHOLD_1_MINUTE];$critical_threshold[&THRESHOLD_1_MINUTE];0;100 cpu${id}-5_minutes=$five_min%;$warning_threshold[&THRESHOLD_5_MINUTES];$critical_threshold[&THRESHOLD_5_MINUTES];0;100" 236 | ); 237 | } 238 | } 239 | 240 | print $outlabel. $nagios_return_code[$return_code] . " $label\n"; 241 | print "| "; 242 | foreach (@perfparse) { 243 | print "$_\n"; 244 | } 245 | exit($return_code); 246 | 247 | sub print_usage () 248 | { 249 | print "Usage:"; 250 | print "$PROGNAME\n"; 251 | print " -H (--hostname) Hostname to query - (required)\n"; 252 | print " -C (--community) SNMP read community (defaults to public,\n"; 253 | print " used with SNMP v1 and v2c\n"; 254 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 255 | print " 2 for SNMP v2c\n"; 256 | print " 3 for SNMP v3\n"; 257 | print " -k (--key) snmp V3 key\n"; 258 | print " -p (--password) snmp V3 password\n"; 259 | print " -u (--username) snmp v3 username \n"; 260 | print " --authprotocol snmp v3 authprotocol md5|sha \n"; 261 | print " --priv snmp V3 priv password\n"; 262 | print " --privprotocol snmp v3 privprotocol des|aes \n"; 263 | print " -V (--version) Plugin version\n"; 264 | print " -h (--help) usage help\n\n"; 265 | print " -i (--sysdescr) use sysdescr instead of sysname for label display\n"; 266 | print " -w (--warning) pass 3 values for warning threshold (5 seconds, 1 minute and 5 minutes cpu average usage in %, default is '80,70,60')\n"; 267 | print " -c (--critical) pass 3 values for critical threshold (5 seconds, 1 minute and 5 minutes cpu average usage in %, default is '90,80,70')\n"; 268 | print "\n"; 269 | print " -d (--debug) debug level (1 -> 15)"; 270 | } 271 | 272 | sub print_help () 273 | { 274 | print "##############################################\n"; 275 | print "# ADEO Services #\n"; 276 | print "##############################################\n"; 277 | print_usage(); 278 | print "\n"; 279 | } 280 | 281 | sub verbose 282 | { 283 | my $message = $_[0]; 284 | my $messagelevel = $_[1]; 285 | 286 | if ($messagelevel <= $loglevel) { 287 | print "$message\n"; 288 | } 289 | } 290 | 291 | sub get_nexus_table 292 | { 293 | my $baseoid = $_[0]; 294 | my $is_indexed = $_[1]; 295 | 296 | verbose("get table for oid $baseoid", "10"); 297 | if ($snmp == 1) { 298 | $result = $session->get_table(-baseoid => $baseoid); 299 | } 300 | else { 301 | $result = $session->get_table(-baseoid => $baseoid, -maxrepetitions => 20); 302 | } 303 | if (!defined($result)) { 304 | print("UNKNOWN: SNMP get_table : " . $session->error() . "\n"); 305 | exit $ERRORS{'UNKNOWN'}; 306 | } 307 | my %nexus_values = %{$result}; 308 | my $id; 309 | my $index; 310 | my %nexus_return; 311 | while (($key, $value) = each(%nexus_values)) { 312 | $index = $id = $key; 313 | if ($is_indexed) { 314 | $id =~ s/.*\.([0-9]+)\.[0-9]*$/$1/; 315 | $key =~ s/(.*)\.[0-9]*\.[0-9]*/$1/; 316 | $index =~ s/.*\.([0-9]+)$/$1/; 317 | verbose("key=$key, id=$id, index=$index, value=$value", "15"); 318 | $nexus_return{$id}{$key}{$index} = $value; 319 | $nexus_return{$id}{"id"}{$index} = $id; 320 | } 321 | else { 322 | $id =~ s/.*\.([0-9]+)$/$1/; 323 | $key =~ s/(.*)\.[0-9]*/$1/; 324 | verbose("key=$key, id=$id, value=$value", "15"); 325 | $nexus_return{$id}{$key} = $value; 326 | $nexus_return{$id}{"id"} = $id; 327 | } 328 | } 329 | return (%nexus_return); 330 | } 331 | 332 | sub get_nexus_entries 333 | { 334 | my (@columns) = @_; 335 | 336 | verbose("get entries", "10"); 337 | if ($snmp == 1) { 338 | $result = $session->get_entries(-columns => @columns); 339 | } 340 | else { 341 | $result = $session->get_entries(-columns => @columns, -maxrepetitions => 20); 342 | } 343 | if (!defined($result)) { 344 | print("UNKNOWN: SNMP get_entries : " . $session->error() . "\n"); 345 | exit $ERRORS{'UNKNOWN'}; 346 | } 347 | my %nexus_values = %{$result}; 348 | my $id; 349 | my %nexus_return; 350 | while (($key, $value) = each(%nexus_values)) { 351 | $id = $key; 352 | $id =~ s/.*\.([0-9]+)$/$1/; 353 | $key =~ s/(.*)\.[0-9]*/$1/; 354 | verbose("key=$key, id=$id, value=$value", "15"); 355 | $nexus_return{$id}{$key} = $value; 356 | $nexus_return{$id}{"id"} = $id; 357 | } 358 | return (%nexus_return); 359 | } 360 | 361 | -------------------------------------------------------------------------------- /check_cisco_nexus/check_cisco_nexus_hardware.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : david.barbion@adeoservices.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Switch; 21 | use List::Util qw[min max]; 22 | use Net::SNMP qw(:snmp); 23 | use FindBin; 24 | use lib "$FindBin::Bin"; 25 | use lib "/usr/local/nagios/libexec"; 26 | 27 | #use utils qw($TIMEOUT %ERRORS &print_revision &support); 28 | use Nagios::Plugin qw(%ERRORS); 29 | use Data::Dumper; 30 | 31 | use vars qw($PROGNAME); 32 | use Getopt::Long; 33 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u $opt_l $opt_d $opt_i $opt_a $opt_o $opt_authproto $opt_priv $opt_privproto); 34 | use constant true => "1"; 35 | use constant false => "0"; 36 | $PROGNAME = $0; 37 | my $version = 1; 38 | my $release = 0; 39 | sub print_help (); 40 | sub print_usage (); 41 | sub verbose; 42 | sub get_nexus_table; 43 | sub get_nexus_entries; 44 | sub get_nexus_component_location; 45 | sub evaluate_sensor; 46 | my $opt_d = 0; 47 | Getopt::Long::Configure('bundling'); 48 | GetOptions( 49 | "h" => \$opt_h, 50 | "help" => \$opt_h, 51 | "u=s" => \$opt_u, 52 | "username=s" => \$opt_u, 53 | "p=s" => \$opt_p, 54 | "password=s" => \$opt_p, 55 | "authprotocol=s" => \$opt_authproto, 56 | "k=s" => \$opt_k, 57 | "key=s" => \$opt_k, 58 | "priv=s" => \$opt_priv, 59 | "privprotocol=s" => \$opt_privproto, 60 | "V" => \$opt_V, 61 | "version" => \$opt_V, 62 | "v=s" => \$opt_v, 63 | "snmp=s" => \$opt_v, 64 | "C=s" => \$opt_C, 65 | "community=s" => \$opt_C, 66 | "w=s" => \$opt_w, 67 | "warning=s" => \$opt_w, 68 | "c=s" => \$opt_c, 69 | "critical=s" => \$opt_c, 70 | "H=s" => \$opt_H, 71 | "hostname=s" => \$opt_H, 72 | "a" => \$opt_a, 73 | "admin" => \$opt_a, 74 | "o" => \$opt_o, 75 | "oper" => \$opt_o, 76 | "d=s" => \$opt_d, 77 | "debug=s" => \$opt_d, 78 | "i" => \$opt_i, 79 | "sysdescr" => \$opt_i, 80 | "l" => \$opt_l, 81 | "list" => \$opt_l 82 | ); 83 | 84 | if ($opt_V) { 85 | print($PROGNAME. ': $Revision: ' . $version . '.' . $release . "\n"); 86 | exit $ERRORS{'OK'}; 87 | } 88 | 89 | if ($opt_h) { 90 | print_help(); 91 | exit $ERRORS{'OK'}; 92 | } 93 | 94 | $opt_H = shift unless ($opt_H); 95 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 96 | 97 | my $snmp = "1"; 98 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 99 | $snmp = $opt_v; 100 | } 101 | 102 | if ($snmp eq "3") { 103 | if (!$opt_u) { 104 | print "Option -u (--username) is required for snmpV3\n"; 105 | exit $ERRORS{'OK'}; 106 | } 107 | if (!$opt_p && !$opt_k) { 108 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 109 | exit $ERRORS{'OK'}; 110 | } 111 | elsif ($opt_p && $opt_k) { 112 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 113 | exit $ERRORS{'OK'}; 114 | } 115 | } 116 | 117 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 118 | 119 | my $name = $0; 120 | $name =~ s/\.pl.*//g; 121 | 122 | #=== create a SNMP session ==== 123 | 124 | my ($session, $error); 125 | if ($snmp eq "1" || $snmp eq "2") { 126 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp, -maxmsgsize => "5000"); 127 | } 128 | elsif ($opt_p && $opt_priv && $opt_authproto && $opt_privproto) { 129 | ($session, $error) = Net::SNMP->session( 130 | -hostname => $opt_H, 131 | -version => $snmp, 132 | -username => $opt_u, 133 | -authpassword => $opt_p, 134 | -authprotocol => $opt_authproto, 135 | -privpassword => $opt_priv, 136 | -privprotocol => $opt_privproto, 137 | -maxmsgsize => "5000" 138 | ); 139 | } 140 | elsif ($opt_p && $opt_priv) { 141 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -privpassword => $opt_priv, -maxmsgsize => "5000"); 142 | } 143 | elsif ($opt_p && $opt_authproto) { 144 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -authprotocol => $opt_authproto, -maxmsgsize => "5000"); 145 | } 146 | elsif ($opt_p) { 147 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -maxmsgsize => "5000"); 148 | } 149 | elsif ($opt_k) { 150 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k, -maxmsgsize => "5000"); 151 | } 152 | 153 | # check that session opened 154 | if (!defined($session)) { 155 | print("UNKNOWN: SNMP Session : $error\n"); 156 | exit $ERRORS{'UNKNOWN'}; 157 | } 158 | 159 | # Here we go ! 160 | my $loglevel = $opt_d; 161 | my $result; 162 | my $label; 163 | my $oid; 164 | my $unit = ""; 165 | my $return_result; 166 | my $output; 167 | my $total_connection = 0; 168 | my $key; 169 | my $value; 170 | my @perfparse; 171 | 172 | # parse sysDescr 173 | my $outlabel_oid; 174 | if ($opt_i) { 175 | 176 | # sysdescr 177 | $outlabel_oid = ".1.3.6.1.2.1.1.1.0"; 178 | } 179 | else { 180 | # sysname 181 | $outlabel_oid = ".1.3.6.1.2.1.1.5.0"; 182 | } 183 | verbose("get sysdescr ($outlabel_oid)", "5"); 184 | my $sysdescr = $session->get_request(-varbindlist => [$outlabel_oid]); 185 | if (!defined($sysdescr)) { 186 | print("UNKNOWN: SNMP get_request : " . $session->error() . "\n"); 187 | exit $ERRORS{'UNKNOWN'}; 188 | } 189 | verbose(" sysdescr is " . $sysdescr->{$outlabel_oid}, "5"); 190 | my $outlabel = $sysdescr->{$outlabel_oid} . ": "; 191 | 192 | # define some useful constants 193 | 194 | # entSensorValues table oids 195 | use constant entSensorType => ".1.3.6.1.4.1.9.9.91.1.1.1.1.1"; 196 | use constant entSensorScale => ".1.3.6.1.4.1.9.9.91.1.1.1.1.2"; 197 | use constant entSensorPrecision => ".1.3.6.1.4.1.9.9.91.1.1.1.1.3"; 198 | use constant entSensorValue => ".1.3.6.1.4.1.9.9.91.1.1.1.1.4"; 199 | use constant entSensorStatus => ".1.3.6.1.4.1.9.9.91.1.1.1.1.5"; 200 | use constant entSensorValueTimeStamp => ".1.3.6.1.4.1.9.9.91.1.1.1.1.6"; 201 | use constant entSensorValueUpdateRate => ".1.3.6.1.4.1.9.9.91.1.1.1.1.7"; 202 | use constant entSensorMeasuredEntity => ".1.3.6.1.4.1.9.9.91.1.1.1.1.8"; 203 | 204 | # all sensors types 205 | my @nexus_sensors_type = ("undefined", "other", "unknown", "voltsAC", "voltsDC", "amperes", "watts", "hertz", "celsius", "percentRH", "rpm", "cmm", "truthvalue", "special", "dBm"); 206 | 207 | # sensors scale 208 | my @nexus_sensors_scale = ("unknown", "yocto", "zepto", "atto", "femto", "pico", "nano", "micro", "milli", "units", "kilo", "mega", "giga", "tera", "exa", "peta", "zetta", "yotta"); 209 | 210 | # all sensors status 211 | my @nexus_sensors_status = ("undefined", "ok", "unavailable", "nonoperational"); 212 | 213 | # entSensorsThresholds oids 214 | use constant entSensorThresholdIndex => ".1.3.6.1.4.1.9.9.91.1.2.1.1.1"; 215 | use constant entSensorThresholdSeverity => ".1.3.6.1.4.1.9.9.91.1.2.1.1.2"; 216 | use constant entSensorThresholdRelation => ".1.3.6.1.4.1.9.9.91.1.2.1.1.3"; 217 | use constant entSensorThresholdValue => ".1.3.6.1.4.1.9.9.91.1.2.1.1.4"; 218 | use constant entSensorThresholdEvaluation => ".1.3.6.1.4.1.9.9.91.1.2.1.1.5"; # not used 219 | use constant entSensorThresholdNotificationEnable => ".1.3.6.1.4.1.9.9.91.1.2.1.1.6"; # not used 220 | 221 | my @nexus_sensors_threshold_relation = ("unknown", "less than", "less or equal than", "greater than", "greater or equal than", "equal to", "not equal to"); 222 | 223 | my @nagios_return_code = ("OK", "WARNING", "CRITICAL", "UNKNOWN"); 224 | 225 | # defines nexus sensor status 226 | use constant NEXUS_OK => 1; 227 | use constant NEXUS_MINOR => 10; 228 | use constant NEXUS_MAJOR => 20; 229 | use constant NEXUS_CRITICAL => 30; 230 | my @nexus_return_code; 231 | $nexus_return_code[&NEXUS_OK] = "OK"; 232 | $nexus_return_code[&NEXUS_MINOR] = "MINOR"; 233 | $nexus_return_code[&NEXUS_MAJOR] = "MAJOR"; 234 | $nexus_return_code[&NEXUS_CRITICAL] = "CRITICAL"; 235 | 236 | # nexus sensor status to nagios status table 237 | my @nexus_sensor_to_nagios; 238 | $nexus_sensor_to_nagios[&NEXUS_OK] = $ERRORS{'OK'}; 239 | $nexus_sensor_to_nagios[&NEXUS_MINOR] = $ERRORS{'WARNING'}; 240 | $nexus_sensor_to_nagios[&NEXUS_MAJOR] = $ERRORS{'CRITICAL'}, $nexus_sensor_to_nagios[&NEXUS_CRITICAL] = $ERRORS{'CRITICAL'}; 241 | ############### 242 | # entPhysical # 243 | ############### 244 | # entPhysical oids 245 | use constant entPhysicalIndex => ".1.3.6.1.2.1.47.1.1.1.1.1"; 246 | use constant entPhysicalDescr => ".1.3.6.1.2.1.47.1.1.1.1.2"; 247 | use constant entPhysicalVendorType => ".1.3.6.1.2.1.47.1.1.1.1.3"; 248 | use constant entPhysicalContainedIn => ".1.3.6.1.2.1.47.1.1.1.1.4"; 249 | use constant entPhysicalClass => ".1.3.6.1.2.1.47.1.1.1.1.5"; 250 | use constant entPhysicalParentRelPos => ".1.3.6.1.2.1.47.1.1.1.1.6"; 251 | use constant entPhysicalName => ".1.3.6.1.2.1.47.1.1.1.1.7"; 252 | use constant entPhysicalHardwareRev => ".1.3.6.1.2.1.47.1.1.1.1.8"; 253 | use constant entPhysicalFirmwareRev => ".1.3.6.1.2.1.47.1.1.1.1.9"; 254 | use constant entPhysicalSoftwareRev => ".1.3.6.1.2.1.47.1.1.1.1.10"; 255 | use constant entPhysicalSerialNum => ".1.3.6.1.2.1.47.1.1.1.1.11"; 256 | use constant entPhysicalMfgName => ".1.3.6.1.2.1.47.1.1.1.1.12"; 257 | use constant entPhysicalModelName => ".1.3.6.1.2.1.47.1.1.1.1.13"; 258 | use constant entPhysicalAlias => ".1.3.6.1.2.1.47.1.1.1.1.14"; 259 | use constant entPhysicalAssetID => ".1.3.6.1.2.1.47.1.1.1.1.15"; 260 | use constant entPhysicalIsFRU => ".1.3.6.1.2.1.47.1.1.1.1.16"; 261 | use constant entPhysicalMfgDate => ".1.3.6.1.2.1.47.1.1.1.1.17"; 262 | use constant entPhysicalUris => ".1.3.6.1.2.1.47.1.1.1.1.18"; 263 | 264 | my @nexus_entphysical_class = ("undefined", "other", "unknown", "chassis", "backplane", "container", "power supply", "fan", "sensor", "module", "port", "stack", "cpu"); 265 | 266 | # Base table OIDs 267 | use constant entSensorValueTable => ".1.3.6.1.4.1.9.9.91.1.1.1"; 268 | use constant entPhysicalTable => ".1.3.6.1.2.1.47.1.1.1"; 269 | use constant cefcFanTrayStatusTable => ".1.3.6.1.4.1.9.9.117.1.4.1"; 270 | use constant cefcFanCoolingTable => ".1.3.6.1.4.1.9.9.117.1.7.2"; 271 | use constant entSensorThresholdTable => ".1.3.6.1.4.1.9.9.91.1.2.1"; 272 | use constant cefcFRUPowerStatusTable => ".1.3.6.1.4.1.9.9.117.1.1.2"; 273 | 274 | # mib2 interface status OIDs 275 | use constant ifDescr => ".1.3.6.1.2.1.2.2.1.2"; 276 | use constant ifAdminStatus => ".1.3.6.1.2.1.2.2.1.7"; 277 | use constant ifOperStatus => ".1.3.6.1.2.1.2.2.1.8"; 278 | 279 | my @nexus_admin_oper_status = ("undefined", "up", "down", "testing"); 280 | 281 | # Fan 282 | use constant cefcFanTrayOperStatus => ".1.3.6.1.4.1.9.9.117.1.4.1.1.1"; 283 | 284 | use constant NEXUS_FANTRAY_UNKNOWN => "1"; 285 | use constant NEXUS_FANTRAY_UP => "2"; 286 | use constant NEXUS_FANTRAY_DOWN => "3"; 287 | use constant NEXUS_FANTRAY_WARNING => "4"; 288 | 289 | my @nexus_fantray_status = ("undefined", "unknown", "up", "down", "warning"); 290 | 291 | # nexus fantray status to nagios status table 292 | my @nexus_fantray_status_to_nagios; 293 | $nexus_fantray_status_to_nagios[&NEXUS_FANTRAY_UNKNOWN] = $ERRORS{'UNKNOWN'}; 294 | $nexus_fantray_status_to_nagios[&NEXUS_FANTRAY_UP] = $ERRORS{'OK'}; 295 | $nexus_fantray_status_to_nagios[&NEXUS_FANTRAY_DOWN] = $ERRORS{'WARNING'}, $nexus_fantray_status_to_nagios[&NEXUS_FANTRAY_WARNING] = $ERRORS{'CRITICAL'}; 296 | my @nexus_fancooling_unit = ("undefined", "cfm", "watts"); 297 | 298 | # PSU 299 | use constant cefcFRUPowerAdminStatus => ".1.3.6.1.4.1.9.9.117.1.1.2.1.1"; 300 | use constant cefcFRUPowerOperStatus => ".1.3.6.1.4.1.9.9.117.1.1.2.1.2"; 301 | use constant cefcFRUCurrent => ".1.3.6.1.4.1.9.9.117.1.1.2.1.3"; 302 | use constant cefcFRUPowerCapability => ".1.3.6.1.4.1.9.9.117.1.1.2.1.4"; 303 | use constant cefcFRURealTimeCurrent => ".1.3.6.1.4.1.9.9.117.1.1.2.1.5"; 304 | 305 | use constant NEXUS_PSU_OFFENVOTHER => "1"; 306 | use constant NEXUS_PSU_ON => "2"; 307 | use constant NEXUS_PSU_OFFADMIN => "3"; 308 | use constant NEXUS_PSU_OFFDENIED => "4"; 309 | use constant NEXUS_PSU_OFFENVPOWER => "5"; 310 | use constant NEXUS_PSU_OFFENVTEMP => "6"; 311 | use constant NEXUS_PSU_OFFENVFAN => "7"; 312 | use constant NEXUS_PSU_FAILED => "8"; 313 | use constant NEXUS_PSU_ONBUTFANFAIL => "9"; 314 | use constant NEXUS_PSU_OFFCOOLING => "10"; 315 | use constant NEXUS_PSU_OFFCONNECTORRATING => "11"; 316 | use constant NEXUS_PSU_ONBUTINLINEPOWERFAIL => "12"; 317 | 318 | my @nexus_psu_status = 319 | ("undefined", "offEnvOther", "on", "offAdmin", "offDenied", "offEnvPower", "offEnvTemp", "offEnvFan", "failed", "onButFanFail", "offCooling", "offConnectorRating", "onbutInlinePowerFail"); 320 | 321 | # nexus psu status to nagios status table 322 | my @nexus_psu_status_to_nagios; 323 | $nexus_psu_status_to_nagios[&NEXUS_PSU_OFFENVOTHER] = $ERRORS{'UNKNOWN'}; 324 | $nexus_psu_status_to_nagios[&NEXUS_PSU_ON] = $ERRORS{'OK'}; 325 | $nexus_psu_status_to_nagios[&NEXUS_PSU_OFFADMIN] = $ERRORS{'WARNING'}; 326 | $nexus_psu_status_to_nagios[&NEXUS_PSU_OFFDENIED] = $ERRORS{'WARNING'}; 327 | $nexus_psu_status_to_nagios[&NEXUS_PSU_OFFENVPOWER] = $ERRORS{'WARNING'}; 328 | $nexus_psu_status_to_nagios[&NEXUS_PSU_OFFENVTEMP] = $ERRORS{'WARNING'}; 329 | $nexus_psu_status_to_nagios[&NEXUS_PSU_OFFENVFAN] = $ERRORS{'WARNING'}; 330 | $nexus_psu_status_to_nagios[&NEXUS_PSU_FAILED] = $ERRORS{'CRITICAL'}; 331 | $nexus_psu_status_to_nagios[&NEXUS_PSU_ONBUTFANFAIL] = $ERRORS{'CRITICAL'}; 332 | $nexus_psu_status_to_nagios[&NEXUS_PSU_OFFCOOLING] = $ERRORS{'CRITICAL'}; 333 | $nexus_psu_status_to_nagios[&NEXUS_PSU_OFFCONNECTORRATING] = $ERRORS{'CRITICAL'}; 334 | $nexus_psu_status_to_nagios[&NEXUS_PSU_ONBUTINLINEPOWERFAIL] = $ERRORS{'CRITICAL'}; 335 | 336 | ##################### RETRIEVE DATA ####################### 337 | ###### get the sensor table 338 | verbose("get sensor table", "5"); 339 | my %nexus_sensors = get_nexus_table(entSensorValueTable, false); 340 | 341 | ###### get the sensor threshold table 342 | verbose("get sensor threshold table", "5"); 343 | my %nexus_sensors_thresholds = get_nexus_table(entSensorThresholdTable, true); 344 | 345 | ###### get the fru fan table 346 | verbose("get fru fan table", "5"); 347 | my %nexus_frufan = get_nexus_table(cefcFanTrayStatusTable, false); 348 | 349 | ###### get the fru PSU table 350 | verbose("get fru psu table", "5"); 351 | my %nexus_frupsu = get_nexus_table(cefcFRUPowerStatusTable, false); 352 | 353 | ###### get the physical table 354 | verbose("get entity physical table", "5"); 355 | 356 | # get only selected columns to speed up data retrieving 357 | my %nexus_entphysical = get_nexus_entries([ &entPhysicalDescr, &entPhysicalContainedIn, &entPhysicalClass ]); 358 | 359 | ###### get the physical table 360 | my %nexus_interface; 361 | if ($opt_a || $opt_o) { 362 | verbose("get interface table", "5"); 363 | 364 | # get only selected columns to speed up data retrieving 365 | if ($opt_a) { 366 | %nexus_interface = get_nexus_interface([ &ifDescr, &ifAdminStatus ]); 367 | } 368 | else { 369 | %nexus_interface = get_nexus_interface([ &ifDescr, &ifOperStatus ]); 370 | } 371 | } 372 | 373 | # When user want to list probes 374 | if ($opt_l) { 375 | print "List of probes:\n"; 376 | } 377 | 378 | ################################################################################# 379 | # parse the table to get the worst status and append it to the output string. # 380 | # nexus sensor can have many thresholds, so we test them and keep the worst one # 381 | ################################################################################# 382 | my $sensor; 383 | my $sensor_alarm; 384 | my $worse_status = 0; 385 | my @failed_items_description = (); 386 | my $number_of_sensors = 0; 387 | my $number_of_failed_sensors = 0; 388 | while ((my $id, $sensor) = each(%nexus_sensors)) { 389 | my $worse_sensor_status = NEXUS_OK; 390 | my $worse_sensor_description = ""; 391 | if (defined($sensor)) { 392 | $number_of_sensors++; 393 | my %sensor_data = %{$sensor}; 394 | 395 | # get all sensor thresholds data 396 | next if (!defined($nexus_sensors_thresholds{ $sensor_data{"id"} }{&entSensorThresholdRelation})); 397 | my %sensor_threshold_data = %{ $nexus_sensors_thresholds{ $sensor_data{"id"} }{&entSensorThresholdRelation} }; 398 | 399 | # test each threshold values and keep the worst one 400 | while ((my $thresh_index, my @thresh_data) = each(%sensor_threshold_data)) { 401 | my $sensor_value = $sensor_data{&entSensorValue}; 402 | my $thresh_value = $nexus_sensors_thresholds{ $sensor_data{"id"} }{&entSensorThresholdValue}{$thresh_index}; 403 | my $thresh_relation = $nexus_sensors_thresholds{ $sensor_data{"id"} }{&entSensorThresholdRelation}{$thresh_index}; 404 | my $thresh_severity = $nexus_sensors_thresholds{ $sensor_data{"id"} }{&entSensorThresholdSeverity}{$thresh_index}; 405 | 406 | # proceed with the evaluation (is sensor value {<=|<|=|!=|>|>=} threshold value) 407 | verbose("threshold data: thresh_value=$thresh_value tresh_relation=$thresh_relation thresh_severity=$thresh_severity sensor_value=$sensor_value", "15"); 408 | $sensor_alarm = evaluate_sensor($sensor_value, $thresh_relation, $thresh_value, $thresh_severity); 409 | if ($sensor_alarm > $worse_sensor_status) { 410 | 411 | # too bad, sensor has detected something abnormal 412 | # keep the alarm description for the user 413 | $worse_sensor_description = 414 | "$sensor_value" 415 | . $nexus_sensors_scale[ $sensor_data{&entSensorScale} ] . " " 416 | . $nexus_sensors_type[ $sensor_data{&entSensorType} ] . " is " 417 | . $nexus_sensors_threshold_relation[$thresh_relation] 418 | . " $thresh_value"; 419 | } 420 | 421 | # if interface is not Admin/Oper down, keep only the worst sensor status (critical status not overwritten by minor status) for the current sensor 422 | if (defined $nexus_entphysical{$id}{&entPhysicalDescr}) { 423 | unless (($opt_a || $opt_o) and $nexus_entphysical{$id}{&entPhysicalDescr} =~ /(\S+)( Lane \d+)? Transceiver/ and defined $nexus_interface{$1} and $nexus_interface{$1} != 1) { 424 | $worse_sensor_status = max($worse_sensor_status, $sensor_alarm); 425 | } 426 | } 427 | } 428 | verbose("sensor_alarm = $worse_sensor_status (nagios_rc=" . $nexus_sensor_to_nagios[$worse_sensor_status] . ")", "10"); 429 | 430 | # put failed items in a separate table 431 | if ($worse_sensor_status ne NEXUS_OK) { 432 | verbose("add new sensor status for sensor_id = " 433 | . $sensor_data{"id"} . " (" 434 | . get_nexus_component_location($id) . ") rc=" 435 | . $nexus_return_code[$sensor_alarm] 436 | . ". type is =" 437 | . $nexus_sensors_type[ $sensor_data{&entSensorType} ], 438 | 15 439 | ); 440 | if (defined($nexus_entphysical{$id}{&entPhysicalDescr})) { 441 | 442 | # skip alert if interface is Admin/Oper down 443 | if (($opt_a || $opt_o) and $nexus_entphysical{$id}{&entPhysicalDescr} =~ /(\S+)( Lane \d+)? Transceiver/ and defined $nexus_interface{$1} and $nexus_interface{$1} != 1) { 444 | verbose("not alerting on Transceiver with interface in state " . $nexus_admin_oper_status[ $nexus_interface{$1} ], 10); 445 | } 446 | else { 447 | $number_of_failed_sensors++; 448 | push(@failed_items_description, 449 | $nexus_return_code[$sensor_alarm] . ": " 450 | . $nexus_sensors_type[ $sensor_data{&entSensorType} ] . " (" 451 | . get_nexus_component_location($sensor_data{"id"}) 452 | . ") is failed: $worse_sensor_description"); 453 | } 454 | } 455 | } 456 | 457 | # if list option enabled, list sensor data 458 | if ($opt_l) { 459 | 460 | # this does the job, but undefined values can be thrown 461 | print "Sensor " . $sensor_data{"id"}; 462 | print " value: " . $sensor_data{&entSensorValue}; 463 | print " " . $nexus_sensors_scale[ $sensor_data{&entSensorScale} ]; 464 | print " " . $nexus_sensors_type[ $sensor_data{&entSensorType} ]; 465 | print " status: " . $nexus_sensors_status[ $sensor_data{&entSensorStatus} ]; 466 | print " type: " . $nexus_entphysical_class[ $nexus_entphysical{ $sensor_data{"id"} }{&entPhysicalClass} ]; 467 | print " located in: " . get_nexus_component_location($sensor_data{"id"}); 468 | print "\n"; 469 | } 470 | if (defined($nexus_entphysical{$id}{&entPhysicalDescr})) { 471 | my $ent_description = $nexus_entphysical{$id}{&entPhysicalDescr}; 472 | $ent_description =~ s/\s/_/g; 473 | $ent_description =~ s/,//g; 474 | #sometimes the entPhysicalDescr is the same for more than one sensor. 475 | #let's add "id" to differentiate the variable name in perf data 476 | $ent_description .= '_' . $sensor_data{"id"}; 477 | push(@perfparse, $ent_description . "=" . $sensor_data{&entSensorValue} . $nexus_sensors_type[ $sensor_data{&entSensorType} ] . ";;;;"); 478 | } 479 | 480 | $worse_status = max($worse_status, $worse_sensor_status); 481 | } 482 | } 483 | 484 | ################################################################################## 485 | # parse the fan table to get the worst status and append it to the output string.# 486 | ################################################################################## 487 | my $fan; 488 | my $fan_data; 489 | my $worst_fan_status = NEXUS_FANTRAY_UP; 490 | my $number_of_failed_fan = 0; 491 | my $number_of_fans; 492 | while ((my $id, $fan) = each(%nexus_frufan)) { 493 | if (defined($fan)) { 494 | my %fan_data = %{$fan}; 495 | 496 | if ($fan_data{&cefcFanTrayOperStatus} != NEXUS_FANTRAY_UP) { 497 | push(@failed_items_description, get_nexus_component_location($fan_data{"id"}) . " is " . $nexus_fantray_status[ $fan_data{&cefcFanTrayOperStatus} ]); 498 | $number_of_failed_fan++; 499 | } 500 | if ($opt_l) { 501 | print "Fan " . $fan_data{"id"}; 502 | print " located in: " . get_nexus_component_location($fan_data{"id"}); 503 | print " status is " . $nexus_fantray_status[ $fan_data{&cefcFanTrayOperStatus} ]; 504 | print "\n"; 505 | } 506 | $worst_fan_status = max($worst_fan_status, $fan_data{&cefcFanTrayOperStatus}); 507 | $number_of_fans++; 508 | } 509 | } 510 | 511 | ########################################################################################### 512 | # parse the power supply table to get the worst status and append it to the output string.# 513 | ########################################################################################### 514 | my $psu; 515 | my $psu_data; 516 | my $worst_psu_status = NEXUS_PSU_ON; 517 | my $number_of_failed_psu = 0; 518 | my $number_of_psu; 519 | while ((my $id, $psu) = each(%nexus_frupsu)) { 520 | if (defined($psu)) { 521 | my %psu_data = %{$psu}; 522 | 523 | if ($psu_data{&cefcFRUPowerOperStatus} != NEXUS_PSU_ON) { 524 | push(@failed_items_description, get_nexus_component_location($psu_data{"id"}) . " is " . $nexus_psu_status[ $psu_data{&cefcFRUPowerOperStatus} ]); 525 | $number_of_failed_psu++; 526 | } 527 | if ($opt_l) { 528 | print "PSU " . $psu_data{"id"}; 529 | print " located in: " . get_nexus_component_location($psu_data{"id"}); 530 | print " status is " . $nexus_psu_status[ $psu_data{&cefcFRUPowerOperStatus} ]; 531 | print "\n"; 532 | } 533 | $worst_psu_status = max($worst_psu_status, $psu_data{&cefcFRUPowerOperStatus}); 534 | $number_of_psu++; 535 | } 536 | } 537 | 538 | # translate the return_code (nexus code) 539 | my $sensor_return_code = $nexus_sensor_to_nagios[$worse_status]; 540 | my $fan_return_code = $nexus_fantray_status_to_nagios[$worst_fan_status]; 541 | my $psu_return_code = $nexus_psu_status_to_nagios[$worst_psu_status]; 542 | 543 | my $worst_final_return_code = max($sensor_return_code, $fan_return_code, $psu_return_code); 544 | 545 | print $outlabel. $nagios_return_code[$worst_final_return_code]; 546 | print " ("; 547 | print "$number_of_failed_sensors sensor" . ($number_of_failed_sensors <= 1 ? "" : "s") . " failed on $number_of_sensors"; 548 | print ", $number_of_failed_fan fan" . ($number_of_failed_fan <= 1 ? "" : "s") . " failed on $number_of_fans"; 549 | print ", $number_of_failed_psu psu failed on $number_of_psu"; 550 | print ")\n"; 551 | foreach (@failed_items_description) { 552 | print "$_\n"; 553 | } 554 | print "| "; 555 | foreach (@perfparse) { 556 | print "$_\n"; 557 | } 558 | exit($worst_final_return_code); 559 | 560 | sub print_usage () 561 | { 562 | print "Usage:"; 563 | print "$PROGNAME\n"; 564 | print " -H (--hostname) Hostname to query - (required)\n"; 565 | print " -C (--community) SNMP read community (defaults to public,\n"; 566 | print " used with SNMP v1 and v2c\n"; 567 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 568 | print " 2 for SNMP v2c\n"; 569 | print " 3 for SNMP v3\n"; 570 | print " -k (--key) snmp V3 key\n"; 571 | print " -p (--password) snmp V3 password\n"; 572 | print " -u (--username) snmp v3 username \n"; 573 | print " --authprotocol snmp v3 authprotocol md5|sha \n"; 574 | print " --priv snmp V3 priv password\n"; 575 | print " --privprotocol snmp v3 privprotocol des|aes \n"; 576 | 577 | print " -V (--version) Plugin version\n"; 578 | print " -h (--help) usage help\n\n"; 579 | print " -l (--list) list probes\n"; 580 | print " -a (--admin) filter Transceiver alerts by adminstatus\n"; 581 | print " -o (--oper) filter Transceiver alerts by operstatus\n"; 582 | print " -i (--sysdescr) use sysdescr instead of sysname for label display\n"; 583 | print "\n"; 584 | print " -d (--debug) debug level (1 -> 15)"; 585 | } 586 | 587 | sub print_help () 588 | { 589 | print "##############################################\n"; 590 | print "# ADEO Services #\n"; 591 | print "##############################################\n"; 592 | print_usage(); 593 | print "\n"; 594 | } 595 | 596 | sub verbose 597 | { 598 | my $message = $_[0]; 599 | my $messagelevel = $_[1]; 600 | 601 | if ($messagelevel <= $loglevel) { 602 | print "$message\n"; 603 | } 604 | } 605 | 606 | sub get_nexus_table 607 | { 608 | my $baseoid = $_[0]; 609 | my $is_indexed = $_[1]; 610 | 611 | verbose("get table for oid $baseoid", "10"); 612 | if ($snmp == 1) { 613 | $result = $session->get_table(-baseoid => $baseoid); 614 | } 615 | else { 616 | $result = $session->get_table(-baseoid => $baseoid, -maxrepetitions => 20); 617 | } 618 | if (!defined($result)) { 619 | print("UNKNOWN: SNMP get_table : " . $session->error() . "\n"); 620 | exit $ERRORS{'UNKNOWN'}; 621 | } 622 | my %nexus_values = %{$result}; 623 | my $id; 624 | my $index; 625 | my %nexus_return; 626 | while (($key, $value) = each(%nexus_values)) { 627 | $index = $id = $key; 628 | if ($is_indexed) { 629 | $id =~ s/.*\.([0-9]+)\.[0-9]*$/$1/; 630 | $key =~ s/(.*)\.[0-9]*\.[0-9]*/$1/; 631 | $index =~ s/.*\.([0-9]+)$/$1/; 632 | verbose("key=$key, id=$id, index=$index, value=$value", "15"); 633 | $nexus_return{$id}{$key}{$index} = $value; 634 | $nexus_return{$id}{"id"}{$index} = $id; 635 | } 636 | else { 637 | $id =~ s/.*\.([0-9]+)$/$1/; 638 | $key =~ s/(.*)\.[0-9]*/$1/; 639 | verbose("key=$key, id=$id, value=$value", "15"); 640 | $nexus_return{$id}{$key} = $value; 641 | $nexus_return{$id}{"id"} = $id; 642 | } 643 | } 644 | return (%nexus_return); 645 | } 646 | 647 | sub get_nexus_entries 648 | { 649 | my (@columns) = @_; 650 | 651 | verbose("get entries", "10"); 652 | if ($snmp == 1) { 653 | $result = $session->get_entries(-columns => @columns); 654 | } 655 | else { 656 | $result = $session->get_entries(-columns => @columns, -maxrepetitions => 20); 657 | } 658 | if (!defined($result)) { 659 | print("UNKNOWN: SNMP get_entries : " . $session->error() . "\n"); 660 | exit $ERRORS{'UNKNOWN'}; 661 | } 662 | my %nexus_values = %{$result}; 663 | my $id; 664 | my %nexus_return; 665 | while (($key, $value) = each(%nexus_values)) { 666 | $id = $key; 667 | $id =~ s/.*\.([0-9]+)$/$1/; 668 | $key =~ s/(.*)\.[0-9]*/$1/; 669 | verbose("key=$key, id=$id, value=$value", "15"); 670 | $nexus_return{$id}{$key} = $value; 671 | $nexus_return{$id}{"id"} = $id; 672 | } 673 | return (%nexus_return); 674 | } 675 | 676 | sub get_nexus_interface 677 | { 678 | my %entries = get_nexus_entries(@_); 679 | my %nexus_return; 680 | for my $int (values %entries) { 681 | $nexus_return{ $$int{ $_[0][0] } } = $$int{ $_[0][1] }; 682 | } 683 | return (%nexus_return); 684 | } 685 | 686 | sub evaluate_sensor 687 | { 688 | my $value = $_[0]; 689 | my $compare = $_[1]; 690 | my $threshold = $_[2]; 691 | my $severity = $_[3]; 692 | my $rc = NEXUS_OK; 693 | verbose("compare $value to $threshold and will return $severity if operator $compare is met", "15"); 694 | switch ($compare) { 695 | case 1 { 696 | verbose("lessthan compare", "10"); 697 | if ($value < $threshold) { 698 | $rc = $severity; 699 | } 700 | } 701 | case 2 { 702 | verbose("lessorequal compare", "10"); 703 | if ($value <= $threshold) { 704 | $rc = $severity; 705 | } 706 | } 707 | case 3 { 708 | verbose("greaterthan compare", "10"); 709 | if ($value > $threshold) { 710 | $rc = $severity; 711 | } 712 | } 713 | case 4 { 714 | verbose("greaterorequal compare", "10"); 715 | if ($value > $threshold) { 716 | $rc = $severity; 717 | } 718 | } 719 | case 5 { 720 | verbose("equalto compare", "10"); 721 | if ($value == $threshold) { 722 | $rc = $severity; 723 | } 724 | } 725 | case 6 { 726 | verbose("noequalto compare", "10"); 727 | if ($value != $threshold) { 728 | $rc = $severity; 729 | } 730 | } 731 | } 732 | verbose("comparison result: $rc", "15"); 733 | return ($rc); 734 | } 735 | 736 | sub get_nexus_component_location 737 | { 738 | my $sensor_id = $_[0]; 739 | my $text_output = ""; 740 | $text_output = $nexus_entphysical{$sensor_id}{&entPhysicalDescr} if (defined($nexus_entphysical{$sensor_id}{&entPhysicalDescr})); 741 | my $parent = $nexus_entphysical{$sensor_id}{&entPhysicalContainedIn}; 742 | while (defined($parent) and $parent ne 0) { 743 | $text_output .= "->" . $nexus_entphysical{$parent}{&entPhysicalDescr}; 744 | $parent = $nexus_entphysical{$parent}{&entPhysicalContainedIn}; 745 | } 746 | return ($text_output); 747 | } 748 | -------------------------------------------------------------------------------- /check_cisco_nexus/check_cisco_nexus_mem.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : david.barbion@adeoservices.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Switch; 21 | use List::Util qw[min max]; 22 | use Net::SNMP qw(:snmp); 23 | use FindBin; 24 | use lib "$FindBin::Bin"; 25 | use lib "/usr/local/nagios/libexec"; 26 | 27 | #use utils qw($TIMEOUT %ERRORS &print_revision &support); 28 | use Nagios::Plugin qw(%ERRORS); 29 | use Data::Dumper; 30 | 31 | use vars qw($PROGNAME); 32 | use Getopt::Long; 33 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u $opt_d $opt_i $opt_authproto $opt_priv $opt_privproto); 34 | use constant true => "1"; 35 | use constant false => "0"; 36 | $PROGNAME = $0; 37 | my $version = 1; 38 | my $release = 0; 39 | sub print_help (); 40 | sub print_usage (); 41 | sub verbose; 42 | sub get_nexus_table; 43 | sub get_nexus_entries; 44 | sub get_nexus_component_location; 45 | sub evaluate_sensor; 46 | my $opt_d = 0; 47 | $opt_w = 0; 48 | $opt_c = 0; 49 | Getopt::Long::Configure('bundling'); 50 | GetOptions( 51 | "h" => \$opt_h, 52 | "help" => \$opt_h, 53 | "u=s" => \$opt_u, 54 | "username=s" => \$opt_u, 55 | "p=s" => \$opt_p, 56 | "password=s" => \$opt_p, 57 | "authprotocol=s" => \$opt_authproto, 58 | "k=s" => \$opt_k, 59 | "key=s" => \$opt_k, 60 | "priv=s" => \$opt_priv, 61 | "privprotocol=s" => \$opt_privproto, 62 | "V" => \$opt_V, 63 | "version" => \$opt_V, 64 | "v=s" => \$opt_v, 65 | "snmp=s" => \$opt_v, 66 | "C=s" => \$opt_C, 67 | "community=s" => \$opt_C, 68 | "w=s" => \$opt_w, 69 | "warning=s" => \$opt_w, 70 | "c=s" => \$opt_c, 71 | "critical=s" => \$opt_c, 72 | "H=s" => \$opt_H, 73 | "hostname=s" => \$opt_H, 74 | "d=s" => \$opt_d, 75 | "debug=s" => \$opt_d, 76 | "i" => \$opt_i, 77 | "sysdescr" => \$opt_i 78 | ); 79 | 80 | if ($opt_V) { 81 | print($PROGNAME. ': $Revision: ' . $version . '.' . $release . "\n"); 82 | exit $ERRORS{'OK'}; 83 | } 84 | 85 | if ($opt_h) { 86 | print_help(); 87 | exit $ERRORS{'OK'}; 88 | } 89 | 90 | $opt_H = shift unless ($opt_H); 91 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 92 | 93 | my $snmp = "1"; 94 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 95 | $snmp = $opt_v; 96 | } 97 | 98 | if ($snmp eq "3") { 99 | if (!$opt_u) { 100 | print "Option -u (--username) is required for snmpV3\n"; 101 | exit $ERRORS{'OK'}; 102 | } 103 | if (!$opt_p && !$opt_k) { 104 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 105 | exit $ERRORS{'OK'}; 106 | } 107 | elsif ($opt_p && $opt_k) { 108 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 109 | exit $ERRORS{'OK'}; 110 | } 111 | } 112 | 113 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 114 | 115 | my $name = $0; 116 | $name =~ s/\.pl.*//g; 117 | 118 | #=== create a SNMP session ==== 119 | 120 | my ($session, $error); 121 | if ($snmp eq "1" || $snmp eq "2") { 122 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp, -maxmsgsize => "5000"); 123 | } 124 | elsif ($opt_p && $opt_priv && $opt_authproto && $opt_privproto) { 125 | ($session, $error) = Net::SNMP->session( 126 | -hostname => $opt_H, 127 | -version => $snmp, 128 | -username => $opt_u, 129 | -authpassword => $opt_p, 130 | -authprotocol => $opt_authproto, 131 | -privpassword => $opt_priv, 132 | -privprotocol => $opt_privproto, 133 | -maxmsgsize => "5000" 134 | ); 135 | } 136 | elsif ($opt_p && $opt_priv) { 137 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -privpassword => $opt_priv, -maxmsgsize => "5000"); 138 | } 139 | elsif ($opt_p && $opt_authproto) { 140 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -authprotocol => $opt_authproto, -maxmsgsize => "5000"); 141 | } 142 | elsif ($opt_p) { 143 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -maxmsgsize => "5000"); 144 | } 145 | elsif ($opt_k) { 146 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k, -maxmsgsize => "5000"); 147 | } 148 | 149 | # check that session opened 150 | if (!defined($session)) { 151 | print("UNKNOWN: SNMP Session : $error\n"); 152 | exit $ERRORS{'UNKNOWN'}; 153 | } 154 | 155 | # Here we go ! 156 | my $loglevel = $opt_d; 157 | my $result; 158 | my $key; 159 | my $value; 160 | my @perfparse; 161 | 162 | # parse sysDescr 163 | my $outlabel_oid; 164 | if ($opt_i) { 165 | 166 | # sysdescr 167 | $outlabel_oid = ".1.3.6.1.2.1.1.1.0"; 168 | } 169 | else { 170 | # sysname 171 | $outlabel_oid = ".1.3.6.1.2.1.1.5.0"; 172 | } 173 | verbose("get sysdescr ($outlabel_oid)", "5"); 174 | my $sysdescr = $session->get_request(-varbindlist => [$outlabel_oid]); 175 | if (!defined($sysdescr)) { 176 | print("UNKNOWN: SNMP get_request : " . $session->error() . "\n"); 177 | exit $ERRORS{'UNKNOWN'}; 178 | } 179 | verbose(" sysdescr is " . $sysdescr->{$outlabel_oid}, "5"); 180 | my $outlabel = $sysdescr->{$outlabel_oid} . ": "; 181 | 182 | my @nagios_return_code = ("OK", "WARNING", "CRITICAL", "UNKNOWN"); 183 | 184 | # prepare warning and critical thresholds 185 | my @warning_threshold = split(',', $opt_w) if (defined($opt_w)); 186 | my @critical_threshold = split(',', $opt_c) if (defined($opt_c)); 187 | 188 | # define some useful constants 189 | 190 | #################### 191 | # cpmCPUTotalTable # 192 | #################### 193 | # base oid 194 | use constant cpmCPUTotalTable => ".1.3.6.1.4.1.9.9.109.1.1.1"; 195 | 196 | use constant cpmCPUMemoryUsed => ".1.3.6.1.4.1.9.9.109.1.1.1.1.12"; 197 | use constant cpmCPUMemoryFree => ".1.3.6.1.4.1.9.9.109.1.1.1.1.13"; 198 | 199 | ##################### RETRIEVE DATA ####################### 200 | ###### get the cpmCPU table 201 | verbose("get cpu statistics table", "5"); 202 | my %nexus_cpu = get_nexus_table(cpmCPUTotalTable, false); 203 | 204 | ########################################################################################### 205 | # 206 | ########################################################################################### 207 | my $cpu; 208 | my $label; 209 | my $cpu_data; 210 | my $return_code = $ERRORS{'OK'}; 211 | my $total_memory = 0; 212 | while ((my $id, $cpu) = each(%nexus_cpu)) { 213 | if (defined($cpu)) { 214 | my %cpu_data = %{$cpu}; 215 | my $memory_used = $cpu_data{&cpmCPUMemoryUsed}; 216 | my $memory_free = $cpu_data{&cpmCPUMemoryFree}; 217 | 218 | $total_memory = $memory_used + $memory_free; 219 | my $warning_level = $total_memory * $opt_w / 100; 220 | my $critical_level = $total_memory * $opt_c / 100; 221 | $label .= "cpu${id}-memory_used=${memory_used}kb,cpu${id}-memory_free=${memory_free}kb "; 222 | push(@perfparse, "cpu${id}-memory_used=${memory_used}kb;$warning_level;$critical_level;0;$total_memory cpu${id}-memory_free=${memory_free}kb;;;;"); 223 | if ($memory_used > $warning_level) { 224 | $return_code = $ERRORS{'WARNING'}; 225 | } 226 | if ($memory_used > $critical_level) { 227 | $return_code = $ERRORS{'CRITICAL'}; 228 | } 229 | } 230 | } 231 | 232 | print $outlabel. $nagios_return_code[$return_code] . " $label\n"; 233 | print "| "; 234 | foreach (@perfparse) { 235 | print "$_\n"; 236 | } 237 | exit($return_code); 238 | 239 | sub print_usage () 240 | { 241 | print "Usage:"; 242 | print "$PROGNAME\n"; 243 | print " -H (--hostname) Hostname to query - (required)\n"; 244 | print " -C (--community) SNMP read community (defaults to public,\n"; 245 | print " used with SNMP v1 and v2c\n"; 246 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 247 | print " 2 for SNMP v2c\n"; 248 | print " 3 for SNMP v3\n"; 249 | print " -k (--key) snmp V3 key\n"; 250 | print " -p (--password) snmp V3 password\n"; 251 | print " -u (--username) snmp v3 username \n"; 252 | print " --authprotocol snmp v3 authprotocol md5|sha \n"; 253 | print " --priv snmp V3 priv password\n"; 254 | print " --privprotocol snmp v3 privprotocol des|aes \n"; 255 | print " -V (--version) Plugin version\n"; 256 | print " -h (--help) usage help\n\n"; 257 | print " -i (--sysdescr) use sysdescr instead of sysname for label display\n"; 258 | print " -w (--warning) warning threshold (%)\n"; 259 | print " -c (--critical) critical threshold (%)\n"; 260 | print "\n"; 261 | print " -d (--debug) debug level (1 -> 15)"; 262 | } 263 | 264 | sub print_help () 265 | { 266 | print "##############################################\n"; 267 | print "# ADEO Services #\n"; 268 | print "##############################################\n"; 269 | print_usage(); 270 | print "\n"; 271 | } 272 | 273 | sub verbose 274 | { 275 | my $message = $_[0]; 276 | my $messagelevel = $_[1]; 277 | 278 | if ($messagelevel <= $loglevel) { 279 | print "$message\n"; 280 | } 281 | } 282 | 283 | sub get_nexus_table 284 | { 285 | my $baseoid = $_[0]; 286 | my $is_indexed = $_[1]; 287 | 288 | verbose("get table for oid $baseoid", "10"); 289 | if ($snmp == 1) { 290 | $result = $session->get_table(-baseoid => $baseoid); 291 | } 292 | else { 293 | $result = $session->get_table(-baseoid => $baseoid, -maxrepetitions => 20); 294 | } 295 | if (!defined($result)) { 296 | print("UNKNOWN: SNMP get_table : " . $session->error() . "\n"); 297 | exit $ERRORS{'UNKNOWN'}; 298 | } 299 | my %nexus_values = %{$result}; 300 | my $id; 301 | my $index; 302 | my %nexus_return; 303 | while (($key, $value) = each(%nexus_values)) { 304 | $index = $id = $key; 305 | if ($is_indexed) { 306 | $id =~ s/.*\.([0-9]+)\.[0-9]*$/$1/; 307 | $key =~ s/(.*)\.[0-9]*\.[0-9]*/$1/; 308 | $index =~ s/.*\.([0-9]+)$/$1/; 309 | verbose("key=$key, id=$id, index=$index, value=$value", "15"); 310 | $nexus_return{$id}{$key}{$index} = $value; 311 | $nexus_return{$id}{"id"}{$index} = $id; 312 | } 313 | else { 314 | $id =~ s/.*\.([0-9]+)$/$1/; 315 | $key =~ s/(.*)\.[0-9]*/$1/; 316 | verbose("key=$key, id=$id, value=$value", "15"); 317 | $nexus_return{$id}{$key} = $value; 318 | $nexus_return{$id}{"id"} = $id; 319 | } 320 | } 321 | return (%nexus_return); 322 | } 323 | 324 | sub get_nexus_entries 325 | { 326 | my (@columns) = @_; 327 | 328 | verbose("get entries", "10"); 329 | if ($snmp == 1) { 330 | $result = $session->get_entries(-columns => @columns); 331 | } 332 | else { 333 | $result = $session->get_entries(-columns => @columns, -maxrepetitions => 20); 334 | } 335 | if (!defined($result)) { 336 | print("UNKNOWN: SNMP get_entries : " . $session->error() . "\n"); 337 | exit $ERRORS{'UNKNOWN'}; 338 | } 339 | my %nexus_values = %{$result}; 340 | my $id; 341 | my %nexus_return; 342 | while (($key, $value) = each(%nexus_values)) { 343 | $id = $key; 344 | $id =~ s/.*\.([0-9]+)$/$1/; 345 | $key =~ s/(.*)\.[0-9]*/$1/; 346 | verbose("key=$key, id=$id, value=$value", "15"); 347 | $nexus_return{$id}{$key} = $value; 348 | $nexus_return{$id}{"id"} = $id; 349 | } 350 | return (%nexus_return); 351 | } 352 | 353 | -------------------------------------------------------------------------------- /check_diskstat/check_all_diskstat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | EXITCODE=0 3 | CHK=/usr/lib/nagios/plugins/check_diskstat.sh 4 | WARN=${1:-"1200,15000000,15000000"} 5 | CRIT=${2:-"2000,20000000,20000000"} 6 | i=0 7 | for DEVICE in `ls /sys/block`; do 8 | if [ -L /sys/block/$DEVICE/device ]; then 9 | DEVNAME=$(echo /dev/$DEVICE | sed 's#!#/#g') 10 | i=`expr $i + 1` 11 | OUTPUT="`$CHK -d $DEVICE -w $WARN -c $CRIT -B`" 12 | STATUS=$? 13 | if [ "$EXITCODE" -le "$STATUS" ]; then 14 | EXITCODE=$STATUS; 15 | fi 16 | if [ $i -gt 1 ];then 17 | perfdatacut=$(echo $OUTPUT | sed "s#=#_$DEVNAME=#g" | cut -d '|' -f2) 18 | perfdata=$perfdata'|'$perfdatacut 19 | statusdatacut=$(echo $OUTPUT | sed "s#=#_$DEVNAME=#g" | cut -d '|' -f1) 20 | statusdata=$statusdata$DEVNAME':'$statusdatacut 21 | else 22 | echo $DEVNAME':'$OUTPUT | sed "s#=#_$DEVNAME=#g" 23 | fi 24 | fi 25 | done 26 | echo $statusdata 27 | echo $perfdata 28 | exit $EXITCODE 29 | 30 | -------------------------------------------------------------------------------- /check_diskstat/check_diskstat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DISK= 4 | WARNING= 5 | CRITICAL= 6 | 7 | E_OK=0 8 | E_WARNING=1 9 | E_CRITICAL=2 10 | E_UNKNOWN=3 11 | 12 | 13 | show_help() { 14 | echo "$0 -d DEVICE -w tps,read,write -c tps,read,write | -h" 15 | echo 16 | echo "This plug-in is used to be alerted when maximum hard drive io/s or sectors read|write/s is reached" 17 | echo 18 | echo " -d DEVICE DEVICE must be without /dev (ex: -d sda)" 19 | echo " -w/c TPS,READ,WRITE TPS means transfer per seconds (aka IO/s)" 20 | echo " READ and WRITE are in Bytes per seconds" 21 | echo 22 | echo " example: $0 -d sda -w 200,10000000,10000000 -c 300,20000000,20000000" 23 | } 24 | 25 | # process args 26 | while [ ! -z "$1" ]; do 27 | case $1 in 28 | -d) shift; DISK=$1 ;; 29 | -w) shift; WARNING=$1 ;; 30 | -c) shift; CRITICAL=$1 ;; 31 | -h) show_help; exit 1 ;; 32 | esac 33 | shift 34 | done 35 | 36 | # generate HISTFILE filename 37 | HISTFILE=/var/tmp/check_diskstat.$DISK 38 | 39 | # check input parameters so we can continu ! 40 | sanitize() { 41 | # check device name 42 | if [ -z "$DISK" ]; then 43 | echo "Need device name, ex: sda" 44 | exit $E_UNKNOWN 45 | fi 46 | 47 | # check thresholds 48 | if [ -z "$WARNING" ]; then 49 | echo "Need warning threshold" 50 | exit $E_UNKNOWN 51 | fi 52 | if [ -z "$CRITICAL" ]; then 53 | echo "Need critical threshold" 54 | exit $E_UNKNOWN 55 | fi 56 | 57 | # 58 | if [ -z "$WARN_TPS" -o -z "$WARN_READ" -o -z "$WARN_WRITE" ]; then 59 | echo "Need 3 values for warning threshold (tps,read,write)" 60 | exit $E_UNKNOWN 61 | fi 62 | if [ -z "$CRIT_TPS" -o -z "$CRIT_READ" -o -z "$CRIT_WRITE" ]; then 63 | echo "Need 3 values for critical threshold (tps,read,write)" 64 | exit $E_UNKNOWN 65 | fi 66 | 67 | 68 | } 69 | 70 | readdiskstat() { 71 | if [ ! -f "/sys/block/$1/stat" ]; then 72 | return $E_UNKNOWN 73 | fi 74 | 75 | cat /sys/block/$1/stat 76 | } 77 | 78 | readhistdiskstat() { 79 | [ -f $HISTFILE ] && cat $HISTFILE 80 | } 81 | 82 | # process thresholds 83 | WARN_TPS=$(echo $WARNING | cut -d , -f 1) 84 | WARN_READ=$(echo $WARNING | cut -d , -f 2) 85 | WARN_WRITE=$(echo $WARNING | cut -d , -f 3) 86 | CRIT_TPS=$(echo $CRITICAL | cut -d , -f 1) 87 | CRIT_READ=$(echo $CRITICAL | cut -d , -f 2) 88 | CRIT_WRITE=$(echo $CRITICAL | cut -d , -f 3) 89 | # check args 90 | sanitize 91 | 92 | 93 | NEWDISKSTAT=$(readdiskstat $DISK) 94 | if [ $? -eq $E_UNKNOWN ]; then 95 | echo "Cannot read disk stats, check your /sys filesystem for $DISK" 96 | exit $E_UNKNOWN 97 | fi 98 | 99 | if [ ! -f $HISTFILE ]; then 100 | echo $NEWDISKSTAT >$HISTFILE 101 | echo "UNKNOWN - Initial buffer creation..." 102 | exit $E_UNKNOWN 103 | fi 104 | 105 | OLDDISKSTAT=$(readhistdiskstat) 106 | if [ $? -ne 0 ]; then 107 | echo "Cannot read histfile $HISTFILE..." 108 | exit $E_UNKNOWN 109 | fi 110 | OLDDISKSTAT_TIME=$(stat $HISTFILE | grep Modify | sed 's/^.*: \(.*\)$/\1/') 111 | OLDDISKSTAT_EPOCH=$(date -d "$OLDDISKSTAT_TIME" +%s) 112 | NEWDISKSTAT_EPOCH=$(date +%s) 113 | 114 | echo $NEWDISKSTAT >$HISTFILE 115 | # now we have old and current stat; 116 | # let compare it 117 | OLD_SECTORS_READ=$(echo $OLDDISKSTAT | awk '{print $3}') 118 | NEW_SECTORS_READ=$(echo $NEWDISKSTAT | awk '{print $3}') 119 | OLD_READ=$(echo $OLDDISKSTAT | awk '{print $1}') 120 | NEW_READ=$(echo $NEWDISKSTAT | awk '{print $1}') 121 | OLD_WRITE=$(echo $OLDDISKSTAT | awk '{print $5}') 122 | NEW_WRITE=$(echo $NEWDISKSTAT | awk '{print $5}') 123 | 124 | OLD_SECTORS_WRITTEN=$(echo $OLDDISKSTAT | awk '{print $7}') 125 | NEW_SECTORS_WRITTEN=$(echo $NEWDISKSTAT | awk '{print $7}') 126 | 127 | # kernel handles sectors by 512bytes 128 | # http://www.mjmwired.net/kernel/Documentation/block/stat.txt 129 | SECTORBYTESIZE=512 130 | 131 | let "SECTORS_READ = $NEW_SECTORS_READ - $OLD_SECTORS_READ" 132 | let "SECTORS_WRITE = $NEW_SECTORS_WRITTEN - $OLD_SECTORS_WRITTEN" 133 | let "TIME = $NEWDISKSTAT_EPOCH - $OLDDISKSTAT_EPOCH" 134 | let "BYTES_READ_PER_SEC = $SECTORS_READ * $SECTORBYTESIZE / $TIME" 135 | let "BYTES_WRITTEN_PER_SEC = $SECTORS_WRITE * $SECTORBYTESIZE / $TIME" 136 | let "TPS=($NEW_READ - $OLD_READ + $NEW_WRITE - $OLD_WRITE) / $TIME" 137 | 138 | let "KBYTES_READ_PER_SEC = $BYTES_READ_PER_SEC / 1024" 139 | let "KBYTES_WRITTEN_PER_SEC = $BYTES_WRITTEN_PER_SEC / 1024" 140 | 141 | OUTPUT="" 142 | EXITCODE=$E_OK 143 | # check TPS 144 | if [ $TPS -gt $WARN_TPS ]; then 145 | if [ $TPS -gt $CRIT_TPS ]; then 146 | OUTPUT="critical IO/s (>$CRIT_TPS), " 147 | EXITCODE=$E_CRITICAL 148 | else 149 | OUTPUT="warning IO/s (>$WARN_TPS), " 150 | EXITCODE=$E_WARNING 151 | fi 152 | fi 153 | # check read 154 | if [ $BYTES_READ_PER_SEC -gt $WARN_READ ]; then 155 | if [ $BYTES_READ_PER_SEC -gt $CRIT_READ ]; then 156 | OUTPUT="${OUTPUT}critical read sectors/s (>$CRIT_READ), " 157 | EXITCODE=$E_CRITICAL 158 | else 159 | OUTPUT="${OUTPUT}warning read sectors/s (>$WARN_READ), " 160 | [ "$EXITCODE" -lt $E_CRITICAL ] && EXITCODE=$E_WARNING 161 | fi 162 | fi 163 | 164 | # check write 165 | if [ $BYTES_WRITTEN_PER_SEC -gt $WARN_WRITE ]; then 166 | if [ $BYTES_WRITTEN_PER_SEC -gt $CRIT_WRITE ]; then 167 | OUTPUT="${OUTPUT}critical write sectors/s (>$CRIT_WRITE), " 168 | EXITCODE=$E_CRITICAL 169 | else 170 | OUTPUT="${OUTPUT}warning write sectors/s (>$WARN_WRITE), " 171 | [ "$EXITCODE" -lt $E_CRITICAL ] && EXITCODE=$E_WARNING 172 | fi 173 | fi 174 | 175 | 176 | echo "${OUTPUT}summary: $TPS io/s, read $SECTORS_READ sectors (${KBYTES_READ_PER_SEC}kB/s), write $SECTORS_WRITE sectors (${KBYTES_WRITTEN_PER_SEC}kB/s) in $TIME seconds | tps=${TPS}io/s;;; read=${BYTES_READ_PER_SEC}b/s;;; write=${BYTES_WRITTEN_PER_SEC}b/s;;; " 177 | exit $EXITCODE 178 | 179 | -------------------------------------------------------------------------------- /check_mirapoint/check_mirapoint_connections.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : contact@merethis.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | use lib "/tmp" ; 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | 27 | use vars qw($PROGNAME); 28 | use Getopt::Long; 29 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); 30 | 31 | $PROGNAME = $0; 32 | sub print_help (); 33 | sub print_usage (); 34 | 35 | Getopt::Long::Configure('bundling'); 36 | GetOptions 37 | ("h" => \$opt_h, "help" => \$opt_h, 38 | "u=s" => \$opt_u, "username=s" => \$opt_u, 39 | "p=s" => \$opt_p, "password=s" => \$opt_p, 40 | "k=s" => \$opt_k, "key=s" => \$opt_k, 41 | "V" => \$opt_V, "version" => \$opt_V, 42 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 43 | "C=s" => \$opt_C, "community=s" => \$opt_C, 44 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 45 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 46 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); 47 | 48 | if ($opt_V) { 49 | print_revision($PROGNAME,'$Revision: 1.0'); 50 | exit $ERRORS{'OK'}; 51 | } 52 | 53 | if ($opt_h) { 54 | print_help(); 55 | exit $ERRORS{'OK'}; 56 | } 57 | 58 | $opt_H = shift unless ($opt_H); 59 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 60 | 61 | my $snmp = "1"; 62 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 63 | $snmp = $opt_v; 64 | } 65 | 66 | if ($snmp eq "3") { 67 | if (!$opt_u) { 68 | print "Option -u (--username) is required for snmpV3\n"; 69 | exit $ERRORS{'OK'}; 70 | } 71 | if (!$opt_p && !$opt_k) { 72 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 73 | exit $ERRORS{'OK'}; 74 | }elsif ($opt_p && $opt_k) { 75 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 76 | exit $ERRORS{'OK'}; 77 | } 78 | } 79 | 80 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 81 | 82 | my $DS_type = "GAUGE"; 83 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 84 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 85 | 86 | 87 | my $name = $0; 88 | $name =~ s/\.pl.*//g; 89 | my $day = 0; 90 | 91 | #=== create a SNMP session ==== 92 | 93 | my ($session, $error); 94 | if ($snmp eq "1" || $snmp eq "2") { 95 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); 96 | if (!defined($session)) { 97 | print("UNKNOWN: SNMP Session : $error\n"); 98 | exit $ERRORS{'UNKNOWN'}; 99 | } 100 | }elsif ($opt_k) { 101 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); 102 | if (!defined($session)) { 103 | print("UNKNOWN: SNMP Session : $error\n"); 104 | exit $ERRORS{'UNKNOWN'}; 105 | } 106 | }elsif ($opt_p) { 107 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); 108 | if (!defined($session)) { 109 | print("UNKNOWN: SNMP Session : $error\n"); 110 | exit $ERRORS{'UNKNOWN'}; 111 | } 112 | } 113 | 114 | 115 | 116 | 117 | 118 | my $result ; 119 | my $label ; 120 | my $oid ; 121 | my $unit = "c"; 122 | my $return_result ; 123 | my $return_code = 0 ; 124 | my $output ; 125 | my $total_connection = 0; 126 | my $outlabel = "Mirapoint Connections : "; 127 | my %oids= ( "AdminConn" , ".1.3.6.1.4.1.3246.2.2.1.4.2.1.0", 128 | "ImapConn", ".1.3.6.1.4.1.3246.2.2.1.4.2.2.0", 129 | "PopConn", ".1.3.6.1.4.1.3246.2.2.1.4.2.3.0", 130 | "SmtpConn", ".1.3.6.1.4.1.3246.2.2.1.4.2.4.0", 131 | "SSLConn", ".1.3.6.1.4.1.3246.2.2.1.4.2.5.0") ; 132 | 133 | while(($label, $oid) = each(%oids)) { 134 | $result = $session->get_request(-varbindlist => [$oid]); 135 | if (!defined($result)) { 136 | printf("UNKNOWN: %s.\n", $session->error); 137 | $session->close; 138 | exit $ERRORS{'UNKNOWN'}; 139 | } 140 | $return_result = $result->{$oid}; 141 | $outlabel .= "$label=$return_result "; 142 | $output .= "'$label'=$return_result"."$unit"; 143 | $output.=" "; 144 | $total_connection+=$return_result ; 145 | } 146 | $outlabel .= "Total=$total_connection "; 147 | $output .= "'TotalConn'=$total_connection"."$unit"; 148 | if (defined($opt_c) && defined($opt_w)) { 149 | if ($total_connection > $opt_w) { 150 | if ($total_connection > $opt_c) { 151 | $return_code = 2 ; 152 | }else { 153 | $return_code = 1 ; 154 | } 155 | } 156 | $output.=";$opt_w;$opt_c" ; 157 | } 158 | 159 | 160 | ################################################################################ 161 | if ($return_code == 0) { 162 | $outlabel.="OK" ; 163 | }elsif($return_code == 1){ 164 | $outlabel.="WARNING" ; 165 | }elsif($return_code == 2){ 166 | $outlabel.="CRITICAL" ; 167 | }else { 168 | $outlabel.="UNKNOWN" ; 169 | } 170 | print $outlabel." | ".$output."\n" ; 171 | exit($return_code) ; 172 | 173 | sub print_usage () { 174 | print "Usage:"; 175 | print "$PROGNAME\n"; 176 | print " -H (--hostname) Hostname to query - (required)\n"; 177 | print " -C (--community) SNMP read community (defaults to public,\n"; 178 | print " used with SNMP v1 and v2c\n"; 179 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 180 | print " 2 for SNMP v2c\n"; 181 | print " -k (--key) snmp V3 key\n"; 182 | print " -p (--password) snmp V3 password\n"; 183 | print " -u (--username) snmp v3 username \n"; 184 | print " -V (--version) Plugin version\n"; 185 | print " -h (--help) usage help\n"; 186 | } 187 | 188 | sub print_help () { 189 | print "##############################################\n"; 190 | print "# ADEO Services #\n"; 191 | print "##############################################\n"; 192 | print_usage(); 193 | print "\n"; 194 | } 195 | -------------------------------------------------------------------------------- /check_mirapoint/check_mirapoint_cpu.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : contact@merethis.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | use lib "/tmp" ; 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | 27 | use vars qw($PROGNAME); 28 | use Getopt::Long; 29 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); 30 | 31 | $PROGNAME = $0; 32 | sub print_help (); 33 | sub print_usage (); 34 | 35 | Getopt::Long::Configure('bundling'); 36 | GetOptions 37 | ("h" => \$opt_h, "help" => \$opt_h, 38 | "u=s" => \$opt_u, "username=s" => \$opt_u, 39 | "p=s" => \$opt_p, "password=s" => \$opt_p, 40 | "k=s" => \$opt_k, "key=s" => \$opt_k, 41 | "V" => \$opt_V, "version" => \$opt_V, 42 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 43 | "C=s" => \$opt_C, "community=s" => \$opt_C, 44 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 45 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 46 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); 47 | 48 | if ($opt_V) { 49 | print_revision($PROGNAME,'$Revision: 1.0'); 50 | exit $ERRORS{'OK'}; 51 | } 52 | 53 | if ($opt_h) { 54 | print_help(); 55 | exit $ERRORS{'OK'}; 56 | } 57 | 58 | $opt_H = shift unless ($opt_H); 59 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 60 | 61 | my $snmp = "1"; 62 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 63 | $snmp = $opt_v; 64 | } 65 | 66 | if ($snmp eq "3") { 67 | if (!$opt_u) { 68 | print "Option -u (--username) is required for snmpV3\n"; 69 | exit $ERRORS{'OK'}; 70 | } 71 | if (!$opt_p && !$opt_k) { 72 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 73 | exit $ERRORS{'OK'}; 74 | }elsif ($opt_p && $opt_k) { 75 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 76 | exit $ERRORS{'OK'}; 77 | } 78 | } 79 | 80 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 81 | 82 | my $DS_type = "GAUGE"; 83 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 84 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 85 | 86 | 87 | my $name = $0; 88 | $name =~ s/\.pl.*//g; 89 | my $day = 0; 90 | 91 | #=== create a SNMP session ==== 92 | 93 | my ($session, $error); 94 | if ($snmp eq "1" || $snmp eq "2") { 95 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); 96 | if (!defined($session)) { 97 | print("UNKNOWN: SNMP Session : $error\n"); 98 | exit $ERRORS{'UNKNOWN'}; 99 | } 100 | }elsif ($opt_k) { 101 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); 102 | if (!defined($session)) { 103 | print("UNKNOWN: SNMP Session : $error\n"); 104 | exit $ERRORS{'UNKNOWN'}; 105 | } 106 | }elsif ($opt_p) { 107 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); 108 | if (!defined($session)) { 109 | print("UNKNOWN: SNMP Session : $error\n"); 110 | exit $ERRORS{'UNKNOWN'}; 111 | } 112 | } 113 | 114 | my $result ; 115 | my $label ; 116 | my $oid ; 117 | my $unit = "KBytes/s"; 118 | my $return_result ; 119 | my $return_code = 0 ; 120 | my $output ; 121 | my $outlabel = "Mirapoint R/W Bytes "; 122 | my %oids= ( "RaidKBRead" , ".1.3.6.1.4.1.3246.2.2.3.22.0", 123 | "RaidKBWrite", ".1.3.6.1.4.1.3246.2.2.3.23.0") ; 124 | 125 | while(($label, $oid) = each(%oids)) { 126 | $result = $session->get_request(-varbindlist => [$oid]); 127 | if (!defined($result)) { 128 | printf("UNKNOWN: %s.\n", $session->error); 129 | $session->close; 130 | exit $ERRORS{'UNKNOWN'}; 131 | } 132 | $return_result = $result->{$oid}; 133 | $outlabel.="$label=$return_result " ; 134 | $output .= "'$label'=$return_result"."$unit"; 135 | 136 | if (defined($opt_c) && defined($opt_w)) { 137 | if ($return_result > $opt_w) { 138 | if ($return_result > $opt_c) { 139 | $return_code = 2 ; 140 | }else { 141 | $return_code = 1 ; 142 | } 143 | } 144 | $output.=";$opt_w;$opt_c" ; 145 | } 146 | $output.=" "; 147 | } 148 | if ($return_code == 0) { 149 | $outlabel.="OK" ; 150 | }elsif($return_code == 1){ 151 | $outlabel.="WARNING" ; 152 | }elsif($return_code == 2){ 153 | $outlabel.="CRITICAL" ; 154 | }else { 155 | $outlabel.="UNKNOWN" ; 156 | } 157 | print $outlabel." | ".$output."\n" ; 158 | exit($return_code) ; 159 | 160 | 161 | sub print_usage () { 162 | print "Usage:"; 163 | print "$PROGNAME\n"; 164 | print " -H (--hostname) Hostname to query - (required)\n"; 165 | print " -C (--community) SNMP read community (defaults to public,\n"; 166 | print " used with SNMP v1 and v2c\n"; 167 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 168 | print " 2 for SNMP v2c\n"; 169 | print " -t (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; 170 | print " -k (--key) snmp V3 key\n"; 171 | print " -p (--password) snmp V3 password\n"; 172 | print " -u (--username) snmp v3 username \n"; 173 | print " -V (--version) Plugin version\n"; 174 | print " -h (--help) usage help\n"; 175 | } 176 | 177 | sub print_help () { 178 | print "##############################################\n"; 179 | print "# ADEO Services #\n"; 180 | print "##############################################\n"; 181 | print_usage(); 182 | print "\n"; 183 | } 184 | -------------------------------------------------------------------------------- /check_mirapoint/check_mirapoint_inboxes.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : contact@merethis.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | use lib "/tmp" ; 25 | #use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | use Nagios::Plugin qw(%ERRORS); 27 | 28 | use vars qw($PROGNAME); 29 | use Getopt::Long; 30 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); 31 | 32 | $PROGNAME = $0; 33 | sub print_help (); 34 | sub print_usage (); 35 | 36 | Getopt::Long::Configure('bundling'); 37 | GetOptions 38 | ("h" => \$opt_h, "help" => \$opt_h, 39 | "u=s" => \$opt_u, "username=s" => \$opt_u, 40 | "p=s" => \$opt_p, "password=s" => \$opt_p, 41 | "k=s" => \$opt_k, "key=s" => \$opt_k, 42 | "V" => \$opt_V, "version" => \$opt_V, 43 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 44 | "C=s" => \$opt_C, "community=s" => \$opt_C, 45 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 46 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 47 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); 48 | 49 | if ($opt_V) { 50 | print_revision($PROGNAME,'$Revision: 1.0'); 51 | exit $ERRORS{'OK'}; 52 | } 53 | 54 | if ($opt_h) { 55 | print_help(); 56 | exit $ERRORS{'OK'}; 57 | } 58 | 59 | $opt_H = shift unless ($opt_H); 60 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 61 | 62 | my $snmp = "1"; 63 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 64 | $snmp = $opt_v; 65 | } 66 | 67 | if ($snmp eq "3") { 68 | if (!$opt_u) { 69 | print "Option -u (--username) is required for snmpV3\n"; 70 | exit $ERRORS{'OK'}; 71 | } 72 | if (!$opt_p && !$opt_k) { 73 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 74 | exit $ERRORS{'OK'}; 75 | }elsif ($opt_p && $opt_k) { 76 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 77 | exit $ERRORS{'OK'}; 78 | } 79 | } 80 | 81 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 82 | 83 | my $DS_type = "GAUGE"; 84 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 85 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 86 | 87 | 88 | my $name = $0; 89 | $name =~ s/\.pl.*//g; 90 | my $day = 0; 91 | 92 | #=== create a SNMP session ==== 93 | 94 | my ($session, $error); 95 | if ($snmp eq "1" || $snmp eq "2") { 96 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); 97 | if (!defined($session)) { 98 | print("UNKNOWN: SNMP Session : $error\n"); 99 | exit $ERRORS{'UNKNOWN'}; 100 | } 101 | }elsif ($opt_k) { 102 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); 103 | if (!defined($session)) { 104 | print("UNKNOWN: SNMP Session : $error\n"); 105 | exit $ERRORS{'UNKNOWN'}; 106 | } 107 | }elsif ($opt_p) { 108 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); 109 | if (!defined($session)) { 110 | print("UNKNOWN: SNMP Session : $error\n"); 111 | exit $ERRORS{'UNKNOWN'}; 112 | } 113 | } 114 | 115 | my $result ; 116 | my $boxes_label = "inboxes"; 117 | my $boxes_unit = "boxes"; 118 | my $users_label = "users"; 119 | my $users_unit = "u"; 120 | my $return_result ; 121 | my $return_code = 0 ; 122 | my $perfparse = "" ; 123 | my $outlabel = "Mirapoint mailboxes: "; 124 | my @oids= (".1.3.6.1.4.1.3246.2.2.1.1.11.0",".1.3.6.1.4.1.3246.2.2.1.1.12.0") ; 125 | # .1.3.6.1.4.1.3246.2.2.1.1.12.0 = inboxes 126 | # .1.3.6.1.4.1.3246.2.2.1.1.11.0 = users 127 | 128 | $result = $session->get_request(-varbindlist => \@oids) ; 129 | my $total_inboxes = $result->{".1.3.6.1.4.1.3246.2.2.1.1.12.0"} ; 130 | my $total_users = $result->{".1.3.6.1.4.1.3246.2.2.1.1.11.0"} ; 131 | 132 | $outlabel.="$total_inboxes boxes for a total of $total_users users " ; 133 | $perfparse .= "'$boxes_label'=".$total_inboxes."$boxes_unit;" ; 134 | $perfparse .= " '$users_label'=".$total_users."$users_unit;" ; 135 | 136 | if (defined($opt_c) && defined($opt_w)) { 137 | if ($total_users > $opt_w) { 138 | if ($total_users > $opt_c) { 139 | $return_code = 2 ; 140 | }else { 141 | $return_code = 1 ; 142 | } 143 | } 144 | $perfparse.="$opt_w;$opt_c;" ; 145 | }else { 146 | $perfparse.=";;" ; 147 | } 148 | 149 | $perfparse .="0;;" ; 150 | 151 | if ($return_code == 0) { 152 | $outlabel.="OK" ; 153 | }elsif($return_code == 1){ 154 | $outlabel.="WARNING" ; 155 | }elsif($return_code == 2){ 156 | $outlabel.="CRITICAL" ; 157 | }else { 158 | $outlabel.="UNKNOWN" ; 159 | } 160 | print $outlabel." | ".$perfparse."\n" ; 161 | exit($return_code) ; 162 | 163 | 164 | sub print_usage () { 165 | print "Usage:"; 166 | print "$PROGNAME\n"; 167 | print " -H (--hostname) Hostname to query - (required)\n"; 168 | print " -C (--community) SNMP read community (defaults to public,\n"; 169 | print " used with SNMP v1 and v2c\n"; 170 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 171 | print " 2 for SNMP v2c\n"; 172 | print " -t (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; 173 | print " -k (--key) snmp V3 key\n"; 174 | print " -p (--password) snmp V3 password\n"; 175 | print " -u (--username) snmp v3 username \n"; 176 | print " -V (--version) Plugin version\n"; 177 | print " -h (--help) usage help\n"; 178 | print " -w warningThreshold (%)\n" ; 179 | print " -c criticalThreshold (%)\n" ; 180 | } 181 | 182 | sub print_help () { 183 | print "##############################################\n"; 184 | print "# ADEO Services #\n"; 185 | print "##############################################\n"; 186 | print_usage(); 187 | print "\n"; 188 | } 189 | -------------------------------------------------------------------------------- /check_mirapoint/check_mirapoint_io.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : contact@merethis.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | use lib "/tmp" ; 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | 27 | use vars qw($PROGNAME); 28 | use Getopt::Long; 29 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); 30 | 31 | $PROGNAME = $0; 32 | sub print_help (); 33 | sub print_usage (); 34 | 35 | Getopt::Long::Configure('bundling'); 36 | GetOptions 37 | ("h" => \$opt_h, "help" => \$opt_h, 38 | "u=s" => \$opt_u, "username=s" => \$opt_u, 39 | "p=s" => \$opt_p, "password=s" => \$opt_p, 40 | "k=s" => \$opt_k, "key=s" => \$opt_k, 41 | "V" => \$opt_V, "version" => \$opt_V, 42 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 43 | "C=s" => \$opt_C, "community=s" => \$opt_C, 44 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 45 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 46 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); 47 | 48 | if ($opt_V) { 49 | print_revision($PROGNAME,'$Revision: 1.0'); 50 | exit $ERRORS{'OK'}; 51 | } 52 | 53 | if ($opt_h) { 54 | print_help(); 55 | exit $ERRORS{'OK'}; 56 | } 57 | 58 | $opt_H = shift unless ($opt_H); 59 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 60 | 61 | my $snmp = "1"; 62 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 63 | $snmp = $opt_v; 64 | } 65 | 66 | if ($snmp eq "3") { 67 | if (!$opt_u) { 68 | print "Option -u (--username) is required for snmpV3\n"; 69 | exit $ERRORS{'OK'}; 70 | } 71 | if (!$opt_p && !$opt_k) { 72 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 73 | exit $ERRORS{'OK'}; 74 | }elsif ($opt_p && $opt_k) { 75 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 76 | exit $ERRORS{'OK'}; 77 | } 78 | } 79 | 80 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 81 | 82 | my $DS_type = "GAUGE"; 83 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 84 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 85 | 86 | 87 | my $name = $0; 88 | $name =~ s/\.pl.*//g; 89 | my $day = 0; 90 | 91 | #=== create a SNMP session ==== 92 | 93 | my ($session, $error); 94 | if ($snmp eq "1" || $snmp eq "2") { 95 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); 96 | if (!defined($session)) { 97 | print("UNKNOWN: SNMP Session : $error\n"); 98 | exit $ERRORS{'UNKNOWN'}; 99 | } 100 | }elsif ($opt_k) { 101 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); 102 | if (!defined($session)) { 103 | print("UNKNOWN: SNMP Session : $error\n"); 104 | exit $ERRORS{'UNKNOWN'}; 105 | } 106 | }elsif ($opt_p) { 107 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); 108 | if (!defined($session)) { 109 | print("UNKNOWN: SNMP Session : $error\n"); 110 | exit $ERRORS{'UNKNOWN'}; 111 | } 112 | } 113 | 114 | my $result ; 115 | my $label ; 116 | my $oid ; 117 | my $unit = "o/s"; 118 | my $return_result ; 119 | my $return_code = 0 ; 120 | my $output ; 121 | my $outlabel = "Mirapoint IO status "; 122 | my %oids= ( "RaidCmdRead" , ".1.3.6.1.4.1.3246.2.2.3.19.0", 123 | "RaidCmdWrite", ".1.3.6.1.4.1.3246.2.2.3.21.0") ; 124 | 125 | while(($label, $oid) = each(%oids)) { 126 | $result = $session->get_request(-varbindlist => [$oid]); 127 | if (!defined($result)) { 128 | printf("UNKNOWN: %s.\n", $session->error); 129 | $session->close; 130 | exit $ERRORS{'UNKNOWN'}; 131 | } 132 | $return_result = $result->{$oid}; 133 | $outlabel .= "$label=$return_result "; 134 | $output .= "'$label'=$return_result"."$unit"; 135 | 136 | if (defined($opt_c) && defined($opt_w)) { 137 | if ($return_result > $opt_w) { 138 | if ($return_result > $opt_c) { 139 | $return_code = 2 ; 140 | }else { 141 | $return_code = 1 ; 142 | } 143 | } 144 | $output.=";$opt_w;$opt_c" ; 145 | } 146 | $output.=" "; 147 | } 148 | if ($return_code == 0) { 149 | $outlabel.="OK" ; 150 | }elsif($return_code == 1){ 151 | $outlabel.="WARNING" ; 152 | }elsif($return_code == 2){ 153 | $outlabel.="CRITICAL" ; 154 | }else { 155 | $outlabel.="UNKNWWN" ; 156 | } 157 | print $outlabel." | ".$output."\n" ; 158 | exit($return_code) ; 159 | 160 | 161 | sub print_usage () { 162 | print "Usage:"; 163 | print "$PROGNAME\n"; 164 | print " -H (--hostname) Hostname to query - (required)\n"; 165 | print " -C (--community) SNMP read community (defaults to public,\n"; 166 | print " used with SNMP v1 and v2c\n"; 167 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 168 | print " 2 for SNMP v2c\n"; 169 | print " -t (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; 170 | print " -k (--key) snmp V3 key\n"; 171 | print " -p (--password) snmp V3 password\n"; 172 | print " -u (--username) snmp v3 username \n"; 173 | print " -V (--version) Plugin version\n"; 174 | print " -h (--help) usage help\n"; 175 | } 176 | 177 | sub print_help () { 178 | print "##############################################\n"; 179 | print "# ADEO Services #\n"; 180 | print "##############################################\n"; 181 | print_usage(); 182 | print "\n"; 183 | } 184 | -------------------------------------------------------------------------------- /check_mirapoint/check_mirapoint_kb.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : contact@merethis.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | use lib "/tmp" ; 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | 27 | use vars qw($PROGNAME); 28 | use Getopt::Long; 29 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); 30 | 31 | $PROGNAME = $0; 32 | sub print_help (); 33 | sub print_usage (); 34 | 35 | Getopt::Long::Configure('bundling'); 36 | GetOptions 37 | ("h" => \$opt_h, "help" => \$opt_h, 38 | "u=s" => \$opt_u, "username=s" => \$opt_u, 39 | "p=s" => \$opt_p, "password=s" => \$opt_p, 40 | "k=s" => \$opt_k, "key=s" => \$opt_k, 41 | "V" => \$opt_V, "version" => \$opt_V, 42 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 43 | "C=s" => \$opt_C, "community=s" => \$opt_C, 44 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 45 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 46 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); 47 | 48 | if ($opt_V) { 49 | print_revision($PROGNAME,'$Revision: 1.0'); 50 | exit $ERRORS{'OK'}; 51 | } 52 | 53 | if ($opt_h) { 54 | print_help(); 55 | exit $ERRORS{'OK'}; 56 | } 57 | 58 | $opt_H = shift unless ($opt_H); 59 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 60 | 61 | my $snmp = "1"; 62 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 63 | $snmp = $opt_v; 64 | } 65 | 66 | if ($snmp eq "3") { 67 | if (!$opt_u) { 68 | print "Option -u (--username) is required for snmpV3\n"; 69 | exit $ERRORS{'OK'}; 70 | } 71 | if (!$opt_p && !$opt_k) { 72 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 73 | exit $ERRORS{'OK'}; 74 | }elsif ($opt_p && $opt_k) { 75 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 76 | exit $ERRORS{'OK'}; 77 | } 78 | } 79 | 80 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 81 | 82 | my $DS_type = "GAUGE"; 83 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 84 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 85 | 86 | 87 | my $name = $0; 88 | $name =~ s/\.pl.*//g; 89 | my $day = 0; 90 | 91 | #=== create a SNMP session ==== 92 | 93 | my ($session, $error); 94 | if ($snmp eq "1" || $snmp eq "2") { 95 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); 96 | if (!defined($session)) { 97 | print("UNKNOWN: SNMP Session : $error\n"); 98 | exit $ERRORS{'UNKNOWN'}; 99 | } 100 | }elsif ($opt_k) { 101 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); 102 | if (!defined($session)) { 103 | print("UNKNOWN: SNMP Session : $error\n"); 104 | exit $ERRORS{'UNKNOWN'}; 105 | } 106 | }elsif ($opt_p) { 107 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); 108 | if (!defined($session)) { 109 | print("UNKNOWN: SNMP Session : $error\n"); 110 | exit $ERRORS{'UNKNOWN'}; 111 | } 112 | } 113 | 114 | my $result ; 115 | my $label ; 116 | my $oid ; 117 | my $unit = "KBytes/s"; 118 | my $return_result ; 119 | my $return_code = 0 ; 120 | my $output ; 121 | my $outlabel = "Mirapoint R/W Bytes "; 122 | my %oids= ( "RaidKBRead" , ".1.3.6.1.4.1.3246.2.2.3.22.0", 123 | "RaidKBWrite", ".1.3.6.1.4.1.3246.2.2.3.23.0") ; 124 | 125 | while(($label, $oid) = each(%oids)) { 126 | $result = $session->get_request(-varbindlist => [$oid]); 127 | if (!defined($result)) { 128 | printf("UNKNOWN: %s.\n", $session->error); 129 | $session->close; 130 | exit $ERRORS{'UNKNOWN'}; 131 | } 132 | $return_result = $result->{$oid}; 133 | $outlabel.="$label=$return_result " ; 134 | $output .= "'$label'=$return_result"."$unit"; 135 | 136 | if (defined($opt_c) && defined($opt_w)) { 137 | if ($return_result > $opt_w) { 138 | if ($return_result > $opt_c) { 139 | $return_code = 2 ; 140 | }else { 141 | $return_code = 1 ; 142 | } 143 | } 144 | $output.=";$opt_w;$opt_c" ; 145 | } 146 | $output.=" "; 147 | } 148 | if ($return_code == 0) { 149 | $outlabel.="OK" ; 150 | }elsif($return_code == 1){ 151 | $outlabel.="WARNING" ; 152 | }elsif($return_code == 2){ 153 | $outlabel.="CRITICAL" ; 154 | }else { 155 | $outlabel.="UNKNOWN" ; 156 | } 157 | print $outlabel." | ".$output."\n" ; 158 | exit($return_code) ; 159 | 160 | 161 | sub print_usage () { 162 | print "Usage:"; 163 | print "$PROGNAME\n"; 164 | print " -H (--hostname) Hostname to query - (required)\n"; 165 | print " -C (--community) SNMP read community (defaults to public,\n"; 166 | print " used with SNMP v1 and v2c\n"; 167 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 168 | print " 2 for SNMP v2c\n"; 169 | print " -t (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; 170 | print " -k (--key) snmp V3 key\n"; 171 | print " -p (--password) snmp V3 password\n"; 172 | print " -u (--username) snmp v3 username \n"; 173 | print " -V (--version) Plugin version\n"; 174 | print " -h (--help) usage help\n"; 175 | } 176 | 177 | sub print_help () { 178 | print "##############################################\n"; 179 | print "# ADEO Services #\n"; 180 | print "##############################################\n"; 181 | print_usage(); 182 | print "\n"; 183 | } 184 | -------------------------------------------------------------------------------- /check_mirapoint/check_mirapoint_lat.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : contact@merethis.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | use lib "/tmp" ; 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | 27 | use vars qw($PROGNAME); 28 | use Getopt::Long; 29 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); 30 | 31 | $PROGNAME = $0; 32 | sub print_help (); 33 | sub print_usage (); 34 | 35 | Getopt::Long::Configure('bundling'); 36 | GetOptions 37 | ("h" => \$opt_h, "help" => \$opt_h, 38 | "u=s" => \$opt_u, "username=s" => \$opt_u, 39 | "p=s" => \$opt_p, "password=s" => \$opt_p, 40 | "k=s" => \$opt_k, "key=s" => \$opt_k, 41 | "V" => \$opt_V, "version" => \$opt_V, 42 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 43 | "C=s" => \$opt_C, "community=s" => \$opt_C, 44 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 45 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 46 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); 47 | 48 | if ($opt_V) { 49 | print_revision($PROGNAME,'$Revision: 1.0'); 50 | exit $ERRORS{'OK'}; 51 | } 52 | 53 | if ($opt_h) { 54 | print_help(); 55 | exit $ERRORS{'OK'}; 56 | } 57 | 58 | $opt_H = shift unless ($opt_H); 59 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 60 | 61 | my $snmp = "1"; 62 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 63 | $snmp = $opt_v; 64 | } 65 | 66 | if ($snmp eq "3") { 67 | if (!$opt_u) { 68 | print "Option -u (--username) is required for snmpV3\n"; 69 | exit $ERRORS{'OK'}; 70 | } 71 | if (!$opt_p && !$opt_k) { 72 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 73 | exit $ERRORS{'OK'}; 74 | }elsif ($opt_p && $opt_k) { 75 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 76 | exit $ERRORS{'OK'}; 77 | } 78 | } 79 | 80 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 81 | 82 | my $DS_type = "GAUGE"; 83 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 84 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 85 | 86 | 87 | my $name = $0; 88 | $name =~ s/\.pl.*//g; 89 | my $day = 0; 90 | 91 | #=== create a SNMP session ==== 92 | 93 | my ($session, $error); 94 | if ($snmp eq "1" || $snmp eq "2") { 95 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); 96 | if (!defined($session)) { 97 | print("UNKNOWN: SNMP Session : $error\n"); 98 | exit $ERRORS{'UNKNOWN'}; 99 | } 100 | }elsif ($opt_k) { 101 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); 102 | if (!defined($session)) { 103 | print("UNKNOWN: SNMP Session : $error\n"); 104 | exit $ERRORS{'UNKNOWN'}; 105 | } 106 | }elsif ($opt_p) { 107 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); 108 | if (!defined($session)) { 109 | print("UNKNOWN: SNMP Session : $error\n"); 110 | exit $ERRORS{'UNKNOWN'}; 111 | } 112 | } 113 | 114 | my $result ; 115 | my $label ; 116 | my $oid ; 117 | my $unit = "ms"; 118 | my $return_result ; 119 | my $return_code = 0 ; 120 | my $output ; 121 | my $outlabel = "Mirapoint R/W Latency "; 122 | my %oids= ( "RaidLatRead" , ".1.3.6.1.4.1.3246.2.2.3.24.0", 123 | "RaidLatWrite", ".1.3.6.1.4.1.3246.2.2.3.25.0") ; 124 | 125 | while(($label, $oid) = each(%oids)) { 126 | $result = $session->get_request(-varbindlist => [$oid]); 127 | if (!defined($result)) { 128 | printf("UNKNOWN: %s.\n", $session->error); 129 | $session->close; 130 | exit $ERRORS{'UNKNOWN'}; 131 | } 132 | $return_result = $result->{$oid}; 133 | $outlabel.="$label=$return_result " ; 134 | $output .= "'$label'=$return_result"."$unit"; 135 | 136 | if (defined($opt_c) && defined($opt_w)) { 137 | if ($return_result > $opt_w) { 138 | if ($return_result > $opt_c) { 139 | $return_code = 2 ; 140 | }else { 141 | $return_code = 1 ; 142 | } 143 | } 144 | $output.=";$opt_w;$opt_c" ; 145 | } 146 | $output.=" "; 147 | } 148 | if ($return_code == 0) { 149 | $outlabel.="OK" ; 150 | }elsif($return_code == 1){ 151 | $outlabel.="WARNING" ; 152 | }elsif($return_code == 2){ 153 | $outlabel.="CRITICAL" ; 154 | }else { 155 | $outlabel.="UNKNOWN" ; 156 | } 157 | print $outlabel." | ".$output."\n" ; 158 | exit($return_code) ; 159 | 160 | 161 | sub print_usage () { 162 | print "Usage:"; 163 | print "$PROGNAME\n"; 164 | print " -H (--hostname) Hostname to query - (required)\n"; 165 | print " -C (--community) SNMP read community (defaults to public,\n"; 166 | print " used with SNMP v1 and v2c\n"; 167 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 168 | print " 2 for SNMP v2c\n"; 169 | print " -t (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; 170 | print " -k (--key) snmp V3 key\n"; 171 | print " -p (--password) snmp V3 password\n"; 172 | print " -u (--username) snmp v3 username \n"; 173 | print " -V (--version) Plugin version\n"; 174 | print " -h (--help) usage help\n"; 175 | } 176 | 177 | sub print_help () { 178 | print "##############################################\n"; 179 | print "# ADEO Services #\n"; 180 | print "##############################################\n"; 181 | print_usage(); 182 | print "\n"; 183 | } 184 | -------------------------------------------------------------------------------- /check_mirapoint/check_mirapoint_mailqueue.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : contact@merethis.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | use lib "/tmp" ; 25 | #use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | use Nagios::Plugin qw(%ERRORS); 27 | 28 | use vars qw($PROGNAME); 29 | use Getopt::Long; 30 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); 31 | 32 | $PROGNAME = $0; 33 | sub print_help (); 34 | sub print_usage (); 35 | 36 | Getopt::Long::Configure('bundling'); 37 | GetOptions 38 | ("h" => \$opt_h, "help" => \$opt_h, 39 | "u=s" => \$opt_u, "username=s" => \$opt_u, 40 | "p=s" => \$opt_p, "password=s" => \$opt_p, 41 | "k=s" => \$opt_k, "key=s" => \$opt_k, 42 | "V" => \$opt_V, "version" => \$opt_V, 43 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 44 | "C=s" => \$opt_C, "community=s" => \$opt_C, 45 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 46 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 47 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); 48 | 49 | if ($opt_V) { 50 | print_revision($PROGNAME,'$Revision: 1.0'); 51 | exit $ERRORS{'OK'}; 52 | } 53 | 54 | if ($opt_h) { 55 | print_help(); 56 | exit $ERRORS{'OK'}; 57 | } 58 | 59 | $opt_H = shift unless ($opt_H); 60 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 61 | 62 | my $snmp = "1"; 63 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 64 | $snmp = $opt_v; 65 | } 66 | 67 | if ($snmp eq "3") { 68 | if (!$opt_u) { 69 | print "Option -u (--username) is required for snmpV3\n"; 70 | exit $ERRORS{'OK'}; 71 | } 72 | if (!$opt_p && !$opt_k) { 73 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 74 | exit $ERRORS{'OK'}; 75 | }elsif ($opt_p && $opt_k) { 76 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 77 | exit $ERRORS{'OK'}; 78 | } 79 | } 80 | 81 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 82 | 83 | my $DS_type = "GAUGE"; 84 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 85 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 86 | 87 | 88 | my $name = $0; 89 | $name =~ s/\.pl.*//g; 90 | my $day = 0; 91 | 92 | #=== create a SNMP session ==== 93 | 94 | my ($session, $error); 95 | if ($snmp eq "1" || $snmp eq "2") { 96 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); 97 | if (!defined($session)) { 98 | print("UNKNOWN: SNMP Session : $error\n"); 99 | exit $ERRORS{'UNKNOWN'}; 100 | } 101 | }elsif ($opt_k) { 102 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); 103 | if (!defined($session)) { 104 | print("UNKNOWN: SNMP Session : $error\n"); 105 | exit $ERRORS{'UNKNOWN'}; 106 | } 107 | }elsif ($opt_p) { 108 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); 109 | if (!defined($session)) { 110 | print("UNKNOWN: SNMP Session : $error\n"); 111 | exit $ERRORS{'UNKNOWN'}; 112 | } 113 | } 114 | 115 | my $result ; 116 | my $label = "mailqueue"; 117 | my $unit = "msg"; 118 | my $return_result ; 119 | my $return_code = 0 ; 120 | my $perfparse = "" ; 121 | my $outlabel = "Mirapoint mailqueue: "; 122 | my @oids= ("1.3.6.1.4.1.3246.2.2.1.4.3.1.0") ; 123 | 124 | $result = $session->get_request(-varbindlist => \@oids) ; 125 | my $mailqueue_size = $result->{"1.3.6.1.4.1.3246.2.2.1.4.3.1.0"} ; 126 | 127 | $outlabel.="$mailqueue_size messages queued " ; 128 | $perfparse .= "'$label'=".$mailqueue_size."$unit;" ; 129 | 130 | if (defined($opt_c) && defined($opt_w)) { 131 | if ($mailqueue_size > $opt_w) { 132 | if ($mailqueue_size > $opt_c) { 133 | $return_code = 2 ; 134 | }else { 135 | $return_code = 1 ; 136 | } 137 | } 138 | $perfparse.="$opt_w;$opt_c;" ; 139 | }else { 140 | $perfparse.=";;" ; 141 | } 142 | 143 | $perfparse .="0;;" ; 144 | 145 | if ($return_code == 0) { 146 | $outlabel.="OK" ; 147 | }elsif($return_code == 1){ 148 | $outlabel.="WARNING" ; 149 | }elsif($return_code == 2){ 150 | $outlabel.="CRITICAL" ; 151 | }else { 152 | $outlabel.="UNKNOWN" ; 153 | } 154 | print $outlabel." | ".$perfparse."\n" ; 155 | exit($return_code) ; 156 | 157 | 158 | sub print_usage () { 159 | print "Usage:"; 160 | print "$PROGNAME\n"; 161 | print " -H (--hostname) Hostname to query - (required)\n"; 162 | print " -C (--community) SNMP read community (defaults to public,\n"; 163 | print " used with SNMP v1 and v2c\n"; 164 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 165 | print " 2 for SNMP v2c\n"; 166 | print " -t (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; 167 | print " -k (--key) snmp V3 key\n"; 168 | print " -p (--password) snmp V3 password\n"; 169 | print " -u (--username) snmp v3 username \n"; 170 | print " -V (--version) Plugin version\n"; 171 | print " -h (--help) usage help\n"; 172 | print " -w warningThreshold (%)\n" ; 173 | print " -c criticalThreshold (%)\n" ; 174 | } 175 | 176 | sub print_help () { 177 | print "##############################################\n"; 178 | print "# ADEO Services #\n"; 179 | print "##############################################\n"; 180 | print_usage(); 181 | print "\n"; 182 | } 183 | -------------------------------------------------------------------------------- /check_mirapoint/check_mirapoint_raid-health.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : contact@merethis.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | use lib "/tmp" ; 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | 27 | use vars qw($PROGNAME); 28 | use Getopt::Long; 29 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); 30 | 31 | $PROGNAME = $0; 32 | sub print_help (); 33 | sub print_usage (); 34 | 35 | Getopt::Long::Configure('bundling'); 36 | GetOptions 37 | ("h" => \$opt_h, "help" => \$opt_h, 38 | "u=s" => \$opt_u, "username=s" => \$opt_u, 39 | "p=s" => \$opt_p, "password=s" => \$opt_p, 40 | "k=s" => \$opt_k, "key=s" => \$opt_k, 41 | "V" => \$opt_V, "version" => \$opt_V, 42 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 43 | "C=s" => \$opt_C, "community=s" => \$opt_C, 44 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 45 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 46 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); 47 | 48 | if ($opt_V) { 49 | print_revision($PROGNAME,'$Revision: 1.0'); 50 | exit $ERRORS{'OK'}; 51 | } 52 | 53 | if ($opt_h) { 54 | print_help(); 55 | exit $ERRORS{'OK'}; 56 | } 57 | 58 | $opt_H = shift unless ($opt_H); 59 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 60 | 61 | my $snmp = "1"; 62 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 63 | $snmp = $opt_v; 64 | } 65 | 66 | if ($snmp eq "3") { 67 | if (!$opt_u) { 68 | print "Option -u (--username) is required for snmpV3\n"; 69 | exit $ERRORS{'OK'}; 70 | } 71 | if (!$opt_p && !$opt_k) { 72 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 73 | exit $ERRORS{'OK'}; 74 | }elsif ($opt_p && $opt_k) { 75 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 76 | exit $ERRORS{'OK'}; 77 | } 78 | } 79 | 80 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 81 | 82 | my $DS_type = "GAUGE"; 83 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 84 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 85 | 86 | 87 | my $name = $0; 88 | $name =~ s/\.pl.*//g; 89 | my $day = 0; 90 | 91 | #=== create a SNMP session ==== 92 | 93 | my ($session, $error); 94 | if ($snmp eq "1" || $snmp eq "2") { 95 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); 96 | if (!defined($session)) { 97 | print("UNKNOWN: SNMP Session : $error\n"); 98 | exit $ERRORS{'UNKNOWN'}; 99 | } 100 | }elsif ($opt_k) { 101 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); 102 | if (!defined($session)) { 103 | print("UNKNOWN: SNMP Session : $error\n"); 104 | exit $ERRORS{'UNKNOWN'}; 105 | } 106 | }elsif ($opt_p) { 107 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); 108 | if (!defined($session)) { 109 | print("UNKNOWN: SNMP Session : $error\n"); 110 | exit $ERRORS{'UNKNOWN'}; 111 | } 112 | } 113 | 114 | 115 | 116 | 117 | 118 | my $result ; 119 | my $label ; 120 | my $oid ; 121 | my $unit = "KBytes/s"; 122 | my $return_result ; 123 | my $return_code = 0 ; 124 | my $output ; 125 | my $outlabel = "Mirapoint Raid status: "; 126 | my %oids= ( "RaidKBRead" , ".1.3.6.1.4.1.3246.2.2.3.22.0", 127 | "RaidKBWrite", ".1.3.6.1.4.1.3246.2.2.3.23.0") ; 128 | 129 | 130 | # check failed raid 131 | $oid = ".1.3.6.1.4.1.3246.2.2.3.10.0"; 132 | $result = $session->get_request(-varbindlist => [$oid]); 133 | if (!defined($result)) { 134 | printf("UNKNOWN: %s.\n", $session->error); 135 | $session->close; 136 | exit $ERRORS{'UNKNOWN'}; 137 | } 138 | $return_result = $result->{$oid}; 139 | $outlabel.="$return_result drive(s) failed" ; 140 | if ($return_result) { 141 | $return_code=2 ; 142 | } 143 | 144 | # check warning raid 145 | 146 | $oid = ".1.3.6.1.4.1.3246.2.2.3.11.0"; 147 | $result = $session->get_request(-varbindlist => [$oid]); 148 | if (!defined($result)) { 149 | printf("UNKNOWN: %s.\n", $session->error); 150 | $session->close; 151 | exit $ERRORS{'UNKNOWN'}; 152 | } 153 | $return_result = $result->{$oid}; 154 | $outlabel.=", $return_result drive(s) in warning state" ; 155 | if ($return_result) { 156 | $return_code=1 ; 157 | } 158 | 159 | # check cache 160 | my %cache_states = (1=> "undef",2 => "write-back",3 => "write-through") ; 161 | $oid = ".1.3.6.1.4.1.3246.2.2.3.12.0"; 162 | $result = $session->get_request(-varbindlist => [$oid]); 163 | if (!defined($result)) { 164 | printf("UNKNOWN: %s.\n", $session->error); 165 | $session->close; 166 | exit $ERRORS{'UNKNOWN'}; 167 | } 168 | $return_result = $result->{$oid}; 169 | $outlabel.=", cache is ".$cache_states{$return_result}." " ; 170 | if ($return_result != 2) { 171 | $return_code=1 ; 172 | } 173 | 174 | ################################################################################ 175 | if ($return_code == 0) { 176 | $outlabel.="OK" ; 177 | }elsif($return_code == 1){ 178 | $outlabel.="WARNING" ; 179 | }elsif($return_code == 2){ 180 | $outlabel.="CRITICAL" ; 181 | }else { 182 | $outlabel.="UNKNOWN" ; 183 | } 184 | print $outlabel."\n" ; 185 | exit($return_code) ; 186 | 187 | 188 | sub print_usage () { 189 | print "Usage:"; 190 | print "$PROGNAME\n"; 191 | print " -H (--hostname) Hostname to query - (required)\n"; 192 | print " -C (--community) SNMP read community (defaults to public,\n"; 193 | print " used with SNMP v1 and v2c\n"; 194 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 195 | print " 2 for SNMP v2c\n"; 196 | print " -k (--key) snmp V3 key\n"; 197 | print " -p (--password) snmp V3 password\n"; 198 | print " -u (--username) snmp v3 username \n"; 199 | print " -V (--version) Plugin version\n"; 200 | print " -h (--help) usage help\n"; 201 | } 202 | 203 | sub print_help () { 204 | print "##############################################\n"; 205 | print "# ADEO Services #\n"; 206 | print "##############################################\n"; 207 | print_usage(); 208 | print "\n"; 209 | } 210 | -------------------------------------------------------------------------------- /check_mirapoint/check_mirapoint_storage.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : contact@merethis.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | use lib "/tmp" ; 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | 27 | use vars qw($PROGNAME); 28 | use Getopt::Long; 29 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); 30 | 31 | $PROGNAME = $0; 32 | sub print_help (); 33 | sub print_usage (); 34 | 35 | Getopt::Long::Configure('bundling'); 36 | GetOptions 37 | ("h" => \$opt_h, "help" => \$opt_h, 38 | "u=s" => \$opt_u, "username=s" => \$opt_u, 39 | "p=s" => \$opt_p, "password=s" => \$opt_p, 40 | "k=s" => \$opt_k, "key=s" => \$opt_k, 41 | "V" => \$opt_V, "version" => \$opt_V, 42 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 43 | "C=s" => \$opt_C, "community=s" => \$opt_C, 44 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 45 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 46 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); 47 | 48 | if ($opt_V) { 49 | print_revision($PROGNAME,'$Revision: 1.0'); 50 | exit $ERRORS{'OK'}; 51 | } 52 | 53 | if ($opt_h) { 54 | print_help(); 55 | exit $ERRORS{'OK'}; 56 | } 57 | 58 | $opt_H = shift unless ($opt_H); 59 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 60 | 61 | my $snmp = "1"; 62 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 63 | $snmp = $opt_v; 64 | } 65 | 66 | if ($snmp eq "3") { 67 | if (!$opt_u) { 68 | print "Option -u (--username) is required for snmpV3\n"; 69 | exit $ERRORS{'OK'}; 70 | } 71 | if (!$opt_p && !$opt_k) { 72 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 73 | exit $ERRORS{'OK'}; 74 | }elsif ($opt_p && $opt_k) { 75 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 76 | exit $ERRORS{'OK'}; 77 | } 78 | } 79 | 80 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 81 | 82 | my $DS_type = "GAUGE"; 83 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 84 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 85 | 86 | 87 | my $name = $0; 88 | $name =~ s/\.pl.*//g; 89 | my $day = 0; 90 | 91 | #=== create a SNMP session ==== 92 | 93 | my ($session, $error); 94 | if ($snmp eq "1" || $snmp eq "2") { 95 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); 96 | if (!defined($session)) { 97 | print("UNKNOWN: SNMP Session : $error\n"); 98 | exit $ERRORS{'UNKNOWN'}; 99 | } 100 | }elsif ($opt_k) { 101 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); 102 | if (!defined($session)) { 103 | print("UNKNOWN: SNMP Session : $error\n"); 104 | exit $ERRORS{'UNKNOWN'}; 105 | } 106 | }elsif ($opt_p) { 107 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); 108 | if (!defined($session)) { 109 | print("UNKNOWN: SNMP Session : $error\n"); 110 | exit $ERRORS{'UNKNOWN'}; 111 | } 112 | } 113 | 114 | my $result ; 115 | my $label = "storage"; 116 | my $unit = "MB"; 117 | my $return_result ; 118 | my $return_code = 0 ; 119 | my $perfparse = "" ; 120 | my $outlabel = "Mirapoint storage "; 121 | my @oids= (".1.3.6.1.4.1.3246.1.1.1.0",".1.3.6.1.4.1.3246.1.1.2.0") ; 122 | 123 | $result = $session->get_request(-varbindlist => \@oids) ; 124 | my $percent_used = sprintf("%.2f", $result->{".1.3.6.1.4.1.3246.1.1.2.0"} / $result->{".1.3.6.1.4.1.3246.1.1.1.0"} * 100) ; 125 | 126 | $outlabel.="$percent_used% used " ; 127 | $perfparse .= "'$label'=".$result->{".1.3.6.1.4.1.3246.1.1.2.0"}."$unit;" ; 128 | 129 | if (defined($opt_c) && defined($opt_w)) { 130 | my $warnused = sprintf("%.0f", $result->{".1.3.6.1.4.1.3246.1.1.1.0"} * $opt_w /100) ; 131 | my $critused = sprintf("%0.f", $result->{".1.3.6.1.4.1.3246.1.1.1.0"} * $opt_c /100) ; 132 | if ($percent_used > $opt_w) { 133 | if ($percent_used > $opt_c) { 134 | $return_code = 2 ; 135 | }else { 136 | $return_code = 1 ; 137 | } 138 | } 139 | $perfparse.="$warnused;$critused;" ; 140 | }else { 141 | $perfparse.=";;" ; 142 | } 143 | 144 | $perfparse .="0;".$result->{".1.3.6.1.4.1.3246.1.1.1.0"} ; 145 | 146 | if ($return_code == 0) { 147 | $outlabel.="OK" ; 148 | }elsif($return_code == 1){ 149 | $outlabel.="WARNING" ; 150 | }elsif($return_code == 2){ 151 | $outlabel.="CRITICAL" ; 152 | }else { 153 | $outlabel.="UNKNOWN" ; 154 | } 155 | print $outlabel." | ".$perfparse."\n" ; 156 | exit($return_code) ; 157 | 158 | 159 | sub print_usage () { 160 | print "Usage:"; 161 | print "$PROGNAME\n"; 162 | print " -H (--hostname) Hostname to query - (required)\n"; 163 | print " -C (--community) SNMP read community (defaults to public,\n"; 164 | print " used with SNMP v1 and v2c\n"; 165 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 166 | print " 2 for SNMP v2c\n"; 167 | print " -t (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; 168 | print " -k (--key) snmp V3 key\n"; 169 | print " -p (--password) snmp V3 password\n"; 170 | print " -u (--username) snmp v3 username \n"; 171 | print " -V (--version) Plugin version\n"; 172 | print " -h (--help) usage help\n"; 173 | print " -w warningThreshold (%)\n" ; 174 | print " -c criticalThreshold (%)\n" ; 175 | } 176 | 177 | sub print_help () { 178 | print "##############################################\n"; 179 | print "# ADEO Services #\n"; 180 | print "##############################################\n"; 181 | print_usage(); 182 | print "\n"; 183 | } 184 | -------------------------------------------------------------------------------- /check_msa_hardware/check_msa_hardware.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | ################################################################### 14 | # Queries MSA2000 health using the fiber channel management MIB 15 | # (FCMGMT-MIB). The MIB is available as fa-mib40.mib in the HP 16 | # SIM MIB kit. 17 | # 18 | # Tested with: 19 | # - HP MSA2324i 20 | # - HP MSA2312i 21 | # - HP MSA2012i 22 | # - HP MSA2012fc 23 | # - HP P2000 G3 MSA (iSCSI & FC) 24 | # 25 | # For information : dbarbion@gmail.com 26 | ################################################################### 27 | # 28 | # Script init 29 | # 30 | 31 | use strict; 32 | use Switch ; 33 | use List::Util qw[min max]; 34 | use Net::SNMP qw(:snmp); 35 | use FindBin; 36 | use lib "$FindBin::Bin"; 37 | use lib "/usr/local/nagios/libexec"; 38 | #use utils qw($TIMEOUT %ERRORS &print_revision &support); 39 | use Monitoring::Plugin qw(%ERRORS); 40 | 41 | use vars qw($PROGNAME); 42 | use Getopt::Long; 43 | use vars qw($opt_h $opt_V $opt_H $opt_P $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u $opt_l); 44 | 45 | $PROGNAME = $0; 46 | sub print_help (); 47 | sub print_usage (); 48 | 49 | Getopt::Long::Configure('bundling'); 50 | GetOptions 51 | ("h" => \$opt_h, "help" => \$opt_h, 52 | "u=s" => \$opt_u, "username=s" => \$opt_u, 53 | "p=s" => \$opt_p, "password=s" => \$opt_p, 54 | "k=s" => \$opt_k, "key=s" => \$opt_k, 55 | "V" => \$opt_V, "version" => \$opt_V, 56 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 57 | "C=s" => \$opt_C, "community=s" => \$opt_C, 58 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 59 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 60 | "H=s" => \$opt_H, "hostname=s" => \$opt_H, 61 | "P=i" => \$opt_P, "port=i" => \$opt_P, 62 | "l" => \$opt_l, "list" => \$opt_l); 63 | 64 | if ($opt_V) { 65 | print_revision($PROGNAME,'$Revision: 1.2'); 66 | exit $ERRORS{'OK'}; 67 | } 68 | 69 | if ($opt_h) { 70 | print_help(); 71 | exit $ERRORS{'OK'}; 72 | } 73 | 74 | $opt_H = shift unless ($opt_H); 75 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 76 | 77 | my $snmp = "1"; 78 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 79 | $snmp = $opt_v; 80 | } 81 | 82 | if ($snmp eq "3") { 83 | if (!$opt_u) { 84 | print "Option -u (--username) is required for snmpV3\n"; 85 | exit $ERRORS{'OK'}; 86 | } 87 | if (!$opt_p && !$opt_k) { 88 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 89 | exit $ERRORS{'OK'}; 90 | }elsif ($opt_p && $opt_k) { 91 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 92 | exit $ERRORS{'OK'}; 93 | } 94 | } 95 | 96 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 97 | ($opt_P) || ($opt_P = shift) || ($opt_P = 161); 98 | 99 | my $DS_type = "GAUGE"; 100 | ($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); 101 | $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); 102 | 103 | 104 | my $name = $0; 105 | $name =~ s/\.pl.*//g; 106 | my $day = 0; 107 | 108 | #=== create a SNMP session ==== 109 | 110 | my ($session, $error); 111 | if ($snmp eq "1" || $snmp eq "2") { 112 | ($session, $error) = Net::SNMP->session( 113 | -hostname => $opt_H, 114 | -port => $opt_P, 115 | -community => $opt_C, 116 | -version => $snmp); 117 | }elsif ($opt_k) { 118 | ($session, $error) = Net::SNMP->session( 119 | -hostname => $opt_H, 120 | -port => $opt_P, 121 | -version => $snmp, 122 | -username => $opt_u, 123 | -authkey => $opt_k); 124 | }elsif ($opt_p) { 125 | ($session, $error) = Net::SNMP->session( 126 | -hostname => $opt_H, 127 | -port => $opt_P, 128 | -version => $snmp, 129 | -username => $opt_u, 130 | -authpassword => $opt_p); 131 | } 132 | # check that session opened 133 | if (!defined($session)) { 134 | print("UNKNOWN: SNMP Session : $error\n"); 135 | exit $ERRORS{'UNKNOWN'}; 136 | } 137 | 138 | 139 | # Here we go ! 140 | my $result ; 141 | my $label ; 142 | my $oid ; 143 | my $unit = ""; 144 | my $return_result ; 145 | my $return_code = 0 ; 146 | my $output ; 147 | my $total_connection = 0; 148 | # parse sysDescr 149 | my $sysdescr = $session->get_request(-varbindlist => [".1.3.6.1.2.1.1.1.0"]) ; 150 | if (!defined($sysdescr)) { 151 | print("UNKNOWN: SNMP get_request : ".$session->error()."\n"); 152 | exit $ERRORS{'UNKNOWN'}; 153 | } 154 | my $outlabel = $sysdescr->{".1.3.6.1.2.1.1.1.0"}.": " ; 155 | 156 | # useful sensors within FCMGMT-MIB::connUnitSensorTable 157 | my %msa_sensors_oids = ( 158 | ".1.3.6.1.3.94.1.8.1.1" => "Sensor unitid", 159 | ".1.3.6.1.3.94.1.8.1.2" => "Sensor index", 160 | ".1.3.6.1.3.94.1.8.1.3" => "Sensor name", 161 | ".1.3.6.1.3.94.1.8.1.4" => "Sensor status", 162 | ".1.3.6.1.3.94.1.8.1.5" => "Sensor info", 163 | ".1.3.6.1.3.94.1.8.1.6" => "Sensor message", 164 | ".1.3.6.1.3.94.1.8.1.7" => "Sensor type", 165 | ".1.3.6.1.3.94.1.8.1.8" => "Sensor characteristic" 166 | ) ; 167 | my %sensor_data_table = ("SENSOR_UNITID" => ".1.3.6.1.3.94.1.8.1.1", 168 | "SENSOR_INDEX" => ".1.3.6.1.3.94.1.8.1.2", 169 | "SENSOR_NAME" => ".1.3.6.1.3.94.1.8.1.3", 170 | "SENSOR_STATUS" => ".1.3.6.1.3.94.1.8.1.4", 171 | "SENSOR_INFO" => ".1.3.6.1.3.94.1.8.1.5", 172 | "SENSOR_MESSAGE" => ".1.3.6.1.3.94.1.8.1.6", 173 | "SENSOR_TYPE" => ".1.3.6.1.3.94.1.8.1.7", 174 | "SENSOR_CHARACTERISTIC" => ".1.3.6.1.3.94.1.8.1.8",) ; 175 | 176 | # all sensors types 177 | my @msa_sensors_type = ("undefined", 178 | "unknown", 179 | "other", 180 | "battery", 181 | "fan", 182 | "power-supply", 183 | "transmitter", 184 | "enclosure", 185 | "board", 186 | "receiver") ; 187 | # all sensors status 188 | my @msa_sensors_status = ("undefined", 189 | "unknown", 190 | "other", 191 | "ok", 192 | "warning", 193 | "failed") ; 194 | 195 | # all sensors characteristics 196 | my @msa_sensors_characteristic = ("undefined", 197 | "unknown", 198 | "other", 199 | "temperature", 200 | "pressure", 201 | "emf", 202 | "currentValue", 203 | "airflow", 204 | "frequency", 205 | "power", 206 | "door" 207 | ) ; 208 | 209 | # get the sensor table 210 | # .1.3.6.1.3.94.1.8 is FCMGMT-MIB::connUnitSensorTable 211 | if ($snmp == 1) { 212 | $result = $session->get_table(-baseoid => ".1.3.6.1.3.94.1.8") ; 213 | }else { 214 | $result = $session->get_table(-baseoid => ".1.3.6.1.3.94.1.8", -maxrepetitions => 10) ; 215 | } 216 | if (!defined($result)) { 217 | print("UNKNOWN: SNMP get_table : ".$session->error()."\n"); 218 | exit $ERRORS{'UNKNOWN'}; 219 | } 220 | my %msa_sensors_values = %{$result} ; 221 | 222 | my $sensor_id ; 223 | my $key ; 224 | my $value ; 225 | my @msa_sensors ; 226 | my $sensor ; 227 | # create the sensor data table 228 | foreach (keys %msa_sensors_values) { 229 | $value = $key = $sensor_id = $_ ; 230 | $sensor_id =~ s/.*\.([0-9]+)$/$1/; 231 | $key =~ s/(\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*).*/$1/ ; 232 | $msa_sensors[$sensor_id]{$key} = $msa_sensors_values{$value}; 233 | } 234 | 235 | # When user whan to list probes 236 | if ($opt_l) { 237 | print "List of probes:\n" ; 238 | } 239 | # parse the table to get the worse status and append it to the output string. 240 | my $worse_status = 0; 241 | foreach $sensor (@msa_sensors) { 242 | if (defined($sensor)) { 243 | my %sensor_data = %{$sensor} ; 244 | $worse_status = max($worse_status, $sensor_data{$sensor_data_table{"SENSOR_STATUS"}}) ; 245 | 246 | # a problem is found 247 | if ($sensor_data{$sensor_data_table{"SENSOR_STATUS"}} > 3) { 248 | $outlabel.=$sensor_data{$sensor_data_table{"SENSOR_MESSAGE"}} ; 249 | $outlabel.=" [".$msa_sensors_type[$sensor_data{$sensor_data_table{"SENSOR_TYPE"}}]."]. " ; 250 | } 251 | 252 | # if list option enabled, list sensor data 253 | if ($opt_l) { 254 | print $sensor_data{$sensor_data_table{"SENSOR_NAME"}}; 255 | print " (type: ".$msa_sensors_characteristic[$sensor_data{$sensor_data_table{"SENSOR_CHARACTERISTIC"}}].")"; 256 | print " has status ".$msa_sensors_status[$sensor_data{$sensor_data_table{"SENSOR_STATUS"}}] ; 257 | print " with message: '".$sensor_data{$sensor_data_table{"SENSOR_MESSAGE"}}."'" ; 258 | print "\n" ; 259 | } 260 | } 261 | } 262 | 263 | # Check overall status (FCMGMT-MIB::connUnitStatus). This should return a 264 | # warning if any component is unhealthy. This is a column of the connUnitTable, 265 | # and the MSA only returns one row - we're looking for the first row. 266 | my $connUnitStatusOid = '.1.3.6.1.3.94.1.6.1.6'; 267 | $result = $session->get_next_request(-varbindlist => [$connUnitStatusOid]); 268 | if (!defined($result)) { 269 | print("UNKNOWN: SNMP get_next_request $connUnitStatusOid : " 270 | . $session->error() . "\n"); 271 | exit $ERRORS{'UNKNOWN'}; 272 | } 273 | if (length(keys(%$result)) != 1) { 274 | print("UNKNOWN: Expected 1 connUnitStatus result, got " 275 | . length(keys(%$result)) . "\n"); 276 | exit $ERRORS{'UNKNOWN'}; 277 | } 278 | foreach my $val (values(%$result)) { 279 | $worse_status = max($worse_status, $val); 280 | if ($val > 3) { 281 | $outlabel .= 'Overall unit status '; 282 | } 283 | if ($opt_l) { 284 | print "connUnitStatus has status " . $msa_sensors_status[$val] . "\n"; 285 | } 286 | last; 287 | } 288 | 289 | # get the return_code 290 | switch ($worse_status) { 291 | case 0 { $return_code = -1 ;} 292 | case 1 { $return_code = -1 ;} 293 | case 2 { $return_code = -1 ;} 294 | case 3 { $return_code = 0 ;} 295 | case 4 { $return_code = 1 ;} 296 | case 5 { $return_code = 2 ;} 297 | else { $return_code = -1 } 298 | } 299 | 300 | ################################################################################ 301 | switch ($return_code) { 302 | case 0 { $outlabel.="OK"; } 303 | case 1 { $outlabel.="WARNING"; } 304 | case 2 { $outlabel.="CRITICAL"; } 305 | else { $outlabel.="UNKOWN"; } 306 | } 307 | print $outlabel."\n" ; 308 | exit($return_code) ; 309 | 310 | sub print_usage () { 311 | print "Usage:"; 312 | print "$PROGNAME\n"; 313 | print " -H (--hostname) Hostname to query - (required)\n"; 314 | print " -P (--port) SNMP port\n"; 315 | print " -C (--community) SNMP read community (defaults to public,\n"; 316 | print " used with SNMP v1 and v2c\n"; 317 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 318 | print " 2 for SNMP v2c\n"; 319 | print " -k (--key) snmp V3 key\n"; 320 | print " -p (--password) snmp V3 password\n"; 321 | print " -u (--username) snmp v3 username \n"; 322 | print " -V (--version) Plugin version\n"; 323 | print " -h (--help) usage help\n\n" ; 324 | print " -l (--list) list probes\n"; 325 | } 326 | 327 | sub print_help () { 328 | print_usage(); 329 | print "\n"; 330 | } 331 | -------------------------------------------------------------------------------- /check_netapp_perf/check_netapp_allvols.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : david.barbion@adeoservices.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use Net::SNMP qw(:snmp); 21 | use FindBin; 22 | use lib "$FindBin::Bin"; 23 | use lib "/usr/local/nagios/libexec"; 24 | #use utils qw($TIMEOUT %ERRORS &print_revision &support); 25 | use Nagios::Plugin qw(%ERRORS); 26 | #use Data::Dumper ; 27 | 28 | use vars qw($PROGNAME); 29 | use Getopt::Long; 30 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u $opt_d $opt_i $opt_I); 31 | use constant true => "1" ; 32 | use constant false => "0" ; 33 | $PROGNAME = $0; 34 | my $version = 1; 35 | my $release = 0; 36 | sub print_help (); 37 | sub print_usage (); 38 | sub verbose ; 39 | my $opt_d = 0 ; 40 | $opt_w=""; 41 | $opt_c=""; 42 | $opt_I=""; 43 | Getopt::Long::Configure('bundling'); 44 | GetOptions 45 | ("h" => \$opt_h, "help" => \$opt_h, 46 | "u=s" => \$opt_u, "username=s" => \$opt_u, 47 | "p=s" => \$opt_p, "password=s" => \$opt_p, 48 | "k=s" => \$opt_k, "key=s" => \$opt_k, 49 | "V" => \$opt_V, "version" => \$opt_V, 50 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 51 | "C=s" => \$opt_C, "community=s" => \$opt_C, 52 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 53 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 54 | "I=s" => \$opt_I, "ignore=s" => \$opt_I, 55 | "H=s" => \$opt_H, "hostname=s" => \$opt_H, 56 | "d=s" => \$opt_d, "debug=s" => \$opt_d, 57 | "i" => \$opt_i, "sysdescr" => \$opt_i); 58 | 59 | if ($opt_V) { 60 | print($PROGNAME.': $Revision: '.$version.'.'.$release."\n"); 61 | exit $ERRORS{'OK'}; 62 | } 63 | 64 | if ($opt_h) { 65 | print_help(); 66 | exit $ERRORS{'OK'}; 67 | } 68 | 69 | $opt_H = shift unless ($opt_H); 70 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 71 | 72 | my $snmp = "1"; 73 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 74 | $snmp = $opt_v; 75 | } 76 | 77 | if ($snmp eq "3") { 78 | if (!$opt_u) { 79 | print "Option -u (--username) is required for snmpV3\n"; 80 | exit $ERRORS{'OK'}; 81 | } 82 | if (!$opt_p && !$opt_k) { 83 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 84 | exit $ERRORS{'OK'}; 85 | }elsif ($opt_p && $opt_k) { 86 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 87 | exit $ERRORS{'OK'}; 88 | } 89 | } 90 | 91 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 92 | 93 | my $name = $0; 94 | $name =~ s/\.pl.*//g; 95 | 96 | #=== create a SNMP session ==== 97 | 98 | my ($session, $error); 99 | if ($snmp eq "1" || $snmp eq "2") { 100 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp, -maxmsgsize => "5000"); 101 | }elsif ($opt_k) { 102 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k, -maxmsgsize => "5000"); 103 | }elsif ($opt_p) { 104 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -maxmsgsize => "5000"); 105 | } 106 | # check that session opened 107 | if (!defined($session)) { 108 | print("UNKNOWN: SNMP Session : $error\n"); 109 | exit $ERRORS{'UNKNOWN'}; 110 | } 111 | 112 | 113 | # Here we go ! 114 | my $loglevel = $opt_d ; 115 | my $result ; 116 | my $key ; 117 | my $value ; 118 | my @perfparse ; 119 | # parse sysDescr 120 | my $outlabel_oid; 121 | if ($opt_i) { 122 | # sysdescr 123 | $outlabel_oid = ".1.3.6.1.2.1.1.1.0" ; 124 | }else { 125 | # sysname 126 | $outlabel_oid = ".1.3.6.1.2.1.1.5.0" ; 127 | } 128 | verbose("get sysdescr ($outlabel_oid)", "5") ; 129 | my $sysdescr = $session->get_request(-varbindlist => [$outlabel_oid]) ; 130 | if (!defined($sysdescr)) { 131 | print("UNKNOWN: SNMP get_request : ".$session->error()."\n"); 132 | exit $ERRORS{'UNKNOWN'}; 133 | } 134 | verbose(" sysdescr is ".$sysdescr->{$outlabel_oid}, "5") ; 135 | my $outlabel = $sysdescr->{$outlabel_oid}.": " ; 136 | 137 | my @nagios_return_code = ("OK", "WARNING", "CRITICAL", "UNKNOWN") ; 138 | 139 | # define some useful constants 140 | 141 | #################### 142 | # cpmCPUTotalTable # 143 | #################### 144 | # base oid 145 | use constant netapp_dfTable => ".1.3.6.1.4.1.789.1.5.4" ; 146 | 147 | use constant netapp_dfTableName => ".1.3.6.1.4.1.789.1.5.4.1.2" ; 148 | use constant netapp_dfTabledfPerCentKBytesCapacity => ".1.3.6.1.4.1.789.1.5.4.1.6" ; 149 | use constant netapp_dfTabledfHighUsedKBytes => ".1.3.6.1.4.1.789.1.5.4.1.16" ; 150 | use constant netapp_dfTabledfLowUsedKBytes => ".1.3.6.1.4.1.789.1.5.4.1.17" ; 151 | use constant netapp_dfTabledfUsedKBytes => ".1.3.6.1.4.1.789.1.5.4.1.30" ; 152 | 153 | 154 | ##################### RETRIEVE DATA ####################### 155 | ###### get the cpmCPU table 156 | verbose("get netapp disk statistics table", "5") ; 157 | my %netapp_df = get_table(netapp_dfTable,false) ; 158 | 159 | ########################################################################################### 160 | # 161 | ########################################################################################### 162 | my $df; 163 | my $label = ''; 164 | my $df_data; 165 | my $return_code = $ERRORS{'OK'} ; 166 | while((my $id,$df) = each(%netapp_df)) { 167 | if (defined($df)) { 168 | my %df_data = %{$df} ; 169 | my $df_volname = $df_data{&netapp_dfTableName} ; 170 | next if ($opt_I ne "" && $df_volname =~ /$opt_I/); 171 | my $df_percentused = $df_data{&netapp_dfTabledfPerCentKBytesCapacity} ; 172 | my $df_highused = $df_data{&netapp_dfTabledfHighUsedKBytes} ; 173 | my $df_lowused = $df_data{&netapp_dfTabledfLowUsedKBytes} ; 174 | 175 | # hack to convert 2 32bits integer to 1 64bits integer 176 | if ( $df_lowused < 0 ) { 177 | $df_lowused=$df_lowused+(1<<32); 178 | } 179 | $df_highused=$df_highused<<32; 180 | my $df_used=$df_lowused+$df_highused ; 181 | 182 | if ($opt_w and $df_percentused > $opt_w) { 183 | if ($opt_c and $df_percentused > $opt_c) { 184 | $return_code = $ERRORS{'CRITICAL'} ; 185 | }else { 186 | $return_code = $ERRORS{'WARNING'} ; 187 | } 188 | # append overquota volume to first line output 189 | $label.="${df_volname}=$df_percentused% (${df_used}KBytes) " ; 190 | } 191 | push(@perfparse, "${df_volname}=$df_percentused%;$opt_w;$opt_c;;") ; 192 | } 193 | } 194 | 195 | print $outlabel.$nagios_return_code[$return_code]." $label\n" ; 196 | print "| "; 197 | foreach (@perfparse) { 198 | print "$_\n" ; 199 | } 200 | exit($return_code) ; 201 | 202 | ############################## 203 | # print help # 204 | ############################## 205 | sub print_usage () { 206 | print "Usage:"; 207 | print "$PROGNAME\n"; 208 | print " -H (--hostname) Hostname to query - (required)\n"; 209 | print " -C (--community) SNMP read community (defaults to public,\n"; 210 | print " used with SNMP v1 and v2c\n"; 211 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 212 | print " 2 for SNMP v2c\n"; 213 | print " -k (--key) snmp V3 key\n"; 214 | print " -p (--password) snmp V3 password\n"; 215 | print " -u (--username) snmp v3 username \n"; 216 | print " -V (--version) Plugin version\n"; 217 | print " -h (--help) usage help\n\n" ; 218 | print " -i (--sysdescr) use sysdescr instead of sysname for label display\n"; 219 | print " -w (--warning) warning threshold (%)\n" ; 220 | print " -c (--critical) critical threshold (%)\n" ; 221 | print " -I (--ignore) regex of volume names to ignore.\n"; 222 | print "\n" ; 223 | print " -d (--debug) debug level (1 -> 15)\n" ; 224 | } 225 | 226 | sub print_help () { 227 | print "##############################################\n"; 228 | print "# ADEO Services #\n"; 229 | print "##############################################\n"; 230 | print_usage(); 231 | print "\n"; 232 | } 233 | 234 | ######################### 235 | # print verbose messages 236 | ######################### 237 | sub verbose { 238 | my $message = $_[0]; 239 | my $messagelevel = $_[1] ; 240 | if ($messagelevel <= $loglevel) { 241 | print "$message\n" ; 242 | } 243 | } 244 | 245 | ####################### 246 | # get snmp table 247 | ####################### 248 | sub get_table { 249 | my $baseoid = $_[0] ; 250 | my $is_indexed = $_[1] ; 251 | 252 | verbose("get table for oid $baseoid", "10") ; 253 | if ($snmp == 1) { 254 | $result = $session->get_table(-baseoid => $baseoid) ; 255 | }else { 256 | $result = $session->get_table(-baseoid => $baseoid, -maxrepetitions => 20) ; 257 | } 258 | if (!defined($result)) { 259 | print("UNKNOWN: SNMP get_table : ".$session->error()."\n"); 260 | exit $ERRORS{'UNKNOWN'}; 261 | } 262 | my %nexus_values = %{$result} ; 263 | my $id; 264 | my $index; 265 | my %nexus_return; 266 | # this section convert Cisco nexus table to perl hash 267 | while(($key,$value) = each(%nexus_values)) { 268 | $index = $id = $key ; 269 | if ($is_indexed) { 270 | $id =~ s/.*\.([0-9]+)\.[0-9]*$/$1/; 271 | $key =~ s/(.*)\.[0-9]*\.[0-9]*/$1/ ; 272 | $index =~ s/.*\.([0-9]+)$/$1/ ; 273 | verbose("key=$key, id=$id, index=$index, value=$value", "15") ; 274 | $nexus_return{$id}{$key}{$index} = $value; 275 | $nexus_return{$id}{"id"}{$index} = $id ; 276 | }else { 277 | $id =~ s/.*\.([0-9]+)$/$1/; 278 | $key =~ s/(.*)\.[0-9]*/$1/ ; 279 | verbose("key=$key, id=$id, value=$value", "15") ; 280 | $nexus_return{$id}{$key} = $value; 281 | $nexus_return{$id}{"id"} = $id ; 282 | } 283 | } 284 | return(%nexus_return) ; 285 | } 286 | 287 | -------------------------------------------------------------------------------- /check_netapp_perf/check_netapp_nfsops.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | ################################################################### 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either version 2 6 | # of the License, or (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # For information : david.barbion@adeoservices.com 14 | #################################################################### 15 | # 16 | # Script init 17 | # 18 | 19 | use strict; 20 | use List::Util qw[min max]; 21 | use Net::SNMP qw(:snmp); 22 | use FindBin; 23 | use lib "$FindBin::Bin"; 24 | use lib "/usr/local/nagios/libexec"; 25 | #use utils qw($TIMEOUT %ERRORS &print_revision &support); 26 | use Nagios::Plugin qw(%ERRORS); 27 | use Data::Dumper ; 28 | 29 | use vars qw($PROGNAME); 30 | use Getopt::Long; 31 | use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u $opt_d $opt_i $opt_P); 32 | use constant true => "1" ; 33 | use constant false => "0" ; 34 | $PROGNAME = $0; 35 | my $version = 1; 36 | my $release = 0; 37 | sub print_help (); 38 | sub print_usage (); 39 | sub verbose ; 40 | sub get_nexus_table ; 41 | sub get_nexus_entries ; 42 | sub get_nexus_component_location ; 43 | sub evaluate_sensor ; 44 | my $opt_d = 0 ; 45 | Getopt::Long::Configure('bundling'); 46 | GetOptions 47 | ("h" => \$opt_h, "help" => \$opt_h, 48 | "u=s" => \$opt_u, "username=s" => \$opt_u, 49 | "p=s" => \$opt_p, "password=s" => \$opt_p, 50 | "k=s" => \$opt_k, "key=s" => \$opt_k, 51 | "V" => \$opt_V, "version" => \$opt_V, 52 | "v=s" => \$opt_v, "snmp=s" => \$opt_v, 53 | "C=s" => \$opt_C, "community=s" => \$opt_C, 54 | "w=s" => \$opt_w, "warning=s" => \$opt_w, 55 | "c=s" => \$opt_c, "critical=s" => \$opt_c, 56 | "H=s" => \$opt_H, "hostname=s" => \$opt_H, 57 | "d=s" => \$opt_d, "debug=s" => \$opt_d, 58 | "i" => \$opt_i, "sysdescr" => \$opt_i, 59 | "P=s" => \$opt_P); 60 | 61 | if ($opt_V) { 62 | print($PROGNAME.': $Revision: '.$version.'.'.$release."\n"); 63 | exit $ERRORS{'OK'}; 64 | } 65 | 66 | if ($opt_h) { 67 | print_help(); 68 | exit $ERRORS{'OK'}; 69 | } 70 | 71 | $opt_H = shift unless ($opt_H); 72 | (print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); 73 | 74 | my $snmp = "1"; 75 | if ($opt_v && $opt_v =~ /^[0-9]$/) { 76 | $snmp = $opt_v; 77 | } 78 | 79 | if ($snmp eq "3") { 80 | if (!$opt_u) { 81 | print "Option -u (--username) is required for snmpV3\n"; 82 | exit $ERRORS{'OK'}; 83 | } 84 | if (!$opt_p && !$opt_k) { 85 | print "Option -k (--key) or -p (--password) is required for snmpV3\n"; 86 | exit $ERRORS{'OK'}; 87 | }elsif ($opt_p && $opt_k) { 88 | print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; 89 | exit $ERRORS{'OK'}; 90 | } 91 | } 92 | 93 | ($opt_C) || ($opt_C = shift) || ($opt_C = "public"); 94 | 95 | my $name = $0; 96 | $name =~ s/\.pl.*//g; 97 | 98 | #=== create a SNMP session ==== 99 | 100 | my ($session, $error); 101 | if ($snmp eq "1" || $snmp eq "2") { 102 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp, -maxmsgsize => "5000"); 103 | }elsif ($opt_k) { 104 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k, -maxmsgsize => "5000"); 105 | }elsif ($opt_p) { 106 | ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p, -maxmsgsize => "5000"); 107 | } 108 | # check that session opened 109 | if (!defined($session)) { 110 | print("UNKNOWN: SNMP Session : $error\n"); 111 | exit $ERRORS{'UNKNOWN'}; 112 | } 113 | 114 | 115 | # Here we go ! 116 | my $loglevel = $opt_d ; 117 | my %perfparse ; 118 | # parse sysDescr 119 | my $outlabel_oid; 120 | if ($opt_i) { 121 | # sysdescr 122 | $outlabel_oid = ".1.3.6.1.2.1.1.1.0" ; 123 | }else { 124 | # sysname 125 | $outlabel_oid = ".1.3.6.1.2.1.1.5.0" ; 126 | } 127 | verbose("get sysdescr ($outlabel_oid)", "5") ; 128 | my $sysdescr = $session->get_request(-varbindlist => [$outlabel_oid]) ; 129 | if (!defined($sysdescr)) { 130 | print("UNKNOWN: SNMP get_request : ".$session->error()."\n"); 131 | exit $ERRORS{'UNKNOWN'}; 132 | } 133 | verbose(" sysdescr is ".$sysdescr->{$outlabel_oid}, "5") ; 134 | my $outlabel = $sysdescr->{$outlabel_oid}.": " ; 135 | my @nagios_return_code = ("OK", "WARNING", "CRITICAL", "UNKNOWN") ; 136 | 137 | ############################### 138 | # define some useful constants 139 | ############################### 140 | use constant netapp_nfsops => ".1.3.6.1.4.1.789.1.2.2.27.0" ; 141 | 142 | ##################### RETRIEVE DATA ####################### 143 | my $label; 144 | my $netapp_nfsops=0 ; 145 | my $mean_netapp_nfsops ; 146 | my $current_netapp_nfsops ; 147 | my $return_code=0; 148 | my $date_of_measure = time() ; 149 | my $cache_file = "/var/lib/centreon/centplugins/netapp_ops.$opt_H" ; 150 | my $interval_time ; 151 | 152 | # get total number of nfsops 153 | verbose("get netapp nfs ops", "5") ; 154 | my $netapp_current_nfsops = $session->get_request(-varbindlist => [&netapp_nfsops]) ; 155 | verbose("nfsops=".$netapp_current_nfsops->{&netapp_nfsops}, 10) ; 156 | $current_netapp_nfsops=$netapp_current_nfsops->{&netapp_nfsops} ; 157 | 158 | # user defined cache path 159 | if (defined($opt_P)) { 160 | $cache_file = $opt_P."/netapp_ops.$opt_H" ; 161 | } 162 | 163 | # retrieve old data store in the cache file 164 | my %history = get_history($cache_file) ; 165 | if (!defined($history{'time'})) { 166 | # the history file is not found, warn user on the first run and return unknown to nagios 167 | verbose("First time running", 5) ; 168 | $label = "Buffer in creation" ; 169 | $return_code = 3 ; 170 | }else { 171 | $interval_time = $date_of_measure - $history{'time'} ; 172 | $netapp_nfsops = $current_netapp_nfsops - $history{'nfsops'} ; 173 | 174 | $mean_netapp_nfsops = $netapp_nfsops / $interval_time ; 175 | 176 | $return_code = 0 ; 177 | if (defined($opt_w) && $mean_netapp_nfsops < $opt_w) { 178 | if (defined($opt_c) && $mean_netapp_nfsops < $opt_c) { 179 | $return_code = 2 ; 180 | }else{ 181 | $return_code = 1 ; 182 | } 183 | } 184 | $label .= "nfsops=$mean_netapp_nfsops (${interval_time}s mean)"; 185 | $perfparse{'nfsops'} = $mean_netapp_nfsops; 186 | } 187 | # prepare data to be save in the history file 188 | $history{'time'} = $date_of_measure ; 189 | $history{'nfsops'} = $current_netapp_nfsops ; 190 | save_history($cache_file, %history) ; 191 | 192 | ###################################### 193 | # time to return information to user 194 | ###################################### 195 | print $outlabel.$nagios_return_code[$return_code]." $label |" ; 196 | if (defined($perfparse{'nfsops'})) { 197 | print " nfsops=".$perfparse{'nfsops'}."ops;" ; 198 | } 199 | print "\n" ; 200 | exit($return_code) ; 201 | 202 | #################################### 203 | # get data from history file 204 | # history file path passed as $arg1 205 | # it returns a hash on exit, 206 | # feel free to use it for you 207 | #################################### 208 | sub get_history { 209 | my $cachefile = $_[0] ; 210 | my $histvalue ; 211 | my $time ; 212 | my %history ; 213 | $history{'time'} = undef ; 214 | my $row ; 215 | if (-e $cachefile) { 216 | open(FILE, "<$cachefile") ; 217 | while($row = ) { 218 | if ($row =~ /^time (.*)/) { 219 | verbose("found last run time from history: $1", 10) ; 220 | $history{'time'} = $1 ; 221 | } 222 | if ($row =~ /^nfsops (.*)/) { 223 | verbose("found last nfsops value from history: $1", 10) ; 224 | $history{'nfsops'} = $1 ; 225 | } 226 | } 227 | close(FILE) ; 228 | } 229 | return(%history) ; 230 | } 231 | 232 | ################################ 233 | # save data to history file 234 | # arg1 is the history file path 235 | # arg2 is the history hash 236 | # feel free to adapt 237 | ################################ 238 | sub save_history { 239 | my $cachefile = $_[0] ; 240 | my $history = $_[1] ; 241 | my $time ; 242 | 243 | open(FILE, ">$cachefile") ; 244 | print FILE "time ".$history{'time'}."\n" ; 245 | print FILE "nfsops ".$history{'nfsops'}."\n" ; 246 | close(FILE) ; 247 | } 248 | 249 | sub print_usage () { 250 | print "Usage:"; 251 | print "$PROGNAME\n"; 252 | print " -H (--hostname) Hostname to query - (required)\n"; 253 | print " -C (--community) SNMP read community (defaults to public,\n"; 254 | print " used with SNMP v1 and v2c\n"; 255 | print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; 256 | print " 2 for SNMP v2c\n"; 257 | print " -k (--key) snmp V3 key\n"; 258 | print " -p (--password) snmp V3 password\n"; 259 | print " -u (--username) snmp v3 username \n"; 260 | print " -V (--version) Plugin version\n"; 261 | print " -h (--help) usage help\n\n" ; 262 | print " -i (--sysdescr) use sysdescr instead of sysname for label display\n"; 263 | print " -w (--warning) minimal threshold for warning\n" ; 264 | print " -c (--critical) minimal threshold for critical\n" ; 265 | print "\n" ; 266 | print " -d (--debug) debug level (1 -> 15)\n" ; 267 | } 268 | 269 | sub print_help () { 270 | print "##############################################\n"; 271 | print "# ADEO Services #\n"; 272 | print "##############################################\n"; 273 | print_usage(); 274 | print "\n"; 275 | } 276 | 277 | sub verbose { 278 | my $message = $_[0]; 279 | my $messagelevel = $_[1] ; 280 | 281 | 282 | if ($messagelevel <= $loglevel) { 283 | print "$message\n" ; 284 | } 285 | } 286 | 287 | sub get_table { 288 | my $baseoid = $_[0] ; 289 | my $is_indexed = $_[1] ; 290 | my $key; 291 | my $value; 292 | my $result ; 293 | 294 | verbose("get table for oid $baseoid", "10") ; 295 | if ($snmp == 1) { 296 | $result = $session->get_table(-baseoid => $baseoid) ; 297 | }else { 298 | $result = $session->get_table(-baseoid => $baseoid, -maxrepetitions => 20) ; 299 | } 300 | if (!defined($result)) { 301 | print("UNKNOWN: SNMP get_table : ".$session->error()."\n"); 302 | exit $ERRORS{'UNKNOWN'}; 303 | } 304 | my %nexus_values = %{$result} ; 305 | my $id; 306 | my $index; 307 | my %nexus_return; 308 | # this support Cisco nexus indexed tables 309 | while(($key,$value) = each(%nexus_values)) { 310 | $index = $id = $key ; 311 | if ($is_indexed) { 312 | $id =~ s/.*\.([0-9]+)\.[0-9]*$/$1/; 313 | $key =~ s/(.*)\.[0-9]*\.[0-9]*/$1/ ; 314 | $index =~ s/.*\.([0-9]+)$/$1/ ; 315 | verbose("key=$key, id=$id, index=$index, value=$value", "15") ; 316 | $nexus_return{$id}{$key}{$index} = $value; 317 | $nexus_return{$id}{"id"}{$index} = $id ; 318 | }else { 319 | $id =~ s/.*\.([0-9]+)$/$1/; 320 | $key =~ s/(.*)\.[0-9]*/$1/ ; 321 | verbose("key=$key, id=$id, value=$value", "15") ; 322 | $nexus_return{$id}{$key} = $value; 323 | $nexus_return{$id}{"id"} = $id ; 324 | } 325 | } 326 | return(%nexus_return) ; 327 | } 328 | 329 | --------------------------------------------------------------------------------