mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2025-04-04 15:03:41 +02:00
Compare commits
349 Commits
nagios-okp
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
ffbdd754d4 | ||
|
0440124d3a | ||
|
36582886c9 | ||
|
21c7874418 | ||
|
6b12d2414a | ||
|
ac1f45311e | ||
|
be3ea24fd8 | ||
|
1f9e1444cc | ||
|
bdb3233198 | ||
|
f22a7d8fb8 | ||
|
6c12036e30 | ||
|
8aed467ab0 | ||
|
df42d6ee6d | ||
|
223331510b | ||
|
ea93f8126f | ||
|
3ad7f64f55 | ||
|
e48179add8 | ||
|
56960140fe | ||
|
9eda5324d5 | ||
|
09f29727fb | ||
|
bb55bd5e09 | ||
|
4d6b5ce427 | ||
|
d9b0b77dc1 | ||
|
23714fa9cd | ||
|
22062ef76f | ||
|
ee29f68bcc | ||
|
077e862e6f | ||
|
b96bb5e207 | ||
|
f774b44b47 | ||
|
51c659990b | ||
|
343c42339f | ||
|
8f89f773e3 | ||
|
24518a74e7 | ||
|
cdc1daad6d | ||
|
c40bee725a | ||
|
892f9c267e | ||
|
3501677f20 | ||
|
6726f614ad | ||
|
ee5adc2363 | ||
|
7dc3b57582 | ||
|
688e8b8412 | ||
|
1ccc433779 | ||
|
ee05a4f24a | ||
|
871c8348fa | ||
|
944d47e18e | ||
|
40ba14c4cb | ||
|
f986b73474 | ||
|
c8e7fbbff8 | ||
|
f23ac92b64 | ||
|
7ab36cbc66 | ||
|
bf0edd899b | ||
|
9060a171f0 | ||
|
1420e93c5c | ||
|
cbcaa14997 | ||
|
03f7389842 | ||
|
f186de5585 | ||
|
c22b89893d | ||
|
d3f75ec93a | ||
|
9862b3c0d9 | ||
|
790619d820 | ||
|
a743def0c8 | ||
|
c414e17b30 | ||
|
b481aadbd5 | ||
|
2049fbd692 | ||
|
5f604b852f | ||
|
e5772ab336 | ||
|
e5498e1554 | ||
|
7d9ba339bc | ||
|
37d504a039 | ||
|
e7af0e4098 | ||
|
6c126130cc | ||
|
f0968997e4 | ||
|
95693e3c73 | ||
|
55daf8f4c9 | ||
|
d11d29185a | ||
|
06194c84cc | ||
|
184d7d3b4a | ||
|
1574cd13d3 | ||
|
b0b55dcd3e | ||
|
b96e973e60 | ||
|
51b75943cf | ||
|
8ff1cf84d0 | ||
|
5cb19c072e | ||
|
6db73d28d6 | ||
|
5ba61f91b2 | ||
|
8f6faa8b59 | ||
|
574538883c | ||
|
245ad9ba21 | ||
|
854b08c601 | ||
|
55ea04bd73 | ||
|
09dcc39f94 | ||
|
48d0a92707 | ||
|
e9222eb215 | ||
|
e64d51ebc3 | ||
|
5d94c9d3a2 | ||
|
22e4293db7 | ||
|
9b89a3d998 | ||
|
553a182dd1 | ||
|
9501bef37b | ||
|
b672f6f508 | ||
|
04d25281e3 | ||
|
9b2474fb49 | ||
|
156459046c | ||
|
a93d887721 | ||
|
2dbec06282 | ||
|
734e7d5596 | ||
|
623c1d5159 | ||
|
19312f9b55 | ||
|
c1005cb911 | ||
|
f5d4cde8b5 | ||
|
067f58f52e | ||
|
5d0df0bfe9 | ||
|
735b2795d8 | ||
|
5593391a3b | ||
|
ee4b10b291 | ||
|
b10d555e52 | ||
|
971afc97f7 | ||
|
fcf90cae3e | ||
|
73b632a828 | ||
|
b375ae66ee | ||
|
3606e03170 | ||
|
63f285a037 | ||
|
be7032f4e4 | ||
|
d259894a9d | ||
|
6d0ce2c869 | ||
|
4aae5f6327 | ||
|
2112847349 | ||
|
f382acb1a6 | ||
|
d7efe24a34 | ||
|
72f2c0de16 | ||
|
7c41c09b2f | ||
|
f87963f554 | ||
|
38a207065e | ||
|
831156308b | ||
|
356bb2c762 | ||
|
bc15b653b1 | ||
|
814426a5a8 | ||
|
2f69dd02cb | ||
|
25b04e822e | ||
|
f3909a08f6 | ||
|
53ec813478 | ||
|
46024baa26 | ||
|
3d867d84c0 | ||
|
6562732a91 | ||
|
c524ee0046 | ||
|
9907356c39 | ||
|
39f2413957 | ||
|
840ef78a7b | ||
|
c6cb2b634d | ||
|
92a6643a4b | ||
|
a21b3adf43 | ||
|
39b7d6a7d9 | ||
|
598a525ac8 | ||
|
ceb039eb45 | ||
|
5ab6e198ec | ||
|
b0663e0495 | ||
|
a01af47d86 | ||
|
30c4b15700 | ||
|
1099ad9c02 | ||
|
677ec90e3e | ||
|
a5dbf632f2 | ||
|
5af347c3df | ||
|
7ad46b2f68 | ||
|
5a8cad9783 | ||
|
5ff4605400 | ||
|
7143d69552 | ||
|
a71110fdff | ||
|
5493c0dd15 | ||
|
f536c03121 | ||
|
6976284504 | ||
|
b884ff14c8 | ||
|
14e8126224 | ||
|
c2e2739519 | ||
|
16e167abfc | ||
|
24c8127c9f | ||
|
92c4d406fd | ||
|
6a69093487 | ||
|
ec0cece507 | ||
|
e67cc67f90 | ||
|
755f10f014 | ||
|
5d331dd5e7 | ||
|
53ede666b7 | ||
|
86430fbbc5 | ||
|
e610610f21 | ||
|
cfd3cfcff8 | ||
|
c7a4b60654 | ||
|
be5d1ce505 | ||
|
911720e5d4 | ||
|
4e21b502b7 | ||
|
0828935d90 | ||
|
d6e0eee0fb | ||
|
c0361e67d9 | ||
|
ad16f4f729 | ||
|
4a4794ea0e | ||
|
91e7874a5b | ||
|
85c1474519 | ||
|
ec2973e743 | ||
|
3591ee0d37 | ||
|
b78e958d4d | ||
|
9ec8d702da | ||
|
746420bd15 | ||
|
5482a7e25c | ||
|
91634a76b7 | ||
|
5eb8ce9199 | ||
|
27e2f7b2d2 | ||
|
f06667b55d | ||
|
5bbcf099c0 | ||
|
98d7723d9f | ||
|
e7a474c07a | ||
|
3cf6cb7f2d | ||
|
5a49b22a10 | ||
|
9840c23642 | ||
|
3828a94a3e | ||
|
e35455fdc8 | ||
|
c0ef6774ad | ||
|
190a9726b1 | ||
|
1dadb17858 | ||
|
fe453cdd23 | ||
|
aa7af97598 | ||
|
18fc77d63f | ||
|
ca8a2ebb73 | ||
|
b5308e5a7c | ||
|
a570b1c40e | ||
|
71673753ff | ||
|
950a169dbd | ||
|
771ec5cf77 | ||
|
ff21dd3ec4 | ||
|
ebd64badf2 | ||
|
e875698a95 | ||
|
9e9c8293cd | ||
|
fb05e9ad4b | ||
|
edf5326de9 | ||
|
ccf72c8c22 | ||
|
d776077d65 | ||
|
4d69437590 | ||
|
43813c1999 | ||
|
6b15a3932b | ||
|
6d3ee7cdc7 | ||
|
cf2f4cc1fd | ||
|
07d3717a29 | ||
|
b29250d12d | ||
|
565cfa5e1a | ||
|
968c6330a0 | ||
|
9be343271c | ||
|
399b57ba3f | ||
|
3553793733 | ||
|
824665b6d9 | ||
|
745c719ac8 | ||
|
61ca426c4b | ||
|
cb9faf65e6 | ||
|
d74d766e99 | ||
|
cee2b2ebf7 | ||
|
270ddb3d97 | ||
|
5b7f683227 | ||
|
0b20e567de | ||
|
ae0968af02 | ||
|
d7f9474ed6 | ||
|
2578b81fe0 | ||
|
c0ce018356 | ||
|
f0a0ce515b | ||
|
468d182014 | ||
|
16ed641f8b | ||
|
77c5917350 | ||
|
8e7144c1a4 | ||
|
89c8e69d1e | ||
|
36e6dbe188 | ||
|
518372579a | ||
|
75511d21da | ||
|
36db6b9661 | ||
|
4a98095f7c | ||
|
2ccd5989e3 | ||
|
626ec4f2b9 | ||
|
1637f8f93b | ||
|
1209c00087 | ||
|
65004322a9 | ||
|
5342a3cf16 | ||
|
d6a23a3ca4 | ||
|
960cb63b40 | ||
|
59b745678a | ||
|
ff9e3d96e7 | ||
|
74cda834ab | ||
|
bd4aa7f57d | ||
|
ba7b80fc1c | ||
|
3c87920fd1 | ||
|
0badbf8619 | ||
|
59dc82fd44 | ||
|
afb015b67d | ||
|
38c56fe3d8 | ||
|
bf9ecb7777 | ||
|
756c0ef1de | ||
|
9346c1a60d | ||
|
77b527f44d | ||
|
5a4d14734e | ||
|
27f4da23bf | ||
|
468f7ef32a | ||
|
682ad04b9e | ||
|
6f5041d8cd | ||
|
2c23f04ffa | ||
|
ceda55b389 | ||
|
af98917b05 | ||
|
ddaad8f39d | ||
|
d6f9b6093f | ||
|
381aef1156 | ||
|
ed9d2eb2b9 | ||
|
9248569b6d | ||
|
26e5c218b9 | ||
|
aa41f16b6e | ||
|
6230193b05 | ||
|
bbc5893cfe | ||
|
599134bc5e | ||
|
f60a518bd3 | ||
|
f4615ffed5 | ||
|
05251498c1 | ||
|
8d0494c4ff | ||
|
1bc3ed0782 | ||
|
da2ae8dd2d | ||
|
28e8660037 | ||
|
9a42e9c21e | ||
|
44fc2600fd | ||
|
b72f03415a | ||
|
bbfaac455c | ||
|
9065fa7ec8 | ||
|
b5e5207c62 | ||
|
82a6090e64 | ||
|
e6dce9e9b5 | ||
|
f14db81ca5 | ||
|
aebaefa4bf | ||
|
2de33b2f02 | ||
|
07cb5f0470 | ||
|
38bbcd056f | ||
|
edc84c54a4 | ||
|
64119882e9 | ||
|
e910d327c5 | ||
|
95d0b84219 | ||
|
f24a7c050e | ||
|
74407957c3 | ||
|
14d5afd698 | ||
|
2ecfed0b40 | ||
|
7779f09241 | ||
|
3ef06cb89f | ||
|
4f13da5ce6 | ||
|
851579e88c | ||
|
294f2d78dd | ||
|
4ac4af674f | ||
|
b23491b453 | ||
|
d31a51e84c | ||
|
26221affd8 | ||
|
5cdbba7b66 | ||
|
15b9e64a88 |
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
*.pyc
|
||||||
|
*.swp
|
||||||
|
.project
|
||||||
|
.pydevproject
|
||||||
|
.settings
|
||||||
|
pagekite*
|
||||||
|
.idea
|
||||||
|
MANIFEST
|
||||||
|
dist
|
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
nagios-plugins
|
||||||
|
==============
|
||||||
|
|
||||||
|
Small army of nagios-plugins either made or maintained by opinkerfi
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
# nagios: -epn
|
||||||
#
|
#
|
||||||
# check_apcext.pl - APC Extra gear monitoring plugin for Nagios
|
# check_apcext.pl - APC Extra gear monitoring plugin for Nagios
|
||||||
# 05.02.07 Paul Venezia
|
# 05.02.07 Paul Venezia
|
||||||
@ -14,6 +15,7 @@ use vars qw/ %opt /;
|
|||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
sub getmasked_values ($$);
|
sub getmasked_values ($$);
|
||||||
|
sub f2c ($);
|
||||||
|
|
||||||
if ($ARGV[0] =~ /(--help|-h|help)/ || !defined$ARGV[0]) {
|
if ($ARGV[0] =~ /(--help|-h|help)/ || !defined$ARGV[0]) {
|
||||||
&usage;
|
&usage;
|
||||||
@ -40,11 +42,11 @@ my %rpduamps;
|
|||||||
my %oids = (
|
my %oids = (
|
||||||
'nbmstemp' => {
|
'nbmstemp' => {
|
||||||
'label' => 'Temp',
|
'label' => 'Temp',
|
||||||
'unit' => ($metric ? 'degC' : 'degF'),
|
'unit' => 'degF',
|
||||||
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.1.1',
|
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.1.1',
|
||||||
'sensor_key' => 5,
|
'sensor_key' => 5,
|
||||||
'sensor_val' => 2,
|
'sensor_val' => 9,
|
||||||
'cdef' => ($metric ? '$val * 0.1' : '($val * .18) + 32')
|
#'cdef' => '$val * 0.1'
|
||||||
},
|
},
|
||||||
'nbmshum' => {
|
'nbmshum' => {
|
||||||
'label' => 'Humidity',
|
'label' => 'Humidity',
|
||||||
@ -94,13 +96,13 @@ my %oids = (
|
|||||||
},
|
},
|
||||||
'acscsupair' => {
|
'acscsupair' => {
|
||||||
'label' => 'Supply Air',
|
'label' => 'Supply Air',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.8.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.8.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
'acscretair' => {
|
'acscretair' => {
|
||||||
'label' => 'Return Air',
|
'label' => 'Return Air',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.10.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.10.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
@ -111,19 +113,19 @@ my %oids = (
|
|||||||
},
|
},
|
||||||
'acscracktemp' => {
|
'acscracktemp' => {
|
||||||
'label' => 'Rack Inlet Temp',
|
'label' => 'Rack Inlet Temp',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.6.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.6.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
'acsccondin' => {
|
'acsccondin' => {
|
||||||
'label' => 'Cond Inlet Temp',
|
'label' => 'Cond Inlet Temp',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.30.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.30.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
'acsccondout' => {
|
'acsccondout' => {
|
||||||
'label' => 'Cond Outlet Temp',
|
'label' => 'Cond Outlet Temp',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.28.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.28.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
@ -151,19 +153,19 @@ my %oids = (
|
|||||||
},
|
},
|
||||||
'acrcracktemp' => {
|
'acrcracktemp' => {
|
||||||
'label' => 'Rack Inlet Temp',
|
'label' => 'Rack Inlet Temp',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.6.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.6.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
'acrcsupair' => {
|
'acrcsupair' => {
|
||||||
'label' => 'Supply Air',
|
'label' => 'Supply Air',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.8.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.8.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
'acrcretair' => {
|
'acrcretair' => {
|
||||||
'label' => 'Return Air',
|
'label' => 'Return Air',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.10.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.10.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
@ -182,13 +184,13 @@ my %oids = (
|
|||||||
},
|
},
|
||||||
'acrcflenttemp' => {
|
'acrcflenttemp' => {
|
||||||
'label' => 'Entering Fluid Temp',
|
'label' => 'Entering Fluid Temp',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.23.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.23.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
'acrcflrettemp' => {
|
'acrcflrettemp' => {
|
||||||
'label' => 'Returning Fluid Temp',
|
'label' => 'Returning Fluid Temp',
|
||||||
'unit' => 'F',
|
'unit' => 'degF',
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.25.0',
|
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.25.0',
|
||||||
'cdef' => '$val * .10'
|
'cdef' => '$val * .10'
|
||||||
},
|
},
|
||||||
@ -367,6 +369,11 @@ if ($param eq "rpduamps") {
|
|||||||
$fval = $val;
|
$fval = $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($metric and $oids{$param}->{unit} eq 'degF') {
|
||||||
|
$oids{$param}->{unit} = 'degC';
|
||||||
|
$fval = sprintf("%.1f", f2c($fval));
|
||||||
|
}
|
||||||
|
|
||||||
if ($fval > $crit) {
|
if ($fval > $crit) {
|
||||||
$retval = 2;
|
$retval = 2;
|
||||||
$outmsg = "CRITICAL";
|
$outmsg = "CRITICAL";
|
||||||
@ -417,6 +424,12 @@ APC ACRC In-Row
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub f2c($) {
|
||||||
|
my $f = shift;
|
||||||
|
|
||||||
|
return ($f - 32) * (5/9);
|
||||||
|
}
|
||||||
|
|
||||||
sub getmasked_values ($$) {
|
sub getmasked_values ($$) {
|
||||||
my ($baseoid, $values) = @_;
|
my ($baseoid, $values) = @_;
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Summary: A Nagios plugin to check APC devices
|
Summary: A Nagios plugin to check APC devices
|
||||||
Name: nagios-okplugin-apc
|
Name: nagios-okplugin-apc
|
||||||
Version: 0.0.2
|
Version: 2.1.2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
@ -11,6 +11,7 @@ Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_apcext.pl/rel
|
|||||||
Requires: nagios-plugins
|
Requires: nagios-plugins
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
Packager: Tomas Edwardsson <tommi@ok.is>
|
Packager: Tomas Edwardsson <tommi@ok.is>
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -37,5 +38,21 @@ rm -rf %{buildroot}
|
|||||||
%{_libdir}/nagios/plugins/*
|
%{_libdir}/nagios/plugins/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jun 09 2014 Tomas Edwardsson <tommi@tommi.org> 2.1.2-1
|
||||||
|
- Disable embedded perl (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Thu Mar 20 2014 Tomas Edwardsson <tommi@tommi.org> 2.1.1-1
|
||||||
|
- Merge github.com:opinkerfi/misc (palli@opensource.is)
|
||||||
|
- Use the right value for the job nbmstemp (tommi@tommi.org)
|
||||||
|
- Fixed metric conversion for all mibs (tommi@opensource.is)
|
||||||
|
- Added fahrenheit to celsius conversion (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Thu Aug 23 2012 Pall Sigurdsson <palli@opensource.is> 2.1.0-1
|
||||||
|
- Version number bumped to 2.1.0 (palli@opensource.is)
|
||||||
|
- Added noarch buildarch (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 0.0.3-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
||||||
- Initial packaging
|
- Initial packaging
|
@ -1,41 +0,0 @@
|
|||||||
%define debug_package %{nil}
|
|
||||||
|
|
||||||
Summary: A Nagios plugin to check APC devices
|
|
||||||
Name: nagios-okplugin-apc
|
|
||||||
Version: 0.0.1
|
|
||||||
Release: 1%{?dist}
|
|
||||||
License: GPLv2+
|
|
||||||
Group: Applications/System
|
|
||||||
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-APC
|
|
||||||
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_apcext.pl/releases/nagios-okplugin-apc-%{version}.tar.gz
|
|
||||||
Requires: nagios-plugins
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
|
||||||
Packager: Tomas Edwardsson <tommi@ok.is>
|
|
||||||
|
|
||||||
|
|
||||||
%description
|
|
||||||
Checks APC devices, both netbotz and UPS
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%setup -q
|
|
||||||
#perl -pi -e "s|/usr/lib|%{_libdir}|g" check_sip
|
|
||||||
|
|
||||||
%build
|
|
||||||
|
|
||||||
|
|
||||||
%install
|
|
||||||
rm -rf %{buildroot}
|
|
||||||
install -D -p -m 0755 check_apcext.pl %{buildroot}%{_libdir}/nagios/plugins/check_apcext.pl
|
|
||||||
install -D -p -m 0755 check_snmp_apc_ups %{buildroot}%{_libdir}/nagios/plugins/snmp_apc_ups
|
|
||||||
|
|
||||||
%clean
|
|
||||||
rm -rf %{buildroot}
|
|
||||||
|
|
||||||
%files
|
|
||||||
%defattr(-,root,root,-)
|
|
||||||
%doc README
|
|
||||||
%{_libdir}/nagios/plugins/*
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
|
||||||
- Initial packaging
|
|
@ -1 +0,0 @@
|
|||||||
check_apcext.pl - APC Extra gear checks (netbotz/pdus)
|
|
@ -1,447 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
#
|
|
||||||
# check_apcext.pl - APC Extra gear monitoring plugin for Nagios
|
|
||||||
# 05.02.07 Paul Venezia
|
|
||||||
#
|
|
||||||
# v0.0.1
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
use Net::SNMP;
|
|
||||||
use Getopt::Std;
|
|
||||||
use Data::Dumper;
|
|
||||||
use vars qw/ %opt /;
|
|
||||||
use strict;
|
|
||||||
|
|
||||||
sub getmasked_values ($$);
|
|
||||||
|
|
||||||
if ($ARGV[0] =~ /(--help|-h|help)/ || !defined$ARGV[0]) {
|
|
||||||
&usage;
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $opts = 's:lmC:H:p:w:c:';
|
|
||||||
getopts ( "$opts", \%opt ) or &usage;
|
|
||||||
|
|
||||||
|
|
||||||
my $host = $opt{H};
|
|
||||||
my $comm = $opt{C};
|
|
||||||
my $param = $opt{p};
|
|
||||||
my $warn = $opt{w};
|
|
||||||
my $crit = $opt{c};
|
|
||||||
my $metric = $opt{m};
|
|
||||||
my $list = $opt{l};
|
|
||||||
my $sensor_int_name = $opt{s};
|
|
||||||
|
|
||||||
my ($oid, $oidbase, $fval, $unit, $outmsg);
|
|
||||||
my $retval = 0;
|
|
||||||
my %rpduamps;
|
|
||||||
|
|
||||||
my %oids = (
|
|
||||||
'nbmstemp' => {
|
|
||||||
'label' => 'Temp',
|
|
||||||
'unit' => ($metric ? 'degC' : 'degF'),
|
|
||||||
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.1.1',
|
|
||||||
'sensor_key' => 5,
|
|
||||||
'sensor_val' => 2,
|
|
||||||
'cdef' => ($metric ? '$val * 0.1' : '($val * .18) + 32')
|
|
||||||
},
|
|
||||||
'nbmshum' => {
|
|
||||||
'label' => 'Humidity',
|
|
||||||
'unit' => '%',
|
|
||||||
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.2.1',
|
|
||||||
'sensor_key' => 5,
|
|
||||||
'sensor_val' => 8,
|
|
||||||
},
|
|
||||||
'nbmsairflow' => {
|
|
||||||
'label' => 'Air Flow',
|
|
||||||
'unit' => 'CFM',
|
|
||||||
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.5.1',
|
|
||||||
'sensor_val' => 8,
|
|
||||||
'sensor_key' => 5,
|
|
||||||
'mod' => 'lt'
|
|
||||||
},
|
|
||||||
'nbmsaudio' => {
|
|
||||||
'label' => 'Audio Level',
|
|
||||||
'unit' => '',
|
|
||||||
'oidbase' => '.1.3.6.1.4.1.5528.100.4.1.4.1',
|
|
||||||
'sensor_val' => 7,
|
|
||||||
'sensor_key' => 5,
|
|
||||||
'mod' => ''
|
|
||||||
},
|
|
||||||
'rpduamps' => {
|
|
||||||
'label' => 'Power Output',
|
|
||||||
'unit' => 'Amps',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acscstatus' => {
|
|
||||||
'label' => 'Status',
|
|
||||||
'unit' => '',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.1.0'
|
|
||||||
},
|
|
||||||
'acscload' => {
|
|
||||||
'label' => 'Cooling Load',
|
|
||||||
'unit' => 'kW',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.3.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acscoutput' => {
|
|
||||||
'label' => 'Cooling output',
|
|
||||||
'unit' => 'kW',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.2.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acscsupair' => {
|
|
||||||
'label' => 'Supply Air',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.8.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acscretair' => {
|
|
||||||
'label' => 'Return Air',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.10.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acscairflow' => {
|
|
||||||
'label' => 'Airflow',
|
|
||||||
'unit' => 'CFM',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.4.0',
|
|
||||||
},
|
|
||||||
'acscracktemp' => {
|
|
||||||
'label' => 'Rack Inlet Temp',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.6.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acsccondin' => {
|
|
||||||
'label' => 'Cond Inlet Temp',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.30.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acsccondout' => {
|
|
||||||
'label' => 'Cond Outlet Temp',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.4.1.2.28.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acrcstatus' => {
|
|
||||||
'label' => 'Status',
|
|
||||||
'unit' => '',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.1.0'
|
|
||||||
},
|
|
||||||
'acrcload' => {
|
|
||||||
'label' => 'Cooling Load',
|
|
||||||
'unit' => 'kW',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.2.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acrcoutput' => {
|
|
||||||
'label' => 'Cooling Output',
|
|
||||||
'unit' => 'kW',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.3.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acrcairflow' => {
|
|
||||||
'label' => 'Airflow',
|
|
||||||
'unit' => 'CFM',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.4.0'
|
|
||||||
},
|
|
||||||
'acrcracktemp' => {
|
|
||||||
'label' => 'Rack Inlet Temp',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.6.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acrcsupair' => {
|
|
||||||
'label' => 'Supply Air',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.8.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acrcretair' => {
|
|
||||||
'label' => 'Return Air',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.10.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acrcfanspeed' => {
|
|
||||||
'label' => 'Fan Speed',
|
|
||||||
'unit' => '%',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.16.0',
|
|
||||||
'cdef' => '$val * .10',
|
|
||||||
},
|
|
||||||
'acrcfluidflow' => {
|
|
||||||
'label' => 'Fluid Flow',
|
|
||||||
'unit' => 'GPM',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.21.0',
|
|
||||||
'cdef' => '$val * .10',
|
|
||||||
'mod' => 'lt'
|
|
||||||
},
|
|
||||||
'acrcflenttemp' => {
|
|
||||||
'label' => 'Entering Fluid Temp',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.23.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
'acrcflrettemp' => {
|
|
||||||
'label' => 'Returning Fluid Temp',
|
|
||||||
'unit' => 'F',
|
|
||||||
'oid' => '.1.3.6.1.4.1.318.1.1.13.3.2.2.2.25.0',
|
|
||||||
'cdef' => '$val * .10'
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($list) {
|
|
||||||
my ($baseoid, $int_name_id, $value_id) = @_;
|
|
||||||
|
|
||||||
my ($session, $error) = Net::SNMP->session(
|
|
||||||
-hostname => $host,
|
|
||||||
-community => $comm,
|
|
||||||
-version => 1,
|
|
||||||
# -translate => [-octetstring => 0x0],
|
|
||||||
-port => "161"
|
|
||||||
);
|
|
||||||
my $response = $session->get_table(-baseoid => ".1.3.6.1.4.1.5528.100.2.1.1");
|
|
||||||
my $err = $session->error;
|
|
||||||
if ($err){
|
|
||||||
$retval = 3;
|
|
||||||
$outmsg = "UNKNOWN";
|
|
||||||
$session->close();
|
|
||||||
print "$outmsg $err - SNMP Error connecting to $host\n";
|
|
||||||
exit $retval;
|
|
||||||
}
|
|
||||||
my %sensor;
|
|
||||||
foreach my $k (keys %{$response}) {
|
|
||||||
my ($type, $id) = (split(/\./, $k))[-2,-1];
|
|
||||||
next if ($type != 1 and $type != 4);
|
|
||||||
next if ($id < 2000000000);
|
|
||||||
if ($type == 1) {
|
|
||||||
$sensor{$id}->{"int_name"} = $response->{$k};
|
|
||||||
} else {
|
|
||||||
$sensor{$id}->{"friendly_name"} = $response->{$k};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print <<" EO";
|
|
||||||
Specify a sensor by using the -s and the INTERNAL name of the sensor
|
|
||||||
|
|
||||||
Detected sensors:
|
|
||||||
|
|
||||||
EO
|
|
||||||
printf("\t%-32s %s\n", "Friendly Name", "Internal Name");
|
|
||||||
foreach my $id (sort { $sensor{$a}->{"friendly_name"} cmp $sensor{$b}->{"friendly_name"} } keys %sensor) {
|
|
||||||
printf ("\t%-32s %s\n", "\"$sensor{$id}->{friendly_name}\"", "\"$sensor{$id}->{int_name}\"");
|
|
||||||
}
|
|
||||||
exit 0;
|
|
||||||
|
|
||||||
|
|
||||||
} elsif (!$oids{$param}) {
|
|
||||||
print "No test parameter specified";
|
|
||||||
exit 3;
|
|
||||||
} else {
|
|
||||||
$oid = $oids{$param}->{oid};
|
|
||||||
$oidbase = $oids{$param}->{oidbase};
|
|
||||||
}
|
|
||||||
|
|
||||||
my ($session, $error) = Net::SNMP->session(
|
|
||||||
-hostname => $host,
|
|
||||||
-community => $comm,
|
|
||||||
-version => 1,
|
|
||||||
# -translate => [-octetstring => 0x0],
|
|
||||||
-port => "161"
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
if ($param eq "rpduamps") {
|
|
||||||
# $param = "RackPDU";
|
|
||||||
my $i;
|
|
||||||
for ($i=1;$i<4;$i++) {
|
|
||||||
my $phoid = $oid . $i;
|
|
||||||
my $response = $session->get_request($phoid);
|
|
||||||
my $err = $session->error;
|
|
||||||
if ($err){
|
|
||||||
$retval = 3;
|
|
||||||
$outmsg = "UNKNOWN";
|
|
||||||
$session->close();
|
|
||||||
print "$outmsg $err - SNMP Error connecting to $host\n";
|
|
||||||
exit $retval;
|
|
||||||
}
|
|
||||||
$rpduamps{$i} = $response->{$phoid};
|
|
||||||
}
|
|
||||||
$session->close;
|
|
||||||
#$crit = ($crit * 10);
|
|
||||||
#$warn = ($warn * 10);
|
|
||||||
|
|
||||||
$unit = "Amps";
|
|
||||||
foreach my $ph ( sort keys %rpduamps ) {
|
|
||||||
my $tphase = ($rpduamps{$ph} * .1);
|
|
||||||
|
|
||||||
if (($tphase >= $crit) && ($retval < 2)) {
|
|
||||||
$retval = 2;
|
|
||||||
$outmsg = "CRITICAL";
|
|
||||||
|
|
||||||
} elsif (($tphase >= $warn) && ($retval < 1)) {
|
|
||||||
$retval = 1;
|
|
||||||
$outmsg = "WARNING";
|
|
||||||
|
|
||||||
} elsif ($retval < 1) {
|
|
||||||
$retval = 0;
|
|
||||||
$outmsg = "OK";
|
|
||||||
}
|
|
||||||
|
|
||||||
$fval .= "Phase $ph: " . $tphase;
|
|
||||||
#$fval .= "Phase $ph: " . ($tphase * .1);
|
|
||||||
if ($ph lt 3) {
|
|
||||||
$fval .= " Amps, ";
|
|
||||||
#} else {
|
|
||||||
# $fval .= " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
my $val;
|
|
||||||
if ($oid) {
|
|
||||||
my $response = $session->get_request($oid);
|
|
||||||
|
|
||||||
my $err = $session->error;
|
|
||||||
if ($err){
|
|
||||||
$retval = 3;
|
|
||||||
$outmsg = "UNKNOWN";
|
|
||||||
$session->close();
|
|
||||||
print "$outmsg $err - SNMP Error connecting to $host\n";
|
|
||||||
exit $retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$val = $response->{$oid};
|
|
||||||
$session->close();
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
my $snmpd = getmasked_values($oidbase, { $oids{$param}->{sensor_key} => 'sensor_key',
|
|
||||||
$oids{$param}->{sensor_val} => 'sensor_val' });
|
|
||||||
|
|
||||||
if ((keys %{$snmpd}) > 1 && !$sensor_int_name) {
|
|
||||||
print "UNKNOWN - Many sensors found but none specified, see -s and -l\n";
|
|
||||||
exit 3;
|
|
||||||
} elsif ((keys %{$snmpd}) == 0) {
|
|
||||||
print "UNKNOWN - no sensors found on this device\n";
|
|
||||||
exit 3;
|
|
||||||
} else {
|
|
||||||
my $id = (keys %{$snmpd})[0];
|
|
||||||
$val = $snmpd->{$id}->{sensor_val};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($sensor_int_name) {
|
|
||||||
foreach my $k (keys %{$snmpd}) {
|
|
||||||
if (lc($snmpd->{$k}->{sensor_key}) eq lc($sensor_int_name)) {
|
|
||||||
$val = $snmpd->{$k}->{sensor_val};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($val eq "") {
|
|
||||||
print Dumper $snmpd;
|
|
||||||
print "UNKNOWN Unable to get sensor status\n";
|
|
||||||
exit 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($param eq "acscstatus" || $param eq "acrcstatus") {
|
|
||||||
if ($val == 1) {
|
|
||||||
$fval = "Standby";
|
|
||||||
$retval = 1;
|
|
||||||
$outmsg = "WARNING";
|
|
||||||
} elsif ($val == 2) {
|
|
||||||
$fval = "On";
|
|
||||||
$retval = 0;
|
|
||||||
$outmsg = "OK";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if ($oids{$param}->{cdef}) {
|
|
||||||
$fval = eval "$oids{$param}->{cdef}";
|
|
||||||
} else {
|
|
||||||
$fval = $val;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($fval > $crit) {
|
|
||||||
$retval = 2;
|
|
||||||
$outmsg = "CRITICAL";
|
|
||||||
} elsif ($fval > $warn) {
|
|
||||||
$retval = 1;
|
|
||||||
$outmsg = "WARNING";
|
|
||||||
} else {
|
|
||||||
$retval = 0;
|
|
||||||
$outmsg = "OK";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print "$outmsg - " . $oids{$param}->{label} . " " .$fval . " " . $oids{$param}->{unit} . " | $param=$fval$oids{$param}->{unit}\n";
|
|
||||||
|
|
||||||
|
|
||||||
exit $retval;
|
|
||||||
|
|
||||||
sub usage {
|
|
||||||
|
|
||||||
print "Usage: $0 -H <hostip> -C <community> -p <parameter> -w <warnval> -c <critval> [-l] [-s sensor]\n";
|
|
||||||
print "\nParameters:\n";
|
|
||||||
print <<" EO";
|
|
||||||
APC NetBotz
|
|
||||||
nbmstemp NetBotz main sensor temp | nbmshum NetBotz main sensor humidity
|
|
||||||
nbmsairflow NetBotz main sensor airflow | nbmsaudio NetBotz main sensor audio
|
|
||||||
-l List connected sensors | -s sensor Sensor we want info from
|
|
||||||
|
|
||||||
APC Metered Rack PDU
|
|
||||||
rpduamps Amps on each phase
|
|
||||||
|
|
||||||
APC ACSC In-Row
|
|
||||||
acscstatus System status (on/standby) | acscload Cooling load
|
|
||||||
acscoutput Cooling output | acscsupair Supply air
|
|
||||||
acscairflow Air flow | acscracktemp Rack inlet temp
|
|
||||||
acsccondin Condenser input temp | acsccondout Condenser outlet temp
|
|
||||||
|
|
||||||
APC ACRC In-Row
|
|
||||||
acrcstatus System status (on/standby) | acrcload Cooling load
|
|
||||||
acrcoutput Cooling output | acrcairflow Air flow
|
|
||||||
acrcracktemp Rack inlet temp | acrcsupair Supply air
|
|
||||||
acrcretair Return air | acrcfanspeed Fan speed
|
|
||||||
acrcfluidflow Fluid flow | acrcflenttemp Fluid entering temp
|
|
||||||
acrcflrettemp Fluid return temp
|
|
||||||
EO
|
|
||||||
|
|
||||||
exit 3;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sub getmasked_values ($$) {
|
|
||||||
my ($baseoid, $values) = @_;
|
|
||||||
|
|
||||||
my ($session, $error) = Net::SNMP->session(
|
|
||||||
-hostname => $host,
|
|
||||||
-community => $comm,
|
|
||||||
-version => 1,
|
|
||||||
-port => "161"
|
|
||||||
);
|
|
||||||
my $response = $session->get_table(-baseoid => $baseoid);
|
|
||||||
my $err = $session->error;
|
|
||||||
if ($err){
|
|
||||||
$retval = 3;
|
|
||||||
$outmsg = "UNKNOWN";
|
|
||||||
$session->close();
|
|
||||||
print "$err - SNMP Error connecting to $host\n";
|
|
||||||
exit $retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
my %snmpdata;
|
|
||||||
foreach my $k (keys %{$response}) {
|
|
||||||
my ($type, $id) = (split(/\./, $k))[-2,-1];
|
|
||||||
if ($values->{$type}) {
|
|
||||||
$snmpdata{$id}->{$values->{$type}} = $response->{$k};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return \%snmpdata;
|
|
||||||
}
|
|
@ -1,562 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
|
|
||||||
# Copyright (C) 2004 Altinity Limited
|
|
||||||
# E: info@altinity.com W: http://www.altinity.com/
|
|
||||||
#
|
|
||||||
# Edited by Roderick Derks (roderick@r71.nl)
|
|
||||||
# I changed the output of this plugin so it can bu used with Nagiosgrapher
|
|
||||||
# to create nice graphs (output is in hours is changed to minutes).
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
#
|
|
||||||
# Adjusted by Roderick Derks (roderick@r71.nl)
|
|
||||||
# Output of snmp query for remaing battery runtime is in minutes or in hours. This
|
|
||||||
# is a problem when you want to create some nice graphs because of the different
|
|
||||||
# output. Now hours are converted to minutes.
|
|
||||||
#
|
|
||||||
|
|
||||||
use Net::SNMP;
|
|
||||||
use Getopt::Std;
|
|
||||||
|
|
||||||
$script = "check_snmp_apcups";
|
|
||||||
$script_version = "2.1.0";
|
|
||||||
|
|
||||||
$metric = 1;
|
|
||||||
|
|
||||||
$ipaddress = "192.168.1.1"; # default IP address, if none supplied
|
|
||||||
$version = "1"; # SNMP version
|
|
||||||
$timeout = 2; # SNMP query timeout
|
|
||||||
# $warning = 100;
|
|
||||||
# $critical = 150;
|
|
||||||
$status = 0;
|
|
||||||
$returnstring = "";
|
|
||||||
|
|
||||||
$community = "public"; # Default community string
|
|
||||||
|
|
||||||
|
|
||||||
# .1.3.6.1.4.1.
|
|
||||||
# enterprises.318.1.1.1.1.1.1.0 = STRING: "SMART-UPS 1000" upsIdent
|
|
||||||
|
|
||||||
# enterprises.318.1.1.1.2.2.1.0 Battery capacity (%)
|
|
||||||
# enterprises.318.1.1.1.2.2.2.0 Temperature (Celcius)
|
|
||||||
# enterprises.318.1.1.1.2.2.3.0 Battery runtime remaining
|
|
||||||
# enterprises.318.1.1.1.2.2.4.0 Battery replace indicator (1=ok, 2=replace)
|
|
||||||
# enterprises.318.1.1.1.2.2.5.0 Number of battery packs
|
|
||||||
# enterprises.318.1.1.1.2.2.6.0 Number of bad battery packs
|
|
||||||
|
|
||||||
# enterprises.318.1.1.1.3.2.1.0 Input voltage
|
|
||||||
# enterprises.318.1.1.1.3.2.4.0 Input frequency
|
|
||||||
# enterprises.318.1.1.1.3.2.5.0 Reason for last transfer to UPS battery power:
|
|
||||||
|
|
||||||
# enterprises.318.1.1.1.4.2.1.0 Output voltage
|
|
||||||
# enterprises.318.1.1.1.4.2.2.0 Output frequency
|
|
||||||
# enterprises.318.1.1.1.4.2.3.0 Output load as % of capacity
|
|
||||||
# enterprises.318.1.1.1.4.2.4.0 Output current in ampheres
|
|
||||||
|
|
||||||
# enterprises.318.1.1.1.4.2.1.0 Configured voltage
|
|
||||||
# enterprises.318.1.1.1.8.1.0 Whether agent is communicating with UPS (1)
|
|
||||||
|
|
||||||
$oid_upstype = ".1.3.6.1.4.1.318.1.1.1.1.1.1.0";
|
|
||||||
$oid_battery_capacity = ".1.3.6.1.4.1.318.1.1.1.2.2.1.0";
|
|
||||||
$oid_battery_temperature = ".1.3.6.1.4.1.318.1.1.1.2.2.2.0";
|
|
||||||
$oid_battery_runtimeremain = ".1.3.6.1.4.1.318.1.1.1.2.2.3.0";
|
|
||||||
$oid_battery_replace = ".1.3.6.1.4.1.318.1.1.1.2.2.4.0";
|
|
||||||
$oid_input_voltage = ".1.3.6.1.4.1.318.1.1.1.3.2.1.0";
|
|
||||||
$oid_input_frequency = ".1.3.6.1.4.1.318.1.1.1.3.2.4.0";
|
|
||||||
$oid_input_reasonforlasttransfer = ".1.3.6.1.4.1.318.1.1.1.3.2.5.0";
|
|
||||||
$oid_output_voltage = ".1.3.6.1.4.1.318.1.1.1.4.2.1.0";
|
|
||||||
$oid_output_frequency = ".1.3.6.1.4.1.318.1.1.1.4.2.2.0";
|
|
||||||
$oid_output_load = ".1.3.6.1.4.1.318.1.1.1.4.2.3.0";
|
|
||||||
$oid_output_current = ".1.3.6.1.4.1.318.1.1.1.4.2.4.0";
|
|
||||||
$oid_output_configuredvoltage = ".1.3.6.1.4.1.318.1.1.1.4.2.1.0";
|
|
||||||
$oid_comms = ".1.3.6.1.4.1.318.1.1.1.8.1.0";
|
|
||||||
$oid_test_result = ".1.3.6.1.4.1.318.1.1.1.7.2.3.0";
|
|
||||||
$oid_test_date = ".1.3.6.1.4.1.318.1.1.1.7.2.4.0";
|
|
||||||
$oid_sysDescr = ".1.3.6.1.2.1.1.1.0";
|
|
||||||
|
|
||||||
$upstype = "";
|
|
||||||
$battery_capacity = 0;
|
|
||||||
$battery_temperature = 0;
|
|
||||||
$battery_runtimeremain = 0;
|
|
||||||
$battery_replace = "";
|
|
||||||
$input_voltage = 0;
|
|
||||||
$input_frequency = 0;
|
|
||||||
$input_reasonforlasttransfer = "";
|
|
||||||
$output_voltage = 0;
|
|
||||||
$output_frequency = 0;
|
|
||||||
$output_load = 0;
|
|
||||||
$output_current = 0;
|
|
||||||
$output_configuredvoltage = 0;
|
|
||||||
$outagecause = "";
|
|
||||||
$test_result = "";
|
|
||||||
$test_date = "";
|
|
||||||
|
|
||||||
|
|
||||||
# Do we have enough information?
|
|
||||||
if (@ARGV < 1) {
|
|
||||||
print "Too few arguments\n";
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
getopts("h:H:C:w:c:");
|
|
||||||
if ($opt_h){
|
|
||||||
usage();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
if ($opt_H){
|
|
||||||
$hostname = $opt_H;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print "No hostname specified\n";
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
if ($opt_C){
|
|
||||||
$community = $opt_C;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Create the SNMP session
|
|
||||||
my ($s, $e) = Net::SNMP->session(
|
|
||||||
-community => $community,
|
|
||||||
-hostname => $hostname,
|
|
||||||
-version => $version,
|
|
||||||
-timeout => $timeout,
|
|
||||||
);
|
|
||||||
|
|
||||||
main();
|
|
||||||
|
|
||||||
# Close the session
|
|
||||||
$s->close();
|
|
||||||
|
|
||||||
if ($returnstring eq ""){
|
|
||||||
$status = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($status == 0){
|
|
||||||
print "Status is OK - $returnstring\n";
|
|
||||||
# print "$returnstring\n";
|
|
||||||
}
|
|
||||||
elsif ($status == 1){
|
|
||||||
print "Status is a WARNING level - $returnstring\n";
|
|
||||||
}
|
|
||||||
elsif ($status == 2){
|
|
||||||
print "Status is CRITICAL - $returnstring\n";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
print "Problem with plugin. No response from SNMP agent.\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
exit $status;
|
|
||||||
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
# This is where we gather data via SNMP and return results #
|
|
||||||
####################################################################
|
|
||||||
|
|
||||||
sub main {
|
|
||||||
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_comms))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$temp = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($temp eq "1"){
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
append("SNMP agent not communicating with UPS");
|
|
||||||
$status = 2;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_upstype))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$upstype = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_battery_capacity))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$battery_capacity = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_battery_temperature))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$battery_temperature = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_battery_runtimeremain))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$battery_runtimeremain = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
|
|
||||||
# RRD if output is in hours, change it to minutes so we can make a nice graph
|
|
||||||
if ( $battery_runtimeremain =~ "hour" ) {
|
|
||||||
$battery_runtimeremain2 = "$battery_runtimeremain";
|
|
||||||
$battery_runtimeremain =~s/hour.*//g;
|
|
||||||
$battery_runtimeremain = $battery_runtimeremain*60;
|
|
||||||
$battery_runtimeremain = "$battery_runtimeremain minutes";
|
|
||||||
}
|
|
||||||
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_battery_replace))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$battery_replace = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_input_voltage))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$input_voltage = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_input_frequency))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$input_frequency = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_input_reasonforlasttransfer))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$input_reasonforlasttransfer = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_output_voltage))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$output_voltage = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_output_frequency))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) { $returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$output_frequency = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_output_load))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$output_load = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_test_result))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$test_result = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
if (!defined($s->get_request($oid_test_date))) {
|
|
||||||
if (!defined($s->get_request($oid_sysDescr))) {
|
|
||||||
$returnstring = "SNMP agent not responding";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$returnstring = "SNMP OID does not exist";
|
|
||||||
$status = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($s->var_bind_names()) {
|
|
||||||
$test_date = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
#######################################################
|
|
||||||
|
|
||||||
$issue = "";
|
|
||||||
|
|
||||||
if ($input_reasonforlasttransfer eq "1"){
|
|
||||||
$outagecause = "No events"
|
|
||||||
}
|
|
||||||
elsif ($input_reasonforlasttransfer eq "2"){
|
|
||||||
$outagecause = "High line voltage"
|
|
||||||
}
|
|
||||||
elsif ($input_reasonforlasttransfer eq "3"){
|
|
||||||
$outagecause = "Brownout"
|
|
||||||
}
|
|
||||||
elsif ($input_reasonforlasttransfer eq "4"){
|
|
||||||
$outagecause = "Loss of mains power"
|
|
||||||
}
|
|
||||||
elsif ($input_reasonforlasttransfer eq "5"){
|
|
||||||
$outagecause = "Small temporary power drop"
|
|
||||||
}
|
|
||||||
elsif ($input_reasonforlasttransfer eq "6"){
|
|
||||||
$outagecause = "Large temporary power drop"
|
|
||||||
}
|
|
||||||
elsif ($input_reasonforlasttransfer eq "7"){
|
|
||||||
$outagecause = "Small spike"
|
|
||||||
}
|
|
||||||
elsif ($input_reasonforlasttransfer eq "8"){
|
|
||||||
$outagecause = "Large spike"
|
|
||||||
}
|
|
||||||
elsif ($input_reasonforlasttransfer eq "9"){
|
|
||||||
$outagecause = "UPS self test"
|
|
||||||
}
|
|
||||||
elsif ($input_reasonforlasttransfer eq "10"){
|
|
||||||
$outagecause = "Excessive input voltage fluctuation"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$outagecause = "Cannot establish reason"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($test_result eq "1") {
|
|
||||||
$test_result_string = "Passed";
|
|
||||||
}
|
|
||||||
elsif ($test_result eq "2") {
|
|
||||||
$test_result_string = "Failed";
|
|
||||||
}
|
|
||||||
elsif ($test_result eq "4") {
|
|
||||||
$test_result_string = "In Progress";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$test_result_string = "Unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($battery_capacity < 50) {
|
|
||||||
$issue = $issue . "BATTERY CAPACITY WARNING! ";
|
|
||||||
$status = 1;
|
|
||||||
}
|
|
||||||
if ($output_load > 80) {
|
|
||||||
$status = 1;
|
|
||||||
$issue = $issue . "OUTPUT LOAD WARNING! ";
|
|
||||||
}
|
|
||||||
if ($test_result eq "2") {
|
|
||||||
$issue = $issue . "SELF TEST FAILED! ";
|
|
||||||
$status = 1;
|
|
||||||
}
|
|
||||||
if ($input_voltage < 1){
|
|
||||||
$status = 2;
|
|
||||||
$issue = $issue . "RUNNING ON BATTERY! ";
|
|
||||||
}
|
|
||||||
if ($battery_capacity < 25) {
|
|
||||||
$issue = $issue . "BATTERY RUNNING LOW! ";
|
|
||||||
$status = 2;
|
|
||||||
}
|
|
||||||
if ($output_load > 90) {
|
|
||||||
$issue = $issue . "HIGH OUTPUT LOAD! ";
|
|
||||||
$status = 2;
|
|
||||||
}
|
|
||||||
if ($battery_replace eq "2") {
|
|
||||||
$issue = $issue . "REPLACE BATTERY! ";
|
|
||||||
$status = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Modified by Pall Sigurdsson <palli@opensource.is> to add some perfdata
|
|
||||||
# Modified 2010-06-03
|
|
||||||
my $perfdata="| 'battery_capacity'=$battery_capacity% 'temperature'=$battery_temperature 'input_voltage'=$input_voltage input_frequency=$input_frequency output_voltage=$output_voltage output_frequency=$output_frequency output_load=$output_load%";
|
|
||||||
|
|
||||||
|
|
||||||
if ($status == 0){
|
|
||||||
$temp = sprintf "$upstype - BATTERY:(capacity $battery_capacity%%, temperature $battery_temperature C, runtime $battery_runtimeremain) INPUT:(voltage $input_voltage V, frequency $input_frequency Hz) OUTPUT:(voltage $output_voltage V, frequency $output_frequency Hz, load $output_load%%) SELF TEST:($test_result_string on $test_date) LAST EVENT:($outagecause) $perfdata";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$temp = sprintf "$issue - $upstype - BATTERY:(capacity $battery_capacity%%, temperature $battery_temperature C, runtime $battery_runtimeremain) INPUT:(voltage $input_voltage V, frequency $input_frequency Hz) OUTPUT:(voltage $output_voltage V, frequency $output_frequency Hz, load $output_load%%) LAST EVENT:$outagecause $perfdata ";
|
|
||||||
}
|
|
||||||
append($temp);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
# help and usage information #
|
|
||||||
####################################################################
|
|
||||||
|
|
||||||
sub usage {
|
|
||||||
print << "USAGE";
|
|
||||||
-----------------------------------------------------------------
|
|
||||||
$script v$script_version
|
|
||||||
|
|
||||||
Monitors APC SmartUPS via AP9617 SNMP management card.
|
|
||||||
|
|
||||||
Usage: $script -H <hostname> -c <community> [...]
|
|
||||||
|
|
||||||
Options: -H Hostname or IP address
|
|
||||||
-C Community (default is public)
|
|
||||||
|
|
||||||
-----------------------------------------------------------------
|
|
||||||
Copyright 2004 Altinity Limited
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it or modify
|
|
||||||
it under the terms of the GNU General Public License
|
|
||||||
-----------------------------------------------------------------
|
|
||||||
|
|
||||||
USAGE
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
# Appends string to existing $returnstring #
|
|
||||||
####################################################################
|
|
||||||
|
|
||||||
sub append {
|
|
||||||
my $appendstring = @_[0];
|
|
||||||
$returnstring = "$returnstring$appendstring";
|
|
||||||
}
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
Summary: A Nagios plugin to check SMTP blacklists
|
Summary: A Nagios plugin to check SMTP blacklists
|
||||||
Name: nagios-okplugin-mailblacklist
|
Name: nagios-okplugin-mailblacklist
|
||||||
Version: 0.0.1
|
Version: 1.1
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-MailBlacklist
|
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-MailBlacklist
|
||||||
@ -11,7 +11,8 @@ Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_bl/releases/%
|
|||||||
Requires: nagios-plugins
|
Requires: nagios-plugins
|
||||||
Requires: nagios-plugins-perl
|
Requires: nagios-plugins-perl
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
Packager: Tomas Edwardsson <tommi@ok.is>
|
Packager: Gardar Thorsteinsson <gardar@ok.is>
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -21,6 +22,8 @@ Checks DNS Blacklists for existance of hosts
|
|||||||
%setup -q
|
%setup -q
|
||||||
perl -pi -e "s|/usr/lib|%{_libdir}|g" check_bl
|
perl -pi -e "s|/usr/lib|%{_libdir}|g" check_bl
|
||||||
|
|
||||||
|
%global __requires_exclude %{?__requires_exclude:%__requires_exclude}|}^perl\\(utils\\)
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
|
||||||
|
|
||||||
@ -37,5 +40,17 @@ rm -rf %{buildroot}
|
|||||||
%{_libdir}/nagios/plugins/*
|
%{_libdir}/nagios/plugins/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri May 04 2018 Richard Allen <ra@ok.is> 1.1-2
|
||||||
|
- Filter out perl-utils dependancy
|
||||||
|
|
||||||
|
* Thu Feb 20 2014 Pall Sigurdsson <palli@opensource.is> 1.1-1
|
||||||
|
-
|
||||||
|
|
||||||
|
* Thu Aug 23 2012 Pall Sigurdsson <palli@opensource.is> 1.0-1
|
||||||
|
- Updated buildarch to noarch (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 0.0.2-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
||||||
- Initial packaging
|
- Initial packaging
|
@ -1,160 +0,0 @@
|
|||||||
#!/usr/bin/perl -w
|
|
||||||
#
|
|
||||||
# check_bl plugin for nagios
|
|
||||||
# $Revision: 1.0 $
|
|
||||||
#
|
|
||||||
# Nagios plugin designed to warn you if you mail servers appear in one of the
|
|
||||||
# many anti-spam 'blacklists'
|
|
||||||
#
|
|
||||||
# By Sam Bashton, Bashton Ltd
|
|
||||||
# bashton.com/content/nagios-plugins
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use lib "/usr/lib/nagios/plugins";
|
|
||||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
|
||||||
use Net::DNS;
|
|
||||||
use vars qw($PROGNAME);
|
|
||||||
my ($verbose,$host),;
|
|
||||||
my ($opt_V,$opt_h,$opt_B,$opt_H,$opt_c);
|
|
||||||
$opt_V = $opt_h = $opt_B = $opt_H = $opt_c = '';
|
|
||||||
my $state = 'UNKNOWN';
|
|
||||||
sub print_help();
|
|
||||||
sub print_usage();
|
|
||||||
|
|
||||||
$PROGNAME = "check_bl";
|
|
||||||
|
|
||||||
$ENV{'BASH_ENV'}='';
|
|
||||||
$ENV{'ENV'}='';
|
|
||||||
$ENV{'PATH'}='';
|
|
||||||
$ENV{'LC_ALL'}='C';
|
|
||||||
|
|
||||||
use Getopt::Long;
|
|
||||||
Getopt::Long::Configure('bundling');
|
|
||||||
GetOptions(
|
|
||||||
"V" => \$opt_V, "version" => \$opt_V,
|
|
||||||
"h" => \$opt_h, "help" => \$opt_h,
|
|
||||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
|
|
||||||
"B=s" => \$opt_B, "blacklists=s" => \$opt_B,
|
|
||||||
"c=s" => \$opt_c, "critical=s" => \$opt_c
|
|
||||||
);
|
|
||||||
|
|
||||||
# -h means display verbose help screen
|
|
||||||
if ($opt_h) { print_help(); exit $ERRORS{'OK'}; }
|
|
||||||
|
|
||||||
# -V means display version number
|
|
||||||
if ($opt_V) {
|
|
||||||
print_revision($PROGNAME,'$Revision: 1.0 $ ');
|
|
||||||
exit $ERRORS{'OK'};
|
|
||||||
}
|
|
||||||
|
|
||||||
# First check the hostname is OK..
|
|
||||||
unless ($opt_H) { print_usage(); exit $ERRORS{'UNKNOWN'}; }
|
|
||||||
|
|
||||||
if (! utils::is_hostname($opt_H)){
|
|
||||||
print "$opt_H is not a valid host name\n";
|
|
||||||
print_usage();
|
|
||||||
exit $ERRORS{"UNKNOWN"};
|
|
||||||
}else{
|
|
||||||
if ($opt_H =~ /[a-zA-Z]/ )
|
|
||||||
# If the host contains letters we assume it's a hostname, not an IP
|
|
||||||
{
|
|
||||||
$host = lookup($opt_H);
|
|
||||||
}
|
|
||||||
else { $host = $opt_H }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# $opt_c is a count of the blacklists a mail server is in,
|
|
||||||
# after which state will be CRITICAL rather than WARNING
|
|
||||||
# By default any listing is CRITICAL
|
|
||||||
my $critcount = 0;
|
|
||||||
if ($opt_c) { $critcount = $opt_c };
|
|
||||||
|
|
||||||
# $opt_B is a comma seperated list of blacklists
|
|
||||||
$opt_B = shift unless ($opt_B);
|
|
||||||
unless ($opt_B) { print_usage(); exit -1 }
|
|
||||||
my @bls = split(/,/, $opt_B);
|
|
||||||
|
|
||||||
|
|
||||||
# Just in case of problems, let's not hang Nagios
|
|
||||||
$SIG{'ALRM'} = sub {
|
|
||||||
print ("ERROR: No response from BL server (alarm)\n");
|
|
||||||
exit $ERRORS{"UNKNOWN"};
|
|
||||||
};
|
|
||||||
alarm($TIMEOUT);
|
|
||||||
|
|
||||||
my %listed; # Hash of blacklists we're listed in.
|
|
||||||
foreach(@bls)
|
|
||||||
{
|
|
||||||
if (blcheck($host,$_)) { $listed{$_} = 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scalar(keys(%listed)) == 0) { $state = 'OK' }
|
|
||||||
elsif (scalar(keys(%listed)) < $critcount) { $state = 'WARNING' }
|
|
||||||
else { $state = 'CRITICAL' }
|
|
||||||
|
|
||||||
if (%listed)
|
|
||||||
{
|
|
||||||
print "Listed at";
|
|
||||||
foreach (keys(%listed)) { print " $_" }
|
|
||||||
print "\n";
|
|
||||||
}
|
|
||||||
else { print "Not black-listed\n" }
|
|
||||||
|
|
||||||
exit $ERRORS{$state};
|
|
||||||
|
|
||||||
|
|
||||||
######## Subroutines ==========================
|
|
||||||
|
|
||||||
|
|
||||||
sub print_help() {
|
|
||||||
print_revision($PROGNAME,'$Revision: 1.0 $ ');
|
|
||||||
print "\n";
|
|
||||||
support();
|
|
||||||
}
|
|
||||||
|
|
||||||
sub print_usage () {
|
|
||||||
print "Usage: \n";
|
|
||||||
print " $PROGNAME -H host -B [blacklist1],[blacklist2] [-c critnum]\n";
|
|
||||||
print " $PROGNAME [-h | --help]\n";
|
|
||||||
print " $PROGNAME [-V | --version]\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub blcheck
|
|
||||||
{
|
|
||||||
my ($ip, $bl) = @_;
|
|
||||||
my $lookupip = $ip;
|
|
||||||
$lookupip =~
|
|
||||||
s/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/$4.$3.$2.$1.$bl/;
|
|
||||||
if (lookup($lookupip)) { return 1 }
|
|
||||||
else { return 0 }
|
|
||||||
}
|
|
||||||
|
|
||||||
sub lookup
|
|
||||||
{
|
|
||||||
my $tolookup = shift;
|
|
||||||
my $res = Net::DNS::Resolver->new;
|
|
||||||
my $query = $res->search($tolookup);
|
|
||||||
if ($query)
|
|
||||||
{
|
|
||||||
foreach my $rr ($query->answer)
|
|
||||||
{
|
|
||||||
next unless $rr->type eq "A"; # We're not interested in TXT records
|
|
||||||
return $rr->address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
Nagios check_bl plugin (C)Copyright 2005 Bashton Ltd
|
|
||||||
----------------------------------------------------
|
|
||||||
|
|
||||||
A Nagios plugin to check whether a server is in any known anti-spam
|
|
||||||
blocklists. Licensed under the GNU GPL v2.0 or later (at your option). For
|
|
||||||
full copyright and warranty details, please see the COPYING file included in
|
|
||||||
this package.
|
|
||||||
|
|
||||||
By Sam Bashton, Bashton Ltd - sam@bashton.com www.bashton.com
|
|
||||||
|
|
||||||
Comments, bug reports etc are welcome.
|
|
||||||
|
|
||||||
Pre-Requisites
|
|
||||||
--------------
|
|
||||||
|
|
||||||
- Working Nagios install
|
|
||||||
- Perl 5 (tested with Perl 5.6.1 and 5.8)
|
|
||||||
- Net::DNS Perl library and associated dependencies
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
- Copy to your nagios plugins directory (possibly /usr/lib/nagios/plugins)
|
|
||||||
- Add the following to your checkcommands.cfg:
|
|
||||||
|
|
||||||
define command{
|
|
||||||
command_name check_bl
|
|
||||||
command_line $USER1$/check_bl -H $HOSTADDRESS$ -B sbl-xbl.spamhaus.or
|
|
||||||
g,bl.spamcop.net,t1.dnsbl.net.au
|
|
||||||
}
|
|
||||||
|
|
||||||
- Alter your services.cfg to include a check against the check_bl command
|
|
||||||
|
|
||||||
Variables
|
|
||||||
---------
|
|
||||||
|
|
||||||
check_bl requires the following variables:
|
|
||||||
|
|
||||||
-H host : Hostname to check
|
|
||||||
-B blacklist1,blacklist2 : Comma separated list of blacklists to check against
|
|
||||||
|
|
||||||
The following optional variable is also available:
|
|
||||||
|
|
||||||
-c critnum : Number of blacklists the server must be listed in before the status is 'critical'. By default, any listing is regarded as critical.
|
|
@ -1,41 +0,0 @@
|
|||||||
%define debug_package %{nil}
|
|
||||||
|
|
||||||
Summary: A Nagios plugin to check SMTP blacklists
|
|
||||||
Name: nagios-okplugin-mailblacklist
|
|
||||||
Version: 0.0.1
|
|
||||||
Release: 1%{?dist}
|
|
||||||
License: GPLv2+
|
|
||||||
Group: Applications/System
|
|
||||||
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-MailBlacklist
|
|
||||||
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_bl/releases/%{name}-%{version}.tar.gz
|
|
||||||
Requires: nagios-plugins
|
|
||||||
Requires: nagios-plugins-perl
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
|
||||||
Packager: Tomas Edwardsson <tommi@ok.is>
|
|
||||||
|
|
||||||
|
|
||||||
%description
|
|
||||||
Checks DNS Blacklists for existance of hosts
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%setup -q
|
|
||||||
perl -pi -e "s|/usr/lib|%{_libdir}|g" check_bl
|
|
||||||
|
|
||||||
%build
|
|
||||||
|
|
||||||
|
|
||||||
%install
|
|
||||||
rm -rf %{buildroot}
|
|
||||||
install -D -p -m 0755 check_bl %{buildroot}%{_libdir}/nagios/plugins/check_bl
|
|
||||||
|
|
||||||
%clean
|
|
||||||
rm -rf %{buildroot}
|
|
||||||
|
|
||||||
%files
|
|
||||||
%defattr(-,root,root,-)
|
|
||||||
%doc README COPYING
|
|
||||||
%{_libdir}/nagios/plugins/*
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
|
||||||
- Initial packaging
|
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
Summary: A Nagios plugin to check network bond devices
|
Summary: A Nagios plugin to check network bond devices
|
||||||
Name: nagios-okplugin-bond
|
Name: nagios-okplugin-bond
|
||||||
Version: 0.0.1
|
Version: 0.0.4
|
||||||
Release: 2%{?dist}
|
Release: 1%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-Bond
|
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-Bond
|
||||||
@ -40,6 +40,16 @@ rm -rf %{buildroot}
|
|||||||
%config(noreplace) %{_sysconfdir}/nrpe.d/check_bond.cfg
|
%config(noreplace) %{_sysconfdir}/nrpe.d/check_bond.cfg
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Feb 20 2014 Pall Sigurdsson <palli@opensource.is> 0.0.4-1
|
||||||
|
- Merge pull request #5 from pallvalmundsson/check_yum_security_patch (palli-
|
||||||
|
github@minor.is)
|
||||||
|
|
||||||
|
* Wed Mar 13 2013 Pall Sigurdsson <palli@opensource.is> 0.0.3-1
|
||||||
|
-
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 0.0.2-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
* Sun Oct 16 2011 Tomas Edwardsson <tommi@opensource.is> 0.1-2
|
* Sun Oct 16 2011 Tomas Edwardsson <tommi@opensource.is> 0.1-2
|
||||||
- Added configuration into package
|
- Added configuration into package
|
||||||
|
|
@ -1,125 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# Copyright 2010, Tomas Edwardsson
|
|
||||||
#
|
|
||||||
# check_bond.py is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# check_bond.py is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import pprint
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
import getopt
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def readbond( interface ):
|
|
||||||
intfile = "/proc/net/bonding/%s" % interface
|
|
||||||
|
|
||||||
# Read interface info
|
|
||||||
try:
|
|
||||||
bondfh = open (intfile, 'r')
|
|
||||||
except IOError, (errno, strerror):
|
|
||||||
print "Unable to open bond %s: %s" % (intfile, strerror)
|
|
||||||
sys.exit(3)
|
|
||||||
except:
|
|
||||||
print "Unexpected error:", sys.exc_info()[0]
|
|
||||||
sys.exit(3)
|
|
||||||
|
|
||||||
# Initialize bond data
|
|
||||||
bond = {}
|
|
||||||
bond['slaves'] = []
|
|
||||||
|
|
||||||
# Which interface are we working with
|
|
||||||
current_int = ''
|
|
||||||
|
|
||||||
# Loop throught the file contents
|
|
||||||
for line in bondfh.readlines():
|
|
||||||
# Remove newlines and split on colon, ignore other
|
|
||||||
try:
|
|
||||||
k, v = line.replace('\n', '').split(': ', 1)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Remove leading whitespaces
|
|
||||||
k = re.sub('^\s*', '', k)
|
|
||||||
# Bonding mode for the channel
|
|
||||||
if k == "Bonding Mode":
|
|
||||||
bond['bonding_mode'] = v
|
|
||||||
# Record current slave interface
|
|
||||||
elif k == "Slave Interface":
|
|
||||||
current_int = v
|
|
||||||
# Slave interface mii status
|
|
||||||
elif current_int and k == "MII Status":
|
|
||||||
bond['slaves'].append( { 'int' : current_int, 'mii_status' : v })
|
|
||||||
# Bond mii status
|
|
||||||
elif k == "MII Status":
|
|
||||||
bond['mii_status'] = v
|
|
||||||
|
|
||||||
return bond
|
|
||||||
|
|
||||||
def usage():
|
|
||||||
print "Usage: %s -i bond0" % sys.argv[0]
|
|
||||||
sys.exit(3)
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
# Set variables
|
|
||||||
interface = ''
|
|
||||||
outstring = ''
|
|
||||||
retval = 0
|
|
||||||
|
|
||||||
# Nagios return code states
|
|
||||||
states = { 0 : 'OK', 1 : 'Warning', 2 : 'Critical', 3 : 'Unknown' }
|
|
||||||
|
|
||||||
# Try to read the arguments
|
|
||||||
try:
|
|
||||||
opts, args = getopt.getopt(argv, "hi:", ["help", "interface="])
|
|
||||||
except getopt.GetoptError:
|
|
||||||
usage()
|
|
||||||
sys.exit(3)
|
|
||||||
|
|
||||||
|
|
||||||
for opt, arg in opts:
|
|
||||||
if opt in ("-h", "--help"):
|
|
||||||
usage()
|
|
||||||
sys.exit(3)
|
|
||||||
elif opt in ("-i", "--interface"):
|
|
||||||
interface = arg
|
|
||||||
|
|
||||||
if (interface == ""):
|
|
||||||
usage()
|
|
||||||
sys.exit(3)
|
|
||||||
|
|
||||||
bond = readbond(interface)
|
|
||||||
|
|
||||||
# The whole bond is down
|
|
||||||
if bond['mii_status'] != 'up':
|
|
||||||
print "Critical: bonding device %s %s" % (interface, bond['mii_status'])
|
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
# Some interface in the bond is down
|
|
||||||
for slave in bond['slaves']:
|
|
||||||
if slave['mii_status'] != 'up':
|
|
||||||
outstring = "%s%s down " % (outstring, slave['int'])
|
|
||||||
if retval < 1:
|
|
||||||
retval = 1
|
|
||||||
|
|
||||||
if retval:
|
|
||||||
print "%s: %s%s %s" % (states[retval], outstring, "in bonding device", interface)
|
|
||||||
sys.exit(retval)
|
|
||||||
|
|
||||||
print "OK: bonding device %s up and running" % interface
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main(sys.argv[1:])
|
|
@ -1,39 +0,0 @@
|
|||||||
%define debug_package %{nil}
|
|
||||||
|
|
||||||
Summary: A Nagios plugin to check network bond devices
|
|
||||||
Name: nagios-okplugin-bond
|
|
||||||
Version: 0.0.1
|
|
||||||
Release: 1%{?dist}
|
|
||||||
License: GPLv2+
|
|
||||||
Group: Applications/System
|
|
||||||
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-Bond
|
|
||||||
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_bond/releases/%{name}-%{version}.tar.gz
|
|
||||||
Requires: nagios-plugins
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
|
||||||
Packager: Tomas Edwardsson <tommi@ok.is>
|
|
||||||
|
|
||||||
|
|
||||||
%description
|
|
||||||
Checks the network bond device on a Linux machine
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%setup -q
|
|
||||||
|
|
||||||
%build
|
|
||||||
|
|
||||||
|
|
||||||
%install
|
|
||||||
rm -rf %{buildroot}
|
|
||||||
install -D -p -m 0755 check_bond %{buildroot}%{_libdir}/nagios/plugins/check_bond
|
|
||||||
|
|
||||||
%clean
|
|
||||||
rm -rf %{buildroot}
|
|
||||||
|
|
||||||
%files
|
|
||||||
%defattr(-,root,root,-)
|
|
||||||
%doc README
|
|
||||||
%{_libdir}/nagios/plugins/*
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
|
||||||
- Initial packaging
|
|
@ -1,3 +0,0 @@
|
|||||||
check_bond
|
|
||||||
|
|
||||||
Simple Nagios plugin that checks the status of bond devices
|
|
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
Summary: A Nagios plugin to check Brocade devices
|
Summary: A Nagios plugin to check Brocade devices
|
||||||
Name: nagios-okplugin-brocade
|
Name: nagios-okplugin-brocade
|
||||||
Version: 0.0.3
|
Version: 0.0.5
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-Brocade
|
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-Brocade
|
||||||
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_brocade/releases/nagios-okplugin-brocade-%{version}.tar.gz
|
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_brocade/releases/nagios-okplugin-brocade-%{version}.tar.gz
|
||||||
Requires: perl-Nagios-Plugin
|
Requires: perl-Nagios-Plugin
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
Packager: Tomas Edwardsson <tommi@ok.is>
|
Packager: Gardar Thorsteinsson <gardar@ok.is>
|
||||||
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -20,6 +20,8 @@ Checks Brocade devices
|
|||||||
%setup -q
|
%setup -q
|
||||||
perl -pi -e "s|/usr/lib|%{_libdir}|g" check_brocade_env
|
perl -pi -e "s|/usr/lib|%{_libdir}|g" check_brocade_env
|
||||||
|
|
||||||
|
%global __requires_exclude %{?__requires_exclude:%__requires_exclude}|}^perl\\(utils\\)
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
|
||||||
|
|
||||||
@ -36,5 +38,14 @@ rm -rf %{buildroot}
|
|||||||
%{_libdir}/nagios/plugins/*
|
%{_libdir}/nagios/plugins/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri May 09 2018 Gardar Thorsteinsson <gardar@ok.is> 0.0.5-2
|
||||||
|
- filter out perl-utils dep
|
||||||
|
|
||||||
|
* Thu Feb 20 2014 Pall Sigurdsson <palli@opensource.is> 0.0.5-1
|
||||||
|
-
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 0.0.4-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
* Mon Nov 21 2010 Tomas Edwardsson <tommi@ok.is> 0.0.3-1
|
* Mon Nov 21 2010 Tomas Edwardsson <tommi@ok.is> 0.0.3-1
|
||||||
- Initial packaging
|
- Initial packaging
|
@ -23,7 +23,7 @@ use Nagios::Plugin;
|
|||||||
# Create the Nagios plugin object
|
# Create the Nagios plugin object
|
||||||
my $np = Nagios::Plugin->new(
|
my $np = Nagios::Plugin->new(
|
||||||
usage => "Usage: %s -H <hostname> -u <username> -p <password> -s <share>",
|
usage => "Usage: %s -H <hostname> -u <username> -p <password> -s <share>",
|
||||||
version => "0.01",
|
version => "1.0",
|
||||||
);
|
);
|
||||||
|
|
||||||
# Add valid arguments
|
# Add valid arguments
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
Summary: A Nagios plugin to check CIFS shares
|
Summary: A Nagios plugin to check CIFS shares
|
||||||
Name: nagios-okplugin-cifs
|
Name: nagios-okplugin-cifs
|
||||||
Version: 0.0.3
|
Version: 1.1
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-Brocade
|
URL: http://opensource.ok.is/trac/wiki/Nagios-OKPlugin-Brocade
|
||||||
@ -11,7 +11,8 @@ Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_cifs/releases
|
|||||||
Requires: perl-Nagios-Plugin
|
Requires: perl-Nagios-Plugin
|
||||||
Requires: samba-client, krb5-workstation
|
Requires: samba-client, krb5-workstation
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
Packager: Tomas Edwardsson <tommi@ok.is>
|
Packager: Gardar Thorsteinsson <gardar@ok.is>
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -22,6 +23,8 @@ NTML authentication
|
|||||||
%setup -q
|
%setup -q
|
||||||
perl -pi -e "s|/usr/lib|%{_libdir}|g" check_cifs
|
perl -pi -e "s|/usr/lib|%{_libdir}|g" check_cifs
|
||||||
|
|
||||||
|
%global __requires_exclude %{?__requires_exclude:%__requires_exclude}|}^perl\\(utils\\)
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
|
||||||
|
|
||||||
@ -38,5 +41,18 @@ rm -rf %{buildroot}
|
|||||||
%{_libdir}/nagios/plugins/*
|
%{_libdir}/nagios/plugins/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri May 09 2018 Gardar Thorsteinsson <gardar@ok.is> 1.1-2
|
||||||
|
- Filter out perl-utils dep
|
||||||
|
|
||||||
|
* Thu Feb 20 2014 Pall Sigurdsson <palli@opensource.is> 1.1-1
|
||||||
|
- Merge github.com:opinkerfi/misc (palli@opensource.is)
|
||||||
|
|
||||||
|
* Thu Aug 23 2012 Pall Sigurdsson <palli@opensource.is> 1.0-1
|
||||||
|
- version number of scripts bumped (palli@opensource.is)
|
||||||
|
- Updates buildarch to noarch (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 0.0.4-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
* Mon Nov 21 2010 Tomas Edwardsson <tommi@ok.is> 0.0.3-1
|
* Mon Nov 21 2010 Tomas Edwardsson <tommi@ok.is> 0.0.3-1
|
||||||
- Initial packaging
|
- Initial packaging
|
59
check_cpu.py/nagios-okplugin-check_cpu.spec
Normal file
59
check_cpu.py/nagios-okplugin-check_cpu.spec
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
%define debug_package %{nil}
|
||||||
|
|
||||||
|
Summary: A Nagios plugin to check CPU on Linux servers
|
||||||
|
Name: nagios-okplugin-check_cpu
|
||||||
|
Version: 1.1
|
||||||
|
Release: 1%{?dist}
|
||||||
|
License: GPLv2+
|
||||||
|
Group: Applications/System
|
||||||
|
URL: https://github.com/opinkerfi/nagios-plugins/
|
||||||
|
Source0: https://github.com/opinkerfi/nagios-plugins/archive/%{name}-%{version}-%{release}.tar.gz
|
||||||
|
Requires: nagios-okplugin-common
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
|
Packager: Tomas Edwardsson <tommi@tommi.org>
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
%description
|
||||||
|
Check cpu states on line machines
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
install -D -p -m 0755 okplugin_check_cpu %{buildroot}%{_libdir}/nagios/plugins/okplugin_check_cpu
|
||||||
|
install -D -p -m 0755 nrpe.d/okplugin_check_cpu.cfg %{buildroot}/etc/nrpe.d/okplugin_check_cpu.cfg
|
||||||
|
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
|
%post
|
||||||
|
/sbin/service nrpe reload
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
%{_libdir}/nagios/plugins/*
|
||||||
|
%{_sysconfdir}/nrpe.d/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Mon Jan 20 2014 Tomas Edwardsson <tommi@tommi.org> 1.1-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
|
* Thu Aug 23 2012 Pall Sigurdsson <palli@opensource.is> 1.0-1
|
||||||
|
- Version number bumped
|
||||||
|
- Updates buildarch to noarch (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 0.3-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
|
* Thu Nov 25 2010 Pall Sigurdsson <palli@opensource.is> 0.1-2
|
||||||
|
- Nrpe config now ships with plugin by default
|
||||||
|
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
||||||
|
- Initial packaging
|
||||||
|
|
1
check_cpu.py/nrpe.d/okplugin_check_cpu.cfg
Normal file
1
check_cpu.py/nrpe.d/okplugin_check_cpu.cfg
Normal file
@ -0,0 +1 @@
|
|||||||
|
command[okplugin_check_cpu]=/usr/lib/nagios/plugins/okplugin_check_cpu
|
131
check_cpu.py/okplugin_check_cpu
Normal file
131
check_cpu.py/okplugin_check_cpu
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
#
|
||||||
|
# Copyright 2014, Tomas Edwardsson
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
"""
|
||||||
|
Gathers information on cpu usage on a linux machine
|
||||||
|
|
||||||
|
It returns performance data for both the last 5 seconds and from last run.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pynag.Plugins import PluginHelper, ok, unknown
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""The main logic of the program"""
|
||||||
|
|
||||||
|
# See man proc and search for /proc/stat
|
||||||
|
stat_fields = ['cpu', 'user', 'nice', 'system', 'idle', 'iowait', 'irq',
|
||||||
|
'softirq', 'steal', 'guest', 'guest_nice']
|
||||||
|
|
||||||
|
pyplug = PluginHelper()
|
||||||
|
|
||||||
|
# Get the statistics from last run
|
||||||
|
old_stat = get_saved_stat()
|
||||||
|
|
||||||
|
# Get current state
|
||||||
|
stat = get_stat()
|
||||||
|
|
||||||
|
# Resample
|
||||||
|
time.sleep(5)
|
||||||
|
stat2 = get_stat()
|
||||||
|
|
||||||
|
try:
|
||||||
|
save_stat(stat)
|
||||||
|
except IOError, err:
|
||||||
|
pyplug.exit(unknown, "Unable to save cpu statistics: %s" % err)
|
||||||
|
|
||||||
|
|
||||||
|
# Calculate averages for the last few seconds
|
||||||
|
current_averages = diff_stats(stat2, stat)
|
||||||
|
for pos in range(len(current_averages)):
|
||||||
|
pyplug.add_metric(label=stat_fields[pos+1],
|
||||||
|
value=current_averages[pos],
|
||||||
|
uom="%")
|
||||||
|
|
||||||
|
# Calculate averages from last run
|
||||||
|
if old_stat:
|
||||||
|
last_run_avg = diff_stats(old_stat, stat)
|
||||||
|
for pos in range(len(current_averages)):
|
||||||
|
pyplug.add_metric(label=stat_fields[pos+1]+"_avg",
|
||||||
|
value=last_run_avg[pos],
|
||||||
|
uom="%")
|
||||||
|
|
||||||
|
pyplug.add_status(ok)
|
||||||
|
pyplug.add_summary("CPU load %.2f%%" % (100.0 - current_averages[3]))
|
||||||
|
pyplug.exit()
|
||||||
|
|
||||||
|
def diff_stats(older, newer):
|
||||||
|
"""Calculates the percentage between two stat arrays"""
|
||||||
|
if older:
|
||||||
|
diff = []
|
||||||
|
for pos in range(len(newer)):
|
||||||
|
diff.append(newer[pos] - older[pos])
|
||||||
|
averages = calc_avg(diff)
|
||||||
|
else:
|
||||||
|
averages = calc_avg(newer)
|
||||||
|
|
||||||
|
return averages
|
||||||
|
|
||||||
|
|
||||||
|
def remove_stale_state():
|
||||||
|
"""Removes the last state file if we have rebooted"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
state_mtime = os.stat("/var/lib/nagios-okplugin/check_cpu").st_mtime
|
||||||
|
boot_time = os.stat("/proc/1").st_mtime
|
||||||
|
if state_mtime < boot_time:
|
||||||
|
os.unlink("/var/lib/nagios-okplugin/check_cpu")
|
||||||
|
except OSError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return state_mtime
|
||||||
|
|
||||||
|
def calc_avg(stat):
|
||||||
|
"""Calculates the average of each int in array"""
|
||||||
|
stat_sum = sum(stat)
|
||||||
|
avg = []
|
||||||
|
for pos in range(len(stat)):
|
||||||
|
avg.append(float(stat[pos]) / stat_sum * 100)
|
||||||
|
return avg
|
||||||
|
|
||||||
|
def get_stat():
|
||||||
|
"""Fetches the first line from /proc/stat and returns the numbers"""
|
||||||
|
stat_fh = open("/proc/stat")
|
||||||
|
return [int(pos) for pos in stat_fh.readline().split()[1:]]
|
||||||
|
|
||||||
|
def get_saved_stat():
|
||||||
|
"""Fetches information about the last run to be able to do averages"""
|
||||||
|
|
||||||
|
remove_stale_state()
|
||||||
|
try:
|
||||||
|
stat_fh = open("/var/lib/nagios-okplugin/check_cpu")
|
||||||
|
except IOError:
|
||||||
|
return None
|
||||||
|
return [int(pos) for pos in stat_fh.readline().split()[1:]]
|
||||||
|
|
||||||
|
def save_stat(stat):
|
||||||
|
"""Save statistics to compare to in next run"""
|
||||||
|
stat_fh = open("/var/lib/nagios-okplugin/check_cpu", "w")
|
||||||
|
|
||||||
|
stat_fh.write("cpu " + " ".join([str(pos) for pos in stat]) + "\n")
|
||||||
|
stat_fh.close()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
|
# vim: sts=4 expandtab
|
@ -167,6 +167,11 @@ must be lower than the critical level!"
|
|||||||
exit $ST_UK
|
exit $ST_UK
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
which bc >> /dev/null
|
||||||
|
if [ $? -gt 0 ]; then
|
||||||
|
echo "UNKNOWN - command 'bc' not found in path. Exiting..."
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
get_cpuvals
|
get_cpuvals
|
||||||
do_output
|
do_output
|
@ -2,15 +2,16 @@
|
|||||||
|
|
||||||
Summary: A Nagios plugin to check CPU on Linux servers
|
Summary: A Nagios plugin to check CPU on Linux servers
|
||||||
Name: nagios-plugins-check_cpu
|
Name: nagios-plugins-check_cpu
|
||||||
Version: 0.2
|
Version: 2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://www.matejunkie.com/cpu-check-plugin-for-nagios/
|
URL: http://www.matejunkie.com/cpu-check-plugin-for-nagios/
|
||||||
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_cpu/releases/nagios-plugins-check_cpu-%{version}.tar.gz
|
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_cpu/releases/nagios-plugins-check_cpu-%{version}.tar.gz
|
||||||
Requires: nrpe
|
Requires: nrpe bc
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
Packager: Tomas Edwardsson <tommi@ok.is>
|
Packager: Tomas Edwardsson <tommi@ok.is>
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This shell script checks cpu utilization (user,system,iowait,idle in %)
|
This shell script checks cpu utilization (user,system,iowait,idle in %)
|
||||||
@ -33,6 +34,9 @@ install -D -p -m 0755 nrpe.d/check_cpu.cfg %{buildroot}/etc/nrpe.d/check_cpu.cfg
|
|||||||
%clean
|
%clean
|
||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
|
%post
|
||||||
|
/sbin/service nrpe reload
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
#%doc README LICENSE
|
#%doc README LICENSE
|
||||||
@ -41,6 +45,18 @@ rm -rf %{buildroot}
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Feb 20 2014 Pall Sigurdsson <palli@opensource.is> 2-1
|
||||||
|
- Added nrpe reload to post section (tommi@tommi.org)
|
||||||
|
- Merge github.com:opinkerfi/misc (palli@opensource.is)
|
||||||
|
- Added dependency on bc (palli@opensource.is)
|
||||||
|
|
||||||
|
* Thu Aug 23 2012 Pall Sigurdsson <palli@opensource.is> 1.0-1
|
||||||
|
- Version number bumped
|
||||||
|
- Updates buildarch to noarch (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 0.3-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
* Thu Nov 25 2010 Pall Sigurdsson <palli@opensource.is> 0.1-2
|
* Thu Nov 25 2010 Pall Sigurdsson <palli@opensource.is> 0.1-2
|
||||||
- Nrpe config now ships with plugin by default
|
- Nrpe config now ships with plugin by default
|
||||||
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
* Mon Mar 1 2010 Tomas Edwardsson <tommi@ok.is> 0.1-1
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -64,7 +64,6 @@ def check_tablespaces():
|
|||||||
global default_warning_threshold
|
global default_warning_threshold
|
||||||
global nagios_status
|
global nagios_status
|
||||||
warn = default_warning_threshold
|
warn = default_warning_threshold
|
||||||
warn = 60
|
|
||||||
max_size = i['max_size'] * 1024
|
max_size = i['max_size'] * 1024
|
||||||
curr_size = i['curr_size'] * 1024
|
curr_size = i['curr_size'] * 1024
|
||||||
occupancy = 100.0 * curr_size / max_size
|
occupancy = 100.0 * curr_size / max_size
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Summary: Nagios Plugins to monitor HP Dataprotector
|
Summary: Nagios Plugins to monitor HP Dataprotector
|
||||||
Name: nagios-okplugin-check_dataprotector
|
Name: nagios-okplugin-check_dataprotector
|
||||||
Version: AUTOVERSION
|
Version: 2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
@ -45,5 +45,12 @@ rm -rf %{buildroot}
|
|||||||
/etc/nrpe.d/check_dataprotector.cfg
|
/etc/nrpe.d/check_dataprotector.cfg
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Feb 20 2014 Pall Sigurdsson <palli@opensource.is> 2-1
|
||||||
|
- removed warning threshold of 60 (palli@opensource.is)
|
||||||
|
- contrib removed from plugin path (palli@opensource.is)
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 1.0.1-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
* Mon Sep 15 2010 Pall Sigurdsson <palli@opensource.is> 0.1-1
|
* Mon Sep 15 2010 Pall Sigurdsson <palli@opensource.is> 0.1-1
|
||||||
- Initial packaging
|
- Initial packaging
|
8
check_dataprotector/nrpe.d/check_dataprotector.cfg
Normal file
8
check_dataprotector/nrpe.d/check_dataprotector.cfg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
command[check_dp_pool]=/usr/lib/nagios/plugins/check_dp_pool "$ARG1$"
|
||||||
|
command[check_dp_tablespace]=/usr/lib/nagios/plugins/check_dp_tablespace
|
||||||
|
command[check_dp_services]=/usr/lib/nagios/plugins/check_dp_services
|
||||||
|
command[check_dp_mountrequest]=/usr/lib/nagios/plugins/check_dp_mountrequest
|
||||||
|
command[check_dp_idb]=/usr/lib/nagios/plugins/check_dp_idb
|
||||||
|
command[check_dp_backups]=/usr/lib/nagios/plugins/check_dp_backups
|
@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
command[check_dp_pool]=/usr/lib/nagios/plugins/contrib/check_dp_pool "$ARG1$"
|
|
||||||
command[check_dp_tablespace]=/usr/lib/nagios/plugins/contrib/check_dp_tablespace
|
|
||||||
command[check_dp_services]=/usr/lib/nagios/plugins/contrib/check_dp_services
|
|
||||||
command[check_dp_mountrequest]=/usr/lib/nagios/plugins/contrib/check_dp_mountrequest
|
|
||||||
command[check_dp_idb]=/usr/lib/nagios/plugins/contrib/check_dp_idb
|
|
@ -24,6 +24,7 @@
|
|||||||
-h | --help : Display this help
|
-h | --help : Display this help
|
||||||
-w | --warning : % free space to send warning alert (default 10)
|
-w | --warning : % free space to send warning alert (default 10)
|
||||||
-c | --critical : % free space to send critical alert (default 5)
|
-c | --critical : % free space to send critical alert (default 5)
|
||||||
|
-I | --inodes : Check for inodes
|
||||||
-H | --host : host you want to check by NRPE (default localhost)
|
-H | --host : host you want to check by NRPE (default localhost)
|
||||||
-u | --user : user for NRPE connection (default nagios)
|
-u | --user : user for NRPE connection (default nagios)
|
||||||
-i | --ignore : Filesystem you want to ignore
|
-i | --ignore : Filesystem you want to ignore
|
||||||
@ -94,6 +95,9 @@ not be used.
|
|||||||
|
|
||||||
$Log: check_disk.pl,v $
|
$Log: check_disk.pl,v $
|
||||||
|
|
||||||
|
Revision 1.10 2013/03/01 14:28:00 tryggvi@ok.is
|
||||||
|
o Added support for inodes
|
||||||
|
|
||||||
Revision 1.9 2010/02/27 00:55:00 palli@ok.is
|
Revision 1.9 2010/02/27 00:55:00 palli@ok.is
|
||||||
o Changed UNKNOWN return code from -1 to 3
|
o Changed UNKNOWN return code from -1 to 3
|
||||||
o Modified to use check_nrpe instead of ssh
|
o Modified to use check_nrpe instead of ssh
|
||||||
@ -129,7 +133,7 @@ use Pod::Usage;
|
|||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
my ($opt_c, $opt_w, $opt_h, $opt_i,$opt_f,$opt_s,$opt_u,$opt_H,$opt_C,$opt_v,
|
my ($opt_c, $opt_w, $opt_h, $opt_i,$opt_f,$opt_s,$opt_u,$opt_H,$opt_C,$opt_v,
|
||||||
$opt_html, $opt_srvperf, $opt_r, $opt_R);
|
$opt_html, $opt_srvperf, $opt_r, $opt_R, $opt_inodes);
|
||||||
|
|
||||||
$ENV{'PATH'} = "/usr/lib/nagios/plugins:/usr/lib64/nagios/plugins:/usr/local/libexec:/usr/libexec:/usr/local/nagios/libexec";
|
$ENV{'PATH'} = "/usr/lib/nagios/plugins:/usr/lib64/nagios/plugins:/usr/local/libexec:/usr/libexec:/usr/local/nagios/libexec";
|
||||||
|
|
||||||
@ -140,12 +144,13 @@ $opt_c = "5"; # Valeur par defaut de critical
|
|||||||
$opt_H = "localhost";
|
$opt_H = "localhost";
|
||||||
$opt_R = q/^$/;
|
$opt_R = q/^$/;
|
||||||
$opt_r = "";
|
$opt_r = "";
|
||||||
|
my $cmd = "/bin/df -k";
|
||||||
|
my $multiply = 1024; # For bytes
|
||||||
|
|
||||||
my $exclude_re = "(^//|^none)";
|
my $exclude_re = "(^//|^none)";
|
||||||
|
|
||||||
my %alldisks; # Tous les disques trouves avec la commande df
|
my %alldisks; # Tous les disques trouves avec la commande df
|
||||||
my %checkdisks; # seulement les disque a verifier
|
my %checkdisks; # seulement les disque a verifier
|
||||||
my $cmd = "/bin/df -k";
|
|
||||||
my $output ;
|
my $output ;
|
||||||
my $retour = 'OK';
|
my $retour = 'OK';
|
||||||
my %EXIT_CODES = (
|
my %EXIT_CODES = (
|
||||||
@ -168,6 +173,7 @@ GetOptions(
|
|||||||
"i=s" => \$opt_i, "ignore=s" => \$opt_i,
|
"i=s" => \$opt_i, "ignore=s" => \$opt_i,
|
||||||
"f=s" => \$opt_f, "filesystem=s" => \$opt_f,
|
"f=s" => \$opt_f, "filesystem=s" => \$opt_f,
|
||||||
"C=s" => \$opt_C, "conf=s" => \$opt_C,
|
"C=s" => \$opt_C, "conf=s" => \$opt_C,
|
||||||
|
"I" => \$opt_inodes, "inodes" => \$opt_inodes,
|
||||||
"v" => \$opt_v, "verbose" => \$opt_v,
|
"v" => \$opt_v, "verbose" => \$opt_v,
|
||||||
"r=s" => \$opt_r, "R=s" => \$opt_R,
|
"r=s" => \$opt_r, "R=s" => \$opt_R,
|
||||||
"html" => \$opt_html,
|
"html" => \$opt_html,
|
||||||
@ -197,26 +203,37 @@ my $args;
|
|||||||
# ->{critical} : taux critique en % espace libre
|
# ->{critical} : taux critique en % espace libre
|
||||||
#
|
#
|
||||||
|
|
||||||
|
if(defined($opt_inodes)){
|
||||||
|
# Using -i for inodes
|
||||||
|
$cmd = "/bin/df -i";
|
||||||
|
$multiply = 1000;
|
||||||
|
}
|
||||||
|
|
||||||
#Si on est en local inutile de faire du nrpe
|
#Si on est en local inutile de faire du nrpe
|
||||||
if($opt_H ne "localhost" and $opt_H ne "127.0.0.1") {
|
if($opt_H ne "localhost" and $opt_H ne "127.0.0.1") {
|
||||||
#$cmd = "ssh $opt_u\@$opt_H '$cmd'";
|
#$cmd = "ssh $opt_u\@$opt_H '$cmd'";
|
||||||
$cmd = "check_nrpe -H $opt_H -c get_disks";
|
if(defined($opt_inodes)){
|
||||||
|
$cmd = "check_nrpe -H $opt_H -c get_disks_inodes";
|
||||||
|
} else {
|
||||||
|
$cmd = "check_nrpe -H $opt_H -c get_disks";
|
||||||
|
}
|
||||||
#$cmd = "cat /tmp/df";
|
#$cmd = "cat /tmp/df";
|
||||||
#print "$cmd";
|
#print "$cmd";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Envoi commande et renseignement Hashage %disks
|
# Envoi commande et renseignement Hashage %disks
|
||||||
my @output = `$cmd`;
|
my @output = `$cmd`;
|
||||||
|
|
||||||
my $ret = $?;
|
my $ret = $?;
|
||||||
|
$ret >>= 8;
|
||||||
|
|
||||||
if ($ret == -1) {
|
if ($ret == -1) {
|
||||||
print "Could not find " . (split(' ', $cmd))[0] . "\n";
|
print "Could not find " . (split(' ', $cmd))[0] . "\n";
|
||||||
exit $EXIT_CODES{'UNKNOWN'};
|
exit $EXIT_CODES{'UNKNOWN'};
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret >>= 8;
|
|
||||||
# 2010/02/25 palli@ok.is : Check if $cmd ran successfully
|
# 2010/02/25 palli@ok.is : Check if $cmd ran successfully
|
||||||
if ($ret > 0) {
|
if ($ret > 1) {
|
||||||
print "Failed to execute $cmd: " . join("\n", @output) . "\n";
|
print "Failed to execute $cmd: " . join("\n", @output) . "\n";
|
||||||
exit $EXIT_CODES{'UNKNOWN'} ;
|
exit $EXIT_CODES{'UNKNOWN'} ;
|
||||||
}
|
}
|
||||||
@ -234,16 +251,16 @@ if ($ret > 0) {
|
|||||||
#
|
#
|
||||||
|
|
||||||
foreach my $l (@output) {
|
foreach my $l (@output) {
|
||||||
|
next if ($l =~ m/$opt_R/);
|
||||||
|
next if ($l !~ m/$opt_r/);
|
||||||
|
next if ($l =~ m/$exclude_re/);
|
||||||
if($l =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+([\/\w\d\.-]+)$/) {
|
if($l =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+([\/\w\d\.-]+)$/) {
|
||||||
next if ($l =~ m/$opt_R/);
|
|
||||||
next if ($l !~ m/$opt_r/);
|
|
||||||
next if ($l =~ m/$exclude_re/);
|
|
||||||
my ($s,$u,$f,$pu,$d) = ($1,$2,$3,$4,$5);
|
my ($s,$u,$f,$pu,$d) = ($1,$2,$3,$4,$5);
|
||||||
$alldisks{$d}->{pused} = $pu;
|
$alldisks{$d}->{pused} = $pu;
|
||||||
$alldisks{$d}->{pfree} = 100-$pu;
|
$alldisks{$d}->{pfree} = 100-$pu;
|
||||||
$alldisks{$d}->{somme} = $s*1024;
|
$alldisks{$d}->{somme} = $s*$multiply;
|
||||||
$alldisks{$d}->{used} = $u*1024;
|
$alldisks{$d}->{used} = $u*$multiply;
|
||||||
$alldisks{$d}->{free} = $f*1024;
|
$alldisks{$d}->{free} = $f*$multiply;
|
||||||
|
|
||||||
# par defaut on prend les taux Warn et Crit specifies
|
# par defaut on prend les taux Warn et Crit specifies
|
||||||
updateRates($d,$opt_w,$opt_c,$alldisks{$d}->{somme});
|
updateRates($d,$opt_w,$opt_c,$alldisks{$d}->{somme});
|
||||||
@ -251,16 +268,16 @@ foreach my $l (@output) {
|
|||||||
# This is the output of df.exe on Windows
|
# This is the output of df.exe on Windows
|
||||||
#C:\ 9097126 6094081 3003045 67% argon-c (ntfs)
|
#C:\ 9097126 6094081 3003045 67% argon-c (ntfs)
|
||||||
else {
|
else {
|
||||||
if ($l =~ /(\w)\:\\\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(.*)$/) {
|
|
||||||
next if ($l =~ m/$opt_R/);
|
next if ($l =~ m/$opt_R/);
|
||||||
next if ($l !~ m/$opt_r/);
|
next if ($l !~ m/$opt_r/);
|
||||||
next if ($l =~ m/$exclude_re/);
|
next if ($l =~ m/$exclude_re/);
|
||||||
|
if ($l =~ /(\w)\:\\\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(.*)$/) {
|
||||||
my ($d,$s,$u,$f,$pu) = ("/$1",$2,$3,$4,$5);
|
my ($d,$s,$u,$f,$pu) = ("/$1",$2,$3,$4,$5);
|
||||||
$alldisks{$d}->{pused} = $pu;
|
$alldisks{$d}->{pused} = $pu;
|
||||||
$alldisks{$d}->{pfree} = 100-$pu;
|
$alldisks{$d}->{pfree} = 100-$pu;
|
||||||
$alldisks{$d}->{somme} = $s*1024;
|
$alldisks{$d}->{somme} = $s*$multiply;
|
||||||
$alldisks{$d}->{used} = $u*1024;
|
$alldisks{$d}->{used} = $u*$multiply;
|
||||||
$alldisks{$d}->{free} = $f*1024;
|
$alldisks{$d}->{free} = $f*$multiply;
|
||||||
#print $l;
|
#print $l;
|
||||||
#print "pused = $pu\n";
|
#print "pused = $pu\n";
|
||||||
#print "pfree = 100-$pu\n";
|
#print "pfree = 100-$pu\n";
|
||||||
@ -307,7 +324,7 @@ if($opt_f) {
|
|||||||
if(defined($alldisks{$f})) {
|
if(defined($alldisks{$f})) {
|
||||||
$checkdisks{$f}=$alldisks{$f};
|
$checkdisks{$f}=$alldisks{$f};
|
||||||
}
|
}
|
||||||
} elsif ($f =~ /([\/\w\d]+)\:(\w+)\:(\w+)/) {
|
} elsif ($f =~ /^(.+?)\:(\w+)\:(\w+)/) {
|
||||||
if(defined($alldisks{$1})) {
|
if(defined($alldisks{$1})) {
|
||||||
$checkdisks{$1}=$alldisks{$1};
|
$checkdisks{$1}=$alldisks{$1};
|
||||||
updateRates($1,$2,$3,$checkdisks{$1}->{somme});
|
updateRates($1,$2,$3,$checkdisks{$1}->{somme});
|
||||||
@ -437,14 +454,15 @@ sub byte2percent {
|
|||||||
print "Erreur : unite inconnue ($unit)\n";
|
print "Erreur : unite inconnue ($unit)\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($unit eq 'K') {
|
if($unit eq 'K') {
|
||||||
$return = sprintf("%d",100*(1024*$value)/$max);
|
$return = sprintf("%d",100*($multiply*$value)/$max);
|
||||||
} elsif ($unit eq 'M') {
|
} elsif ($unit eq 'M') {
|
||||||
$return = sprintf("%d",100*(1024*1024*$value)/$max);
|
$return = sprintf("%d",100*($multiply*$multiply*$value)/$max);
|
||||||
} elsif ($unit eq 'G') {
|
} elsif ($unit eq 'G') {
|
||||||
$return = sprintf("%d",100*(1024*1024*1024*$value)/$max);
|
$return = sprintf("%d",100*($multiply*$multiply*$multiply*$value)/$max);
|
||||||
} elsif ($unit eq 'T') {
|
} elsif ($unit eq 'T') {
|
||||||
$return = sprintf("%d",100*(1024*1024*1024*1024*$value)/$max);
|
$return = sprintf("%d",100*($multiply*$multiply*$multiply*$multiply*$value)/$max);
|
||||||
}
|
}
|
||||||
#Borne a 100 %
|
#Borne a 100 %
|
||||||
if($return > 100) {
|
if($return > 100) {
|
||||||
@ -459,8 +477,8 @@ sub byte2human {
|
|||||||
|
|
||||||
my @units = qw/B K M G T/;
|
my @units = qw/B K M G T/;
|
||||||
|
|
||||||
while (($value / 1024) >= 1) {
|
while (($value / $multiply) >= 1) {
|
||||||
$value /= 1024;
|
$value /= $multiply;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
return sprintf('%.1f%s',$value, $units[$i]);
|
return sprintf('%.1f%s',$value, $units[$i]);
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
Summary: A Nagios plugin to check disks via NRPE
|
Summary: A Nagios plugin to check disks via NRPE
|
||||||
Name: nagios-okplugin-check_disks
|
Name: nagios-okplugin-check_disks
|
||||||
Version: AUTOVERSION
|
Version: 1.0.7
|
||||||
Release: 2%{?dist}
|
Release: 1%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://opensource.is/trac/wiki/check_disks
|
URL: http://opensource.is/trac/wiki/check_disks
|
||||||
@ -40,6 +40,29 @@ rm -rf %{buildroot}
|
|||||||
%{_libdir}/nagios/plugins/check_disks.pl
|
%{_libdir}/nagios/plugins/check_disks.pl
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Oct 29 2014 Tomas Edwardsson <tommi@tommi.org> 1.0.7-1
|
||||||
|
- Fix invalid regex if mountpoint has . in path (tommi@tommi.org)
|
||||||
|
- Regex filtering broke disk checks (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Tue Mar 25 2014 Tomas Edwardsson <tommi@tommi.org> 1.0.6-1
|
||||||
|
- Bumped version
|
||||||
|
|
||||||
|
* Tue Mar 25 2014 Tomas Edwardsson <tommi@tommi.org> 1.0.5-1
|
||||||
|
- Added support for inodes (tryggvi@linux.is)
|
||||||
|
|
||||||
|
* Sat Mar 02 2013 Tryggvi Farestveit <tryggvi@linux.is> 1.0.4-1
|
||||||
|
- Added support for inodes
|
||||||
|
|
||||||
|
* Wed May 16 2012 Tomas Edwardsson <tommi@tommi.org> 1.0.3-1
|
||||||
|
- Updated version of nagios-okplugin-check_disks (tommi@tommi.org)
|
||||||
|
- Issue #56, temporary fix for selinux and disk checks (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Mon May 16 2012 Tomas Edwardsson <tommi@opensource.is> 1.0.2-1
|
||||||
|
- Ignore warning states from nrpe
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 1.0.1-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
* Sun Oct 16 2011 Tomas Edwardsson <tommi@opensource.is> 0.1-2
|
* Sun Oct 16 2011 Tomas Edwardsson <tommi@opensource.is> 0.1-2
|
||||||
- Fixed dependencies and build arch
|
- Fixed dependencies and build arch
|
||||||
|
|
59
check_drbd/nagios-okplugin-check_drbd.spec
Normal file
59
check_drbd/nagios-okplugin-check_drbd.spec
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
%define debug_package %{nil}
|
||||||
|
|
||||||
|
%define plugin_name check_drbd
|
||||||
|
|
||||||
|
|
||||||
|
Summary: A Nagios plugin to check Linux Devicemapper Multipathing
|
||||||
|
Name: nagios-okplugin-%{plugin_name}
|
||||||
|
Version: 0.0.4
|
||||||
|
Release: 1%{?dist}
|
||||||
|
License: GPLv2+
|
||||||
|
Group: Applications/System
|
||||||
|
URL: http://opensource.is/trac/wiki/%{plugin_name}
|
||||||
|
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/%{plugin_name}/releases/%{name}-%{version}.tar.gz
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
|
Packager: Pall Sigurdsson <palli@opensource.is>
|
||||||
|
|
||||||
|
|
||||||
|
%description
|
||||||
|
%{summary}
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
perl -pi -e "s|/usr/lib|%{_libdir}|g" nrpe.d/%{plugin_name}.cfg
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
install -D -p -m 0755 check_drbd %{buildroot}%{_libdir}/nagios/plugins/check_drbd
|
||||||
|
install -D -p -m 0755 nrpe.d/%{plugin_name}.cfg %{buildroot}/etc/nrpe.d/%{plugin_name}.cfg
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
#%doc README LICENSE
|
||||||
|
%{_libdir}/nagios/plugins/*
|
||||||
|
/etc/nrpe.d/%{plugin_name}.cfg
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Wed Mar 14 2012 Pall Sigurdsson <palli@opensource.is> 0.0.4-1
|
||||||
|
- licence and readme removed from specfile (palli@opensource.is)
|
||||||
|
|
||||||
|
* Wed Mar 14 2012 Pall Sigurdsson <palli@opensource.is>
|
||||||
|
- licence and readme removed from specfile (palli@opensource.is)
|
||||||
|
|
||||||
|
* Wed Mar 14 2012 Pall Sigurdsson <palli@opensource.is>
|
||||||
|
- licence and readme removed from specfile (palli@opensource.is)
|
||||||
|
|
||||||
|
* Wed Mar 14 2012 Pall Sigurdsson <palli@opensource.is>
|
||||||
|
- licence and readme removed from specfile (palli@opensource.is)
|
||||||
|
|
||||||
|
* Wed Mar 14 2012 Pall Sigurdsson <palli@opensource.is> 0.0.3-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 0.0.2-1
|
||||||
|
- new package built with tito
|
@ -288,7 +288,7 @@ sub check_disk {
|
|||||||
}
|
}
|
||||||
close (NAVICLIOUT);
|
close (NAVICLIOUT);
|
||||||
if ($disk_ok_count eq 0) {
|
if ($disk_ok_count eq 0) {
|
||||||
print "No disk were founded !\n";
|
print "No disk were found !\n";
|
||||||
$state = 'UNKNOWN';
|
$state = 'UNKNOWN';
|
||||||
} elsif ($crit_count > 0) {
|
} elsif ($crit_count > 0) {
|
||||||
$state='CRITICAL';
|
$state='CRITICAL';
|
767
check_eva/check_eva.py
Normal file
767
check_eva/check_eva.py
Normal file
@ -0,0 +1,767 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
#
|
||||||
|
# Copyright 2010, Pall Sigurdsson <palli@opensource.is>
|
||||||
|
#
|
||||||
|
# check_eva.py is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# check_eva.py is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# About this script
|
||||||
|
#
|
||||||
|
# This script will check the status of all EVA arrays via the sssu binary.
|
||||||
|
# You will need the sssu binary in path (/usr/bin/sssu is a good place)
|
||||||
|
# If you do not have sssu, check your commandview CD, it should have both
|
||||||
|
# binaries for Windows and Linux
|
||||||
|
|
||||||
|
|
||||||
|
# Some Defaults
|
||||||
|
show_perfdata = True
|
||||||
|
show_longserviceoutput = True
|
||||||
|
debugging = False
|
||||||
|
|
||||||
|
|
||||||
|
# check_eva defaults
|
||||||
|
hostname = "localhost"
|
||||||
|
username = "eva"
|
||||||
|
password = "eva1234"
|
||||||
|
mode = "check_systems"
|
||||||
|
path = ''
|
||||||
|
nagios_server = "94.142.154.10"
|
||||||
|
nagios_port = 80
|
||||||
|
nagios_myhostname = None
|
||||||
|
do_phone_home = False
|
||||||
|
escape_newlines = False
|
||||||
|
check_system = None # By default check all systems
|
||||||
|
proxyserver = None
|
||||||
|
timeout = 0 # 0 means no timeout
|
||||||
|
|
||||||
|
|
||||||
|
# set to true, if you do not have sssu binary handy
|
||||||
|
server_side_troubleshooting = False
|
||||||
|
|
||||||
|
# No real need to change anything below here
|
||||||
|
version = "1.0.1"
|
||||||
|
ok = 0
|
||||||
|
warning = 1
|
||||||
|
critical = 2
|
||||||
|
unknown = 3
|
||||||
|
not_present = -1
|
||||||
|
|
||||||
|
|
||||||
|
state = {}
|
||||||
|
state[not_present] = "Not Present"
|
||||||
|
state[ok] = "OK"
|
||||||
|
state[warning] = "Warning"
|
||||||
|
state[critical] = "Critical"
|
||||||
|
state[unknown] = "Unknown"
|
||||||
|
|
||||||
|
longserviceoutput = "\n"
|
||||||
|
perfdata = ""
|
||||||
|
|
||||||
|
valid_modes = ("check_systems", "check_controllers", "check_diskgroups",
|
||||||
|
"check_disks", "check_diskshelfs", "check_diskshelves")
|
||||||
|
|
||||||
|
from sys import exit
|
||||||
|
from sys import argv
|
||||||
|
from os import getenv, environ
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import xmlrpclib
|
||||||
|
import httplib
|
||||||
|
|
||||||
|
# we need to set socket default timeout in case we are using the phone-home part
|
||||||
|
import socket
|
||||||
|
socket.setdefaulttimeout(5)
|
||||||
|
|
||||||
|
|
||||||
|
def print_help():
|
||||||
|
print "check_eva version %s" % version
|
||||||
|
print "This plugin checks HP EVA Array with the sssu command"
|
||||||
|
print ""
|
||||||
|
print "Usage: %s [OPTIONS]" % argv[0]
|
||||||
|
print "OPTIONS:"
|
||||||
|
print " [--host <host>]"
|
||||||
|
print " [--username <user>]"
|
||||||
|
print " [--password <password]"
|
||||||
|
print " [--path </path/to/sssu>]"
|
||||||
|
print " [--mode <mode>] "
|
||||||
|
print " [--test]"
|
||||||
|
print " [--timeout <timeout>]"
|
||||||
|
print " [--debug]"
|
||||||
|
print " [--help]"
|
||||||
|
print ""
|
||||||
|
print " Valid modes are: %s" % ', '.join(valid_modes)
|
||||||
|
print ""
|
||||||
|
print "Example: %s --host commandview.example.net --username eva --password myPassword --mode check_systems" % (argv[0])
|
||||||
|
|
||||||
|
|
||||||
|
def error(errortext):
|
||||||
|
print "* Error: %s" % errortext
|
||||||
|
print_help()
|
||||||
|
print "* Error: %s" % errortext
|
||||||
|
exit(unknown)
|
||||||
|
|
||||||
|
|
||||||
|
def debug(debugtext):
|
||||||
|
global debugging
|
||||||
|
if debugging:
|
||||||
|
print debugtext
|
||||||
|
|
||||||
|
# parse arguments
|
||||||
|
|
||||||
|
arguments = argv[1:]
|
||||||
|
while len(arguments) > 0:
|
||||||
|
arg = arguments.pop(0)
|
||||||
|
if arg == 'invalid':
|
||||||
|
pass
|
||||||
|
elif arg == '-H' or arg == '--host':
|
||||||
|
hostname = arguments.pop(0)
|
||||||
|
elif arg == '-U' or arg == '--username':
|
||||||
|
username = arguments.pop(0)
|
||||||
|
elif arg == '-P' or arg == '--password':
|
||||||
|
password = arguments.pop(0)
|
||||||
|
elif arg == '-T' or arg == '--test':
|
||||||
|
testmode = 1
|
||||||
|
elif arg == '--timeout':
|
||||||
|
timeout = int(arguments.pop(0))
|
||||||
|
elif arg == '--path':
|
||||||
|
path = arguments.pop(0) + '/'
|
||||||
|
elif arg == '-M' or arg == '--mode':
|
||||||
|
mode = arguments.pop(0)
|
||||||
|
if mode not in valid_modes:
|
||||||
|
error("Invalid --mode %s" % arg)
|
||||||
|
elif arg == '-d' or arg == '--debug':
|
||||||
|
debugging = True
|
||||||
|
elif arg == '--longserviceoutput':
|
||||||
|
show_longserviceoutput = True
|
||||||
|
elif arg == '--no-longserviceoutput':
|
||||||
|
show_longserviceoutput = False
|
||||||
|
elif arg == '--perfdata':
|
||||||
|
show_perfdata = True
|
||||||
|
elif arg == '--no-perfdata':
|
||||||
|
show_perfdata = False
|
||||||
|
elif arg == '--nagios_myhostname':
|
||||||
|
nagios_myhostname = arguments.pop(0)
|
||||||
|
elif arg == '--nagios_server':
|
||||||
|
nagios_server = arguments.pop(0)
|
||||||
|
elif arg == '--nagios_port':
|
||||||
|
nagios_port = arguments.pop(0)
|
||||||
|
elif arg == '--system':
|
||||||
|
check_system = arguments.pop(0)
|
||||||
|
elif arg == '--phone-home':
|
||||||
|
do_phone_home = True
|
||||||
|
elif arg == '--proxy':
|
||||||
|
proxyserver = arguments.pop(0)
|
||||||
|
elif arg == '--escape-newlines':
|
||||||
|
escape_newlines = True
|
||||||
|
elif arg == '-h' or arg == '--help':
|
||||||
|
print_help()
|
||||||
|
exit(ok)
|
||||||
|
else:
|
||||||
|
error("Invalid argument %s" % arg)
|
||||||
|
|
||||||
|
|
||||||
|
subitems = {}
|
||||||
|
subitems['fan'] = 'fans'
|
||||||
|
subitems['source'] = 'powersources'
|
||||||
|
subitems['hostport'] = 'hostports'
|
||||||
|
subitems['module'] = 'modules'
|
||||||
|
subitems['sensor'] = 'sensors'
|
||||||
|
subitems['powersupply'] = 'powersupplies'
|
||||||
|
subitems['bus'] = 'communicationbuses'
|
||||||
|
subitems['port'] = 'fibrechannelports'
|
||||||
|
|
||||||
|
|
||||||
|
def runCommand(command):
|
||||||
|
""" runCommand: Runs command from the shell prompt. Exit Nagios style if unsuccessful """
|
||||||
|
proc = subprocess.Popen(
|
||||||
|
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,)
|
||||||
|
stdout, stderr = proc.communicate('through stdin to stdout')
|
||||||
|
if proc.returncode > 0:
|
||||||
|
print "Error %s: %s\n command was: '%s'" % (proc.returncode, stderr.strip(), command)
|
||||||
|
# File not found, lets print path
|
||||||
|
if proc.returncode == 127 or proc.returncode == 1:
|
||||||
|
path = getenv("PATH")
|
||||||
|
print "Current Path: %s" % path
|
||||||
|
exit(unknown)
|
||||||
|
else:
|
||||||
|
return stdout
|
||||||
|
|
||||||
|
|
||||||
|
def run_sssu(system=None, command="ls system full"):
|
||||||
|
"""Runs the sssu command. This one is responsible for error checking from sssu"""
|
||||||
|
commands = []
|
||||||
|
|
||||||
|
continue_on_error = "set option on_error=continue"
|
||||||
|
login = "select manager %s USERNAME=%s PASSWORD=%s" % (
|
||||||
|
hostname, username, password)
|
||||||
|
|
||||||
|
commands.append(continue_on_error)
|
||||||
|
commands.append(login)
|
||||||
|
if system is not None:
|
||||||
|
commands.append('select SYSTEM "%s"' % system)
|
||||||
|
commands.append(command)
|
||||||
|
|
||||||
|
commandstring = "sssu "
|
||||||
|
for i in commands:
|
||||||
|
commandstring += '"%s" ' % i
|
||||||
|
global server_side_troubleshooting
|
||||||
|
if server_side_troubleshooting == True:
|
||||||
|
commandstring = 'cat "debug/%s"' % command
|
||||||
|
|
||||||
|
# print mystring
|
||||||
|
# if command == "ls system full":
|
||||||
|
# output = runCommand("cat sssu.out")
|
||||||
|
# elif command == "ls disk_groups full":
|
||||||
|
# output = runCommand("cat ls_disk*")
|
||||||
|
# elif command == "ls controller full":
|
||||||
|
# output = runCommand("cat ls_controller")
|
||||||
|
# else:
|
||||||
|
# print "What command is this?", command
|
||||||
|
# exit(unknown)
|
||||||
|
output = runCommand(commandstring)
|
||||||
|
debug(commandstring)
|
||||||
|
|
||||||
|
output = output.split('\n')
|
||||||
|
|
||||||
|
# Lets process the top few results from the sssu command. Make sure the
|
||||||
|
# results make sense
|
||||||
|
error = 0
|
||||||
|
if output.pop(0).strip() != '':
|
||||||
|
error = 1
|
||||||
|
if output.pop(0).strip() != '':
|
||||||
|
error = 2
|
||||||
|
if output.pop(0).strip().find('SSSU for HP') != 0:
|
||||||
|
error = 3
|
||||||
|
if output.pop(0).strip().find('Version:') != 0:
|
||||||
|
error = 4
|
||||||
|
if output.pop(0).strip().find('Build:') != 0:
|
||||||
|
error = 5
|
||||||
|
if output.pop(0).strip().find('NoSystemSelected> ') != 0:
|
||||||
|
error = 6
|
||||||
|
#if output.pop(0).strip() != '': error = 1
|
||||||
|
#if output.pop(0).strip().find('NoSystemSelected> ') != 0: error=1
|
||||||
|
#if output.pop(0).strip() != '': error = 1
|
||||||
|
str_buffer = ""
|
||||||
|
for i in output:
|
||||||
|
str_buffer = str_buffer + i + "\n"
|
||||||
|
if i.find('Error') > -1:
|
||||||
|
print "This is the command i was trying to execute: %s" % i
|
||||||
|
error = 1
|
||||||
|
if i.find('information:') > 0:
|
||||||
|
break
|
||||||
|
if error > 0:
|
||||||
|
print "Error running the sssu command: " + str(error)
|
||||||
|
print commandstring
|
||||||
|
print str_buffer
|
||||||
|
exit(unknown)
|
||||||
|
objects = []
|
||||||
|
current_object = None
|
||||||
|
for line in output:
|
||||||
|
if len(line) == 0:
|
||||||
|
continue
|
||||||
|
line = line.strip()
|
||||||
|
tmp = line.split()
|
||||||
|
if len(tmp) == 0:
|
||||||
|
if current_object:
|
||||||
|
if not current_object['master'] in objects:
|
||||||
|
objects.append(current_object['master'])
|
||||||
|
current_object = None
|
||||||
|
continue
|
||||||
|
key = tmp[0].strip()
|
||||||
|
if current_object and not current_object['master'] in objects:
|
||||||
|
objects.append(current_object['master'])
|
||||||
|
if key == 'object':
|
||||||
|
current_object = {}
|
||||||
|
current_object['master'] = current_object
|
||||||
|
if key == 'controllertemperaturestatus':
|
||||||
|
current_object = current_object['master']
|
||||||
|
if key == 'iomodules':
|
||||||
|
key = 'modules'
|
||||||
|
# if key in subitems.values():
|
||||||
|
# object['master'][key] = []
|
||||||
|
if key in subitems.keys():
|
||||||
|
mastergroup = subitems[key]
|
||||||
|
master = current_object['master']
|
||||||
|
current_object = {}
|
||||||
|
current_object['object_type'] = key
|
||||||
|
current_object['master'] = master
|
||||||
|
if not current_object['master'].has_key(mastergroup):
|
||||||
|
current_object['master'][mastergroup] = []
|
||||||
|
current_object['master'][mastergroup].append(current_object)
|
||||||
|
|
||||||
|
if line.find('.:') > 0:
|
||||||
|
# We work on first come, first serve basis, so if
|
||||||
|
# we accidentally see same key again, we will ignore
|
||||||
|
if not current_object.has_key(key):
|
||||||
|
value = ' '.join(tmp[2:]).strip()
|
||||||
|
current_object[key] = value
|
||||||
|
# Check if we were instructed to check only one eva system
|
||||||
|
global check_system
|
||||||
|
if command == "ls system full" and check_system is not None:
|
||||||
|
tmp_objects = []
|
||||||
|
for i in objects:
|
||||||
|
if i['objectname'] == check_system:
|
||||||
|
tmp_objects.append(i)
|
||||||
|
objects = tmp_objects
|
||||||
|
return objects
|
||||||
|
|
||||||
|
|
||||||
|
def end(summary, perfdata, longserviceoutput, nagios_state):
|
||||||
|
global show_longserviceoutput
|
||||||
|
global show_perfdata
|
||||||
|
global nagios_server
|
||||||
|
global do_phone_home
|
||||||
|
global nagios_port
|
||||||
|
global nagios_myhostname
|
||||||
|
global hostname
|
||||||
|
global mode
|
||||||
|
global escape_newlines
|
||||||
|
global check_system
|
||||||
|
|
||||||
|
message = "%s - %s" % (state[nagios_state], summary)
|
||||||
|
if show_perfdata:
|
||||||
|
message = "%s | %s" % (message, perfdata)
|
||||||
|
if show_longserviceoutput:
|
||||||
|
message = "%s\n%s" % (message, longserviceoutput.strip())
|
||||||
|
if escape_newlines == True:
|
||||||
|
lines = message.split('\n')
|
||||||
|
message = '\\n'.join(lines)
|
||||||
|
debug("do_phone_home = %s" % do_phone_home)
|
||||||
|
if do_phone_home == True:
|
||||||
|
try:
|
||||||
|
if nagios_myhostname is None:
|
||||||
|
if environ.has_key('HOSTNAME'):
|
||||||
|
nagios_myhostname = environ['HOSTNAME']
|
||||||
|
elif environ.has_key('COMPUTERNAME'):
|
||||||
|
nagios_myhostname = environ['COMPUTERNAME']
|
||||||
|
else:
|
||||||
|
nagios_myhostname = hostname
|
||||||
|
try:
|
||||||
|
phone_home(nagios_server,
|
||||||
|
nagios_port,
|
||||||
|
status=nagios_state,
|
||||||
|
message=message,
|
||||||
|
hostname=nagios_myhostname,
|
||||||
|
servicename=mode,
|
||||||
|
system=check_system
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
print message
|
||||||
|
exit(nagios_state)
|
||||||
|
|
||||||
|
|
||||||
|
class ProxiedTransport(xmlrpclib.Transport):
|
||||||
|
|
||||||
|
def set_proxy(self, proxy):
|
||||||
|
self.proxy = proxy
|
||||||
|
|
||||||
|
def make_connection(self, host):
|
||||||
|
self.realhost = host
|
||||||
|
h = httplib.HTTP(self.proxy)
|
||||||
|
return h
|
||||||
|
|
||||||
|
def send_request(self, connection, handler, request_body):
|
||||||
|
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
|
||||||
|
|
||||||
|
def send_host(self, connection, host):
|
||||||
|
connection.putheader('Host', self.realhost)
|
||||||
|
|
||||||
|
|
||||||
|
def phone_home(nagios_server, nagios_port, status, message, hostname=None, servicename=None, system=None):
|
||||||
|
"""phone_home: Sends results to remote nagios server via python xml-rpc"""
|
||||||
|
debug("phoning home: %s" % servicename)
|
||||||
|
if system is not None:
|
||||||
|
servicename = str(servicename) + str(system)
|
||||||
|
uri = "http://%s:%s" % (nagios_server, nagios_port)
|
||||||
|
|
||||||
|
global proxyserver
|
||||||
|
if proxyserver is not None:
|
||||||
|
p = ProxiedTransport()
|
||||||
|
p.set_proxy(proxyserver)
|
||||||
|
s = xmlrpclib.Server(uri, transport=p)
|
||||||
|
else:
|
||||||
|
s = xmlrpclib.ServerProxy(uri)
|
||||||
|
s.nagiosupdate(hostname, servicename, status, message)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def check_systems():
|
||||||
|
summary = ""
|
||||||
|
perfdata = ""
|
||||||
|
# longserviceoutput="\n"
|
||||||
|
nagios_state = ok
|
||||||
|
objects = run_sssu()
|
||||||
|
for i in objects:
|
||||||
|
name = i['objectname']
|
||||||
|
operationalstate = i['operationalstate']
|
||||||
|
# Lets see if this array is working
|
||||||
|
if operationalstate != 'good':
|
||||||
|
nagios_state = max(nagios_state, warning)
|
||||||
|
# Lets add to the summary
|
||||||
|
summary += " %s=%s " % (name, operationalstate)
|
||||||
|
# Collect the performance data
|
||||||
|
interesting_perfdata = 'totalstoragespace|usedstoragespace|availablestoragespace'
|
||||||
|
perfdata += get_perfdata(
|
||||||
|
i, interesting_perfdata.split('|'), identifier="%s_" % name)
|
||||||
|
# Collect extra info for longserviceoutput
|
||||||
|
longoutput("%s = %s (%s)\n" %
|
||||||
|
(i['objectname'], i['operationalstate'], i['operationalstatedetail']))
|
||||||
|
interesting_fields = 'licensestate|systemtype|firmwareversion|nscfwversion|totalstoragespace|usedstoragespace|availablestoragespace'
|
||||||
|
for x in interesting_fields.split('|'):
|
||||||
|
longoutput("- %s = %s \n" % (x, i[x]))
|
||||||
|
longoutput("\n")
|
||||||
|
end(summary, perfdata, longserviceoutput, nagios_state)
|
||||||
|
|
||||||
|
|
||||||
|
def get_perfdata(my_object, interesting_fields, identifier=""):
|
||||||
|
perfdata = ""
|
||||||
|
for i in interesting_fields:
|
||||||
|
if i == '':
|
||||||
|
continue
|
||||||
|
perfdata += "'%s%s'=%s " % (identifier, i, my_object[i])
|
||||||
|
return perfdata
|
||||||
|
|
||||||
|
|
||||||
|
def add_perfdata(text):
|
||||||
|
global perfdata
|
||||||
|
text = text.strip()
|
||||||
|
perfdata += " %s " % text
|
||||||
|
|
||||||
|
|
||||||
|
def longoutput(text):
|
||||||
|
global longserviceoutput
|
||||||
|
longserviceoutput = longserviceoutput + text
|
||||||
|
|
||||||
|
|
||||||
|
def get_longserviceoutput(my_object, interesting_fields):
|
||||||
|
longserviceoutput = ""
|
||||||
|
for i in interesting_fields:
|
||||||
|
longserviceoutput += "%s = %s \n" % (i, my_object[i])
|
||||||
|
return longserviceoutput
|
||||||
|
|
||||||
|
|
||||||
|
def check_operationalstate(my_object, print_failed_objects=False, namefield='objectname', detailfield='operationalstatedetail', statefield='operationalstate', valid_states=None):
|
||||||
|
if not valid_states:
|
||||||
|
valid_states = ['good']
|
||||||
|
if not my_object.has_key(detailfield):
|
||||||
|
detailfield = statefield
|
||||||
|
if not my_object.has_key(statefield):
|
||||||
|
if print_failed_objects:
|
||||||
|
longoutput("- Warning, %s does not have any '%s'" %
|
||||||
|
(my_object[namefield], statefield))
|
||||||
|
return warning
|
||||||
|
if my_object[statefield] not in valid_states:
|
||||||
|
if print_failed_objects:
|
||||||
|
longoutput("- Warning, %s=%s (%s)\n" %
|
||||||
|
(my_object[namefield], my_object['operationalstate'], my_object[detailfield]))
|
||||||
|
return warning
|
||||||
|
debug("OK, %s=%s (%s)\n" %
|
||||||
|
(my_object[namefield], my_object['operationalstate'], my_object[detailfield]))
|
||||||
|
return ok
|
||||||
|
|
||||||
|
|
||||||
|
def check_generic(command="ls disk full", namefield="objectname", perfdata_fields=None, longserviceoutputfields=None, detailedsummary=False):
|
||||||
|
if not perfdata_fields:
|
||||||
|
perfdata_fields = []
|
||||||
|
if not longserviceoutputfields:
|
||||||
|
longserviceoutputfields = []
|
||||||
|
global perfdata
|
||||||
|
nagios_state = ok
|
||||||
|
systems = run_sssu()
|
||||||
|
objects = []
|
||||||
|
if command == 'ls system full':
|
||||||
|
objects = systems
|
||||||
|
for i in systems:
|
||||||
|
i['systemname'] = '' # i['objectname']
|
||||||
|
else:
|
||||||
|
for i in systems:
|
||||||
|
result = run_sssu(system=i['objectname'], command=command)
|
||||||
|
for x in result:
|
||||||
|
x['systemname'] = i['objectname']
|
||||||
|
objects.append(x)
|
||||||
|
summary = "%s objects found " % len(objects)
|
||||||
|
usedstoragespacegb = 0
|
||||||
|
occupancyalarmlvel = 0
|
||||||
|
warninggb = 0
|
||||||
|
for i in objects:
|
||||||
|
systemname = i['systemname']
|
||||||
|
# Some versions of commandview use "objectname" instead of namefield
|
||||||
|
if i.has_key(namefield):
|
||||||
|
objectname = i[namefield]
|
||||||
|
else:
|
||||||
|
objectname = i['objectname']
|
||||||
|
# Some versions of CV also return garbage objects, luckily it is easy
|
||||||
|
# to find these
|
||||||
|
if i.has_key('objecttype') and i['objecttype'] == 'typenotset':
|
||||||
|
longoutput(
|
||||||
|
"Object %s was skipped because objecttype == typenotset\n" % objectname)
|
||||||
|
continue
|
||||||
|
# Lets see if this object is working
|
||||||
|
nagios_state = max(check_operationalstate(i), nagios_state)
|
||||||
|
|
||||||
|
# Lets add to the summary
|
||||||
|
if i['operationalstate'] != 'good' or detailedsummary == True:
|
||||||
|
summary += " %s/%s=%s " % (
|
||||||
|
systemname, objectname, i['operationalstate'])
|
||||||
|
|
||||||
|
# Lets get some perfdata
|
||||||
|
identifier = "%s/%s_" % (systemname, objectname)
|
||||||
|
i['identifier'] = identifier
|
||||||
|
|
||||||
|
for field in perfdata_fields:
|
||||||
|
if field == '':
|
||||||
|
continue
|
||||||
|
add_perfdata("'%s%s'=%s " %
|
||||||
|
(identifier, field, i.get(field, None)))
|
||||||
|
|
||||||
|
# Disk group gets a special perfdata treatment
|
||||||
|
if command == "ls disk_group full":
|
||||||
|
totalstoragespacegb = float(i['totalstoragespacegb'])
|
||||||
|
usedstoragespacegb = float(i['usedstoragespacegb'])
|
||||||
|
occupancyalarmlvel = float(i['occupancyalarmlevel'])
|
||||||
|
warninggb = totalstoragespacegb * occupancyalarmlvel / 100
|
||||||
|
add_perfdata(" '%sdiskusage'=%s;%s;%s " %
|
||||||
|
(identifier, usedstoragespacegb, warninggb, totalstoragespacegb))
|
||||||
|
|
||||||
|
# Long Serviceoutput
|
||||||
|
|
||||||
|
# There are usually to many disks for nagios to display. Skip.
|
||||||
|
if command != "ls disk full":
|
||||||
|
longoutput("\n%s/%s = %s (%s)\n" %
|
||||||
|
(systemname, objectname, i['operationalstate'], i['operationalstatedetail']))
|
||||||
|
|
||||||
|
# If diskgroup has a problem because it is over allocated. Lets inform
|
||||||
|
# about that
|
||||||
|
if command == "ls disk_group full" and usedstoragespacegb > warninggb:
|
||||||
|
longoutput(
|
||||||
|
"- %s - diskgroup usage is over %s%% threshold !\n" %
|
||||||
|
(state[warning], occupancyalarmlvel))
|
||||||
|
# If a disk has a problem, lets display some extra info on it
|
||||||
|
elif command == "ls disk full" and i['operationalstate'] != 'good':
|
||||||
|
longoutput("Warning - %s=%s (%s)\n" %
|
||||||
|
(i['diskname'], i['operationalstate'], i['operationalstatedetail']))
|
||||||
|
fields = "modelnumber firmwareversion serialnumber failurepredicted diskdrivetype".split(
|
||||||
|
)
|
||||||
|
for field in fields:
|
||||||
|
longoutput("- %s = %s\n" % (field, i[field]))
|
||||||
|
|
||||||
|
nagios_state = max(nagios_state, check_multiple_objects(i, 'sensors'))
|
||||||
|
nagios_state = max(nagios_state, check_multiple_objects(i, 'fans'))
|
||||||
|
nagios_state = max(
|
||||||
|
nagios_state, check_multiple_objects(i, 'powersupplies'))
|
||||||
|
nagios_state = max(
|
||||||
|
nagios_state, check_multiple_objects(i, 'communicationbuses'))
|
||||||
|
nagios_state = max(
|
||||||
|
nagios_state, check_multiple_objects(i, 'fibrechannelports'))
|
||||||
|
nagios_state = max(nagios_state, check_multiple_objects(i, 'modules'))
|
||||||
|
for x in longserviceoutputfields:
|
||||||
|
if i.has_key(x):
|
||||||
|
longoutput("- %s = %s\n" % (x, i[x]))
|
||||||
|
|
||||||
|
end(summary, perfdata, longserviceoutput, nagios_state)
|
||||||
|
|
||||||
|
|
||||||
|
def check_multiple_objects(my_object, name):
|
||||||
|
item_status = not_present
|
||||||
|
if my_object.has_key(name):
|
||||||
|
item_status = not_present
|
||||||
|
valid_states = ['good']
|
||||||
|
namefield = "name"
|
||||||
|
detailfield = 'operationalstatedetail'
|
||||||
|
|
||||||
|
if name == 'fans' or name == 'sensors':
|
||||||
|
valid_states = [
|
||||||
|
'good', 'notavailable', 'unsupported', 'notinstalled']
|
||||||
|
elif name == 'fibrechannelports':
|
||||||
|
valid_states.append('notinstalled')
|
||||||
|
num_items = len(my_object[name])
|
||||||
|
for item in my_object[name]:
|
||||||
|
stat = check_operationalstate(
|
||||||
|
item, print_failed_objects=True, namefield=namefield, valid_states=valid_states, detailfield=detailfield)
|
||||||
|
item_status = max(stat, item_status)
|
||||||
|
longoutput('- %s on %s (%s detected)\n' %
|
||||||
|
(state[item_status], name, num_items))
|
||||||
|
add_perfdata(" '%s%s'=%s" %
|
||||||
|
(my_object['identifier'], name, num_items))
|
||||||
|
return item_status
|
||||||
|
|
||||||
|
|
||||||
|
def check_controllers():
|
||||||
|
perfdata = ""
|
||||||
|
# longserviceoutput="\n"
|
||||||
|
nagios_state = ok
|
||||||
|
systems = run_sssu()
|
||||||
|
controllers = []
|
||||||
|
for i in systems:
|
||||||
|
result = run_sssu(system=i['objectname'], command="ls controller full")
|
||||||
|
for controller in result:
|
||||||
|
controller['systemname'] = i['objectname']
|
||||||
|
controllers.append(controller)
|
||||||
|
summary = "%s objects found " % len(controllers)
|
||||||
|
for i in controllers:
|
||||||
|
systemname = i['systemname']
|
||||||
|
if i.has_key('controllername'):
|
||||||
|
controllername = i['controllername']
|
||||||
|
else:
|
||||||
|
controllername = i['objectname']
|
||||||
|
# Lets see if this controller is working
|
||||||
|
nagios_state = max(check_operationalstate(i), nagios_state)
|
||||||
|
|
||||||
|
# Lets add to the summary
|
||||||
|
if not i.has_key('operationalstate'):
|
||||||
|
summary += " %s does not have any operationalstate " % controllername
|
||||||
|
nagios_state = max(unknown, nagios_state)
|
||||||
|
continue
|
||||||
|
elif i['operationalstate'] != 'good':
|
||||||
|
summary += " %s/%s=%s " % (
|
||||||
|
systemname, controllername, i['operationalstate'])
|
||||||
|
|
||||||
|
# Lets get some perfdata
|
||||||
|
interesting_fields = "controllermainmemory"
|
||||||
|
identifier = "%s/%s_" % (systemname, controllername)
|
||||||
|
perfdata += get_perfdata(
|
||||||
|
i, interesting_fields.split('|'), identifier=identifier)
|
||||||
|
|
||||||
|
# Long Serviceoutput
|
||||||
|
#longserviceoutput = longserviceoutput + get_longserviceoutput(i, interesting_fields.split('|') )
|
||||||
|
#longserviceoutput = longserviceoutput + "\n%s/%s\n"%(systemname,controllername)
|
||||||
|
longoutput("\n%s/%s = %s (%s)\n" %
|
||||||
|
(systemname, controllername, i['operationalstate'], i['operationalstatedetail']))
|
||||||
|
longoutput("- firmwareversion = %s \n" % (i['firmwareversion']))
|
||||||
|
longoutput("- serialnumber = %s \n" % (i['serialnumber']))
|
||||||
|
|
||||||
|
controllertemperaturestatus = not_present
|
||||||
|
fanstate = not_present
|
||||||
|
hostportstate = not_present
|
||||||
|
sensorstate = ok
|
||||||
|
source_state = not_present
|
||||||
|
module_state = not_present
|
||||||
|
|
||||||
|
# Check the cache status
|
||||||
|
if i['cachecondition'] == 'good':
|
||||||
|
cache_state = ok
|
||||||
|
else:
|
||||||
|
cache_state = warning
|
||||||
|
|
||||||
|
# Check Temperature
|
||||||
|
if i.has_key("controllertemperaturestatus"):
|
||||||
|
if i['controllertemperaturestatus'] == 'normal':
|
||||||
|
controllertemperaturestatus = ok
|
||||||
|
else:
|
||||||
|
controllertemperaturestatus = warning
|
||||||
|
|
||||||
|
# Process the subsensors
|
||||||
|
for hostport in i['hostports']:
|
||||||
|
#long(" %s = %s\n" % (hostport['portname'], hostport['operationalstate']))
|
||||||
|
hostportstate = max(hostportstate, ok)
|
||||||
|
if hostport['operationalstate'] != 'good':
|
||||||
|
hostportstate = max(warning, hostportstate)
|
||||||
|
message = "Hostport %s state = %s\n" % (
|
||||||
|
hostport['portname'], hostport['operationalstate'])
|
||||||
|
longoutput(message)
|
||||||
|
if i.has_key('fans'):
|
||||||
|
for fan in i['fans']:
|
||||||
|
fanstate = max(fanstate, ok)
|
||||||
|
#long(" %s = %s\n" % (fan['fanname'], fan['status']))
|
||||||
|
if fan.has_key('status'):
|
||||||
|
status = fan['status']
|
||||||
|
elif fan.has_key('installstatus'):
|
||||||
|
status = fan['installstatus']
|
||||||
|
if status != 'normal' and status != 'yes':
|
||||||
|
fanstate = max(warning, fanstate)
|
||||||
|
longoutput("Fan %s status = %s\n" %
|
||||||
|
(fan['fanname'], status))
|
||||||
|
if i.has_key('powersources'):
|
||||||
|
for source in i['powersources']:
|
||||||
|
source_state = max(source_state, ok)
|
||||||
|
if not source.has_key('status'):
|
||||||
|
continue
|
||||||
|
if source['state'] != 'good':
|
||||||
|
source_state = max(warning, source_state)
|
||||||
|
longoutput("Powersource %s status = %s\n" %
|
||||||
|
(source['type'], source['state']))
|
||||||
|
if i.has_key('modules'):
|
||||||
|
for module in i['modules']:
|
||||||
|
module_state = max(module_state, ok)
|
||||||
|
if module['operationalstate'] not in ('good', 'not_present'):
|
||||||
|
module_state = max(warning, module_state)
|
||||||
|
longoutput("Battery Module %s status = %s\n" %
|
||||||
|
(module['name'], module['operationalstate']))
|
||||||
|
|
||||||
|
for i in (fanstate, hostportstate, sensorstate, source_state, module_state, cache_state, controllertemperaturestatus):
|
||||||
|
nagios_state = max(nagios_state, i)
|
||||||
|
|
||||||
|
longoutput("- %s on fans\n" % (state[fanstate]))
|
||||||
|
longoutput("- %s on cachememory\n" % (state[cache_state]))
|
||||||
|
longoutput("- %s on temperature\n" %
|
||||||
|
(state[controllertemperaturestatus]))
|
||||||
|
longoutput("- %s on hostports\n" % (state[hostportstate]))
|
||||||
|
longoutput("- %s on sensors\n" % (state[sensorstate]))
|
||||||
|
longoutput("- %s on powersupplies\n" % (state[source_state]))
|
||||||
|
longoutput("- %s on batterymodules\n" % (state[module_state]))
|
||||||
|
|
||||||
|
longoutput('\n')
|
||||||
|
end(summary, perfdata, longserviceoutput, nagios_state)
|
||||||
|
|
||||||
|
|
||||||
|
def set_path():
|
||||||
|
global path
|
||||||
|
current_path = getenv('PATH')
|
||||||
|
if path == '':
|
||||||
|
if current_path.find('C:\\') > -1: # We are on this platform
|
||||||
|
path = ";C:\\Program Files\\Hewlett-Packard\\Sanworks\\Element Manager for StorageWorks HSV"
|
||||||
|
else:
|
||||||
|
path = ":/usr/local/bin"
|
||||||
|
current_path = "%s%s" % (current_path, path)
|
||||||
|
environ['PATH'] = current_path
|
||||||
|
set_path()
|
||||||
|
|
||||||
|
|
||||||
|
# Create an alarm so that plugin can exit properly if timeout occurs
|
||||||
|
exit_with_timeout = lambda x, y: error("Timeout of %s seconds exceeded" % timeout)
|
||||||
|
signal.signal(signal.SIGALRM, exit_with_timeout)
|
||||||
|
signal.alarm(timeout)
|
||||||
|
|
||||||
|
if mode == 'check_systems':
|
||||||
|
perfdata_fields = 'totalstoragespace usedstoragespace availablestoragespace'.split(
|
||||||
|
)
|
||||||
|
longserviceoutputfields = 'licensestate systemtype firmwareversion nscfwversion totalstoragespace usedstoragespace availablestoragespace'.split(
|
||||||
|
)
|
||||||
|
command = "ls system full"
|
||||||
|
namefield = "objectname"
|
||||||
|
check_generic(command=command, namefield=namefield,
|
||||||
|
longserviceoutputfields=longserviceoutputfields, perfdata_fields=perfdata_fields)
|
||||||
|
elif mode == 'check_controllers':
|
||||||
|
check_controllers()
|
||||||
|
elif mode == 'check_diskgroups':
|
||||||
|
command = "ls disk_group full"
|
||||||
|
namefield = 'diskgroupname'
|
||||||
|
longserviceoutputfields = "totaldisks levelingstate levelingprogress totalstoragespacegb usedstoragespacegb occupancyalarmlevel".split(
|
||||||
|
)
|
||||||
|
perfdata_fields = "totaldisks".split()
|
||||||
|
check_generic(command=command, namefield=namefield,
|
||||||
|
longserviceoutputfields=longserviceoutputfields, perfdata_fields=perfdata_fields)
|
||||||
|
elif mode == 'check_disks':
|
||||||
|
check_generic(command="ls disk full", namefield="objectname")
|
||||||
|
elif mode == 'check_diskshelfs' or mode == 'check_diskshelves':
|
||||||
|
check_generic(command="ls diskshelf full", namefield="diskshelfname",
|
||||||
|
longserviceoutputfields=[], perfdata_fields=[])
|
||||||
|
else:
|
||||||
|
print "* Error: Mode %s not found" % mode
|
||||||
|
print_help()
|
||||||
|
print "* Error: Mode %s not found" % mode
|
||||||
|
exit(unknown)
|
67
check_eva/nagios-okplugin-check_eva.spec
Normal file
67
check_eva/nagios-okplugin-check_eva.spec
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
%define debug_package %{nil}
|
||||||
|
|
||||||
|
Summary: A Nagios plugin to check HP EVA Disk Systems
|
||||||
|
Name: nagios-okplugin-check_eva
|
||||||
|
Version: 2
|
||||||
|
Release: 1%{?dist}
|
||||||
|
License: GPLv2+
|
||||||
|
Group: Applications/System
|
||||||
|
URL: http://opensource.is/trac/wiki/check_eva
|
||||||
|
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_eva/releases/nagios-okplugin-check_eva-%{version}.tar.gz
|
||||||
|
Requires: sssu,nagios-plugins
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
|
Packager: Pall Sigurdsson <palli@opensource.is>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%description
|
||||||
|
Checks HP EVA Disk Systems with the sssu binary
|
||||||
|
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
perl -pi -e "s|/usr/lib|%{_libdir}|g" nrpe.d/check_eva.cfg
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
install -D -p -m 0755 check_eva.py %{buildroot}%{_libdir}/nagios/plugins/check_eva.py
|
||||||
|
install -D -p -m 0755 nrpe.d/check_eva.cfg %{buildroot}/etc/nrpe.d/check_eva.cfg
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
%doc README LICENSE
|
||||||
|
%{_libdir}/nagios/plugins/*
|
||||||
|
/etc/nrpe.d/check_eva.cfg
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Thu Feb 20 2014 Pall Sigurdsson <palli@opensource.is> 2-1
|
||||||
|
- Merge pull request #10 from gitmopp/patch-2 (palli-github@minor.is)
|
||||||
|
- bug in for loop. Looped only once (mopp@gmx.net)
|
||||||
|
- Fixed output to be more compatible (mopp@gmx.net)
|
||||||
|
- check_eva new Make sure --timeout is an integer (palli@opensource.is)
|
||||||
|
- check_eva new command line option --timeout (palli@opensource.is)
|
||||||
|
- check_eva Fix undefined fix typos (palli@opensource.is)
|
||||||
|
- PEP8 cleanup (palli@opensource.is)
|
||||||
|
- merged (palli@opensource.is)
|
||||||
|
- check_eva - minor bugfixes (palli@opensource.is)
|
||||||
|
- check_eva.py more code cleanup with pycharm inspections (palli@opensource.is)
|
||||||
|
- check_eva.py - Make code more readable (palli@opensource.is)
|
||||||
|
- convert from tabs to spaces (palli@opensource.is)
|
||||||
|
- check_eva - fix mixed tab/spaces (palli@opensource.is)
|
||||||
|
- Update check_eva.py (sander.grendelman@gmail.com)
|
||||||
|
|
||||||
|
* Thu Aug 23 2012 Pall Sigurdsson <palli@opensource.is> 1.0.2-1
|
||||||
|
- changed sssu subcommands from being singlequoted to doublequoted for windows
|
||||||
|
compatibility (palli@opensource.is)
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 1.0.1-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
|
* Mon Mar 1 2010 Pall Sigurdsson <palli@opensource.is> 0.1-1
|
||||||
|
- Initial packaging
|
@ -1,693 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
#
|
|
||||||
# Copyright 2010, Pall Sigurdsson <palli@opensource.is>
|
|
||||||
#
|
|
||||||
# check_eva.py is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# check_eva.py is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# About this script
|
|
||||||
#
|
|
||||||
# This script will check the status of all EVA arrays via the sssu binary.
|
|
||||||
# You will need the sssu binary in path (/usr/bin/sssu is a good place)
|
|
||||||
# If you do not have sssu, check your commandview CD, it should have both
|
|
||||||
# binaries for Windows and Linux
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Some Defaults
|
|
||||||
show_perfdata = True
|
|
||||||
show_longserviceoutput = True
|
|
||||||
debugging = False
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# check_eva defaults
|
|
||||||
hostname="localhost"
|
|
||||||
username="eva"
|
|
||||||
password="eva1234"
|
|
||||||
mode="check_systems"
|
|
||||||
path=''
|
|
||||||
nagios_server = "94.142.154.10"
|
|
||||||
nagios_port = 80
|
|
||||||
nagios_myhostname = None
|
|
||||||
do_phone_home = False
|
|
||||||
escape_newlines = False
|
|
||||||
check_system = None # By default check all systems
|
|
||||||
proxyserver = None
|
|
||||||
|
|
||||||
server_side_troubleshooting = False # set to true, if you do not have sssu binary handy
|
|
||||||
|
|
||||||
# No real need to change anything below here
|
|
||||||
version="1.0"
|
|
||||||
ok=0
|
|
||||||
warning=1
|
|
||||||
critical=2
|
|
||||||
unknown=3
|
|
||||||
not_present = -1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
state = {}
|
|
||||||
state[not_present] = "Not Present"
|
|
||||||
state[ok] = "OK"
|
|
||||||
state[warning] = "Warning"
|
|
||||||
state[critical] = "Critical"
|
|
||||||
state[unknown] = "Unknown"
|
|
||||||
|
|
||||||
longserviceoutput="\n"
|
|
||||||
perfdata=""
|
|
||||||
|
|
||||||
valid_modes = ( "check_systems", "check_controllers", "check_diskgroups","check_disks", "check_diskshelfs", "check_diskshelves")
|
|
||||||
|
|
||||||
from sys import exit
|
|
||||||
from sys import argv
|
|
||||||
from os import getenv,putenv,environ
|
|
||||||
import subprocess
|
|
||||||
import xmlrpclib,httplib
|
|
||||||
import socket
|
|
||||||
socket.setdefaulttimeout(5)
|
|
||||||
|
|
||||||
|
|
||||||
def print_help():
|
|
||||||
print "check_eva version %s" % version
|
|
||||||
print "This plugin checks HP EVA Array with the sssu command"
|
|
||||||
print ""
|
|
||||||
print "Usage: %s [OPTIONS]" % argv[0]
|
|
||||||
print "OPTIONS:"
|
|
||||||
print " [--host <host>]"
|
|
||||||
print " [--username <user>]"
|
|
||||||
print " [--password <password]"
|
|
||||||
print " [--path </path/to/sssu>]"
|
|
||||||
print " [--mode <mode>] "
|
|
||||||
print " [--test]"
|
|
||||||
print " [--debug]"
|
|
||||||
print " [--help]"
|
|
||||||
print ""
|
|
||||||
print " Valid modes are: %s" % ', '.join(valid_modes)
|
|
||||||
print ""
|
|
||||||
print "Example: %s --host commandview.example.net --username eva --password myPassword --mode check_systems" % (argv[0])
|
|
||||||
|
|
||||||
|
|
||||||
def error(errortext):
|
|
||||||
print "* Error: %s" % errortext
|
|
||||||
print_help()
|
|
||||||
print "* Error: %s" % errortext
|
|
||||||
exit(unknown)
|
|
||||||
|
|
||||||
def debug( debugtext ):
|
|
||||||
global debugging
|
|
||||||
if debugging:
|
|
||||||
print debugtext
|
|
||||||
|
|
||||||
# parse arguments
|
|
||||||
|
|
||||||
arguments=argv[1:]
|
|
||||||
while len(arguments) > 0:
|
|
||||||
arg=arguments.pop(0)
|
|
||||||
if arg == 'invalid':
|
|
||||||
pass
|
|
||||||
elif arg == '-H' or arg == '--host':
|
|
||||||
hostname=arguments.pop(0)
|
|
||||||
elif arg == '-U' or arg == '--username':
|
|
||||||
username=arguments.pop(0)
|
|
||||||
elif arg == '-P' or arg == '--password':
|
|
||||||
password = arguments.pop(0)
|
|
||||||
elif arg == '-T' or arg == '--test':
|
|
||||||
testmode=1
|
|
||||||
elif arg == '--path':
|
|
||||||
path = arguments.pop(0) + '/'
|
|
||||||
elif arg == '-M' or arg == '--mode':
|
|
||||||
mode=arguments.pop(0)
|
|
||||||
if mode not in valid_modes:
|
|
||||||
error("Invalid --mode %s" % arg)
|
|
||||||
elif arg == '-d' or arg == '--debug':
|
|
||||||
debugging=True
|
|
||||||
elif arg == '--longserviceoutput':
|
|
||||||
show_longserviceoutput = True
|
|
||||||
elif arg == '--no-longserviceoutput':
|
|
||||||
show_longserviceoutput = False
|
|
||||||
elif arg == '--perfdata':
|
|
||||||
show_perfdata = True
|
|
||||||
elif arg == '--no-perfdata':
|
|
||||||
show_perfdata = False
|
|
||||||
elif arg == '--nagios_myhostname':
|
|
||||||
nagios_myhostname = arguments.pop(0)
|
|
||||||
elif arg == '--nagios_server':
|
|
||||||
nagios_server = arguments.pop(0)
|
|
||||||
elif arg == '--nagios_port':
|
|
||||||
nagios_port = arguments.pop(0)
|
|
||||||
elif arg == '--system':
|
|
||||||
check_system = arguments.pop(0)
|
|
||||||
elif arg == '--phone-home':
|
|
||||||
do_phone_home = True
|
|
||||||
elif arg == '--proxy':
|
|
||||||
proxyserver = arguments.pop(0)
|
|
||||||
elif arg == '--escape-newlines':
|
|
||||||
escape_newlines = True
|
|
||||||
elif arg == '-h' or arg == '--help':
|
|
||||||
print_help()
|
|
||||||
exit(ok)
|
|
||||||
else:
|
|
||||||
error( "Invalid argument %s"% arg)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
subitems = {}
|
|
||||||
subitems['fan'] = 'fans'
|
|
||||||
subitems['source'] = 'powersources'
|
|
||||||
subitems['hostport'] = 'hostports'
|
|
||||||
subitems['module'] = 'modules'
|
|
||||||
subitems['sensor'] = 'sensors'
|
|
||||||
subitems['powersupply'] = 'powersupplies'
|
|
||||||
subitems['bus'] = 'communicationbuses'
|
|
||||||
subitems['port'] = 'fibrechannelports'
|
|
||||||
|
|
||||||
|
|
||||||
'''runCommand: Runs command from the shell prompt. Exit Nagios style if unsuccessful'''
|
|
||||||
def runCommand(command):
|
|
||||||
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE,)
|
|
||||||
stdout, stderr = proc.communicate('through stdin to stdout')
|
|
||||||
if proc.returncode > 0:
|
|
||||||
print "Error %s: %s\n command was: '%s'" % (proc.returncode,stderr.strip(),command)
|
|
||||||
if proc.returncode == 127 or proc.returncode == 1: # File not found, lets print path
|
|
||||||
path=getenv("PATH")
|
|
||||||
print "Current Path: %s" % (path)
|
|
||||||
exit(unknown)
|
|
||||||
else:
|
|
||||||
return stdout
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''Runs the sssu command. This one is responsible for error checking from sssu'''
|
|
||||||
def run_sssu(system=None, command="ls system full"):
|
|
||||||
commands = []
|
|
||||||
|
|
||||||
continue_on_error="set option on_error=continue"
|
|
||||||
login="select manager %s USERNAME=%s PASSWORD=%s"%(hostname,username,password)
|
|
||||||
|
|
||||||
commands.append(continue_on_error)
|
|
||||||
commands.append(login)
|
|
||||||
if system != None:
|
|
||||||
commands.append('select SYSTEM "%s"' % system)
|
|
||||||
commands.append(command)
|
|
||||||
|
|
||||||
commandstring = "sssu "
|
|
||||||
for i in commands: commandstring = commandstring + "'%s' " % i
|
|
||||||
global server_side_troubleshooting
|
|
||||||
if server_side_troubleshooting == True:
|
|
||||||
commandstring = 'cat "debug/%s"' % command
|
|
||||||
|
|
||||||
#print mystring
|
|
||||||
#if command == "ls system full":
|
|
||||||
# output = runCommand("cat sssu.out")
|
|
||||||
#elif command == "ls disk_groups full":
|
|
||||||
# output = runCommand("cat ls_disk*")
|
|
||||||
#elif command == "ls controller full":
|
|
||||||
# output = runCommand("cat ls_controller")
|
|
||||||
#else:
|
|
||||||
# print "What command is this?", command
|
|
||||||
# exit(unknown)
|
|
||||||
output = runCommand(commandstring)
|
|
||||||
debug( commandstring )
|
|
||||||
|
|
||||||
output = output.split('\n')
|
|
||||||
|
|
||||||
# Lets process the top few results from the sssu command. Make sure the results make sense
|
|
||||||
error = 0
|
|
||||||
if output.pop(0).strip() != '': error = 1
|
|
||||||
if output.pop(0).strip() != '': error = 1
|
|
||||||
if output.pop(0).strip() != 'SSSU for HP StorageWorks Command View EVA': error = 1
|
|
||||||
if output.pop(0).strip().find('Version:') != 0: error=1
|
|
||||||
if output.pop(0).strip().find('Build:') != 0: error=1
|
|
||||||
if output.pop(0).strip().find('NoSystemSelected> ') != 0: error=1
|
|
||||||
#if output.pop(0).strip() != '': error = 1
|
|
||||||
#if output.pop(0).strip().find('NoSystemSelected> ') != 0: error=1
|
|
||||||
#if output.pop(0).strip() != '': error = 1
|
|
||||||
buffer = ""
|
|
||||||
for i in output:
|
|
||||||
buffer = buffer + i + "\n"
|
|
||||||
if i.find('Error') > -1:
|
|
||||||
print "This is the command i was trying to execute: %s" % i
|
|
||||||
error = 1
|
|
||||||
if i.find('information:') > 0: break
|
|
||||||
if error > 0:
|
|
||||||
print "Error running the sssu command"
|
|
||||||
print commandstring
|
|
||||||
print buffer
|
|
||||||
exit(unknown)
|
|
||||||
|
|
||||||
objects = []
|
|
||||||
object = None
|
|
||||||
parent_object = None
|
|
||||||
for line in output:
|
|
||||||
if len(line) == 0:
|
|
||||||
continue
|
|
||||||
line = line.strip()
|
|
||||||
tmp = line.split()
|
|
||||||
if len(tmp) == 0:
|
|
||||||
if object:
|
|
||||||
if not object['master'] in objects: objects.append( object['master'] )
|
|
||||||
object = None
|
|
||||||
continue
|
|
||||||
key = tmp[0].strip()
|
|
||||||
if object and not object['master'] in objects: objects.append( object['master'] )
|
|
||||||
if key == 'object':
|
|
||||||
object = {}
|
|
||||||
object['master'] = object
|
|
||||||
if key == 'controllertemperaturestatus':
|
|
||||||
object = object['master']
|
|
||||||
if key == 'iomodules':
|
|
||||||
key = 'modules'
|
|
||||||
#if key in subitems.values():
|
|
||||||
# object['master'][key] = []
|
|
||||||
if key in subitems.keys():
|
|
||||||
mastergroup = subitems[key]
|
|
||||||
master = object['master']
|
|
||||||
object = {}
|
|
||||||
object['object_type'] = key
|
|
||||||
object['master'] = master
|
|
||||||
if not object['master'].has_key(mastergroup):
|
|
||||||
object['master'][mastergroup] = []
|
|
||||||
object['master'][mastergroup].append(object)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if line.find('.:') > 0:
|
|
||||||
# We work on first come, first serve basis, so if
|
|
||||||
# we accidentally see same key again, we will ignore
|
|
||||||
if not object.has_key(key):
|
|
||||||
value = ' '.join( tmp[2:] ).strip()
|
|
||||||
object[key] = value
|
|
||||||
# Check if we were instructed to check only one eva system
|
|
||||||
global check_system
|
|
||||||
if command == "ls system full" and check_system != None:
|
|
||||||
tmp_objects = []
|
|
||||||
for i in objects:
|
|
||||||
if i['objectname'] == check_system:
|
|
||||||
tmp_objects.append( i )
|
|
||||||
objects = tmp_objects
|
|
||||||
return objects
|
|
||||||
|
|
||||||
def end(summary,perfdata,longserviceoutput,nagios_state):
|
|
||||||
global show_longserviceoutput
|
|
||||||
global show_perfdata
|
|
||||||
global nagios_server
|
|
||||||
global do_phone_home
|
|
||||||
global nagios_port
|
|
||||||
global nagios_myhostname
|
|
||||||
global hostname
|
|
||||||
global mode
|
|
||||||
global escape_newlines
|
|
||||||
global check_system
|
|
||||||
|
|
||||||
message = "%s - %s" % ( state[nagios_state], summary)
|
|
||||||
if show_perfdata:
|
|
||||||
message = "%s | %s" % ( message, perfdata)
|
|
||||||
if show_longserviceoutput:
|
|
||||||
message = "%s\n%s" % ( message, longserviceoutput.strip())
|
|
||||||
if escape_newlines == True:
|
|
||||||
lines = message.split('\n')
|
|
||||||
message = '\\n'.join(lines)
|
|
||||||
debug( "do_phone_home = %s" %(do_phone_home) )
|
|
||||||
if do_phone_home == True:
|
|
||||||
try:
|
|
||||||
if nagios_myhostname is None:
|
|
||||||
if environ.has_key( 'HOSTNAME' ):
|
|
||||||
nagios_myhostname = environ['HOSTNAME']
|
|
||||||
elif environ.has_key( 'COMPUTERNAME' ):
|
|
||||||
nagios_myhostname = environ['COMPUTERNAME']
|
|
||||||
else:
|
|
||||||
nagios_myhostname = hostname
|
|
||||||
try: phone_home(nagios_server,nagios_port, status=nagios_state, message=message, hostname=nagios_myhostname, servicename=mode,system=check_system)
|
|
||||||
except:pass
|
|
||||||
|
|
||||||
except:
|
|
||||||
raise
|
|
||||||
print message
|
|
||||||
exit(nagios_state)
|
|
||||||
class ProxiedTransport(xmlrpclib.Transport):
|
|
||||||
def set_proxy(self, proxy):
|
|
||||||
self.proxy = proxy
|
|
||||||
def make_connection(self, host):
|
|
||||||
self.realhost = host
|
|
||||||
h = httplib.HTTP(self.proxy)
|
|
||||||
return h
|
|
||||||
def send_request(self, connection, handler, request_body):
|
|
||||||
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
|
|
||||||
def send_host(self, connection, host):
|
|
||||||
connection.putheader('Host', self.realhost)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
''' phone_home: Sends results to remote nagios server via python xml-rpc '''
|
|
||||||
def phone_home(nagios_server,nagios_port, status, message, hostname=None, servicename=None,system=None):
|
|
||||||
debug("phoning home: %s" % (servicename) )
|
|
||||||
if system is not None:
|
|
||||||
servicename = str(servicename) + str(system)
|
|
||||||
uri = "http://%s:%s" % (nagios_server,nagios_port)
|
|
||||||
|
|
||||||
global proxyserver
|
|
||||||
if proxyserver != None:
|
|
||||||
p = ProxiedTransport()
|
|
||||||
p.set_proxy(proxyserver)
|
|
||||||
s = xmlrpclib.Server( uri, transport=p )
|
|
||||||
else:
|
|
||||||
s = xmlrpclib.ServerProxy( uri )
|
|
||||||
s.nagiosupdate(hostname, servicename, status, message)
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def check_systems():
|
|
||||||
summary=""
|
|
||||||
perfdata=""
|
|
||||||
#longserviceoutput="\n"
|
|
||||||
nagios_state = ok
|
|
||||||
objects = run_sssu()
|
|
||||||
for i in objects:
|
|
||||||
name = i['objectname']
|
|
||||||
operationalstate = i['operationalstate']
|
|
||||||
# Lets see if this array is working
|
|
||||||
if operationalstate != 'good':
|
|
||||||
nagios_state = max(nagios_state, warning)
|
|
||||||
# Lets add to the summary
|
|
||||||
summary = summary + " %s=%s " %(name, operationalstate)
|
|
||||||
# Collect the performance data
|
|
||||||
interesting_perfdata = 'totalstoragespace|usedstoragespace|availablestoragespace'
|
|
||||||
perfdata = perfdata + get_perfdata(i,interesting_perfdata.split('|'), identifier="%s_"% name)
|
|
||||||
# Collect extra info for longserviceoutput
|
|
||||||
long("%s = %s (%s)\n" % ( i['objectname'], i['operationalstate'], i['operationalstatedetail']) )
|
|
||||||
interesting_fields = 'licensestate|systemtype|firmwareversion|nscfwversion|totalstoragespace|usedstoragespace|availablestoragespace'
|
|
||||||
for x in interesting_fields.split('|'):
|
|
||||||
long( "- %s = %s \n" %(x, i[x]) )
|
|
||||||
long("\n")
|
|
||||||
end(summary,perfdata,longserviceoutput,nagios_state)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_perfdata(object, interesting_fields, identifier=""):
|
|
||||||
perfdata = ""
|
|
||||||
for i in interesting_fields:
|
|
||||||
if i == '': continue
|
|
||||||
perfdata = perfdata + "'%s%s'=%s " % (identifier, i, object[i])
|
|
||||||
return perfdata
|
|
||||||
|
|
||||||
def add_perfdata(text):
|
|
||||||
global perfdata
|
|
||||||
text = text.strip()
|
|
||||||
perfdata = perfdata + " %s " % (text)
|
|
||||||
|
|
||||||
def long(text):
|
|
||||||
global longserviceoutput
|
|
||||||
longserviceoutput = longserviceoutput + text
|
|
||||||
def get_longserviceoutput(object, interesting_fields):
|
|
||||||
longserviceoutput = ""
|
|
||||||
for i in interesting_fields:
|
|
||||||
longserviceoutput = longserviceoutput + "%s = %s \n" %(i, object[i])
|
|
||||||
return longserviceoutput
|
|
||||||
|
|
||||||
def check_operationalstate(object, print_failed_objects=False,namefield='objectname',detailfield='operationalstatedetail',statefield='operationalstate',valid_states=['good']):
|
|
||||||
if not object.has_key(detailfield): detailfield = statefield
|
|
||||||
if not object.has_key(statefield):
|
|
||||||
if print_failed_objects:
|
|
||||||
long("- Warning, %s does not have any '%s'" % ( object[namefield], statefield ) )
|
|
||||||
return warning
|
|
||||||
if object[statefield] not in valid_states:
|
|
||||||
if print_failed_objects:
|
|
||||||
long("- Warning, %s=%s (%s)\n" % ( object[namefield], object['operationalstate'], object[detailfield] ))
|
|
||||||
return warning
|
|
||||||
debug( "OK, %s=%s (%s)\n" % ( object[namefield], object['operationalstate'], object[detailfield] ) )
|
|
||||||
return ok
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def check_generic(command="ls disk full",namefield="objectname", perfdata_fields=[], longserviceoutputfields=[], detailedsummary=False):
|
|
||||||
summary=""
|
|
||||||
global perfdata
|
|
||||||
nagios_state = ok
|
|
||||||
systems = run_sssu()
|
|
||||||
objects = []
|
|
||||||
if command == 'ls system full':
|
|
||||||
objects = systems
|
|
||||||
for i in systems: i['systemname'] = '' #i['objectname']
|
|
||||||
else:
|
|
||||||
for i in systems:
|
|
||||||
result = run_sssu(system=i['objectname'], command=command)
|
|
||||||
for x in result:
|
|
||||||
x['systemname'] = i['objectname']
|
|
||||||
objects.append( x )
|
|
||||||
summary = "%s objects found " % len(objects)
|
|
||||||
for i in objects:
|
|
||||||
systemname = i['systemname']
|
|
||||||
|
|
||||||
# Some versions of commandview use "objectname" instead of namefield
|
|
||||||
if i.has_key( namefield ):
|
|
||||||
objectname = i[namefield]
|
|
||||||
else:
|
|
||||||
objectname = i['objectname']
|
|
||||||
# Some versions of CV also return garbage objects, luckily it is easy to find these
|
|
||||||
if i.has_key('objecttype') and i['objecttype'] == 'typenotset':
|
|
||||||
long("Object %s was skipped because objecttype == typenotset\n" % objectname )
|
|
||||||
continue
|
|
||||||
# Lets see if this object is working
|
|
||||||
nagios_state = max( check_operationalstate(i), nagios_state )
|
|
||||||
|
|
||||||
|
|
||||||
# Lets add to the summary
|
|
||||||
if i['operationalstate'] != 'good' or detailedsummary == True:
|
|
||||||
summary = summary + " %s/%s=%s " %(systemname,objectname, i['operationalstate'])
|
|
||||||
|
|
||||||
# Lets get some perfdata
|
|
||||||
identifier = "%s/%s_" % (systemname,objectname)
|
|
||||||
i['identifier'] = identifier
|
|
||||||
|
|
||||||
|
|
||||||
for field in perfdata_fields:
|
|
||||||
if field == '': continue
|
|
||||||
add_perfdata( "'%s%s'=%s " % (identifier, field, i[field]) )
|
|
||||||
|
|
||||||
# Disk group gets a special perfdata treatment
|
|
||||||
if command == "ls disk_group full":
|
|
||||||
totalstoragespacegb= float( i['totalstoragespacegb'] )
|
|
||||||
usedstoragespacegb= float ( i['usedstoragespacegb'] )
|
|
||||||
occupancyalarmlvel = float( i['occupancyalarmlevel'] )
|
|
||||||
warninggb= totalstoragespacegb * occupancyalarmlvel / 100
|
|
||||||
add_perfdata( " '%sdiskusage'=%s;%s;%s "% (identifier, usedstoragespacegb,warninggb,totalstoragespacegb) )
|
|
||||||
|
|
||||||
# Long Serviceoutput
|
|
||||||
|
|
||||||
# There are usually to many disks for nagios to display. Skip.
|
|
||||||
if command != "ls disk full":
|
|
||||||
long( "\n%s/%s = %s (%s)\n"%(systemname,objectname,i['operationalstate'], i['operationalstatedetail']) )
|
|
||||||
|
|
||||||
# If diskgroup has a problem because it is over allocated. Lets inform about that
|
|
||||||
if command == "ls disk_group full" and usedstoragespacegb > warninggb:
|
|
||||||
long("- %s - diskgroup usage is over %s%% threshold !\n" % (state[warning], occupancyalarmlvel) )
|
|
||||||
# If a disk has a problem, lets display some extra info on it
|
|
||||||
elif command == "ls disk full" and i['operationalstate'] != 'good':
|
|
||||||
long( "Warning - %s=%s (%s)\n" % (i['diskname'], i['operationalstate'], i['operationalstatedetail'] ))
|
|
||||||
fields="modelnumber firmwareversion serialnumber failurepredicted diskdrivetype".split()
|
|
||||||
for field in fields:
|
|
||||||
long( "- %s = %s\n" % (field, i[field]) )
|
|
||||||
|
|
||||||
|
|
||||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'sensors'))
|
|
||||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'fans'))
|
|
||||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'powersupplies'))
|
|
||||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'communicationbuses'))
|
|
||||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'fibrechannelports'))
|
|
||||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'modules'))
|
|
||||||
for x in longserviceoutputfields:
|
|
||||||
if i.has_key( x ):
|
|
||||||
long( "- %s = %s\n" % (x, i[x]))
|
|
||||||
|
|
||||||
end(summary,perfdata,longserviceoutput,nagios_state)
|
|
||||||
|
|
||||||
def check_multiple_objects(object, name):
|
|
||||||
item_status = not_present
|
|
||||||
if object.has_key(name):
|
|
||||||
item_status = not_present
|
|
||||||
valid_states=['good']
|
|
||||||
namefield="name"
|
|
||||||
detailfield = 'operationalstatedetail'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if name == 'fans' or name == 'sensors':
|
|
||||||
valid_states = ['good','notavailable','unsupported','notinstalled']
|
|
||||||
elif name == 'fibrechannelports':
|
|
||||||
valid_states.append( 'notinstalled' )
|
|
||||||
num_items = len(object[name])
|
|
||||||
for item in object[name]:
|
|
||||||
stat = check_operationalstate( item,print_failed_objects=True, namefield=namefield, valid_states=valid_states,detailfield=detailfield)
|
|
||||||
item_status = max( stat, item_status )
|
|
||||||
long('- %s on %s (%s detected)\n'% (state[item_status], name, num_items) )
|
|
||||||
add_perfdata( " '%s%s'=%s" % (object['identifier'],name, num_items) )
|
|
||||||
return item_status
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def check_controllers():
|
|
||||||
summary=""
|
|
||||||
perfdata=""
|
|
||||||
#longserviceoutput="\n"
|
|
||||||
nagios_state = ok
|
|
||||||
systems = run_sssu()
|
|
||||||
controllers =[]
|
|
||||||
for i in systems:
|
|
||||||
result = run_sssu(system=i['objectname'], command="ls controller full")
|
|
||||||
for controller in result:
|
|
||||||
controller['systemname'] = i['objectname']
|
|
||||||
controllers.append( controller )
|
|
||||||
summary = "%s objects found " % len(controllers)
|
|
||||||
for i in controllers:
|
|
||||||
systemname = i['systemname']
|
|
||||||
if i.has_key('controllername'):
|
|
||||||
controllername = i['controllername']
|
|
||||||
else:
|
|
||||||
controllername = i['objectname']
|
|
||||||
# Lets see if this controller is working
|
|
||||||
nagios_state = max( check_operationalstate(i), nagios_state )
|
|
||||||
|
|
||||||
# Lets add to the summary
|
|
||||||
if not i.has_key('operationalstate'):
|
|
||||||
summary = summary + " %s does not have any operationalstate " % controllername
|
|
||||||
nagios_state = max( unknown, nagios_state )
|
|
||||||
continue
|
|
||||||
elif i['operationalstate'] != 'good':
|
|
||||||
summary = summary + " %s/%s=%s " %(systemname,controllername, i['operationalstate'])
|
|
||||||
|
|
||||||
# Lets get some perfdata
|
|
||||||
interesting_fields = "controllermainmemory"
|
|
||||||
identifier = "%s/%s_" % (systemname,controllername)
|
|
||||||
perfdata = perfdata + get_perfdata(i, interesting_fields.split('|'), identifier=identifier)
|
|
||||||
|
|
||||||
# Long Serviceoutput
|
|
||||||
interesting_fields = "operationalstate|operationalstatedetail|firmwareversion|serialnumber"
|
|
||||||
#longserviceoutput = longserviceoutput + get_longserviceoutput(i, interesting_fields.split('|') )
|
|
||||||
#longserviceoutput = longserviceoutput + "\n%s/%s\n"%(systemname,controllername)
|
|
||||||
long( "\n%s/%s = %s (%s)\n"%(systemname,controllername,i['operationalstate'], i['operationalstatedetail']) )
|
|
||||||
long( "- firmwareversion = %s \n" %(i['firmwareversion']))
|
|
||||||
long( "- serialnumber = %s \n" %(i['serialnumber']))
|
|
||||||
|
|
||||||
|
|
||||||
controllertemperaturestatus = not_present
|
|
||||||
cache_state = not_present
|
|
||||||
fanstate = not_present
|
|
||||||
hostportstate = not_present
|
|
||||||
sensorstate = ok
|
|
||||||
source_state = not_present
|
|
||||||
module_state = not_present
|
|
||||||
|
|
||||||
# Check the cache status
|
|
||||||
if i['cachecondition'] == 'good':
|
|
||||||
cache_state = ok
|
|
||||||
else:
|
|
||||||
cache_state = warning
|
|
||||||
|
|
||||||
# Check Temperature
|
|
||||||
if i.has_key("controllertemperaturestatus"):
|
|
||||||
if i['controllertemperaturestatus'] == 'normal':
|
|
||||||
controllertemperaturestatus = ok
|
|
||||||
else:
|
|
||||||
controllertemperaturestatus = warning
|
|
||||||
|
|
||||||
|
|
||||||
# Process the subsensors
|
|
||||||
for hostport in i['hostports']:
|
|
||||||
#long(" %s = %s\n" % (hostport['portname'], hostport['operationalstate']))
|
|
||||||
hostportstate = max(hostportstate,ok)
|
|
||||||
if hostport['operationalstate'] != 'good':
|
|
||||||
hostportstate = max(warning,hostport_state)
|
|
||||||
long("Hostport %s state = %s\n" % hostport['portname'], hostport['operationalstate'])
|
|
||||||
if i.has_key('fans'):
|
|
||||||
for fan in i['fans']:
|
|
||||||
fanstate = max(fanstate,ok)
|
|
||||||
#long(" %s = %s\n" % (fan['fanname'], fan['status']))
|
|
||||||
if fan.has_key('status'): status = fan['status']
|
|
||||||
elif fan.has_key('installstatus'): status = fan['installstatus']
|
|
||||||
if status != 'normal' and status != 'yes':
|
|
||||||
fanstate = max(warning,fanstate)
|
|
||||||
long("Fan %s status = %s\n" % (fan['fanname'],status))
|
|
||||||
if i.has_key('powersources'):
|
|
||||||
for source in i['powersources']:
|
|
||||||
source_state = max(source_state,ok)
|
|
||||||
if not source.has_key('status'): continue
|
|
||||||
if source['state'] != 'good':
|
|
||||||
source_state = max(warning,source_state)
|
|
||||||
long("Powersource %s status = %s\n" % (source['type'],source['state']))
|
|
||||||
if i.has_key('modules'):
|
|
||||||
for module in i['modules']:
|
|
||||||
module_state = max(module_state,ok)
|
|
||||||
if module['operationalstate'] not in ('good','not_present'):
|
|
||||||
module_state = max(warning,module_state)
|
|
||||||
long("Battery Module %s status = %s\n" % (module['name'],module['operationalstate']))
|
|
||||||
|
|
||||||
|
|
||||||
for i in (fanstate,hostportstate,sensorstate,source_state,module_state,cache_state,controllertemperaturestatus):
|
|
||||||
nagios_state = max(nagios_state, i)
|
|
||||||
|
|
||||||
long("- %s on fans\n"%( state[fanstate] ) )
|
|
||||||
long("- %s on cachememory\n"%( state[cache_state] ) )
|
|
||||||
long("- %s on temperature\n"%( state[controllertemperaturestatus] ) )
|
|
||||||
long("- %s on hostports\n"%( state[hostportstate] ) )
|
|
||||||
long("- %s on sensors\n"%( state[sensorstate] ) )
|
|
||||||
long("- %s on powersupplies\n"%( state[source_state] ) )
|
|
||||||
long("- %s on batterymodules\n"%( state[module_state] ) )
|
|
||||||
|
|
||||||
|
|
||||||
long('\n')
|
|
||||||
end(summary,perfdata,longserviceoutput,nagios_state)
|
|
||||||
|
|
||||||
def set_path():
|
|
||||||
global path
|
|
||||||
current_path = getenv('PATH')
|
|
||||||
if path == '':
|
|
||||||
if current_path.find('C:\\') > -1: # We are on this platform
|
|
||||||
path = ";C:\\Program Files\\Hewlett-Packard\\Sanworks\\Element Manager for StorageWorks HSV"
|
|
||||||
else:
|
|
||||||
path = ":/usr/local/bin"
|
|
||||||
current_path = "%s%s" % (current_path,path)
|
|
||||||
environ['PATH'] = current_path
|
|
||||||
set_path()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if mode == 'check_systems':
|
|
||||||
perfdata_fields = 'totalstoragespace usedstoragespace availablestoragespace'.split()
|
|
||||||
longserviceoutputfields = 'licensestate systemtype firmwareversion nscfwversion totalstoragespace usedstoragespace availablestoragespace'.split()
|
|
||||||
command = "ls system full"
|
|
||||||
namefield="objectname"
|
|
||||||
check_generic(command=command,namefield=namefield,longserviceoutputfields=longserviceoutputfields, perfdata_fields=perfdata_fields)
|
|
||||||
#check_systems
|
|
||||||
elif mode == 'check_controllers':
|
|
||||||
check_controllers()
|
|
||||||
elif mode == 'check_diskgroups':
|
|
||||||
command = "ls disk_group full"
|
|
||||||
namefield='diskgroupname'
|
|
||||||
longserviceoutputfields = "totaldisks levelingstate levelingprogress totalstoragespacegb usedstoragespacegb occupancyalarmlevel".split()
|
|
||||||
perfdata_fields="totaldisks".split()
|
|
||||||
check_generic(command=command,namefield=namefield,longserviceoutputfields=longserviceoutputfields, perfdata_fields=perfdata_fields)
|
|
||||||
elif mode == 'check_disks':
|
|
||||||
check_generic(command="ls disk full",namefield="objectname")
|
|
||||||
elif mode == 'check_diskshelfs' or mode == 'check_diskshelves':
|
|
||||||
check_generic(command="ls diskshelf full",namefield="diskshelfname",longserviceoutputfields=[], perfdata_fields=[])
|
|
||||||
else:
|
|
||||||
print "* Error: Mode %s not found" % mode
|
|
||||||
print_help()
|
|
||||||
print "* Error: Mode %s not found" % mode
|
|
||||||
exit(unknown)
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
%define debug_package %{nil}
|
|
||||||
|
|
||||||
Summary: A Nagios plugin to check HP EVA Disk Systems
|
|
||||||
Name: nagios-okplugin-check_eva
|
|
||||||
Version: AUTOVERSION
|
|
||||||
Release: 1%{?dist}
|
|
||||||
License: GPLv2+
|
|
||||||
Group: Applications/System
|
|
||||||
URL: http://opensource.is/trac/wiki/check_eva
|
|
||||||
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_eva/releases/nagios-okplugin-check_eva-%{version}.tar.gz
|
|
||||||
Requires: sssu,nagios-plugins
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
|
||||||
Packager: Pall Sigurdsson <palli@opensource.is>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%description
|
|
||||||
Checks HP EVA Disk Systems with the sssu binary
|
|
||||||
|
|
||||||
|
|
||||||
%prep
|
|
||||||
%setup -q
|
|
||||||
perl -pi -e "s|/usr/lib|%{_libdir}|g" nrpe.d/check_eva.cfg
|
|
||||||
|
|
||||||
%build
|
|
||||||
|
|
||||||
|
|
||||||
%install
|
|
||||||
rm -rf %{buildroot}
|
|
||||||
install -D -p -m 0755 check_eva.py %{buildroot}%{_libdir}/nagios/plugins/check_eva.py
|
|
||||||
install -D -p -m 0755 nrpe.d/check_eva.cfg %{buildroot}/etc/nrpe.d/check_eva.cfg
|
|
||||||
|
|
||||||
%clean
|
|
||||||
rm -rf %{buildroot}
|
|
||||||
|
|
||||||
%files
|
|
||||||
%defattr(-,root,root,-)
|
|
||||||
%doc README LICENSE
|
|
||||||
%{_libdir}/nagios/plugins/*
|
|
||||||
/etc/nrpe.d/check_eva.cfg
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
* Mon Mar 1 2010 Pall Sigurdsson <palli@opensource.is> 0.1-1
|
|
||||||
- Initial packaging
|
|
23
check_firewall_active/check_firewall_active.sh
Executable file
23
check_firewall_active/check_firewall_active.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
EXIT_OK=0
|
||||||
|
EXIT_WARN=1
|
||||||
|
EXIT_CRIT=2
|
||||||
|
|
||||||
|
PATH=/sbin:/usr/sbin:$PATH
|
||||||
|
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "This script must be run as root" 1>&2
|
||||||
|
exit $EXIT_CRIT
|
||||||
|
fi
|
||||||
|
|
||||||
|
blocks=$(iptables -L -v -n | egrep 'REJECT|DROP' | wc -l)
|
||||||
|
|
||||||
|
if [ $blocks -eq 0 ]; then
|
||||||
|
echo "CRITICAL: No firewall detected"
|
||||||
|
exit $EXIT_CRIT
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "OK: Firewall is active"
|
||||||
|
exit $EXIT_OK
|
||||||
|
|
@ -0,0 +1,52 @@
|
|||||||
|
%define debug_package %{nil}
|
||||||
|
|
||||||
|
Summary: A Nagios plugin to check if iptables are actually enforcing rules
|
||||||
|
Name: nagios-okplugin-check_firewall_active
|
||||||
|
Version: 1.0.2
|
||||||
|
Release: 1%{?dist}
|
||||||
|
License: GPLv2+
|
||||||
|
Group: Applications/System
|
||||||
|
URL: https://github.com/opinkerfi/nagios-plugins/issues
|
||||||
|
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_firewall_active/releases/nagios-okplugin-check_firewall_active-%{version}.tar.gz
|
||||||
|
Requires: nagios-nrpe
|
||||||
|
Requires: iptables
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
|
Packager: Richard Allen <ra@ok.is>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%description
|
||||||
|
A Nagios plugin to check if iptables are actually enforcing rules
|
||||||
|
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
#perl -pi -e "s|/usr/lib64|%{_libdir}|g" nrpe.d/check_firewall_active.cfg
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
install -D -p -m 0755 check_firewall_active.sh %{buildroot}%{_libdir}/nagios/plugins/check_firewall_active.sh
|
||||||
|
install -D -p -m 0755 nrpe.d/check_firewall_active.cfg %{buildroot}/etc/nrpe.d/check_firewall_active.cfg
|
||||||
|
install -D -p -m 0644 sudoers.d/check_firewall_active %{buildroot}/etc/sudoers.d/check_firewall_active
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
#%doc README LICENSE
|
||||||
|
%{_libdir}/nagios/plugins/*
|
||||||
|
/etc/nrpe.d/check_firewall_active.cfg
|
||||||
|
/etc/sudoers.d/check_firewall_active
|
||||||
|
|
||||||
|
%post
|
||||||
|
restorecon -v %{_libdir}/nagios/plugins/check_firewall_active.sh /etc/nrpe.d/check_firewall_active.cfg /etc/sudoers.d/check_firewall_active
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Thu Dec 21 2016 Gardar Thorsteinsson <gardart@gmail.com> 1.0.1-1
|
||||||
|
* Thu Dec 21 2016 Gardar Thorsteinsson <gardart@gmail.com> 1.0.0-3
|
||||||
|
* Thu Dec 20 2016 Richard Allen <ra@ok.is> 0.1-1
|
||||||
|
- Initial packaging
|
3
check_firewall_active/nrpe.d/check_firewall_active.cfg
Normal file
3
check_firewall_active/nrpe.d/check_firewall_active.cfg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
command[check_firewall_active]=sudo /usr/lib64/nagios/plugins/check_firewall_active.sh
|
2
check_firewall_active/sudoers.d/check_firewall_active
Normal file
2
check_firewall_active/sudoers.d/check_firewall_active
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Defaults:nrpe !requiretty
|
||||||
|
nrpe ALL = (root) NOPASSWD: /usr/lib64/nagios/plugins/check_firewall_active.sh
|
362
check_hpacucli/check_hpacucli.py
Normal file
362
check_hpacucli/check_hpacucli.py
Normal file
@ -0,0 +1,362 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
#
|
||||||
|
# Copyright 2010, Pall Sigurdsson <palli@opensource.is>
|
||||||
|
#
|
||||||
|
# check_hpacucli.py is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# check_hpacucli.py is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# About this script
|
||||||
|
#
|
||||||
|
# This script will check the status of Smart Array Raid Controller
|
||||||
|
# You need the hpacucli binary in path (/usr/sbin/hpacucli is a good place)
|
||||||
|
# hpacucli comes with the Proliant Support Pack (PSP) from HP
|
||||||
|
|
||||||
|
debugging = False
|
||||||
|
|
||||||
|
# No real need to change anything below here
|
||||||
|
version = "1.1"
|
||||||
|
ok = 0
|
||||||
|
warning = 1
|
||||||
|
critical = 2
|
||||||
|
unknown = 3
|
||||||
|
not_present = -1
|
||||||
|
nagios_status = -1
|
||||||
|
|
||||||
|
state = {}
|
||||||
|
state[not_present] = "Not Present"
|
||||||
|
state[ok] = "OK"
|
||||||
|
state[warning] = "Warning"
|
||||||
|
state[critical] = "Critical"
|
||||||
|
state[unknown] = "Unknown"
|
||||||
|
|
||||||
|
|
||||||
|
longserviceoutput = "\n"
|
||||||
|
perfdata = ""
|
||||||
|
summary = ""
|
||||||
|
sudo = False
|
||||||
|
|
||||||
|
|
||||||
|
from sys import exit
|
||||||
|
from sys import argv
|
||||||
|
from os import getenv, putenv, environ
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def print_help():
|
||||||
|
print "check_hpacucli version %s" % version
|
||||||
|
print "This plugin checks HP Array with the hpacucli command"
|
||||||
|
print ""
|
||||||
|
print "Usage: %s " % argv[0]
|
||||||
|
print "Usage: %s [--help]" % argv[0]
|
||||||
|
print "Usage: %s [--version]" % argv[0]
|
||||||
|
print "Usage: %s [--path </path/to/hpacucli>]" % argv[0]
|
||||||
|
print "Usage: %s [--no-perfdata]" % argv[0]
|
||||||
|
print "Usage: %s [--no-longoutput]" % argv[0]
|
||||||
|
print ""
|
||||||
|
|
||||||
|
|
||||||
|
def error(errortext):
|
||||||
|
print "* Error: %s" % errortext
|
||||||
|
print_help()
|
||||||
|
print "* Error: %s" % errortext
|
||||||
|
exit(unknown)
|
||||||
|
|
||||||
|
|
||||||
|
def debug(debugtext):
|
||||||
|
global debugging
|
||||||
|
if debugging:
|
||||||
|
print debugtext
|
||||||
|
|
||||||
|
|
||||||
|
def runCommand(command):
|
||||||
|
""" Run command from the shell prompt. Exit Nagios style if unsuccessful"""
|
||||||
|
proc = subprocess.Popen(command,
|
||||||
|
shell=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
stdout, stderr = proc.communicate('through stdin to stdout')
|
||||||
|
if proc.returncode > 0:
|
||||||
|
print "Error %s: %s\n command was: '%s'"\
|
||||||
|
% (proc.returncode, stderr.strip(), command)
|
||||||
|
debug("results: %s" % (stdout.strip()))
|
||||||
|
if proc.returncode == 127: # File not found, lets print path
|
||||||
|
path = getenv("PATH")
|
||||||
|
print "Check if your path is correct %s" % (path)
|
||||||
|
if stderr.find('Password:') == 0 and command.find('sudo') == 0:
|
||||||
|
print "Check if user is in the sudoers file"
|
||||||
|
if stderr.find('sorry, you must have a tty to run sudo') == 0 and command.find('sudo') == 0:
|
||||||
|
print "Please remove 'requiretty' from /etc/sudoers"
|
||||||
|
exit(unknown)
|
||||||
|
else:
|
||||||
|
return stdout
|
||||||
|
|
||||||
|
|
||||||
|
def end():
|
||||||
|
global summary
|
||||||
|
global longserviceoutput
|
||||||
|
global perfdata
|
||||||
|
global nagios_status
|
||||||
|
print "%s - %s | %s" % (state[nagios_status], summary, perfdata)
|
||||||
|
print longserviceoutput
|
||||||
|
if nagios_status < 0:
|
||||||
|
nagios_status = unknown
|
||||||
|
exit(nagios_status)
|
||||||
|
|
||||||
|
|
||||||
|
def add_perfdata(text):
|
||||||
|
global perfdata
|
||||||
|
text = text.strip()
|
||||||
|
perfdata = perfdata + " %s " % (text)
|
||||||
|
|
||||||
|
|
||||||
|
def add_long(text):
|
||||||
|
global longserviceoutput
|
||||||
|
longserviceoutput = longserviceoutput + text + '\n'
|
||||||
|
|
||||||
|
|
||||||
|
def add_summary(text):
|
||||||
|
global summary
|
||||||
|
summary = summary + text
|
||||||
|
|
||||||
|
|
||||||
|
def set_path(path):
|
||||||
|
current_path = getenv('PATH')
|
||||||
|
if current_path.find('C:\\') > -1: # We are on this platform
|
||||||
|
if path == '':
|
||||||
|
path = ";C:\Program Files\Hewlett-Packard\Sanworks\Element Manager for StorageWorks HSV"
|
||||||
|
path = path + ";C:\Program Files (x86)\Compaq\Hpacucli\Bin"
|
||||||
|
path = path + ";C:\Program Files\Compaq\Hpacucli\Bin"
|
||||||
|
else:
|
||||||
|
path = ';' + path
|
||||||
|
else: # Unix/Linux, etc
|
||||||
|
if path == '':
|
||||||
|
path = ":/usr/sbin"
|
||||||
|
else:
|
||||||
|
path = ':' + path
|
||||||
|
current_path = "%s%s" % (current_path, path)
|
||||||
|
environ['PATH'] = current_path
|
||||||
|
|
||||||
|
|
||||||
|
def run_hpacucli(run_type='controllers', controller=None):
|
||||||
|
if run_type == 'controllers':
|
||||||
|
command = "hpacucli controller all show detail"
|
||||||
|
elif run_type in ('logicaldisks', 'physicaldisks'):
|
||||||
|
if 'Slot' not in controller:
|
||||||
|
add_summary("Controller not found")
|
||||||
|
end()
|
||||||
|
identifier = 'slot=%s' % (controller['Slot'])
|
||||||
|
command = "hpacucli controller %s %s all show detail"
|
||||||
|
if run_type == 'logicaldisks':
|
||||||
|
subcommand = 'ld'
|
||||||
|
elif run_type == 'physicaldisks':
|
||||||
|
subcommand = 'pd'
|
||||||
|
else:
|
||||||
|
end()
|
||||||
|
return
|
||||||
|
command = command % (identifier, subcommand)
|
||||||
|
debug(command)
|
||||||
|
if sudo:
|
||||||
|
command = "sudo " + command
|
||||||
|
output = runCommand(command)
|
||||||
|
# Some basic error checking
|
||||||
|
error_strings = ['Permission denied']
|
||||||
|
error_strings.append('Error: You need to have administrator rights to continue.')
|
||||||
|
for error in error_strings:
|
||||||
|
if output.find(error) > -1 and output.find("sudo") != 0:
|
||||||
|
command = "sudo " + command
|
||||||
|
print command
|
||||||
|
output = runCommand(command)
|
||||||
|
output = output.split('\n')
|
||||||
|
objects = []
|
||||||
|
my_object = None
|
||||||
|
for i in output:
|
||||||
|
if len(i) == 0:
|
||||||
|
continue
|
||||||
|
if i.strip() == '':
|
||||||
|
continue
|
||||||
|
if i.startswith('Note:'):
|
||||||
|
continue
|
||||||
|
if run_type == 'controllers' and i[0] != ' ': # space on first line
|
||||||
|
if my_object and not my_object in objects:
|
||||||
|
objects.append(my_object)
|
||||||
|
my_object = {}
|
||||||
|
my_object['name'] = i
|
||||||
|
elif run_type == 'logicaldisks' and i.find('Logical Drive:') > 0:
|
||||||
|
if my_object and not my_object in objects:
|
||||||
|
objects.append(my_object)
|
||||||
|
my_object = {}
|
||||||
|
my_object['name'] = i.strip()
|
||||||
|
elif run_type == 'physicaldisks' and i.find('physicaldrive') > 0:
|
||||||
|
if my_object and not my_object in objects:
|
||||||
|
objects.append(my_object)
|
||||||
|
my_object = {}
|
||||||
|
my_object['name'] = i.strip()
|
||||||
|
else:
|
||||||
|
i = i.strip()
|
||||||
|
if i.find(':') < 1:
|
||||||
|
continue
|
||||||
|
i = i.split(':')
|
||||||
|
if i[0] == '':
|
||||||
|
continue # skip empty lines
|
||||||
|
if len(i) == 1:
|
||||||
|
continue
|
||||||
|
key = i[0].strip()
|
||||||
|
value = ' '.join(i[1:]).strip()
|
||||||
|
my_object[key] = value
|
||||||
|
if my_object and not my_object in objects:
|
||||||
|
objects.append(my_object)
|
||||||
|
return objects
|
||||||
|
|
||||||
|
|
||||||
|
controllers = []
|
||||||
|
|
||||||
|
|
||||||
|
def check_controllers():
|
||||||
|
global controllers
|
||||||
|
status = -1
|
||||||
|
controllers = run_hpacucli()
|
||||||
|
if len(controllers) == 0:
|
||||||
|
add_summary("No Disk Controllers Found. Exiting...")
|
||||||
|
global nagios_state
|
||||||
|
nagios_state = unknown
|
||||||
|
end()
|
||||||
|
add_summary("Found %s controllers" % (len(controllers)))
|
||||||
|
for i in controllers:
|
||||||
|
controller_status = check(i, 'Controller Status', 'OK')
|
||||||
|
status = max(status, controller_status)
|
||||||
|
|
||||||
|
cache_status = check(i, 'Cache Status')
|
||||||
|
status = max(status, cache_status)
|
||||||
|
|
||||||
|
controller_serial = 'n/a'
|
||||||
|
cache_serial = 'n/a'
|
||||||
|
if 'Serial Number' in i:
|
||||||
|
controller_serial = i['Serial Number']
|
||||||
|
if 'Cache Serial Number' in i:
|
||||||
|
cache_serial = i['Cache Serial Number']
|
||||||
|
add_long("%s" % (i['name']))
|
||||||
|
add_long("- Controller Status: %s (sn: %s)"
|
||||||
|
% (state[controller_status], controller_serial))
|
||||||
|
add_long("- Cache Status: %s (sn: %s)"
|
||||||
|
% (state[cache_status], cache_serial))
|
||||||
|
|
||||||
|
if controller_status > ok or cache_status > ok:
|
||||||
|
add_summary(";%s on %s;" % (state[controller_status], i['name']))
|
||||||
|
|
||||||
|
add_summary(', ')
|
||||||
|
return status
|
||||||
|
|
||||||
|
|
||||||
|
def check_logicaldisks():
|
||||||
|
global controllers
|
||||||
|
if len(controllers) < 1:
|
||||||
|
controllers = run_hpacucli()
|
||||||
|
logicaldisks = []
|
||||||
|
for controller in controllers:
|
||||||
|
for ld in run_hpacucli(run_type='logicaldisks',
|
||||||
|
controller=controller):
|
||||||
|
logicaldisks.append(ld)
|
||||||
|
status = -1
|
||||||
|
add_long("\nChecking logical Disks:")
|
||||||
|
add_summary("%s logicaldisks" % (len(logicaldisks)))
|
||||||
|
for i in logicaldisks:
|
||||||
|
ld_status = check(i, 'Status')
|
||||||
|
status = max(status, ld_status)
|
||||||
|
|
||||||
|
if i.get('Status') == 'Failed':
|
||||||
|
status = max(status, critical)
|
||||||
|
|
||||||
|
mount_point = i['Mount Points']
|
||||||
|
add_long("- %s (%s) = %s" % (i['name'], mount_point, state[ld_status]))
|
||||||
|
add_summary(". ")
|
||||||
|
|
||||||
|
|
||||||
|
def check_physicaldisks():
|
||||||
|
global controllers
|
||||||
|
disktype = 'physicaldisks'
|
||||||
|
if len(controllers) < 1:
|
||||||
|
controllers = run_hpacucli()
|
||||||
|
disks = []
|
||||||
|
for controller in controllers:
|
||||||
|
for disk in run_hpacucli(run_type=disktype, controller=controller):
|
||||||
|
disks.append(disk)
|
||||||
|
status = -1
|
||||||
|
add_long("\nChecking Physical Disks:")
|
||||||
|
add_summary("%s %s" % (len(disks), disktype))
|
||||||
|
for i in disks:
|
||||||
|
disk_status = check(i, 'Status')
|
||||||
|
status = max(status, disk_status)
|
||||||
|
|
||||||
|
size = i['Size']
|
||||||
|
firmware = i['Firmware Revision']
|
||||||
|
interface = i['Interface Type']
|
||||||
|
serial = i['Serial Number']
|
||||||
|
model = i['Model']
|
||||||
|
add_long("- %s, %s, %s = %s" %
|
||||||
|
(i['name'], interface, size, state[disk_status])
|
||||||
|
)
|
||||||
|
if disk_status > ok:
|
||||||
|
error_str = "-- Replace drive, firmware=%s, model=%s, serial=%s"
|
||||||
|
add_long(error_str % (firmware, model, serial))
|
||||||
|
if status > ok:
|
||||||
|
add_summary("(errors)")
|
||||||
|
add_summary(". ")
|
||||||
|
|
||||||
|
|
||||||
|
def check(my_object, field, valid_states=None):
|
||||||
|
if valid_states is None:
|
||||||
|
valid_states = ['OK']
|
||||||
|
state = -1
|
||||||
|
global nagios_status
|
||||||
|
if field in my_object:
|
||||||
|
if my_object[field] in valid_states:
|
||||||
|
state = ok
|
||||||
|
else:
|
||||||
|
state = warning
|
||||||
|
nagios_status = max(nagios_status, state)
|
||||||
|
return state
|
||||||
|
|
||||||
|
|
||||||
|
def parse_arguments():
|
||||||
|
arguments = argv[1:]
|
||||||
|
while len(arguments) > 0:
|
||||||
|
arg = arguments.pop(0)
|
||||||
|
if arg == '--help':
|
||||||
|
print_help()
|
||||||
|
exit(ok)
|
||||||
|
elif arg == '--path':
|
||||||
|
path = arguments.pop(0)
|
||||||
|
set_path(path)
|
||||||
|
elif arg == '--debug':
|
||||||
|
global debugging
|
||||||
|
debugging = True
|
||||||
|
elif arg == '--sudo':
|
||||||
|
global sudo
|
||||||
|
sudo = True
|
||||||
|
else:
|
||||||
|
print_help()
|
||||||
|
exit(unknown)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parse_arguments()
|
||||||
|
set_path('')
|
||||||
|
check_controllers()
|
||||||
|
check_logicaldisks()
|
||||||
|
check_physicaldisks()
|
||||||
|
end()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Summary: A Nagios plugin to check HP Array with hpacucli
|
Summary: A Nagios plugin to check HP Array with hpacucli
|
||||||
Name: nagios-okplugin-check_hpacucli
|
Name: nagios-okplugin-check_hpacucli
|
||||||
Version: 0.0.2
|
Version: 2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
@ -19,6 +19,7 @@ Checks HP Array with hpacucli
|
|||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
perl -pi -e "s|/usr/lib|%{_libdir}|g" nrpe.d/check_hpacucli.cfg
|
perl -pi -e "s|/usr/lib|%{_libdir}|g" nrpe.d/check_hpacucli.cfg
|
||||||
|
perl -pi -e "s|/usr/lib64|%{_libdir}|g" sudoers.d/*
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ perl -pi -e "s|/usr/lib|%{_libdir}|g" nrpe.d/check_hpacucli.cfg
|
|||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
install -D -p -m 0755 check_hpacucli.py %{buildroot}%{_libdir}/nagios/plugins/check_hpacucli.py
|
install -D -p -m 0755 check_hpacucli.py %{buildroot}%{_libdir}/nagios/plugins/check_hpacucli.py
|
||||||
install -D -p -m 0755 nrpe.d/check_hpacucli.cfg %{buildroot}/etc/nrpe.d/check_hpacucli.cfg
|
install -D -p -m 0755 nrpe.d/check_hpacucli.cfg %{buildroot}/etc/nrpe.d/check_hpacucli.cfg
|
||||||
|
install -D -p -m 0440 sudoers.d/check_hpacucli %{buildroot}/etc/sudoers.d/check_hpacucli
|
||||||
|
|
||||||
%clean
|
%clean
|
||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
@ -36,7 +38,28 @@ rm -rf %{buildroot}
|
|||||||
%doc README LICENSE
|
%doc README LICENSE
|
||||||
%{_libdir}/nagios/plugins/*
|
%{_libdir}/nagios/plugins/*
|
||||||
/etc/nrpe.d/check_hpacucli.cfg
|
/etc/nrpe.d/check_hpacucli.cfg
|
||||||
|
/etc/sudoers.d/check_hpacucli
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Feb 20 2014 Pall Sigurdsson <palli@opensource.is> 2-1
|
||||||
|
- check_hpacucli.py - fix typo in hpacucli command (palli@opensource.is)
|
||||||
|
- check_hpacucli.py: pep8 cleanup (palli@opensource.is)
|
||||||
|
- check_hpacucli - fix tab indentation (palli@opensource.is)
|
||||||
|
- check_hpacucli: ignore hpacucli output that starts with "Note:"
|
||||||
|
(palli@opensource.is)
|
||||||
|
- sudoers.d added to install (you@example.com)
|
||||||
|
- dummy commit (you@example.com)
|
||||||
|
- dummy commit (you@example.com)
|
||||||
|
- Add sudoers support to check_hpacucli (palli@opensource.is)
|
||||||
|
|
||||||
|
* Thu Aug 23 2012 Pall Sigurdsson <palli@opensource.is> 1.2-2
|
||||||
|
- version number of scripts bumped (palli@opensource.is)
|
||||||
|
|
||||||
|
* Thu Aug 23 2012 Pall Sigurdsson <palli@opensource.is> 1.2-1
|
||||||
|
- check_command is now sudo'ed (palli@opensource.is)
|
||||||
|
|
||||||
|
* Mon Mar 12 2012 Pall Sigurdsson <palli@opensource.is> 0.0.3-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
* Mon Mar 1 2010 Pall Sigurdsson <palli@opensource.is> 0.1-1
|
* Mon Mar 1 2010 Pall Sigurdsson <palli@opensource.is> 0.1-1
|
||||||
- Initial packaging
|
- Initial packaging
|
2
check_hpacucli/nrpe.d/check_hpacucli.cfg
Normal file
2
check_hpacucli/nrpe.d/check_hpacucli.cfg
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
command[check_hpacucli]=sudo /usr/lib/nagios/plugins/check_hpacucli.py
|
||||||
|
|
2
check_hpacucli/sudoers.d/check_hpacucli
Normal file
2
check_hpacucli/sudoers.d/check_hpacucli
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Defaults:nrpe !requiretty
|
||||||
|
nrpe ALL=(ALL) NOPASSWD: /usr/lib64/nagios/plugins/check_hpacucli.py
|
@ -1,329 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
#
|
|
||||||
# Copyright 2010, Pall Sigurdsson <palli@opensource.is>
|
|
||||||
#
|
|
||||||
# check_hpacucli.py is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# check_hpacucli.py is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# About this script
|
|
||||||
#
|
|
||||||
# This script will check the status of Smart Array Raid Controller
|
|
||||||
# You will need the hpacucli binary in path (/usr/sbin/hpacucli is a good place)
|
|
||||||
# hpacucli comes with the Proliant Support Pack (PSP) from HP
|
|
||||||
|
|
||||||
debugging = False
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# No real need to change anything below here
|
|
||||||
version="1.0"
|
|
||||||
ok=0
|
|
||||||
warning=1
|
|
||||||
critical=2
|
|
||||||
unknown=3
|
|
||||||
not_present = -1
|
|
||||||
nagios_status = -1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
state = {}
|
|
||||||
state[not_present] = "Not Present"
|
|
||||||
state[ok] = "OK"
|
|
||||||
state[warning] = "Warning"
|
|
||||||
state[critical] = "Critical"
|
|
||||||
state[unknown] = "Unknown"
|
|
||||||
|
|
||||||
|
|
||||||
longserviceoutput="\n"
|
|
||||||
perfdata=""
|
|
||||||
summary=""
|
|
||||||
sudo=False
|
|
||||||
|
|
||||||
|
|
||||||
from sys import exit
|
|
||||||
from sys import argv
|
|
||||||
from os import getenv,putenv,environ
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def print_help():
|
|
||||||
print "check_hpacucli version %s" % version
|
|
||||||
print "This plugin checks HP Array with the hpacucli command"
|
|
||||||
print ""
|
|
||||||
print "Usage: %s " % argv[0]
|
|
||||||
print "Usage: %s [--help]" % argv[0]
|
|
||||||
print "Usage: %s [--version]" % argv[0]
|
|
||||||
print "Usage: %s [--path </path/to/hpacucli>]" % argv[0]
|
|
||||||
print "Usage: %s [--no-perfdata]" % argv[0]
|
|
||||||
print "Usage: %s [--no-longoutput]" % argv[0]
|
|
||||||
print ""
|
|
||||||
|
|
||||||
|
|
||||||
def error(errortext):
|
|
||||||
print "* Error: %s" % errortext
|
|
||||||
print_help()
|
|
||||||
print "* Error: %s" % errortext
|
|
||||||
exit(unknown)
|
|
||||||
|
|
||||||
def debug( debugtext ):
|
|
||||||
global debugging
|
|
||||||
if debugging:
|
|
||||||
print debugtext
|
|
||||||
|
|
||||||
|
|
||||||
'''runCommand: Runs command from the shell prompt. Exit Nagios style if unsuccessful'''
|
|
||||||
def runCommand(command):
|
|
||||||
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE,)
|
|
||||||
stdout, stderr = proc.communicate('through stdin to stdout')
|
|
||||||
if proc.returncode > 0:
|
|
||||||
print "Error %s: %s\n command was: '%s'" % (proc.returncode,stderr.strip(),command)
|
|
||||||
debug("results: %s" % (stdout.strip() ) )
|
|
||||||
if proc.returncode == 127: # File not found, lets print path
|
|
||||||
path=getenv("PATH")
|
|
||||||
print "Check if your path is correct %s" % (path)
|
|
||||||
if stderr.find('Password:') == 0 and command.find('sudo') == 0:
|
|
||||||
print "Check if user is in the sudoers file"
|
|
||||||
if stderr.find('sorry, you must have a tty to run sudo') == 0 and command.find('sudo') == 0:
|
|
||||||
print "Please remove 'requiretty' from /etc/sudoers"
|
|
||||||
exit(unknown)
|
|
||||||
else:
|
|
||||||
return stdout
|
|
||||||
|
|
||||||
def end():
|
|
||||||
global summary
|
|
||||||
global longserviceoutput
|
|
||||||
global perfdata
|
|
||||||
global nagios_status
|
|
||||||
print "%s - %s | %s" % (state[nagios_status], summary,perfdata)
|
|
||||||
print longserviceoutput
|
|
||||||
if nagios_status < 0: nagios_status = unknown
|
|
||||||
exit(nagios_status)
|
|
||||||
|
|
||||||
def add_perfdata(text):
|
|
||||||
global perfdata
|
|
||||||
text = text.strip()
|
|
||||||
perfdata = perfdata + " %s " % (text)
|
|
||||||
|
|
||||||
def add_long(text):
|
|
||||||
global longserviceoutput
|
|
||||||
longserviceoutput = longserviceoutput + text + '\n'
|
|
||||||
|
|
||||||
def add_summary(text):
|
|
||||||
global summary
|
|
||||||
summary = summary + text
|
|
||||||
|
|
||||||
def set_path(path):
|
|
||||||
current_path = getenv('PATH')
|
|
||||||
if current_path.find('C:\\') > -1: # We are on this platform
|
|
||||||
if path == '':
|
|
||||||
path = ";C:\Program Files\Hewlett-Packard\Sanworks\Element Manager for StorageWorks HSV"
|
|
||||||
path = path + ";C:\Program Files (x86)\Compaq\Hpacucli\Bin"
|
|
||||||
path = path + ";C:\Program Files\Compaq\Hpacucli\Bin"
|
|
||||||
else: path = ';' + path
|
|
||||||
else: # Unix/Linux, etc
|
|
||||||
if path == '': path = ":/usr/sbin"
|
|
||||||
else: path = ':' + path
|
|
||||||
current_path = "%s%s" % (current_path,path)
|
|
||||||
environ['PATH'] = current_path
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run_hpacucli(type='controllers', controller=None):
|
|
||||||
if type=='controllers':
|
|
||||||
command="hpacucli controller all show detail"
|
|
||||||
elif type=='logicaldisks' or type=='physicaldisks':
|
|
||||||
if controller.has_key('Slot'):
|
|
||||||
identifier = 'slot=%s' % (controller['Slot'] )
|
|
||||||
else:
|
|
||||||
add_summary( "Controller not found" )
|
|
||||||
end()
|
|
||||||
if type=='logicaldisks':
|
|
||||||
command = "hpacucli controller %s ld all show detail" % (identifier)
|
|
||||||
if type=='physicaldisks':
|
|
||||||
command = "hpacucli controller %s pd all show detail" % (identifier)
|
|
||||||
|
|
||||||
#command="hpacucli controller slot=1 ld all show detail"
|
|
||||||
#command="hpacucli controller slot=1 ld all show detail"
|
|
||||||
debug ( command )
|
|
||||||
if sudo: command = "sudo " + command
|
|
||||||
output = runCommand(command)
|
|
||||||
# Some basic error checking
|
|
||||||
error_strings = [ 'Permission denied' ]
|
|
||||||
error_strings.append('Error: You need to have administrator rights to continue.')
|
|
||||||
for error in error_strings:
|
|
||||||
if output.find( error ) > -1 and output.find("sudo") != 0:
|
|
||||||
command = "sudo " + command
|
|
||||||
print command
|
|
||||||
output = runCommand(command)
|
|
||||||
output = output.split('\n')
|
|
||||||
objects = []
|
|
||||||
object = None
|
|
||||||
for i in output:
|
|
||||||
if len(i) == 0: continue
|
|
||||||
if i.strip() == '': continue
|
|
||||||
if type=='controllers' and i[0] != ' ': # No space on first line
|
|
||||||
if object and not object in objects: objects.append(object)
|
|
||||||
object = {}
|
|
||||||
object['name'] = i
|
|
||||||
elif type=='logicaldisks' and i.find('Logical Drive:') > 0:
|
|
||||||
if object and not object in objects: objects.append(object)
|
|
||||||
object = {}
|
|
||||||
object['name'] = i.strip()
|
|
||||||
elif type=='physicaldisks' and i.find('physicaldrive') > 0:
|
|
||||||
if object and not object in objects: objects.append(object)
|
|
||||||
object = {}
|
|
||||||
object['name'] = i.strip()
|
|
||||||
else:
|
|
||||||
i = i.strip()
|
|
||||||
if i.find(':') < 1: continue
|
|
||||||
i = i.split(':')
|
|
||||||
if i[0] == '': continue # skip empty lines
|
|
||||||
if len(i) == 1: continue
|
|
||||||
key = i[0].strip()
|
|
||||||
value = ' '.join( i[1:] ).strip()
|
|
||||||
object[key] = value
|
|
||||||
if object and not object in objects: objects.append(object)
|
|
||||||
return objects
|
|
||||||
|
|
||||||
controllers = []
|
|
||||||
def check_controllers():
|
|
||||||
global controllers
|
|
||||||
status = -1
|
|
||||||
controllers = run_hpacucli()
|
|
||||||
if len(controllers) == 0:
|
|
||||||
add_summary("No Disk Controllers Found. Exiting...")
|
|
||||||
global nagios_state
|
|
||||||
nagios_state = unknown
|
|
||||||
end()
|
|
||||||
add_summary( "Found %s controllers" % ( len(controllers) ) )
|
|
||||||
for i in controllers:
|
|
||||||
controller_status = check(i, 'Controller Status', 'OK' )
|
|
||||||
status = max(status, controller_status)
|
|
||||||
|
|
||||||
cache_status = check(i, 'Cache Status' )
|
|
||||||
status = max(status, cache_status)
|
|
||||||
|
|
||||||
controller_serial = 'n/a'
|
|
||||||
cache_serial = 'n/a'
|
|
||||||
if i.has_key('Serial Number'):
|
|
||||||
controller_serial = i['Serial Number']
|
|
||||||
if i.has_key('Cache Serial Number'):
|
|
||||||
cache_serial = i['Cache Serial Number']
|
|
||||||
add_long ( "%s" % (i['name']) )
|
|
||||||
add_long( "- Controller Status: %s (sn: %s)" % ( state[controller_status], controller_serial ) )
|
|
||||||
add_long( "- Cache Status: %s (sn: %s)" % ( state[cache_status], cache_serial ) )
|
|
||||||
|
|
||||||
if controller_status > ok or cache_status > ok:
|
|
||||||
add_summary( ";%s on %s;" % (state[controller_status], i['name']) )
|
|
||||||
|
|
||||||
add_summary(', ')
|
|
||||||
return status
|
|
||||||
|
|
||||||
|
|
||||||
def check_logicaldisks():
|
|
||||||
global controllers
|
|
||||||
if len(controllers) < 1:
|
|
||||||
controllers = run_hpacucli()
|
|
||||||
logicaldisks = []
|
|
||||||
for controller in controllers:
|
|
||||||
for ld in run_hpacucli(type='logicaldisks', controller=controller):
|
|
||||||
logicaldisks.append ( ld )
|
|
||||||
status = -1
|
|
||||||
add_long("\nChecking logical Disks:" )
|
|
||||||
add_summary( "%s logicaldisks" % ( len(logicaldisks) ) )
|
|
||||||
for i in logicaldisks:
|
|
||||||
ld_status = check(i, 'Status' )
|
|
||||||
status = max(status, ld_status)
|
|
||||||
|
|
||||||
mount_point = i['Mount Points']
|
|
||||||
add_long( "- %s (%s) = %s" % (i['name'], mount_point, state[ld_status]) )
|
|
||||||
add_summary(". ")
|
|
||||||
|
|
||||||
def check_physicaldisks():
|
|
||||||
global controllers
|
|
||||||
disktype='physicaldisks'
|
|
||||||
if len(controllers) < 1:
|
|
||||||
controllers = run_hpacucli()
|
|
||||||
disks = []
|
|
||||||
for controller in controllers:
|
|
||||||
for disk in run_hpacucli(type=disktype, controller=controller):
|
|
||||||
disks.append ( disk )
|
|
||||||
status = -1
|
|
||||||
add_long("\nChecking Physical Disks:" )
|
|
||||||
add_summary( "%s %s" % ( len(disks), disktype ) )
|
|
||||||
for i in disks:
|
|
||||||
disk_status = check(i, 'Status' )
|
|
||||||
status = max(status, disk_status)
|
|
||||||
|
|
||||||
size = i['Size']
|
|
||||||
firmware = i['Firmware Revision']
|
|
||||||
interface = i['Interface Type']
|
|
||||||
serial = i['Serial Number']
|
|
||||||
model = i['Model']
|
|
||||||
add_long( "- %s, %s, %s = %s" % (i['name'], interface, size, state[disk_status]) )
|
|
||||||
if disk_status > ok:
|
|
||||||
add_long( "-- Replace drive, firmware=%s, model=%s, serial=%s" % (firmware,model, serial))
|
|
||||||
if status > ok:
|
|
||||||
add_summary( "(errors)" )
|
|
||||||
add_summary(". ")
|
|
||||||
|
|
||||||
|
|
||||||
def check(object, field, valid_states = ['OK']):
|
|
||||||
state = -1
|
|
||||||
global nagios_status
|
|
||||||
if object.has_key(field):
|
|
||||||
if object[field] in valid_states:
|
|
||||||
state = ok
|
|
||||||
else:
|
|
||||||
state = warning
|
|
||||||
nagios_status = max(nagios_status, state)
|
|
||||||
return state
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
|
||||||
arguments = argv[1:]
|
|
||||||
while len(arguments) > 0:
|
|
||||||
arg = arguments.pop(0)
|
|
||||||
if arg == '--help':
|
|
||||||
print_help()
|
|
||||||
exit(ok)
|
|
||||||
elif arg == '--path':
|
|
||||||
path = arguments.pop(0)
|
|
||||||
set_path(path)
|
|
||||||
elif arg == '--debug':
|
|
||||||
global debugging
|
|
||||||
debugging = True
|
|
||||||
elif arg == '--sudo':
|
|
||||||
global sudo
|
|
||||||
sudo = True
|
|
||||||
else:
|
|
||||||
print_help()
|
|
||||||
exit(unknown)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parse_arguments()
|
|
||||||
set_path('')
|
|
||||||
check_controllers()
|
|
||||||
check_logicaldisks()
|
|
||||||
check_physicaldisks()
|
|
||||||
end()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
@ -1,2 +0,0 @@
|
|||||||
command[check_hpacucli]=/usr/lib/nagios/plugins/check_hpacucli.py
|
|
||||||
|
|
@ -81,7 +81,7 @@ check_raid()
|
|||||||
{
|
{
|
||||||
raid_ok=`cat $TEMPFILE |grep -i ok|wc -l`
|
raid_ok=`cat $TEMPFILE |grep -i ok|wc -l`
|
||||||
raid_warning=`cat $TEMPFILE|grep -i -E 'rebuild|predictive' |wc -l`
|
raid_warning=`cat $TEMPFILE|grep -i -E 'rebuild|predictive' |wc -l`
|
||||||
raid_critical_1=`cat $TEMPFILE|grep -i 'failed|recovery' | wc -l`
|
raid_critical_1=`cat $TEMPFILE|grep -i -E 'failed|recovery' | wc -l`
|
||||||
|
|
||||||
err_check=`expr $raid_ok + $raid_warning + $raid_critical_1 `
|
err_check=`expr $raid_ok + $raid_warning + $raid_critical_1 `
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ case "$1" in
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--all)
|
--all)
|
||||||
controllers=`sudo -u root hpacucli controller all show | sed 's/.*Slot \([0-9]*\).*/\1/'`
|
controllers=`sudo -u root $HPACUCLI controller all show | sed 's/.*Slot \([0-9]*\).*/\1/'`
|
||||||
for i in $controllers ; do sudo -u root $HPACUCLI controller slot=$i pd all show status;done > $TEMPFILE
|
for i in $controllers ; do sudo -u root $HPACUCLI controller slot=$i pd all show status;done > $TEMPFILE
|
||||||
check_raid
|
check_raid
|
||||||
;;
|
;;
|
55
check_hpasm/nagios-okplugin-check_hpasm.spec
Normal file
55
check_hpasm/nagios-okplugin-check_hpasm.spec
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
%define debug_package %{nil}
|
||||||
|
|
||||||
|
Summary: A Nagios plugin to check HP Hardware Status
|
||||||
|
Name: nagios-okplugin-check_hpasm
|
||||||
|
Version: 4.1.4
|
||||||
|
Release: 1%{?dist}
|
||||||
|
License: GPLv2+
|
||||||
|
Group: Applications/System
|
||||||
|
URL: http://opensource.is/trac/wiki/check_hpasm
|
||||||
|
Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_hpasm/releases/nagios-okplugin-check_hpasm-%{version}.tar.gz
|
||||||
|
Requires: nagios-okconfig-nrpe
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
|
Packager: Pall Sigurdsson <palli@opensource.is>
|
||||||
|
BuildArch: noarch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%description
|
||||||
|
A Nagios plugin to check HP Hardware Status
|
||||||
|
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
|
||||||
|
%build
|
||||||
|
perl -pi -e "s|/usr/lib|%{_libdir}|g" sudoers.d/check_hpasm
|
||||||
|
perl -pi -e "s|/usr/lib|%{_libdir}|g" nrpe.d/check_hpasm.cfg
|
||||||
|
|
||||||
|
%install
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
install -D -p -m 0755 check_hpasm %{buildroot}%{_libdir}/nagios/plugins/check_hpasm
|
||||||
|
install -D -p -m 0440 sudoers.d/check_hpasm %{buildroot}/etc/sudoers.d/check_hpasm
|
||||||
|
install -D -p -m 0644 nrpe.d/check_hpasm.cfg %{buildroot}/etc/nrpe.d/check_hpasm.cfg
|
||||||
|
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %{buildroot}
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root,-)
|
||||||
|
#%doc README LICENSE
|
||||||
|
#%{_libdir}/nagios/plugins/*
|
||||||
|
%{_libdir}/nagios/plugins/check_hpasm
|
||||||
|
/etc/sudoers.d/check_hpasm
|
||||||
|
/etc/nrpe.d/check_hpasm.cfg
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Fri Oct 03 2014 Tomas Edwardsson <tommi@tommi.org> 4.1.4-1
|
||||||
|
- hpasm invalid nrpe check command name (tommi@tommi.org)
|
||||||
|
|
||||||
|
* Thu May 15 2014 Tomas Edwardsson <tommi@tommi.org> 4.1.3-1
|
||||||
|
- new package built with tito
|
||||||
|
|
||||||
|
* Tue Jun 4 2013 Pall Sigurdsson <palli@opensource.is> 4.1.2-1
|
||||||
|
- Initial packaging
|
3
check_hpasm/nrpe.d/check_hpasm.cfg
Normal file
3
check_hpasm/nrpe.d/check_hpasm.cfg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
command[check_hpasm]=sudo /usr/lib/nagios/plugins/check_hpasm
|
2
check_hpasm/sudoers.d/check_hpasm
Normal file
2
check_hpasm/sudoers.d/check_hpasm
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Defaults:nrpe !requiretty
|
||||||
|
nrpe ALL = (root) NOPASSWD: /usr/lib/nagios/plugins/check_hpasm
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user