E710

From timswiki
Jump to: navigation, search

HP E710 Munin plugins

The following Munin plugins support the reporting of statistics for HP e710 series printers.

With later devices HP has removed some of the useful SNMP accessible OIDs and moved to an XML based approach. Whilst more flexible this requires additional steps to make the information available via Munin plugins.


HP E710 Cron Job

First it is necessary to create a cron-job which runs to query the printer at specific intervals. The munin plugins are then much simpler and simply cat the pre-fetched results.

In crontab enter a line similar to:

17 * * * * /usr/local/scripts/munin/printer-cron 2>&1

The cron script is shown below.

#!/bin/bash
# Adjust as required
STATEDIR=/var/lib/munin/plugin-state
# Assumes scripts are all stored in a munin directory under ${SCRIPTS}
SCRIPTS=/usr/local/scripts
PRINTER=192.168.1.7
#----------------------------------------------
INK=${STATEDIR}/e710_ink.state
PAGES=${STATEDIR}/e710_pages.state
COPIES=${STATEDIR}/e710_copies.state
SCANS=${STATEDIR}/e710_scans.state

/bin/ping -c 3 ${PRINTER} >/dev/null 2>&1

/bin/mv -f ${INK} ${INK}.bak
/usr/bin/touch ${INK}
RC=-1
ATTEMPT=0
while [[ ! -s "${INK}" && "${ATTEMPT}" -lt "4" ]]; do
        ATTEMPT=$((ATTEMPT + 1))
        /usr/bin/perl ${SCRIPTS}/munin/printer_ink.pl > ${INK}
        if [[ ! -s "${INK}" ]] ; then
                /bin/sleep 5
        fi
done
if [[ "$ATTEMPT" -gt "1" ]] ; then
        echo "INK exited after attempt = "${ATTEMPT}
fi
if [[ ! -s "${INK}"  && -s "${INK}.bak" ]] ; then
        /bin/mv -f ${INK}.bak ${INK}
else
        /bin/rm -f ${INK}.bak
fi

/bin/mv -f ${PAGES} ${PAGES}.bak
/usr/bin/touch ${PAGES}
RC=-1
ATTEMPT=0
while [[ ! -s "${PAGES}" && "${ATTEMPT}" -lt "4" ]]; do
        ATTEMPT=$((ATTEMPT + 1))
        /usr/bin/perl ${SCRIPTS}/munin/printer_pages.pl > ${PAGES}
        if [[ ! -s "${PAGES}" ]] ; then
                /bin/sleep 5
        fi
done
if [[ "$ATTEMPT" -gt "1" ]] ; then
        echo "PAGES exited after attempt = "${ATTEMPT}
fi
if [[ ! -s "${PAGES}"  && -s "${PAGES}.bak" ]] ; then
        /bin/mv -f ${PAGES}.bak ${PAGES}
else
        /bin/rm -f ${PAGES}.bak
fi

/bin/mv -f ${COPIES} ${COPIES}.bak
/usr/bin/touch ${COPIES}
RC=-1
ATTEMPT=0
while [[ ! -s "${COPIES}" && "${ATTEMPT}" -lt "4" ]]; do
        ATTEMPT=$((ATTEMPT + 1))
        /usr/bin/perl ${SCRIPTS}/munin/printer_copies.pl > ${COPIES}
        if [[ ! -s "${COPIES}" ]] ; then
                /bin/sleep 5
        fi
done
if [[ "$ATTEMPT" -gt "1" ]] ; then
        echo "COPIES exited after attempt = "${ATTEMPT}
fi
if [[ ! -s "${COPIES}"  && -s "${COPIES}.bak" ]] ; then
        /bin/mv -f ${COPIES}.bak ${COPIES}
else
        /bin/rm -f ${COPIES}.bak
fi

/bin/mv -f ${SCANS} ${SCANS}.bak
/usr/bin/touch ${SCANS}
RC=-1
ATTEMPT=0
while [[ ! -s "${SCANS}" && "${ATTEMPT}" -lt "4" ]]; do
        ATTEMPT=$((ATTEMPT + 1))
        /usr/bin/perl ${SCRIPTS}/munin/printer_scan.pl > ${SCANS}
        if [[ ! -s "${SCANS}" ]] ; then
                /bin/sleep 5
        fi
done
if [[ "$ATTEMPT" -gt "1" ]] ; then
        echo "SCANS exited after attempt = "${ATTEMPT}
fi
if [[ ! -s "${SCANS}"  && -s "${SCANS}.bak" ]] ; then
        /bin/mv -f ${SCANS}.bak ${SCANS}
else
        /bin/rm -f ${SCANS}.bak
fi

HP e710 PERL scripts

printer_ink.pl - change the $printer variable to refer to your printer - replace hp710 with either an IP address or your actual DNS name. Once you have modified and saved the script ensure that it runs successfully standalone before proceeding.

#!/usr/bin/perl
use LWP::UserAgent;
use XML::Simple;
use Data::Dumper;
my $printer = "hp710";
my $url = 'http://'.$printer.'/DevMgmt/ConsumableConfigDyn.xml';
my $ua = new LWP::UserAgent;
$ua->timeout(30);
$ua->agent('Mozilla/5.0');
#$ua->proxy('http','http://localhost:3128/');
my $request = new HTTP::Request('GET', $url);
my $response = $ua->request($request);
my $Response = $response->content;
die "Failed get $url" unless defined $Response;
my $xml = new XML::Simple;
my $data = $xml->XMLin($Response);
my $type = $data->{'ccdyn:ConsumableInfo'};
foreach my $item (@$type)
{
        # print "item = $item :\n";
        if ($item->{'dd:ConsumableTypeEnum'} eq 'ink')
        {
                my $colour = $item->{'dd:ConsumableLabelCode'};
                my $remaining = $item->{'dd:ConsumablePercentageLevelRemaining'};
                my $realcolour = '';
                if    ($colour =~ /C/) { $realcolour = 'cyan'; }
                elsif ($colour =~ /M/) { $realcolour = 'magenta'; }
                elsif ($colour =~ /Y/) { $realcolour = 'yellow'; }
                elsif ($colour =~ /K/) { $realcolour = 'black'; }
                else                   { $realcolour = 'bad things:'.$colour; }
                printf("%s.value %d\n", $realcolour, $remaining);
        }
}

printer_copies.pl - change the $printer variable to refer to your printer - replace hp710 with either an IP address or your actual DNS name. Once you have modified and saved the script ensure that it runs successfully standalone before proceeding.

#!/usr/bin/perl
use LWP::UserAgent;
use XML::Simple;
use Data::Dumper;
my $printer = 'hp710';
my $url = 'http://'.$printer.'/DevMgmt/ProductUsageDyn.xml';

my $ua = new LWP::UserAgent;
$ua->agent('Mozilla/5.0');
$ua->timeout(30);
#$ua->proxy('http','http://localhost:3128/');
my $request = new HTTP::Request('GET', $url);
my $response = $ua->request($request);
my $Response = $response->content;
die "Failed get $url" unless defined $Response;

my $xml = new XML::Simple;
my $data = $xml->XMLin($Response);
#print Dumper($data);
#my $type = $data->{'pudyn:PrinterSubunit'};
my $totalcopies =  $data->{'pudyn:CopyApplicationSubunit'}->{'dd:TotalImpressions'}->{'content'};
print "totalcopies.value ",$totalcopies,"\n";
my $bwcopies =  $data->{'pudyn:CopyApplicationSubunit'}->{'dd:MonochromeImpressions'}->{'content'};
print "bwcopies.value ",$bwcopies,"\n";
my $colourcopies =  $data->{'pudyn:CopyApplicationSubunit'}->{'dd:ColorImpressions'}->{'content'};
print "colourcopies.value ",$colourcopies,"\n";
my $flatbedcopies =  $data->{'pudyn:CopyApplicationSubunit'}->{'dd:FlatbedImages'};
print "flatbedcopies.value ",$flatbedcopies,"\n";
my $adfcopies =  $data->{'pudyn:CopyApplicationSubunit'}->{'dd:AdfImages'}->{'content'};
print "adfcopies.value ",$adfcopies,"\n";
exit(0);
foreach my $item (@$type)
{
        # print "item = $item :\n";
        my $totalpages =  $item->{'dd:TotalImpressions'};
}


printer_pages.pl - change the $printer variable to refer to your printer - replace hp710 with either an IP address or your actual DNS name. Once you have modified and saved the script ensure that it runs successfully standalone before proceeding.

#!/usr/bin/perl
use LWP::UserAgent;
use XML::Simple;
use Data::Dumper;
my $printer = 'hp710';
my $url = 'http://'.$printer.'/DevMgmt/ProductUsageDyn.xml';

my $ua = new LWP::UserAgent;
$ua->agent('Mozilla/5.0');
$ua->timeout(30);
# $ua->proxy('http','http://localhost:3128/');
my $request = new HTTP::Request('GET', $url);
my $response = $ua->request($request);
my $Response = $response->content;
die "Failed get $url" unless defined $Response;

my $xml = new XML::Simple;
my $data = $xml->XMLin($Response);
#print Dumper($data);
#my $type = $data->{'pudyn:PrinterSubunit'};
my $totalpages =  $data->{'pudyn:PrinterSubunit'}->{'dd:TotalImpressions'}->{'content'};
print "totalpages.value ",$totalpages,"\n";
my $bwpages =  $data->{'pudyn:PrinterSubunit'}->{'dd:MonochromeImpressions'}->{'content'};
print "monochromepages.value ",$bwpages,"\n";
my $colourpages =  $data->{'pudyn:PrinterSubunit'}->{'dd:ColorImpressions'}->{'content'};
print "colourpages.value ",$colourpages,"\n";
my $simplexpages =  $data->{'pudyn:PrinterSubunit'}->{'dd:SimplexSheets'};
print "simplexpages.value ",$simplexpages,"\n";
my $duplexpages =  $data->{'pudyn:PrinterSubunit'}->{'dd:DuplexSheets'}->{'content'};
print "duplexpages.value ",$duplexpages,"\n";
my $jampages =  $data->{'pudyn:PrinterSubunit'}->{'dd:JamEvents'}->{'content'};
print "jampages.value ",$jampages,"\n";
my $mispickpages =  $data->{'pudyn:PrinterSubunit'}->{'dd:MispickEvents'}->{'content'};
print "mispickpages.value ",$mispickpages,"\n";
exit(0);
foreach my $item (@$type)
{
        # print "item = $item :\n";
        my $totalpages =  $item->{'dd:TotalImpressions'};
}

printer_scan.pl - change the $printer variable to refer to your printer - replace hp710 with either an IP address or your actual DNS name. Once you have modified and saved the script ensure that it runs successfully standalone before proceeding.

#!/usr/bin/perl
use LWP::UserAgent;
use XML::Simple;
use Data::Dumper;
my $printer = 'hp710';
my $url = 'http://'.$printer.'/DevMgmt/ProductUsageDyn.xml';

my $ua = new LWP::UserAgent;
$ua->agent('Mozilla/5.0');
$ua->timeout(30);
#$ua->proxy('http','http://localhost:3128/');
my $request = new HTTP::Request('GET', $url);
my $response = $ua->request($request);
my $Response = $response->content;
die "Failed get $url" unless defined $Response;

my $xml = new XML::Simple;
my $data = $xml->XMLin($Response);
#print Dumper($data);
#my $type = $data->{'pudyn:PrinterSubunit'};
my $totalscans =  $data->{'pudyn:ScannerEngineSubunit'}->{'dd:ScanImages'}->{'content'};
print "totalscans.value ",$totalscans,"\n";
my $flatbedscans =  $data->{'pudyn:ScannerEngineSubunit'}->{'dd:FlatbedImages'};
print "flatbedscans.value ",$flatbedscans,"\n";
my $adfscans =  $data->{'pudyn:ScannerEngineSubunit'}->{'dd:AdfImages'}->{'content'};
print "adfscans.value ",$adfscans,"\n";
my $tocardscans =  $data->{'pudyn:ScannerEngineSubunit'}->{'dd:ScanToCardCount'}->{'content'};
print "tocardscans.value ",$tocardscans,"\n";
my $tohostscans =  $data->{'pudyn:ScannerEngineSubunit'}->{'dd:TMAScanToHostImages'}->{'content'};
print "tohostscans.value ",$tohostscans,"\n";
my $jamscans =  $data->{'pudyn:ScannerEngineSubunit'}->{'dd:JamEvents'}->{'content'};
print "jamscans.value ",$jamscans,"\n";
my $mispickscans =  $data->{'pudyn:ScannerEngineSubunit'}->{'dd:MispickEvents'}->{'content'};
print "mispickscans.value ",$mispickscans,"\n";
exit(0);
foreach my $item (@$type)
{
        # print "item = $item :\n";
        my $totalpages =  $item->{'dd:TotalImpressions'};
}

HP E710 Copier Plugin

This plugin should be saved as e710_copier and a link made from its source location into the /etc/munin/plugins directory.

$ ln -s /usr/local/scripts/munin/e710_copier /etc/munin/plugins/e710_copier


#!/bin/sh
#
# Plugin to measure remaining ink level on an HP E710 series device.
#
# Contributed by Tim Chappell
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=manual
#%# capabilities=autoconf

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = "config" ]; then

        echo 'graph_category printing'
        echo 'graph_title E710 Printer Copies'
        echo 'graph_args -l 0 '
        echo 'graph_vlabel Copies (number of)'
        echo 'totalcopies.label Total'
        echo 'totalcopies.draw LINE1'
        echo 'bwcopies.label BW copies'
        echo 'bwcopies.draw LINE1'
        echo 'colourcopies.label Colour copies'
        echo 'colourcopies.draw LINE1'
        echo 'flatbedcopies.label Flatbed copies'
        echo 'flatbedcopies.draw LINE1'
        echo 'adfcopies.label ADF copies'
        echo 'adfcopies.draw LINE1'
        exit 0
fi
STATE=/var/lib/munin/plugin-state/e710_copies.state
if [[ -s "$STATE" ]]; then
        /bin/cat ${STATE}
else
        echo 'totalcopies.value 0'
        echo 'bwcopies.value 0'
        echo 'colourcopies.value 0'
        echo 'flatbedcopies.value 0'
        echo 'adfcopies.value 0'
fi
exit 0

HP E710 Ink Plugin

This plugin should be saved as e710_ink and a link made from its source location into the /etc/munin/plugins directory.

$ ln -s /usr/local/scripts/munin/e710_ink /etc/munin/plugins/e710_ink


#!/bin/sh
#
# Plugin to measure remaining ink level on an HP E710 series device.
#
# Contributed by Tim Chappell
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=manual
#%# capabilities=autoconf

DEBUG=1
#IP=${0##*/e710_ink_}
COLOURS="black yellow cyan magenta"

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = "config" ]; then

        echo 'graph_category printing'
        echo 'graph_title E710 Printer Ink Level'
        echo 'graph_args --upper-limit 100 -l 0 '
        echo 'graph_vlabel Remaining level (%)'
        echo 'black.label Black ink'
        echo 'black.draw LINE1'
        echo 'black.type GAUGE'
        echo 'black.warning 40:'
        echo 'black.critical 30:'
        echo 'black.colour 000000'
        echo 'yellow.label Yellow ink'
        echo 'yellow.type GAUGE'
        echo 'yellow.draw LINE1'
        echo 'yellow.warning 40:'
        echo 'yellow.critical 30:'
        echo 'yellow.colour ffff00'
        echo 'cyan.label Cyan ink'
        echo 'cyan.type GAUGE'
        echo 'cyan.draw LINE1'
        echo 'cyan.warning 40:'
        echo 'cyan.critical 30:'
        echo 'cyan.colour 00ffff'
        echo 'magenta.label Magenta ink'
        echo 'magenta.type GAUGE'
        echo 'magenta.draw LINE1'
        echo 'magenta.warning 40:'
        echo 'magenta.critical 30:'
        echo 'magenta.colour ff00ff'
        exit 0
fi
STATE=/var/lib/munin/plugin-state/e710_ink.state
if [[ -s "$STATE" ]]; then
/bin/cat ${STATE}
fi
exit 0

HP E710 Pages Plugin

This plugin should be saved as e710_pages and a link made from its source location into the /etc/munin/plugins directory.

$ ln -s /usr/local/scripts/munin/e710_pages /etc/munin/plugins/e710_pages


#!/bin/sh
#
# Plugin to report printer page count.
#
# Contributed by Tim Chappell
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=manual
#%# capabilities=autoconf

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = "config" ]; then

        echo 'graph_category printing'
        echo 'graph_title E710 Printer Page Count'
        echo 'graph_args --base 1000'
        echo 'graph_vlabel Pages (number)'
        echo 'totalpages.label Total Pages'
        echo 'totalpages.draw LINE1'
        echo 'monochromepages.label Total BW Pages'
        echo 'monochromepages.draw LINE1'
        echo 'colourpages.label Total Colour Pages'
        echo 'colourpages.draw LINE1'
        echo 'simplexpages.label Total Simplex Pages'
        echo 'simplexpages.draw LINE1'
        echo 'duplexpages.label Total Duplex Pages'
        echo 'duplexpages.draw LINE1'
        echo 'jampages.label Total Jammed Pages'
        echo 'jampages.draw LINE1'
        echo 'mispickpages.label Total Mispicked Pages'
        echo 'mispickpages.draw LINE1'
        exit 0
fi
STATE=/var/lib/munin/plugin-state/e710_pages.state
if [[ -s "$STATE" ]] ; then
/bin/cat ${STATE}
fi
exit 0

HP E710 Scans Plugin

This plugin should be saved as e710_scanner and a link made from its source location into the /etc/munin/plugins directory.

$ ln -s /usr/local/scripts/munin/e710_scanner /etc/munin/plugins/e710_scanner


#!/bin/sh
#
# Plugin to report scans on an HP e710 series device.
#
# Contributed by Tim Chappell
#
# Magic markers - optional - used by installation scripts and
# munin-config:
#
#%# family=manual
#%# capabilities=autoconf

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = "config" ]; then

        echo 'graph_category printing'
        echo 'graph_title E710 Printer Scans'
        echo 'graph_args -l 0 '
        echo 'graph_vlabel Scans (number of)'
        echo 'totalscans.label Total'
        echo 'totalscans.draw LINE1'
        echo 'flatbedscans.label FlatBed scans'
        echo 'flatbedscans.draw LINE1'
        echo 'adfscans.label ADF scans'
        echo 'adfscans.draw LINE1'
        echo 'tocardscans.label Scans to Card'
        echo 'tocardscans.draw LINE1'
        echo 'tohostscans.label Scans to PC'
        echo 'tohostscans.draw LINE1'
        echo 'jamscans.label Jammed scans'
        echo 'jamscans.draw LINE1'
        echo 'mispickscans.label Mispicked scans'
        echo 'mispickscans.draw LINE1'
        exit 0
fi
STATE=/var/lib/munin/plugin-state/e710_scans.state
if [[ -s "$STATE" ]]; then
        /bin/cat ${STATE}
else
        echo 'totalscans.value 0'
        echo 'flatbedscans.value 0'
        echo 'adfscans.value 0'
        echo 'tocardscans.value 0'
        echo 'tohostscans.value 0'
        echo 'jamscans.value 0'
        echo 'mispickscans.value 0'
fi
exit 0


This website publishes a Privacy Policy. Continued use of this website implies your consent to the use of data outlined in the policy.