Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / printer / hp2600_status_ @ 430d68ff

Historique | Voir | Annoter | Télécharger (1,46 ko)

1 e29c8845 Andriy Yakovlev
#!/bin/sh
2
#
3
4
myname=`basename $0 | sed 's/^hp2600_status_//g'`
5
6
name="${name-}"
7
REGEX="${regex-\<$name\>}"
8
9
printer_ip=$name
10
printer_ip='10.34.9.12'
11
12
get_data (){
13
    /usr/local/bin/wget  -q -O - http://${printer_ip}/SSI/supply_status_info.htm | egrep -e '>[0-9]+'| awk -F '(<|>)' '{a=$5; sub("%"," ",a);sub("\r","",a); print a}'
14
}
15
16
do_stats () {
17
    count=1
18
    for I in `get_data`; do 
19
	[ $count = 1 ]  && echo "statb.value $I" 
20
	[ $count = 4 ]  && echo "staty.value $I" 
21
	[ $count = 7 ]  && echo "statc.value $I" 
22
	[ $count = 10 ] && echo "statm.value $I" 
23
	count=$(($count + 1))
24
    done
25
26
}
27
28
case $1 in
29
    config)
30
        cat <<'EOF'
31
host_name printers
32
graph_title HP 2600 cartridge status 
33
graph_vlabel Status (%)
34
graph_category HP2600 Printer
35
graph_info Toner status.
36
graph_args --upper-limit 400 -l 0 
37
line.label ---
38
line.line 400
39
statb.label Black
40
statb.draw AREA
41
statb.colour 000000
42
statb.min 0
43
statb.max 100
44
lineb.label ---
45
lineb.draw STACK
46
lineb.colour ffffff
47
lineb.skipprint 1
48
lineb.cdef 100,statb,-
49
staty.label Yellow
50
staty.min 0
51
staty.max 100
52
staty.draw STACK
53
staty.colour ffff00
54
liney.label ---
55
liney.draw STACK
56
liney.colour ffffff
57
liney.skipprint 1
58
liney.cdef 100,staty,-
59
statc.label Cyan
60
statc.min 0
61
statc.max 100
62
statc.draw STACK
63
statc.colour 00ffff
64
linec.label ---
65
linec.draw STACK
66
linec.colour ffffff
67
linec.skipprint 1
68
linec.cdef 100,statc,-
69
statm.label Magenta
70
statm.min 0
71
statm.max 100
72
statm.draw STACK
73
statm.colour ff00ff
74
EOF
75
        exit 0
76
        ;;
77
esac
78
79
do_stats
80
81
82
#EOF