#!/bin/bash

HOST=${host:-"127.0.0.1"}

: << =cut

=head1 NAME

snmp_HPLJ2015 - Consumables level on HP LaserJet 2015n reported over SNMP

=head1 CONFIGURATION

HOST

=head1 AUTHOR

Oleksiy Kochkin

=head1 LICENSE

As is.

=back

=head1 MAGIC MARKERS

 #%# family=contrib
 #%# capabilities=autoconf

=cut

case $1 in
config)

echo "graph_title Consumables level @ $HOST"
echo 'graph_args --upper-limit 100 -l 0'
echo 'graph_vlabel %'
echo 'graph_category printers'
echo 'graph_scale no'
echo 'black.label Black toner level'
echo 'black.draw LINE2'
echo 'black.type GAUGE'
echo 'black.colour 000000'
echo 'black.warning 5:'
echo 'black.critical 1:'
echo 'black.min 0'
echo 'black.max 100'
exit 0;;
esac

BLACK_MAX_OID=".1.3.6.1.2.1.43.11.1.1.8.1.1"
BLACK_LVL_OID=".1.3.6.1.2.1.43.11.1.1.9.1.1"

BLACK_MAX=`snmpget -v 1 -c public -Ov -Oq $HOST $BLACK_MAX_OID`
BLACK_LVL=`snmpget -v 1 -c public -Ov -Oq $HOST $BLACK_LVL_OID`
BLACK_LVL_PERCENTS=$(($BLACK_LVL*100/$BLACK_MAX))

echo -n "black.value "
echo $BLACK_LVL_PERCENTS
