Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !/bin/bash
- #- Pieter Steyn '08
- poll_device() {
- #Colour Printer
- colour_black=`snmpget 192.168.229.12:161 -v 1 -c public 1.3.6.1.2.1.43.11.1.1.9.1.1 -Ovq` #Black
- colour_cyan=`snmpget 192.168.229.12:161 -v 1 -c public 1.3.6.1.2.1.43.11.1.1.9.1.2 -Ovq` #Cyan
- colour_magenta=`snmpget 192.168.229.12:161 -v 1 -c public 1.3.6.1.2.1.43.11.1.1.9.1.3 -Ovq` #Magenta
- colour_yellow=`snmpget 192.168.229.12:161 -v 1 -c public 1.3.6.1.2.1.43.11.1.1.9.1.4 -Ovq` #Yellow
- colour_tonerdrum=`snmpget 192.168.229.12:161 -v 1 -c public 1.3.6.1.2.1.43.11.1.1.9.1.5 -Ovq` #Toner Drum
- }
- create() {
- #Create the RRD file if they don't already exist.
- if ! [ -e $NAME.rrd ]; then
- rrdtool create $NAME.rrd \
- DS:black:GAUGE:300:0:10000000 \
- DS:cyan:GAUGE:300:0:10000000 \
- DS:magenta:GAUGE:300:0:10000000 \
- DS:yellow:GAUGE:300:0:10000000 \
- DS:toner_drum:GAUGE:300:0:10000000 \
- RRA:LAST:0.5:1:9600 \
- RRA:LAST:0.5:4:9600 \
- RRA:LAST:0.5:24:6000;
- fi
- }
- update() {
- #Update the RRD files.
- poll_device
- echo "$colour_black $colour_cyan $colour_magenta $colour_yellow $colour_tonerdrum"
- rrdtool update $NAME.rrd -t black N:$colour_black
- rrdtool update $NAME.rrd -t cyan N:$colour_cyan
- rrdtool update $NAME.rrd -t magenta N:$colour_magenta
- rrdtool update $NAME.rrd -t yellow N:$colour_yellow
- rrdtool update $NAME.rrd -t toner_drum N:$colour_tonerdrum
- }
- # --start=-6400 \
- graph() {
- #Graph the RRD files.
- rrdtool graph $NAME.png \
- --imgformat=PNG \
- --start="now -1h" \
- --title="HP Color Laserjet 2550" \
- --base=1000 \
- --height=120 \
- --width=500 \
- --alt-autoscale-max \
- --lower-limit=0 \
- --vertical-label="" \
- DEF:blacklast=$NAME.rrd:black:LAST \
- LINE1:blacklast#736F6E:"Current Black Level" \
- GPRINT:blacklast:LAST:"mg remaining\:%6.2lf" \
- DEF:cyanlast=$NAME.rrd:cyan:LAST \
- LINE1:cyanlast#50EBEC:"Current Cyan Level" \
- GPRINT:cyanlast:LAST:"mg remaining\:%6.2lf" \
- GPRINT:cyanlast:LAST:"mg remaining\:%6.2lf" \
- DEF:magentalast=$NAME.rrd:magenta:LAST \
- LINE1:magentalast#E238EC:"Current Magenta Level" \
- GPRINT:magentalast:LAST:"mg remaining\:%6.2lf" \
- DEF:yellowlast=$NAME.rrd:yellow:LAST \
- LINE1:yellowlast#FFFC17:"Current Yellow Level" \
- GPRINT:yellowlast:LAST:"mg remaining\:%6.2lf"
- }
- update_loop() {
- #Update the RRD every 15 mins.
- while true; do
- update
- sleep 5m;
- done
- }
- NAME="colour_printer"
- create
- update
- update_loop
- #DONE
- #RESULTS:
- 892 360 330 188 0 #5mins passed
- 892 360 330 188 0 #5mins passed
- 892 360 330 188 0 #5mins passed
- 892 360 330 188 0 #5mins passed
- 892 360 330 188 0 #5mins passed
- #OK, now I graph:
- 581x227
- But the graph has only NAN's WHY?
Add Comment
Please, Sign In to add comment