i very problem to use this script
http://www.koders.com/perl/fid631F219FF353175BA5F08985533642B5F8B427FD.aspx
#!/usr/local/bin/perl -w
# check_snmp_printer - check for printer status via snmp
# Supports both standard PRINT-MIB (RFC-1759) and HP Enterprise print-mib
# that is supported by some of the older JetDirect interfaces
# Acknowledgements:
# the JetDirect code is taken from check_hpjd.c by Ethan Galstad
#
# The idea for the plugin (as well as some code) were taken from Jim
# Trocki's pinter alert script in his mon utility, found at
# http://www.kernel.org/software/mon
#
# Notes:
# 'JetDirect' is copyrighted by Hewlett-Packard
#
#
# License Information:
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# TODO: Query HOST-RESOURCE MIB for a quick status
#
# hrPrinterStatus = .1.3.6.1.2.1.25.3.5.1;
# hrPrinterDetectedErrorState = .1.3.6.1.2.1.25.3.5.1.2
#
# hrPrinterStatus OBJECT-TYPE
#SYNTAX INTEGER {
# other(1),
# unknown(2),
# idle(3),
# printing(4),
# warmup(5)
# }
#
# hrPrinterDetectedErrorState OBJECT-TYPE
#SYNTAX OCTET STRING
#MAX-ACCESS read-only
#STATUS current
#DESCRIPTION
#This object represents any error conditions detected
#by the printer. The error conditions are encoded as
#bits in an octet string, with the following
#definitions:
#
# Condition Bit #
#
# lowPaper 0
#
# noPaper 1
# lowToner 2
# noToner 3
# doorOpen 4
# jammed5
# offline 6
# serviceRequested 7
# inputTrayMissing 8
# outputTrayMissing 9
# markerSupplyMissing 10
# outputNearFull 11
# outputFull 12
# inputTrayEmpty 13
# overduePreventMaint 14
#
#
#
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_H $opt_P $opt_t $opt_d $session $error
$answer
$key
$response $PROGNAME $port $hostname );
use lib utils.pm;
use utils qw(%ERRORS print_revision support usage );
use Net::SNMP;
sub print_help ();
sub print_usage ();
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
# defaults
my $ptype = 1; # to
standard
RFC printer type
my $state = $ERRORS{'UNKNOWN'};
my $community = public;
my $snmp_version = 1;
my $port = 161;
Getopt::Long::Configure('bundling');
GetOptions
(d = \$opt_d, debug = \$opt_d,
V = \$opt_V, version= \$opt_V,
P=s = \$opt_P, Printer=s = \$opt_P,# printer type -
HP
or RFC
v=i = \$snmp_version, snmp_version=i = \$snmp_version,
p=i = \$port, port=i = \$port,
C=s = \$community,community=s = \$community,
h = \$opt_h, help = \$opt_h,
H=s = \$opt_H, hostname=s = \$opt_H);
$PROGNAME = check_snmp_printer;
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.1 $');
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
unless (defined $opt_H) {
print No target hostname specified\n;
exit $ERRORS{UNKNOWN};
}
$hostname = $opt_H;
if (! utils::is_hostname($hostname)){
usage( $hostname did not match pattern\n);
exit $ERRORS{UNKNOWN};
}
if (defined $opt_P) {
if ($opt_P eq HP ) {
$ptype = 2;
}elsif ($opt_P eq RFC ) {
$ptype = 1;
}else{
print Only \HP\ and \RFC\ are supported as printer
options
at this time.\n;
exit $ERRORS{UNKNOWN};
}
}
if ( $snmp_version =~ /[12]/ ) {
($session, $error) = Net::SNMP-session(
-hostname = $hostname,
-community = $community,
-port = $port,
-version = $snmp_version
);
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ($state: no session -