1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571
|
## 01_update_pre_1.1.2 by Jan Wagner
##
## DP: Update to the latest know CVS verions
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,38 @@
################################
+Release 1.1.2 / Jun 2007 :
+
+Scripts, actual CVS version and changelog :
+check_snmp_mem.pl : 1.3
+check_snmp_vrrp.pl : 1.3
+check_snmp_linkproof_nhr.pl : 1.1
+check_snmp_process.pl : 1.7
+ - Added option to select process with his parameter
+ - Added option for performance output
+ - Corrected negative CPU when process restarts
+ - Added delta option for cpu average (-d option)
+check_snmp_boostedge.pl : 1.2
+check_snmp_nsbox.pl : 1.2
+check_snmp_css_main.pl : 1.1
+check_snmp_cpfw.pl : 1.7
+check_snmp_int.pl : 1.22
+ - Correct speed query for interface > 4 Gbps
+ - Reduced snmp queries to 2 instead of 3 when perf data is on
+ - Bad maximum in perfdata when in Bps
+ - Added option to make dormant state OK
+check_snmp_storage.pl : 1.10
+ - Return an UNKNOWN status when size/used/alloc is not defined in snmp
+ - Patch from Alexander Greiner-B?r to remove the reserved disk space for superuser on ext2/3 FS.
+ New -R option for this
+ - Added -G (giga) option for output & levels in Gigabytes
+check_snmp_win.pl : 0.6
+check_snmp_css.pl : 1.3
+check_snmp_env.pl : 1.8
+ - Added test to check existence of some OIDs
+check_snmp_load.pl : 1.11
+ - Corrected bug in performance output
+ - Added SIG{ALRM} sub and % sign in output
+
+################################
Release 1.1.1 / April 2007 :
Added documentation in doc/ directory : (html format).
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,15 @@
+Installation:
+-------------
+
+You can simply copy the .pl files to the Nagios Plugin directory if
+- Nagios plugins and utils.pm file are in /usr/local/nagios/libexec.
+- You are sure Net::SNMP is installed. (Getopt::Long is standard).
+- perl is in /usr/bin/perl
+- Temp files can be written by Nagios in /tmp
+
+You can also use the "install.sh" script provided in this directory to install the plugins.
+Type : "./install.sh" to install all the plugins or "./install.sh <plugin name>" for a specific one.
+
+The script will check for dependencies and ask for Nagios and temp directories.
+It will modify the scripts depending on these answers and install the scripts.
+
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Nagios SNMP plugins 1.1.1 README
+Nagios SNMP plugins 1.1.2 README
------------------------------
@@ -32,7 +32,7 @@
Legal stuff:
------------
- Nagios SNMP plugins version 1.1.1, Copyright (C) 2004-2007 Patrick Proy (nagios at proy.org)
+ Nagios SNMP plugins version 1.1.2, Copyright (C) 2004-2007 Patrick Proy (nagios at proy.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
--- a/check_snmp_cpfw.pl
+++ b/check_snmp_cpfw.pl
@@ -1,10 +1,11 @@
#!/usr/bin/perl -w
############################## check_snmp_cpfw ##############
-# Version : 1.2.1
-# Date : April 19 2007
+my $Version='1.8';
+# Date : Oct 20 2007
# Author : Patrick Proy (patrick at proy.org)
# Help : http://nagios.manubulon.com
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
+# Contrib : StaGue
# TODO :
# - check sync method
#################################################################
@@ -18,10 +19,8 @@
# Nagios specific
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
########### SNMP Datas ###########
@@ -73,8 +72,6 @@
#################################### Globals ##############################""
-my $Version='1.2.1';
-
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_version2 =undef; # Version 2
@@ -247,7 +244,7 @@
}
$SIG{'ALRM'} = sub {
- print "No answer from host\n";
+ print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
@@ -332,15 +329,15 @@
}
}
} else {
- $svn_print .= "cannot find oids";
+ $svn_print .= "cannot find OIDs";
#Critical state if not found because it means soft is not activated
$svn_state=2;
}
if ($svn_state == 0) {
- $svn_print="SVN : OK";
+ $svn_print="SVN: OK";
} else {
- $svn_print="SVN : " . $svn_print;
+ $svn_print="SVN: " . $svn_print;
}
verb("$svn_print");
}
@@ -363,14 +360,14 @@
}
}
} else {
- $mgmt_print .= "cannot find oids";
+ $mgmt_print .= "cannot find OIDs";
#Critical state if not found because it means soft is not activated
$mgmt_state=2;
}
if ($mgmt_state == 0) {
- $mgmt_print="MGMT : OK";
+ $mgmt_print="MGMT: OK";
} else {
- $mgmt_print="MGMT : " . $mgmt_print;
+ $mgmt_print="MGMT: " . $mgmt_print;
}
verb("$svn_print");
}
@@ -402,7 +399,7 @@
if (defined($o_policy)) {
if ($$resultat{$policy_name} ne $o_policy) {
$fw_state=2;
- $fw_print .= "Policy installed : $$resultat{$policy_name}";
+ $fw_print .= "Policy installed: $$resultat{$policy_name}";
}
}
@@ -419,15 +416,15 @@
$perf_conn=$$resultat{$connections};
}
} else {
- $fw_print .= "cannot find oids";
+ $fw_print .= "cannot find OIDs";
#Critical state if not found because it means soft is not activated
$fw_state=2;
}
if ($fw_state==0) {
- $fw_print="FW : OK";
+ $fw_print="FW: OK";
} else {
- $fw_print="FW : " . $fw_print;
+ $fw_print="FW: " . $fw_print;
}
}
@@ -460,7 +457,7 @@
}
#my $ha_mode = "1.3.6.1.4.1.2620.1.5.11.0"; # "Sync only" : ha Working mode
} else {
- $ha_print .= "cannot find oids";
+ $ha_print .= "cannot find OIDs";
#Critical state if not found because it means soft is not activated
$ha_state_n=2;
}
@@ -484,7 +481,7 @@
}
}
} else {
- $ha_print .= "cannot find oids" if ($ha_state_n ==0);
+ $ha_print .= "cannot find OIDs" if ($ha_state_n ==0);
#Critical state if not found because it means soft is not activated
$ha_state_n=2;
}
@@ -513,9 +510,9 @@
}
if ($ha_state_n == 0) {
- $ha_print = "HA : OK";
+ $ha_print = "HA: OK";
} else {
- $ha_print = "HA : " . $ha_print;
+ $ha_print = "HA: " . $ha_print;
}
}
@@ -532,9 +529,9 @@
if (defined ($o_mgmt)) { $f_print = (defined ($f_print)) ? $f_print . " / ". $mgmt_print : $mgmt_print }
my $exit_status=undef;
-$f_print .= " / CPFW Status : ";
+$f_print .= " / CPFW Status: ";
if (($ha_state_n+$svn_state+$fw_state+$mgmt_state) == 0 ) {
- $f_print .= "OK";
+ $f_print .= "OK, " . $perf_conn . " conn.";
$exit_status= $ERRORS{"OK"};
} else {
if (($fw_state==1) || ($ha_state_n==1) || ($svn_state==1) || ($mgmt_state==1)) {
@@ -547,7 +544,7 @@
}
if (defined($o_perf) && defined ($perf_conn)) {
- $f_print .= " | fw_connexions=" . $perf_conn;
+ $f_print .= " | fw_connexions=" . $perf_conn . ";" . $o_warn . ";" . $o_crit . ";0";
}
print "$f_print\n";
--- a/check_snmp_env.pl
+++ b/check_snmp_env.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
############################## check_snmp_env #################
-# Version : 1.2
-# Date : April 19 2007
+# Version : 1.3
+# Date : May 24 2007
# Author : Patrick Proy ( patrick at proy.org)
# Help : http://www.manubulon.com/nagios/
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
@@ -145,9 +145,24 @@
my @foundry_status = (3,0,2); # oper status : 1:other, 2: Normal, 3: Failure
+# Linux Net-SNMP with LM-SENSORS
+my $linux_temp = "1.3.6.1.4.1.2021.13.16.2.1"; # temperature table
+my $linux_temp_descr = "1.3.6.1.4.1.2021.13.16.2.1.2"; # temperature entry description
+my $linux_temp_value = "1.3.6.1.4.1.2021.13.16.2.1.3"; # temperature entry value (mC)
+my $linux_fan = "1.3.6.1.4.1.2021.13.16.3.1"; # fan table
+my $linux_fan_descr = "1.3.6.1.4.1.2021.13.16.3.1.2"; # fan entry description
+my $linux_fan_value = "1.3.6.1.4.1.2021.13.16.3.1.3"; # fan entry value (RPM)
+my $linux_volt = "1.3.6.1.4.1.2021.13.16.4.1"; # voltage table
+my $linux_volt_descr = "1.3.6.1.4.1.2021.13.16.4.1.2"; # voltage entry description
+my $linux_volt_value = "1.3.6.1.4.1.2021.13.16.4.1.3"; # voltage entry value (mV)
+my $linux_misc = "1.3.6.1.4.1.2021.13.16.4.1"; # misc table
+my $linux_misc_descr = "1.3.6.1.4.1.2021.13.16.4.1.2"; # misc entry description
+my $linux_misc_value = "1.3.6.1.4.1.2021.13.16.4.1.3"; # misc entry value
+
+
# Globals
-my $Version='1.2';
+my $Version='1.3';
my $o_host = undef; # hostname
my $o_community = undef; # community
@@ -160,7 +175,7 @@
my $o_version2= undef; # use snmp v2c
# check type
my $o_check_type= "cisco"; # default Cisco
-my @valid_types =("cisco","nokia","bc","iron","foundry");
+my @valid_types =("cisco","nokia","bc","iron","foundry","linux");
my $o_temp= undef; # max temp
my $o_fan= undef; # min fan speed
@@ -177,7 +192,7 @@
sub p_version { print "check_snmp_env version : $Version\n"; }
sub print_usage {
- print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -T (cisco|nokia|bc|iron|foundry) [-F <rpm>] [-c <celcius>] [-f] [-t <timeout>] [-V]\n";
+ print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -T (cisco|nokia|bc|iron|foundry|linux) [-F <rpm>] [-c <celcius>] [-f] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
@@ -221,17 +236,18 @@
-P, --port=PORT
SNMP port (Default 161)
-T, --type=cisco|nokia|bc|iron|foundry
- Environemental check :
- cisco : voltage,temp,fan,power supply status
- will try to check everything present
- nokia : fan and power supply
- bc : fans, power supply, voltage, disks
- iron : fans, power supply, temp
- foundry : power supply, temp
+ Environemental check :
+ cisco : All Cisco equipements : voltage,temp,fan,power supply
+ (will try to check everything in the env mib)
+ nokia : Nokia IP platforms : fan and power supply
+ bc : BlueCoat platforms : fans, power supply, voltage, disks
+ iron : IronPort platforms : fans, power supply, temp
+ foundry : Foundry Network platforms : power supply, temp
+ linux : Net-SNMP with LM-SENSORS : temp, fan, volt, misc
-F, --fan=<rpm>
- Minimum fan rpm value
+ Minimum fan rpm value (only needed for 'iron' & 'linux')
-c, --celcius=<celcius>
- Maximum temp in degree celcius
+ Maximum temp in degree celcius (only needed for 'iron' & 'linux')
-f, --perfparse
Perfparse compatible output
-t, --timeout=INTEGER
@@ -428,8 +444,10 @@
if (!defined ($cur_status)) { ### Error TODO
$volt_global=1;
}
- $perf_output.=" '".$$resultat{$ciscoVoltageTableDesc .".".$voltindex[$i]}."'=" ;
- $perf_output.=$$resultat{$ciscoVoltageTableValue."." . $voltindex[$i]};
+ if (defined($$resultat{$ciscoVoltageTableValue."." . $voltindex[$i]})) {
+ $perf_output.=" '".$$resultat{$ciscoVoltageTableDesc .".".$voltindex[$i]}."'=" ;
+ $perf_output.=$$resultat{$ciscoVoltageTableValue."." . $voltindex[$i]};
+ }
if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") {
$volt_global= 1;
$volt_status{$$resultat{$ciscoVoltageTableDesc .".".$voltindex[$i]}}=$cur_status;
@@ -448,8 +466,10 @@
if (!defined ($cur_status)) { ### Error TODO
$temp_global=1;
}
- $perf_output.=" '".$$resultat{$ciscoTempTableDesc .".".$tempindex[$i]}."'=" ;
- $perf_output.=$$resultat{$ciscoTempTableValue."." . $tempindex[$i]};
+ if (defined($$resultat{$ciscoTempTableValue."." . $tempindex[$i]})) {
+ $perf_output.=" '".$$resultat{$ciscoTempTableDesc .".".$tempindex[$i]}."'=" ;
+ $perf_output.=$$resultat{$ciscoTempTableValue."." . $tempindex[$i]};
+ }
if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") {
$temp_global= 1;
$temp_status{$$resultat{$ciscoTempTableDesc .".".$tempindex[$i]}}=$cur_status;
@@ -1003,4 +1023,14 @@
}
-exit (3);
+########### Cisco env checks ##############
+if ($o_check_type eq "linux") {
+
+ verb("Checking linux env");
+
+ print "Not implemented yet : UNKNOWN\n";
+ exit $ERRORS{"UNKNOWN"};
+}
+
+print "Unknown check type : UNKNOWN\n";
+exit $ERRORS{"UNKNOWN"};
--- a/check_snmp_int.pl
+++ b/check_snmp_int.pl
@@ -1,13 +1,12 @@
#!/usr/bin/perl -w
############################## check_snmp_int ##############
-# Version : 1.4.6
-# Date : April 23 2007
+my $Version='1.24';
+# Date : Oct 10 2007
# Author : Patrick Proy ( patrick at proy.org )
# Help : http://nagios.manubulon.com
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
# Contrib : J. Jungmann, S. Probst, R. Leroy, M. Berger
# TODO :
-# Check isdn "dormant" state
# Maybe put base directory for performance as an option
#################################################################
#
@@ -23,10 +22,8 @@
# Nagios specific
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 5;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
@@ -36,6 +33,7 @@
my $oper_table = '1.3.6.1.2.1.2.2.1.8.';
my $admin_table = '1.3.6.1.2.1.2.2.1.7.';
my $speed_table = '1.3.6.1.2.1.2.2.1.5.';
+my $speed_table_64 = '1.3.6.1.2.1.31.1.1.1.15.';
my $in_octet_table = '1.3.6.1.2.1.2.2.1.10.';
my $in_octet_table_64 = '1.3.6.1.2.1.31.1.1.1.6.';
my $in_error_table = '1.3.6.1.2.1.2.2.1.14.';
@@ -49,7 +47,6 @@
# Globals
-my $Version='1.4.6';
# Standard options
my $o_host = undef; # hostname
@@ -58,6 +55,7 @@
my $o_help= undef; # wan't some help ?
my $o_admin= undef; # admin status instead of oper
my $o_inverse= undef; # Critical when up
+my $o_dormant= undef; # Dormant state is OK
my $o_verb= undef; # verbose mode
my $o_version= undef; # print version
my $o_noreg= undef; # Do not use Regexp for name
@@ -66,16 +64,16 @@
# Performance data options
my $o_perf= undef; # Output performance data
my $o_perfe= undef; # Output discard/error also in perf data
-my $o_perfs= undef; # include speed in performance output (-S)
-my $o_perfp= undef; # output performance data in % of max speed (-y)
-my $o_perfr= undef; # output performance data in bits/s or Bytes/s (-Y)
+my $o_perfs= undef; # include speed in performance output (-S)
+my $o_perfp= undef; # output performance data in % of max speed (-y)
+my $o_perfr= undef; # output performance data in bits/s or Bytes/s (-Y)
# Speed/error checks
my $o_checkperf= undef; # checks in/out/err/disc values
my $o_delta= 300; # delta of time of perfcheck (default 5min)
my $o_ext_checkperf= undef; # extended perf checks (+error+discard)
my $o_warn_opt= undef; # warning options
my $o_crit_opt= undef; # critical options
-my $o_kbits= undef; # Warn and critical in Kbits instead of KBytes
+my $o_kbits= undef; # Warn and critical in Kbits instead of KBytes
my @o_warn= undef; # warning levels of perfcheck
my @o_crit= undef; # critical levels of perfcheck
my $o_highperf= undef; # Use 64 bits counters
@@ -152,7 +150,7 @@
sub p_version { print "check_snmp_int version : $Version\n"; }
sub print_usage {
- print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>) [-p <port>] -n <name in desc_oid> [-i] [-a] [-r] [-f[eSyY]] [-k[qBMGu] -g -w<warn levels> -c<crit levels> -d<delta>] [-o <octet_length>] [-t <timeout>] [-s] --label [-V]\n";
+ print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>) [-p <port>] -n <name in desc_oid> [-i -a -D] [-r] [-f[eSyY]] [-k[qBMGu] -g -w<warn levels> -c<crit levels> -d<delta>] [-o <octet_length>] [-t <timeout>] [-s] --label [-V]\n";
}
sub isnnum { # Return true if arg is not a number
@@ -195,6 +193,8 @@
Make critical when up
-a, --admin
Use administrative status instead of operational
+-D, --dormant
+ Dormant state is an OK state
-o, --octetlength=INTEGER
max-size of the SNMP message, usefull in case of Too Long responses.
Be carefull with network filters. Range 484 - 65535, default are
@@ -214,8 +214,8 @@
--label
Add label before speed in output : in=, out=, errors-out=, etc...
-g, --64bits
- Use 64 bits counters instead of the standard counters
- when checking bandwidth & performance data.
+ Use 64 bits counters instead of the standard counters when checking
+ bandwidth & performance data for interface >= 1Gbps.
You must use snmp v2c or v3 to get 64 bits counters.
-d, --delta=seconds
make an average of <delta> seconds (default 300=5min)
@@ -284,7 +284,8 @@
'u' => \$o_prct, 'prct' => \$o_prct,
'o:i' => \$o_octetlength, 'octetlength:i' => \$o_octetlength,
'label' => \$o_label,
- 'd:i' => \$o_delta, 'delta:i' => \$o_delta
+ 'd:i' => \$o_delta, 'delta:i' => \$o_delta,
+ 'D' => \$o_dormant, 'dormant' => \$o_dormant
);
if (defined ($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}};
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}};
@@ -460,6 +461,7 @@
my (@oid_perf,@oid_perf_outoct,@oid_perf_inoct,@oid_perf_inerr,@oid_perf_outerr,@oid_perf_indisc,@oid_perf_outdisc)=
(undef,undef,undef,undef,undef,undef,undef);
my @oid_speed=undef;
+my @oid_speed_high=undef;
my $num_int = 0;
# Change to 64 bit counters if option is set :
@@ -494,7 +496,8 @@
if (defined($o_perf) || defined($o_checkperf)) {
$oid_perf_inoct[$num_int]= $in_octet_table . $tindex[$num_int];
$oid_perf_outoct[$num_int]= $out_octet_table . $tindex[$num_int];
- $oid_speed[$num_int]=$speed_table . $tindex[$num_int];
+ $oid_speed[$num_int]=$speed_table . $tindex[$num_int];
+ $oid_speed_high[$num_int]=$speed_table_64 . $tindex[$num_int];
if (defined($o_ext_checkperf) || defined($o_perfe)) {
$oid_perf_indisc[$num_int]= $in_discard_table . $tindex[$num_int];
$oid_perf_outdisc[$num_int]= $out_discard_table . $tindex[$num_int];
@@ -509,25 +512,25 @@
# No interface found -> error
if ( $num_int == 0 ) { print "ERROR : Unknown interface $o_descr\n" ; exit $ERRORS{"UNKNOWN"};}
-my ($result,$resultf)=(undef,undef);
+my $result=undef;
+# Add performance oids if requested
+if (defined($o_perf)||defined($o_checkperf)) {
+ @oids=(@oids,@oid_perf_outoct,@oid_perf_inoct,@oid_speed);
+ if (defined($o_highperf)) {
+ @oids=(@oids,@oid_speed_high);
+ }
+ if (defined ($o_ext_checkperf) || defined($o_perfe)) {
+ @oids=(@oids,@oid_perf_inerr,@oid_perf_outerr,@oid_perf_indisc,@oid_perf_outdisc);
+ }
+}
+
# Get the requested oid values
$result = $session->get_request(
Varbindlist => \@oids
);
-if (!defined($result)) { printf("ERROR: Status table : %s.\n", $session->error); $session->close;
+if (!defined($result)) { printf("ERROR: Status/statistics table : %s.\n", $session->error); $session->close;
exit $ERRORS{"UNKNOWN"};
}
-# Get the perf value if -f (performance) option defined or -k (check bandwidth)
-if (defined($o_perf)||defined($o_checkperf)) {
- @oid_perf=(@oid_perf_outoct,@oid_perf_inoct,@oid_perf_inerr,@oid_perf_outerr,@oid_perf_indisc,@oid_perf_outdisc,@oid_speed);
- $resultf = $session->get_request(
- Varbindlist => \@oid_perf
- );
- if (!defined($resultf)) { printf("ERROR: Statistics table : %s.\n", $session->error); $session->close;
- exit $ERRORS{"UNKNOWN"};
- }
-}
-
$session->close;
@@ -544,6 +547,7 @@
my $trigger_low=$timenow - 3*$o_delta;
my ($old_value,$old_time)=undef;
my $speed_unit=undef;
+my $speed_real=undef; # speed of interface using either standard or highperf mib.
# define the OK value depending on -i option
my $ok_val= defined ($o_inverse) ? 2 : 1;
@@ -570,7 +574,22 @@
$n_rows = shift(@ret_array);
if ($n_rows != 0) { @file_values = @ret_array };
verb ("File read returns : $return with $n_rows rows");
- verb ("Interface speed : $$resultf{$oid_speed[$i]}");
+ # Get the speed in normal or highperf speed counters
+ if ($$result{$oid_speed[$i]} == 4294967295) { # Too high for this counter (cf IF-MIB)
+ if (! defined($o_highperf) && (defined($o_prct) || defined ($o_perfs) || defined ($o_perfp))) {
+ print "Cannot get interface speed with standard MIB, use highperf mib (-g) : UNKNOWN\n";
+ exit $ERRORS{"UNKNOWN"}
+ }
+ if (defined ($$result{$oid_speed_high[$i]}) && $$result{$oid_speed_high[$i]} != 0) {
+ $speed_real=$$result{$oid_speed_high[$i]} * 1000000;
+ } else {
+ print "Cannot get interface speed using highperf mib : UNKNOWN\n";
+ exit $ERRORS{"UNKNOWN"}
+ }
+ } else {
+ $speed_real=$$result{$oid_speed[$i]};
+ }
+ verb ("Interface speed : $speed_real");
#make the checks if the file is OK
if ($return ==0) {
my $j=$n_rows-1;
@@ -583,7 +602,7 @@
my $speed_metric=undef;
if (defined($o_prct)) { # in % of speed
# Speed is in bits/s, calculated speed is in Bytes/s
- $speed_metric=$$resultf{$oid_speed[$i]}/800;
+ $speed_metric=$speed_real/800;
$speed_unit="%";
} else {
if (defined($o_kbits)) { # metric in bits
@@ -614,24 +633,24 @@
# First set the modulus depending on highperf counters or not
my $overfl_mod = defined ($o_highperf) ? 18446744073709551616 : 4294967296;
# Check counter (s)
- my $overfl = ($$resultf{$oid_perf_inoct[$i]} >= $file_values[$j][1] ) ? 0 : $overfl_mod;
- $checkperf_out_raw[0] = ( ($overfl + $$resultf{$oid_perf_inoct[$i]} - $file_values[$j][1])/
+ my $overfl = ($$result{$oid_perf_inoct[$i]} >= $file_values[$j][1] ) ? 0 : $overfl_mod;
+ $checkperf_out_raw[0] = ( ($overfl + $$result{$oid_perf_inoct[$i]} - $file_values[$j][1])/
($timenow - $file_values[$j][0] ));
$checkperf_out[0] = $checkperf_out_raw[0] / $speed_metric;
- $overfl = ($$resultf{$oid_perf_outoct[$i]} >= $file_values[$j][2] ) ? 0 : $overfl_mod;
- $checkperf_out_raw[1] = ( ($overfl + $$resultf{$oid_perf_outoct[$i]} - $file_values[$j][2])/
+ $overfl = ($$result{$oid_perf_outoct[$i]} >= $file_values[$j][2] ) ? 0 : $overfl_mod;
+ $checkperf_out_raw[1] = ( ($overfl + $$result{$oid_perf_outoct[$i]} - $file_values[$j][2])/
($timenow - $file_values[$j][0] ));
$checkperf_out[1] = $checkperf_out_raw[1] / $speed_metric;
if (defined($o_ext_checkperf)) {
- $checkperf_out[2] = ( ($$resultf{$oid_perf_inerr[$i]} - $file_values[$j][3])/
+ $checkperf_out[2] = ( ($$result{$oid_perf_inerr[$i]} - $file_values[$j][3])/
($timenow - $file_values[$j][0] ))*60;
- $checkperf_out[3] = ( ($$resultf{$oid_perf_outerr[$i]} - $file_values[$j][4])/
+ $checkperf_out[3] = ( ($$result{$oid_perf_outerr[$i]} - $file_values[$j][4])/
($timenow - $file_values[$j][0] ))*60;
- $checkperf_out[4] = ( ($$resultf{$oid_perf_indisc[$i]} - $file_values[$j][5])/
+ $checkperf_out[4] = ( ($$result{$oid_perf_indisc[$i]} - $file_values[$j][5])/
($timenow - $file_values[$j][0] ))*60;
- $checkperf_out[5] = ( ($$resultf{$oid_perf_outdisc[$i]} - $file_values[$j][6])/
+ $checkperf_out[5] = ( ($$result{$oid_perf_outdisc[$i]} - $file_values[$j][6])/
($timenow - $file_values[$j][0] ))*60;
}
}
@@ -641,13 +660,13 @@
}
# Put the new values in the array and write the file
$file_values[$n_rows][0]=$timenow;
- $file_values[$n_rows][1]=$$resultf{$oid_perf_inoct[$i]};
- $file_values[$n_rows][2]=$$resultf{$oid_perf_outoct[$i]};
+ $file_values[$n_rows][1]=$$result{$oid_perf_inoct[$i]};
+ $file_values[$n_rows][2]=$$result{$oid_perf_outoct[$i]};
if (defined($o_ext_checkperf)) { # Add other values (error & disc)
- $file_values[$n_rows][3]=$$resultf{$oid_perf_inerr[$i]};
- $file_values[$n_rows][4]=$$resultf{$oid_perf_outerr[$i]};
- $file_values[$n_rows][5]=$$resultf{$oid_perf_indisc[$i]};
- $file_values[$n_rows][6]=$$resultf{$oid_perf_outdisc[$i]};
+ $file_values[$n_rows][3]=$$result{$oid_perf_inerr[$i]};
+ $file_values[$n_rows][4]=$$result{$oid_perf_outerr[$i]};
+ $file_values[$n_rows][5]=$$result{$oid_perf_indisc[$i]};
+ $file_values[$n_rows][6]=$$result{$oid_perf_outdisc[$i]};
}
$n_rows++;
$return=write_file($temp_file_name,$n_rows,$n_items_check,@file_values);
@@ -703,62 +722,79 @@
}
# Get rid of special caracters for performance in description
$descr[$i] =~ s/'\/\(\)/_/g;
- if ( $int_status == $ok_val) {
+ if (( $int_status == $ok_val)||(defined($o_dormant) && $int_status == 5)) {
$num_ok++;
}
if (( $int_status == 1 ) && defined ($o_perf)) {
if (defined ($o_perfp)) { # output in % of speed
if ($usable_data==1) {
+ my $warn_factor=1;
+ if (!defined($o_prct)) { # warn&crit in K|M|G B|bps -> put warn_factor to make %
+ $warn_factor = (defined($o_meg)) ? 1000000 : (defined($o_gig)) ? 1000000000 : 1000;
+ if (!defined($o_kbits)) { $warn_factor*=8;}
+ $warn_factor/=$speed_real;
+ $warn_factor*=100; # now turn into displayed % : 0,1 = 10%
+ }
$perf_out .= "'" . $descr[$i] ."_in_prct'=";
- $perf_out .= sprintf("%.0f",$checkperf_out_raw[0] * 800 / $$resultf{$oid_speed[$i]}) ."%;";
- $perf_out .= ($o_warn[0]!=0) ? $o_warn[0] . ";" : ";";
- $perf_out .= ($o_crit[0]!=0) ? $o_crit[0] . ";" : ";";
+ $perf_out .= sprintf("%.0f",$checkperf_out_raw[0] * 800 / $speed_real) ."%;";
+ $perf_out .= ($o_warn[0]!=0) ? sprintf("%.0f",$o_warn[0]*$warn_factor) . ";" : ";";
+ $perf_out .= ($o_crit[0]!=0) ? sprintf("%.0f",$o_crit[0]*$warn_factor) . ";" : ";";
$perf_out .= "0;100 ";
$perf_out .= "'" . $descr[$i] ."_out_prct'=";
- $perf_out .= sprintf("%.0f",$checkperf_out_raw[1] * 800 / $$resultf{$oid_speed[$i]}) ."%;";
- $perf_out .= ($o_warn[1]!=0) ? $o_warn[1] . ";" : ";";
- $perf_out .= ($o_crit[1]!=0) ? $o_crit[1] . ";" : ";";
+ $perf_out .= sprintf("%.0f",$checkperf_out_raw[1] * 800 / $speed_real) ."%;";
+ $perf_out .= ($o_warn[1]!=0) ? sprintf("%.0f",$o_warn[1]*$warn_factor) . ";" : ";";
+ $perf_out .= ($o_crit[1]!=0) ? sprintf("%.0f",$o_crit[1]*$warn_factor) . ";" : ";";
$perf_out .= "0;100 ";
}
} elsif (defined ($o_perfr)) { # output in bites or Bytes /s
if ($usable_data==1) {
if (defined($o_kbits)) { # bps
# put warning and critical levels into bps or Bps
- my $warn_factor = (defined($o_meg)) ? 1000000 : (defined($o_gig)) ? 1000000000 : 1000;
+ my $warn_factor;
+ if (defined($o_prct)) { # warn&crit in % -> put warn_factor to 1% of speed in bps
+ $warn_factor=$speed_real/100;
+ } else { # just convert from K|M|G bps
+ $warn_factor = (defined($o_meg)) ? 1000000 : (defined($o_gig)) ? 1000000000 : 1000;
+ }
$perf_out .= "'" . $descr[$i] ."_in_bps'=";
$perf_out .= sprintf("%.0f",$checkperf_out_raw[0] * 8) .";";
$perf_out .= ($o_warn[0]!=0) ? $o_warn[0]*$warn_factor . ";" : ";";
$perf_out .= ($o_crit[0]!=0) ? $o_crit[0]*$warn_factor . ";" : ";";
- $perf_out .= "0;". $$resultf{$oid_speed[$i]} ." ";
+ $perf_out .= "0;". $speed_real ." ";
$perf_out .= "'" . $descr[$i] ."_out_bps'=";
$perf_out .= sprintf("%.0f",$checkperf_out_raw[1] * 8) .";";
$perf_out .= ($o_warn[1]!=0) ? $o_warn[1]*$warn_factor . ";" : ";";
$perf_out .= ($o_crit[1]!=0) ? $o_crit[1]*$warn_factor . ";" : ";";
- $perf_out .= "0;". $$resultf{$oid_speed[$i]} ." ";
+ $perf_out .= "0;". $speed_real ." ";
} else { # Bps
- my $warn_factor = (defined($o_meg)) ? 1048576 : (defined($o_gig)) ? 1073741824 : 1024;
+ my $warn_factor;
+ if (defined($o_prct)) { # warn&crit in % -> put warn_factor to 1% of speed in Bps
+ $warn_factor=$speed_real/800;
+ } else { # just convert from K|M|G bps
+ $warn_factor = (defined($o_meg)) ? 1048576 : (defined($o_gig)) ? 1073741824 : 1024;
+ }
$perf_out .= "'" . $descr[$i] ."_in_Bps'=" . sprintf("%.0f",$checkperf_out_raw[0]) .";";
$perf_out .= ($o_warn[0]!=0) ? $o_warn[0]*$warn_factor . ";" : ";";
$perf_out .= ($o_crit[0]!=0) ? $o_crit[0]*$warn_factor . ";" : ";";
- $perf_out .= "0;". $$resultf{$oid_speed[$i]} ." ";
+ $perf_out .= "0;". $speed_real / 8 ." ";
$perf_out .= "'" . $descr[$i] ."_out_Bps'=" . sprintf("%.0f",$checkperf_out_raw[1]) .";" ;
$perf_out .= ($o_warn[1]!=0) ? $o_warn[1]*$warn_factor . ";" : ";";
$perf_out .= ($o_crit[1]!=0) ? $o_crit[1]*$warn_factor . ";" : ";";
- $perf_out .= "0;". $$resultf{$oid_speed[$i]} ." ";
+ $perf_out .= "0;". $speed_real / 8 ." ";
}
}
} else { # output in octet counter
- $perf_out .= "'" . $descr[$i] ."_in_octet'=". $$resultf{$oid_perf_inoct[$i]} ."c ";
- $perf_out .= "'" . $descr[$i] ."_out_octet'=". $$resultf{$oid_perf_outoct[$i]} ."c";
+ $perf_out .= "'" . $descr[$i] ."_in_octet'=". $$result{$oid_perf_inoct[$i]} ."c ";
+ $perf_out .= "'" . $descr[$i] ."_out_octet'=". $$result{$oid_perf_outoct[$i]} ."c ";
}
if (defined ($o_perfe)) {
- $perf_out .= " '" . $descr[$i] ."_in_error'=". $$resultf{$oid_perf_inerr[$i]} ."c ";
- $perf_out .= "'" . $descr[$i] ."_in_discard'=". $$resultf{$oid_perf_indisc[$i]} ."c ";
- $perf_out .= "'" . $descr[$i] ."_out_error'=". $$resultf{$oid_perf_outerr[$i]} ."c ";
- $perf_out .= "'" . $descr[$i] ."_out_discard'=". $$resultf{$oid_perf_outdisc[$i]} ."c";
+ $perf_out .= "'" . $descr[$i] ."_in_error'=". $$result{$oid_perf_inerr[$i]} ."c ";
+ $perf_out .= "'" . $descr[$i] ."_in_discard'=". $$result{$oid_perf_indisc[$i]} ."c ";
+ $perf_out .= "'" . $descr[$i] ."_out_error'=". $$result{$oid_perf_outerr[$i]} ."c ";
+ $perf_out .= "'" . $descr[$i] ."_out_discard'=". $$result{$oid_perf_outdisc[$i]} ."c ";
}
if (defined ($o_perfs)) {
- $perf_out .= " '" . $descr[$i] ."_speed_bps'=".$$resultf{$oid_speed[$i]};
+ $perf_out .= "'" . $descr[$i] ."_speed_bps'=".$speed_real;
}
}
}
--- a/check_snmp_load.pl
+++ b/check_snmp_load.pl
@@ -1,11 +1,10 @@
#!/usr/bin/perl -w
############################## check_snmp_load #################
-# Version : 1.3.2
-# Date : Jan 16 2007
+my $Version='1.12';
+# Date : Oct 12 2007
# Author : Patrick Proy ( patrick at proy.org)
-# Help : http://www.manubulon.com/nagios/
+# Help : http://nagios.manubulon.com/
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
-# Changelog : HP-UX load added.
# Contributors : F. Lacroix and many others !!!
#################################################################
#
@@ -18,10 +17,8 @@
# Nagios specific
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
@@ -94,7 +91,6 @@
# Globals
-my $Version='1.3.2';
my $o_host = undef; # hostname
my $o_community = undef; # community
--- a/check_snmp_mem.pl
+++ b/check_snmp_mem.pl
@@ -1,11 +1,11 @@
#!/usr/bin/perl -w
############################## check_snmp_mem ##############
-# Version : 1.1
-# Date : Jul 09 2006
+my $Version='1.5';
+# Date : 17 October 2007
# Author : Patrick Proy (nagios at proy.org)
-# Help : http://www.manubulon.com/nagios/
+# Help : http://nagios.manubulon.com/
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
-# Contrib : Jan Jungmann
+# Contrib : Jan Jungmann, Patrick Griffin
# TODO :
#################################################################
#
@@ -18,10 +18,8 @@
# Nagios specific
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
@@ -29,10 +27,11 @@
my $nets_ram_free = "1.3.6.1.4.1.2021.4.6.0"; # Real memory free
my $nets_ram_total = "1.3.6.1.4.1.2021.4.5.0"; # Real memory total
-my $nets_ram_cache = "1.3.6.1.4.1.2021.4.15.0"; # Real memory cached
+my $nets_ram_buffer = "1.3.6.1.4.1.2021.4.14.0"; # Real memory buffered
+my $nets_ram_cache = "1.3.6.1.4.1.2021.4.15.0"; # Real memory cached
my $nets_swap_free = "1.3.6.1.4.1.2021.4.4.0"; # swap memory free
my $nets_swap_total = "1.3.6.1.4.1.2021.4.3.0"; # Swap memory total
-my @nets_oids = ($nets_ram_free,$nets_ram_total,$nets_swap_free,$nets_swap_total,$nets_ram_cache);
+my @nets_oids = ($nets_ram_free,$nets_ram_total,$nets_swap_free,$nets_swap_total,$nets_ram_cache,$nets_ram_buffer);
# Cisco
@@ -60,7 +59,6 @@
# Globals
-my $Version='1.1';
my $o_host = undef; # hostname
my $o_community = undef; # community
@@ -79,6 +77,7 @@
my $o_critS= undef; # critical level for swap
my $o_perf= undef; # Performance data option
my $o_cache= undef; # Include cached memory as used memory
+my $o_buffer= undef; # Exclude buffered memory as used memory
my $o_timeout= undef; # Timeout (Default 5)
my $o_version2= undef; # use snmp v2c
# SNMPv3 specific
@@ -94,7 +93,7 @@
sub p_version { print "check_snmp_mem version : $Version\n"; }
sub print_usage {
- print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -w <warn level> -c <crit level> [-I|-N|-E] [-f] [-m] [-t <timeout>] [-V]\n";
+ print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -w <warn level> -c <crit level> [-I|-N|-E] [-f] [-m -b] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
@@ -109,11 +108,11 @@
sub help {
print "\nSNMP Memory Monitor for Nagios version ",$Version,"\n";
- print "(c)2004-2006 to my cat Ratoune - Author: Patrick Proy\n\n";
+ print "GPL licence, (c)2004-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
- print extra debugging information (including interface list on the system)
+ print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
@@ -144,6 +143,8 @@
check linux memory & swap provided by Net SNMP
-m, --memcache
include cached memory in used memory (only with Net-SNMP)
+-b, --membuffer
+ exclude buffered memory in used memory (only with Net-SNMP)
-I, --cisco
check cisco memory (sum of all memory pools)
-E, --hp
@@ -187,6 +188,7 @@
'c:s' => \$o_crit, 'critical:s' => \$o_crit,
'w:s' => \$o_warn, 'warn:s' => \$o_warn,
'm' => \$o_cache, 'memcache' => \$o_cache,
+ 'b' => \$o_buffer, 'membuffer' => \$o_buffer,
'f' => \$o_perf, 'perfdata' => \$o_perf
);
if (defined ($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}};
@@ -267,6 +269,7 @@
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
+ -port => $o_port,
-timeout => $o_timeout
);
} else {
@@ -279,6 +282,7 @@
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
+ -port => $o_port,
-timeout => $o_timeout
);
}
@@ -473,22 +477,23 @@
}
my ($realused,$swapused)=(undef,undef);
+ my $totalcachedbuffered = 0;
+ if (defined($o_buffer)) {
+ $totalcachedbuffered = $$resultat{$nets_ram_buffer};
+ }
+ if (!defined($o_cache)) {
+ $totalcachedbuffered = $totalcachedbuffered + $$resultat{$nets_ram_cache};
+ }
+
+ $realused = ($$resultat{$nets_ram_total}-($$resultat{$nets_ram_free}+$totalcachedbuffered)) / $$resultat{$nets_ram_total};
- $realused= defined($o_cache) ?
- ($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free})/$$resultat{$nets_ram_total}
- :
- ($$resultat{$nets_ram_total}-($$resultat{$nets_ram_free}+$$resultat{$nets_ram_cache}))/$$resultat{$nets_ram_total};
-
if($$resultat{$nets_ram_total} == 0) { $realused = 0; }
$swapused= ($$resultat{$nets_swap_total} == 0) ? 0 :
($$resultat{$nets_swap_total}-$$resultat{$nets_swap_free})/$$resultat{$nets_swap_total};
$realused=round($realused*100,0);
$swapused=round($swapused*100,0);
- defined($o_cache) ?
- verb ("Ram : $$resultat{$nets_ram_free} / $$resultat{$nets_ram_total} : $realused")
- :
- verb ("Ram : $$resultat{$nets_ram_free} ($$resultat{$nets_ram_cache} cached) / $$resultat{$nets_ram_total} : $realused");
+ verb ("Ram : $$resultat{$nets_ram_free} ($$resultat{$nets_ram_cache} cached, $$resultat{$nets_ram_buffer} buff) / $$resultat{$nets_ram_total} : $realused");
verb ("Swap : $$resultat{$nets_swap_free} / $$resultat{$nets_swap_total} : $swapused");
my $n_status="OK";
--- a/check_snmp_process.pl
+++ b/check_snmp_process.pl
@@ -1,45 +1,43 @@
#!/usr/bin/perl -w
############################## check_snmp_process ##############
-# Version : 1.4
-# Date : March 12 2007
-# Author : Patrick Proy (patrick at proy.org)
+my $Version='1.10';
+# Date : Oct 12 2007
+# Author : Patrick Proy (patrick at proy dot org)
# Help : http://nagios.manubulon.com
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
-# Contrib : Makina Corpus
+# Contrib : Makina Corpus, adam At greekattic d0t com
# TODO : put $o_delta as an option
-# Contrib :
+# If testing on localhost, selects itself....
###############################################################
#
# help : ./check_snmp_process -h
+use strict;
+use Net::SNMP;
+use Getopt::Long;
+
############### BASE DIRECTORY FOR TEMP FILE ########
my $o_base_dir="/tmp/tmp_Nagios_proc.";
my $file_history=200; # number of data to keep in files.
my $delta_of_time_to_make_average=300; # 5minutes by default
-
-use strict;
-use Net::SNMP;
-use Getopt::Long;
# Nagios specific
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 5;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
my $process_table= '1.3.6.1.2.1.25.4.2.1';
my $index_table = '1.3.6.1.2.1.25.4.2.1.1';
my $run_name_table = '1.3.6.1.2.1.25.4.2.1.2';
my $run_path_table = '1.3.6.1.2.1.25.4.2.1.4';
+my $run_param_table = '1.3.6.1.2.1.25.4.2.1.5';
my $proc_mem_table = '1.3.6.1.2.1.25.5.1.1.2'; # Kbytes
my $proc_cpu_table = '1.3.6.1.2.1.25.5.1.1.1'; # Centi sec of CPU
my $proc_run_state = '1.3.6.1.2.1.25.4.2.1.7';
# Globals
-my $Version='1.4';
my $o_host = undef; # hostname
my $o_community =undef; # community
@@ -57,6 +55,8 @@
my $o_path= undef; # check path instead of name
my $o_inverse= undef; # checks max instead of min number of process
my $o_get_all= undef; # get all tables at once
+my $o_param= undef; # Add process parameters for selection
+my $o_perf= undef; # Add performance output
my $o_timeout= 5; # Default 5s Timeout
# SNMP V3 specific
my $o_login= undef; # snmp v3 login
@@ -80,7 +80,7 @@
sub p_version { print "check_snmp_process version : $Version\n"; }
sub print_usage {
- print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd) [-p <port>] -n <name> [-w <min_proc>[,<max_proc>] -c <min_proc>[,max_proc] ] [-m<warn Mb>,<crit Mb> -a -u<warn %>,<crit%> ] [-t <timeout>] [-o <octet_length>] [-f ] [-r] [-V] [-g]\n";
+ print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd) [-p <port>] -n <name> [-w <min_proc>[,<max_proc>] -c <min_proc>[,max_proc] ] [-m<warn Mb>,<crit Mb> -a -u<warn %>,<crit%> -d<delta> ] [-t <timeout>] [-o <octet_length>] [-f -A -F ] [-r] [-V] [-g]\n";
}
sub isnotnum { # Return true if arg is not a number
@@ -174,6 +174,12 @@
-f, --fullpath
Use full path name instead of process name
(Windows doesn't provide full path name)
+-A, --param
+ Add parameters to select processes.
+ ex : "named.*-t /var/named/chroot" will only select named process with this parameter
+-F, --perfout
+ Add performance output
+ outputs : memory_usage, num_process, cpu_usage
-w, --warn=MIN[,MAX]
Number of process that will cause a warning
-1 for no warning, MAX must be >0. Ex : -w-1,50
@@ -193,6 +199,8 @@
checks cpu usage of all process
values are warning and critical values in % of CPU usage
if more than one CPU, value can be > 100% : 100%=1 CPU
+-d, --delta=seconds
+ make an average of <delta> seconds for CPU (default 300=5min)
-g, --getall
In some cases, it is necessary to get all data at once because
process die very frequently.
@@ -242,6 +250,9 @@
'2' => \$o_version2, 'v2c' => \$o_version2,
'o:i' => \$o_octetlength, 'octetlength:i' => \$o_octetlength,
'g' => \$o_get_all, 'getall' => \$o_get_all,
+ 'A' => \$o_param, 'param' => \$o_param,
+ 'F' => \$o_perf, 'perfout' => \$o_perf,
+ 'd:i' => \$o_delta, 'delta:i' => \$o_delta,
'V' => \$o_version, 'version' => \$o_version
);
if (defined ($o_help)) { help(); exit $ERRORS{"UNKNOWN"}};
@@ -411,6 +422,19 @@
exit $ERRORS{"UNKNOWN"};
}
+my $resultat_param=undef;
+if (defined($o_param)) { # Get parameter table too
+ $resultat_param = (Net::SNMP->VERSION < 4) ?
+ $session->get_table($run_param_table)
+ :$session->get_table(Baseoid => $run_param_table);
+ if (!defined($resultat_param)) {
+ printf("ERROR: Process param table : %s.\n", $session->error);
+ $session->close;
+ exit $ERRORS{"UNKNOWN"};
+ }
+
+}
+
if (defined ($o_get_all)) {
$getall_run = (Net::SNMP->VERSION < 4) ?
$session->get_table($proc_run_state )
@@ -458,8 +482,14 @@
verb("Filter : $o_descr");
foreach my $key ( keys %$resultat) {
- verb("OID : $key, Desc : $$resultat{$key}");
# test by regexp or exact match
+ # First add param if necessary
+ if (defined($o_param)){
+ my $pid = (split /\./,$key)[-1];
+ $pid = $run_param_table .".".$pid;
+ $$resultat{$key} .= " " . $$resultat_param{$pid};
+ }
+ verb("OID : $key, Desc : $$resultat{$key}");
my $test = defined($o_noreg)
? $$resultat{$key} eq $o_descr
: $$resultat{$key} =~ /$o_descr/;
@@ -545,6 +575,7 @@
}
my $final_status=0;
+my $perf_output;
my ($res_memory,$res_cpu)=(0,0);
my $memory_print="";
my $cpu_print="";
@@ -571,6 +602,9 @@
} else {
$memory_print=", Mem : ".sprintf("%.1f",$res_memory)."Mb OK";
}
+ if (defined($o_perf)) {
+ $perf_output= "'memory_usage'=".sprintf("%.1f",$res_memory) ."MB;".$o_memL[0].";".$o_memL[1];
+ }
}
######## Checks CPU usage
@@ -609,6 +643,10 @@
if ($file_values[$j][0] > $trigger_low) {
# found value = centiseconds / seconds = %cpu
$found_value= ($res_cpu-$file_values[$j][1]) / ($timenow - $file_values[$j][0] );
+ if ($found_value <0) { # in case of program restart
+ $j=0;$found_value=undef; # don't look for more values
+ $n_rows=0; # reset file
+ }
}
}
$j--;
@@ -631,6 +669,10 @@
} else {
$cpu_print.=", Cpu : ".sprintf("%.0f",$found_value)."% OK";
}
+ if (defined($o_perf)) {
+ if (!defined($perf_output)) {$perf_output="";} else {$perf_output.=" ";}
+ $perf_output.= "'cpu_usage'=". sprintf("%.0f",$found_value)."%;".$o_cpuL[0].";".$o_cpuL[1];
+ }
} else {
if ($final_status==0) { $final_status=3 };
$cpu_print.=", No data for CPU (".$n_rows." line(s)):UNKNOWN";
@@ -659,7 +701,14 @@
print " (<= ",$o_warnL[1],"):OK";
}
-print $memory_print,$cpu_print,"\n";
+print $memory_print,$cpu_print;
+
+if (defined($o_perf)) {
+ if (!defined($perf_output)) {$perf_output="";} else {$perf_output.=" ";}
+ $perf_output.= "'num_process'=". $num_int_ok.";".$o_warnL[0].";".$o_critL[0];
+ print " | ",$perf_output;
+}
+print "\n";
if ($final_status==2) { exit $ERRORS{"CRITICAL"};}
if ($final_status==1) { exit $ERRORS{"WARNING"};}
--- a/check_snmp_storage.pl
+++ b/check_snmp_storage.pl
@@ -1,12 +1,12 @@
#!/usr/bin/perl -w
############################## check_snmp_storage ##############
-# Version : 1.3.2
-# Date : March 12 2007
+# Version : 1.3.3
+# Date : Jun 1 2007
# Author : Patrick Proy ( patrick at proy.org)
# Help : http://nagios.manubulon.com
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
# TODO :
-# Contribs : Dimo Velev, Makina Corpus
+# Contribs : Dimo Velev, Makina Corpus, A. Greiner-Br
#################################################################
#
# help : ./check_snmp_storage -h
@@ -57,7 +57,7 @@
# Globals
my $Name='check_snmp_storage';
-my $Version='1.3.2';
+my $Version='1.3.3';
my $o_host = undef; # hostname
my $o_community = undef; # community
@@ -80,6 +80,8 @@
my $o_perf= undef; # Output performance data
my $o_short= undef; # Short output parameters
my @o_shortL= undef; # output type,where,cut
+my $o_reserve= 0; # % reserved blocks (A. Greiner-Br patch)
+my $o_giga= undef; # output and levels in gigabytes instead of megabytes
# SNMPv3 specific
my $o_login= undef; # Login for snmpv3
my $o_passwd= undef; # Pass for snmpv3
@@ -95,7 +97,7 @@
sub p_version { print "$Name version : $Version\n"; }
sub print_usage {
- print "Usage: $Name [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -m <name in desc_oid> [-q storagetype] -w <warn_level> -c <crit_level> [-t <timeout>] [-T pl|pu|bl|bu ] [-r] [-s] [-i] [-e] [-S 0|1[,1,<car>]] [-o <octet_length>]\n";
+ print "Usage: $Name [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -m <name in desc_oid> [-q storagetype] -w <warn_level> -c <crit_level> [-t <timeout>] [-T pl|pu|bl|bu ] [-r -s -i -G] [-e] [-S 0|1[,1,<car>]] [-o <octet_length>] [-R <% reserved>]\n";
}
sub round ($$) {
@@ -122,7 +124,7 @@
sub help {
print "\nSNMP Disk Monitor for Nagios version ",$Version,"\n";
- print "(c)2004-2006 Patrick Proy\n\n";
+ print "(c)2004-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
By default, plugin will monitor %used on drives :
@@ -135,7 +137,7 @@
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies SNMP v1)
-2, --v2c
+-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
@@ -179,6 +181,11 @@
-c, --critical=INTEGER
percent / MB of disk used to generate CRITICAL state
you can add the % sign
+-R, --reserved=INTEGER
+ % reserved blocks for superuser
+ For ext2/3 filesystems, it is 5% by default
+-G, --gigabyte
+ output, warning & critical levels in gigabytes
-f, --perfparse
Perfparse compatible output
-S, --short=<type>[,<where>,<cut>]
@@ -245,7 +252,9 @@
'q:s' => \$o_storagetype, 'storagetype:s'=> \$o_storagetype,
'S:s' => \$o_short, 'short:s' => \$o_short,
'o:i' => \$o_octetlength, 'octetlength:i' => \$o_octetlength,
- 'f' => \$o_perf, 'perfparse' => \$o_perf
+ 'f' => \$o_perf, 'perfparse' => \$o_perf,
+ 'R:i' => \$o_reserve, 'reserved:i' => \$o_reserve,
+ 'G' => \$o_giga, 'gigabyte' => \$o_giga
);
if (defined($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}};
if (defined($o_version) ) { p_version(); exit $ERRORS{"UNKNOWN"}};
@@ -271,6 +280,9 @@
# Check compulsory attributes
if ( ! defined($o_descr) || ! defined($o_host) || !defined($o_warn) ||
!defined($o_crit)) { print_usage(); exit $ERRORS{"UNKNOWN"}};
+ # Get rid of % sign if any
+ $o_warn =~ s/\%//;
+ $o_crit =~ s/\%//;
# Check for positive numbers
if (($o_warn < 0) || ($o_crit < 0)) { print " warn and critical > 0 \n";print_usage(); exit $ERRORS{"UNKNOWN"}};
# check if warn or crit in % and MB is tested
@@ -278,9 +290,6 @@
print "warning or critical cannot be in % when MB are tested\n";
print_usage(); exit $ERRORS{"UNKNOWN"};
}
- # Get rid of % sign
- $o_warn =~ s/\%//;
- $o_crit =~ s/\%//;
# Check warning and critical values
if ( ( $o_type eq 'pu' ) || ( $o_type eq 'bu' )) {
if ($o_warn >= $o_crit) { print " warn < crit if type=",$o_type,"\n";print_usage(); exit $ERRORS{"UNKNOWN"}};
@@ -306,6 +315,10 @@
if (defined ($o_octetlength) && (isnnum($o_octetlength) || $o_octetlength > 65535 || $o_octetlength < 484 )) {
print "octet lenght must be < 65535 and > 484\n";print_usage(); exit $ERRORS{"UNKNOWN"};
}
+ #### reserved blocks checks (A. Greiner-Br patch).
+ if (defined ($o_reserve) && (isnnum($o_reserve) || $o_reserve > 99 || $o_reserve < 0 )) {
+ print "reserved blocks must be < 100 and >= 0\n";print_usage(); exit $ERRORS{"UNKNOWN"};
+ }
}
########## MAIN #######
@@ -521,21 +534,35 @@
my $crit_state=0;
my ($p_warn,$p_crit);
my $output=undef;
+my $output_metric_val = 1024**2;
+my $output_metric = "M";
+# Set the metric
+if (defined($o_giga)) {
+ $output_metric_val *= 1024;
+ $output_metric='G';
+}
+
for ($i=0;$i<$num_int;$i++) {
verb("Descr : $descr[$i]");
verb("Size : $$result{$size_table . $tindex[$i]}");
verb("Used : $$result{$used_table . $tindex[$i]}");
verb("Alloc : $$result{$alloc_units . $tindex[$i]}");
- my $to = $$result{$size_table . $tindex[$i]} * $$result{$alloc_units . $tindex[$i]} / 1024**2;
+ if (!defined($$result{$size_table . $tindex[$i]}) ||
+ !defined($$result{$used_table . $tindex[$i]}) ||
+ !defined ($$result{$alloc_units . $tindex[$i]})) {
+ print "Data not fully defined for storage ",$descr[$i]," : UNKNOWN\n";
+ exit $ERRORS{"UNKNOWN"};
+ }
+ my $to = $$result{$size_table . $tindex[$i]} * ( ( 100 - $o_reserve ) / 100 ) * $$result{$alloc_units . $tindex[$i]} / $output_metric_val;
my $pu=undef;
if ( $$result{$used_table . $tindex[$i]} != 0 ) {
- $pu = $$result{$used_table . $tindex[$i]}*100 / $$result{$size_table . $tindex[$i]};
+ $pu = $$result{$used_table . $tindex[$i]}* 100 / ( $$result{$size_table . $tindex[$i]} * ( 100 - $o_reserve ) / 100 );
}else {
$pu=0;
}
- my $bu = $$result{$used_table . $tindex[$i]} * $$result{$alloc_units . $tindex[$i]} / 1024**2;
+ my $bu = $$result{$used_table . $tindex[$i]} * $$result{$alloc_units . $tindex[$i]} / $output_metric_val;
my $pl = 100 - $pu;
- my $bl = ($$result{$size_table . $tindex[$i]}- $$result{$used_table . $tindex[$i]}) * $$result{$alloc_units . $tindex[$i]} / 1024**2;
+ my $bl = ( ( $$result{$size_table . $tindex[$i]} * ( ( 100 - $o_reserve ) / 100 ) - ( $$result{$used_table . $tindex[$i]} ) ) * $$result{$alloc_units . $tindex[$i]} / $output_metric_val );
# add a ' ' if some data exists in $perf_out
$perf_out .= " " if (defined ($perf_out)) ;
##### Ouputs and checks
@@ -554,7 +581,7 @@
|| (($pu >= $o_warn) && ($locstate=$warn_state=1));
if (defined($o_shortL[2])) {}
if (!defined($o_shortL[0]) || ($locstate==1)) { # print full output if warn or critical state
- $output.=sprintf ("%s: %.0f%%used(%.0fMB/%.0fMB) ",$descr[$i],$pu,$bu,$to);
+ $output.=sprintf ("%s: %.0f%%used(%.0f%sB/%.0f%sB) ",$descr[$i],$pu,$bu,$output_metric,$to,$output_metric);
} elsif ($o_shortL[0] == 1) {
$output.=sprintf ("%s: %.0f%% ",$descr[$i],$pu);
}
@@ -566,9 +593,9 @@
( ($bu >= $o_crit) && ($locstate=$crit_state=1) )
|| ( ($bu >= $o_warn) && ($locstate=$warn_state=1) );
if (!defined($o_shortL[0]) || ($locstate==1)) { # print full output if warn or critical state
- $output.=sprintf("%s: %.0fMBused/%.0fMB (%.0f%%) ",$descr[$i],$bu,$to,$pu);
+ $output.=sprintf("%s: %.0f%sBused/%.0f%sB (%.0f%%) ",$descr[$i],$bu,$output_metric,$to,$output_metric,$pu);
} elsif ($o_shortL[0] == 1) {
- $output.=sprintf("%s: %.0fMB ",$descr[$i],$bu);
+ $output.=sprintf("%s: %.0f%sB ",$descr[$i],$bu,$output_metric);
}
}
@@ -578,9 +605,9 @@
( ($bl <= $o_crit) && ($locstate=$crit_state=1) )
|| ( ($bl <= $o_warn) && ($locstate=$warn_state=1) );
if (!defined($o_shortL[0]) || ($locstate==1)) { # print full output if warn or critical state
- $output.=sprintf ("%s: %.0fMBleft/%.0fMB (%.0f%%) ",$descr[$i],$bl,$to,$pl);
+ $output.=sprintf ("%s: %.0f%sBleft/%.0f%sB (%.0f%%) ",$descr[$i],$bl,$output_metric,$to,$output_metric,$pl);
} elsif ($o_shortL[0] == 1) {
- $output.=sprintf ("%s: %.0fMB ",$descr[$i],$bl);
+ $output.=sprintf ("%s: %.0f%sB ",$descr[$i],$bl,$output_metric);
}
}
@@ -590,13 +617,13 @@
( ($pl <= $o_crit) && ($locstate=$crit_state=1) )
|| ( ($pl <= $o_warn) && ($locstate=$warn_state=1) );
if (!defined($o_shortL[0]) || ($locstate==1)) { # print full output if warn or critical state
- $output.=sprintf ("%s: %.0f%%left(%.0fMB/%.0fMB) ",$descr[$i],$pl,$bl,$to);
+ $output.=sprintf ("%s: %.0f%%left(%.0f%sB/%.0f%sB) ",$descr[$i],$pl,$bl,$output_metric,$to,$output_metric);
} elsif ($o_shortL[0] == 1) {
$output.=sprintf ("%s: %.0f%% ",$descr[$i],$pl);
}
}
# Performance output (in MB)
- $perf_out .= "'".$Pdescr. "'=" . round($bu,0) . "MB;" . round($p_warn,0)
+ $perf_out .= "'".$Pdescr. "'=" . round($bu,0) . $output_metric ."B;" . round($p_warn,0)
. ";" . round($p_crit,0) . ";0;" . round($to,0);
}
@@ -606,8 +633,8 @@
my $comp_unit=undef;
($o_type eq "pu") && ($comp_oper ="<") && ($comp_unit ="%");
($o_type eq "pl") && ($comp_oper =">") && ($comp_unit ="%");
-($o_type eq "bu") && ($comp_oper ="<") && ($comp_unit ="MB");
-($o_type eq 'bl') && ($comp_oper =">") && ($comp_unit ="MB");
+($o_type eq "bu") && ($comp_oper ="<") && ($comp_unit = $output_metric."B");
+($o_type eq 'bl') && ($comp_oper =">") && ($comp_unit =$output_metric."B");
if (!defined ($output)) { $output="All selected storages "; }
--- a/check_snmp_vrrp.pl
+++ b/check_snmp_vrrp.pl
@@ -1,11 +1,11 @@
#!/usr/bin/perl -w
############################## check_snmp_vrrp ##############
-# Version : 1.3
-# Date : Aug 23 2006
+my $Version='1.4';
+# Date : Oct 17 2007
# Author : Patrick Proy (patrick at proy.org)
-# Help : http://www.manubulon.com/nagios/
+# Help : http://nagios.manubulon.com/
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
-# Contrib : C. Maser (Alteon + Netscreen)
+# Contrib : C. Maser (Alteon + Netscreen), Harm-Jan Blok (Foundry)
#################################################################
#
# Help : ./check_snmp_vrrp.pl -h
@@ -17,10 +17,8 @@
# Nagios specific
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 15;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas
@@ -59,32 +57,43 @@
my $ns_vrrp_admin = "";
my $ns_vrrp_prio = "1.3.6.1.4.1.3224.6.2.2.1.4";
+######## Foundry
+my $foundry_base_vrrp = "1.3.6.1.4.1.1991.1.2.12.3.1.1"; # oid for vrrp
+my $foundry_vrrp_oper = "1.3.6.1.4.1.1991.1.2.12.3.1.1.10"; # vrrp operational status
+my $foundry_vrrp_admin ="1.3.6.1.4.1.1991.1.2.12.3.1.1.3"; # vrrp admin status
+my $foundry_vrrp_prio = "1.3.6.1.4.1.1991.1.2.12.3.1.1.6"; # vrrp vrid priority
+
+
######### Make an array
my %base_vrrp = ("nokia",$nokia_base_vrrp,
"lp",$lp_base_vrrp,
"alteon",$alteon_base_vrrp,
- "nsc",$ns_base_vrrp
+ "nsc",$ns_base_vrrp,
+ "foundry",$foundry_base_vrrp
);
my %vrrp_oper = ("nokia",$nokia_vrrp_oper,
"lp",$lp_vrrp_oper,
"alteon",$alteon_vrrp_oper,
- "nsc",$ns_vrrp_oper
+ "nsc",$ns_vrrp_oper,
+ "foundry",$foundry_vrrp_oper
);
my %vrrp_admin =("nokia",$nokia_vrrp_admin,
"lp",$lp_vrrp_admin,
"alteon",$alteon_vrrp_admin,
- "nsc",$ns_vrrp_admin
+ "nsc",$ns_vrrp_admin,
+ "foundry",$foundry_vrrp_admin
);
my %vrrp_prio = ("nokia",$nokia_vrrp_prio,
"lp",$lp_vrrp_prio,
"alteon",$alteon_vrrp_prio,
- "nsc",$ns_vrrp_prio);
-my %state_master=("nokia",3,"alteon",2,"lp",3,"nsc",2);
-my %state_backup=("nokia",2,"alteon",3,"lp",2,"nsc",3);
+ "nsc",$ns_vrrp_prio,
+ "foundry",$foundry_vrrp_oper
+ );
-# Globals
+my %state_master=("nokia",3,"alteon",2,"lp",3,"nsc",2,"foundry",1);
+my %state_backup=("nokia",2,"alteon",3,"lp",2,"nsc",3,"foundry",2);
-my $Version='1.3';
+# Globals
my $o_host = undef; # hostname
my $o_community = undef; # community
@@ -96,7 +105,7 @@
my $o_state= undef; # Check master or backup state for ok
my $o_clustnum= undef; # number of cluster members
my $o_clustprct= undef; # Max % assigned to one cluster.
-my $o_type= 'nokia'; # Check type : nokia|alteon|lp|nsc
+my $o_type= 'nokia'; # Check type : nokia|alteon|lp|nsc|foundry
my $o_long= undef; # Make output long
my $o_timeout= 5; # Default 5s Timeout
@@ -113,7 +122,7 @@
sub p_version { print "check_snmp_vrrp version : $Version\n"; }
sub print_usage {
- print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) -s <master|backup|num,%> [-T <nokia|alteon|lp|nsc|ipsocluster>] [-p <port>] [-t <timeout>] [-V]\n";
+ print "Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) -s <master|backup|num,%> [-T <nokia|alteon|lp|nsc|ipsocluster|foundry>] [-p <port>] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
@@ -124,11 +133,11 @@
sub help {
print "\nSNMP VRRP Monitor for Nagios version ",$Version,"\n";
- print "(c)2004-2006 to my cat Ratoune - Author : Patrick Proy\n\n";
+ print "GPL licence, (c)2004-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
- print extra debugging information (including interface list on the system)
+ print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
@@ -149,11 +158,12 @@
SNMP port (Default 161)
-T, --type=<nokia|alteon|lp|nsc|ipso>
Type of vrrp router to check
- nokia (default) : Nokai vrrp. Should be working for most vrrp routers
+ nokia (default) : Nokia vrrp. Should be working for most vrrp routers
alteon : for Alteon AD4 Loadbalancers
lp : Radware Linkproof
nsc : Nescreen (ScreenOS 5.x NSRP)
ipso : Nokia IPSO clustering
+ foundry : Foundry VRRP
-s, --state=master|backup|num,%
Nokia ipso clustering : number of members, max % assigned to nodes.
Other : check vrrp interface to be master or backup
@@ -226,7 +236,7 @@
{ print "state must be master or backup\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}
}
# Check type
- if ( !defined($o_type) || (($o_type ne "nokia") && ($o_type ne "alteon") && ($o_type ne "lp") && ($o_type ne"nsc") && ($o_type ne"ipso")) )
+ if ( !defined($o_type) || (($o_type ne "nokia") && ($o_type ne "alteon") && ($o_type ne "lp") && ($o_type ne"nsc") && ($o_type ne"ipso") && ($o_type ne "foundry")) )
{ print "type must be alteon,nokia,lp,nsc or ipso\n"; print_usage(); exit $ERRORS{"UNKNOWN"}}
}
@@ -257,6 +267,7 @@
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
+ -port => $o_port,
-timeout => $o_timeout
);
} else {
@@ -269,6 +280,7 @@
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
+ -port => $o_port,
-timeout => $o_timeout
);
}
@@ -429,7 +441,11 @@
$key= $vrrp_admin{$o_type} . "." . $vrid[$i];
$value = ($$resultat{$key} == 1) ? "up" : "down";
$output.= $value . "/";
- ($value eq "up" ) && $ok++;
+ if (($o_type eq 'foundry') && ($o_state eq 'backup') && ($value eq "down")) {
+ $ok++
+ } else {
+ ($value eq "up") && $ok++;
+ }
}
# Get the priority
$key=$vrrp_prio{$o_type}.".".$vrid[$i];
--- a/check_snmp_win.pl
+++ b/check_snmp_win.pl
@@ -1,10 +1,11 @@
#!/usr/bin/perl -w
############################## check_snmp_win ##############
-# Version : 0.6
-# Date : Nov 29 2006
+my $Version='1.1';
+# Date : Oct 12 2007
# Author : Patrick Proy (patrick at proy.org)
-# Help : http://www.manubulon.com/nagios/
+# Help : http://nagios.manubulon.com/
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
+# Contrib : Tenaku
# TODO :
###############################################################
#
@@ -16,10 +17,10 @@
# Nagios specific
-use lib "/usr/local/nagios/libexec";
-use utils qw(%ERRORS $TIMEOUT);
-#my $TIMEOUT = 5;
-#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
+#use lib "/usr/local/nagios/libexec";
+#use utils qw(%ERRORS $TIMEOUT);
+my $TIMEOUT = 15;
+my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
# SNMP Datas for processes (MIB II)
my $process_table= '1.3.6.1.2.1.25.4.2.1';
@@ -44,7 +45,6 @@
# Globals
-my $Version='0.6';
my $Name='check_snmp_win';
my $o_host = undef; # hostname
@@ -93,7 +93,7 @@
sub help {
print "\nSNMP Windows Monitor for Nagios version ",$Version,"\n";
- print "GPL licence, (c)2004-2005 Patrick Proy\n\n";
+ print "GPL licence, (c)2004-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
@@ -344,7 +344,11 @@
foreach my $List (@o_descrL) {
my $test=0;
for (my $i=0; $i< $num_int; $i++) {
- if ( $descr[$i] =~ /$List/i ) { $test++; }
+ if (defined($o_noreg)){
+ if ($descr[$i] eq $List) { $test++;}
+ } else {
+ if ( $descr[$i] =~ /$List/i ) { $test++; }
+ }
}
if ($test==0) {
$output .= ", " if defined($output);
|