Hp JetDirect Page count...

Subhendu Ghosh sghosh at sghosh.org
Tue Jun 24 17:57:19 CEST 2003


added simple exit status to make it work as plugin...

--start of plugin
#!/usr/bin/perl
# vi: set sw=4 ts=4:
#
use IO;
$ipaddress = $ARGV[0];
my $sock = IO::Socket::INET->new(
                                PeerAddr => $ipaddress,
                                PeerPort => 9100,
                                Proto    => 'tcp'
                                )
        || die "Impossibile connettersi a $ipaddress, porta 9100: $!\n";
 
my $eol="\x0A"; # LF
my $esc="\x1B"; # ESC
my $pagecount="$esc\%-12345X\@PJL JOB$eol"
                    . "\@PJL INFO PAGECOUNT$eol"
                    . "\@PJL EOJ$eol"
                    . "$esc\%-12345X";
my $dati;
$sock->send("$pagecount");
$sock->recv($dati, 1024);
close $sock;
#print "Output:\n$dati\n";

@lines = split("\n", $dati);
foreach $line (@lines) {

	if ($line =~ /PAGECOUNT=/ ) {
		($p, $count) = split ("=",$line);
	}	
}

if (defined $count) {
	print "OK: pagecount=$count\n";
	exit 0;
}else{
	print "UNKNOWN: Could not get pagecount\n";
	exit 3;
}

exit 4;


---end of plugin

















On Tue, 24 Jun 2003, Federico De Marchi wrote:

> Anyone have maked a plugin for have the count
> of the pages?
> i have found this code, but i'm unable to pilot the code....
> ---------begin perl code----------------------
> #!/usr/bin/perl
> # vi: set sw=4 ts=4:
> #
> use IO;
> $ipaddress = $ARGV[0];
> my $sock = IO::Socket::INET->new(
>                                 PeerAddr => $ipaddress,
>                                 PeerPort => 9100,
>                                 Proto    => 'tcp'
>                                 )
>         || die "Impossibile connettersi a $ipaddress, porta 9100: $!\n";
>  
> my $eol="\x0A"; # LF
> my $esc="\x1B"; # ESC
> my $pagecount="$esc\%-12345X\@PJL JOB$eol"
>                     . "\@PJL INFO PAGECOUNT$eol"
>                     . "\@PJL EOJ$eol"
>                     . "$esc\%-12345X";
> my $dati;
> $sock->send("$pagecount");
> $sock->recv($dati, 1024);
> close $sock;
> print "Output:\n$dati\n";
> -------------end perl code----------------
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null
> 

-- 




-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list