| 1 |
# /usr/bin/perl -w |
| 2 |
|
| 3 |
use strict; |
| 4 |
no warnings qw(once); |
| 5 |
|
| 6 |
if ( ! grep /BEGIN/, keys %Monitoring::GLPlugin::) { |
| 7 |
eval { |
| 8 |
require Monitoring::GLPlugin; |
| 9 |
require Monitoring::GLPlugin::SNMP; |
| 10 |
require Monitoring::GLPlugin::UPNP; |
| 11 |
}; |
| 12 |
if ($@) { |
| 13 |
printf "UNKNOWN - module Monitoring::GLPlugin was not found. Either build a standalone version of this plugin or set PERL5LIB\n"; |
| 14 |
printf "%s\n", $@; |
| 15 |
exit 3; |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
my $plugin = Classes::Device->new( |
| 20 |
shortname => '', |
| 21 |
usage => 'Usage: %s [ -v|--verbose ] [ -t <timeout> ] '. |
| 22 |
'--mode <what-to-do> '. |
| 23 |
'--hostname <network-component> --community <snmp-community>'. |
| 24 |
' ...]', |
| 25 |
version => '$Revision: #PACKAGE_VERSION# $', |
| 26 |
blurb => 'This plugin checks various parameters of network printers ', |
| 27 |
url => 'http://labs.consol.de/nagios/check_printer_health', |
| 28 |
timeout => 60, |
| 29 |
plugin => $Monitoring::GLPlugin::pluginname, |
| 30 |
); |
| 31 |
$plugin->add_mode( |
| 32 |
internal => 'device::hardware::health', |
| 33 |
spec => 'hardware-health', |
| 34 |
alias => undef, |
| 35 |
help => 'Check the status of hardware, if printing is possible', |
| 36 |
); |
| 37 |
$plugin->add_mode( |
| 38 |
internal => 'device::printer::consumables', |
| 39 |
spec => 'supplies-status', |
| 40 |
help => 'Check the availability of consumables (toner, ink, ...)', |
| 41 |
); |
| 42 |
$plugin->add_snmp_modes(); |
| 43 |
$plugin->add_snmp_args(); |
| 44 |
$plugin->add_default_args(); |
| 45 |
$plugin->mod_arg("name", |
| 46 |
help => "--name |
| 47 |
The name of an interface (ifDescr) or pool or ...", |
| 48 |
); |
| 49 |
|
| 50 |
$plugin->getopts(); |
| 51 |
$plugin->classify(); |
| 52 |
$plugin->validate_args(); |
| 53 |
|
| 54 |
if (! $plugin->check_messages()) { |
| 55 |
$plugin->init(); |
| 56 |
if (! $plugin->check_messages()) { |
| 57 |
$plugin->add_ok($plugin->get_summary()) |
| 58 |
if $plugin->get_summary(); |
| 59 |
$plugin->add_ok($plugin->get_extendedinfo(" ")) |
| 60 |
if $plugin->get_extendedinfo(); |
| 61 |
} |
| 62 |
} elsif ($plugin->opts->snmpwalk && $plugin->opts->offline) { |
| 63 |
; |
| 64 |
} else { |
| 65 |
; |
| 66 |
} |
| 67 |
my ($code, $message) = $plugin->opts->multiline ? |
| 68 |
$plugin->check_messages(join => "\n", join_all => ', ') : |
| 69 |
$plugin->check_messages(join => ', ', join_all => ', '); |
| 70 |
$message .= sprintf "\n%s\n", $plugin->get_info("\n") |
| 71 |
if $plugin->opts->verbose >= 1; |
| 72 |
|
| 73 |
$plugin->nagios_exit($code, $message); |