... | ... |
@@ -35,3 +35,21 @@ function mem_pressure () { |
35 | 35 |
meminfo[i+2]=$(( ( ${meminfo[i+1]} - $margin ) / 100000 )) |
36 | 36 |
test ${meminfo[i+2]} -ge ${#range[@]} || echo "${level[${meminfo[i+2]}]}: available ${meminfo[i+1]}kB" |
37 | 37 |
} |
38 |
+ |
|
39 |
+function printer () { |
|
40 |
+ _turn 24 || return |
|
41 |
+ local min=20 |
|
42 |
+ local level=(extreme danger warning info) |
|
43 |
+ local printer=192.168.1.54 |
|
44 |
+ local prtMarkerSuppliesMaxCapacity=1.3.6.1.2.1.43.11.1.1.8.1 |
|
45 |
+ local prtMarkerSuppliesLevel=1.3.6.1.2.1.43.11.1.1.9.1 |
|
46 |
+ local left=$(snmpget -v 1 -c public $printer ${prtMarkerSuppliesLevel}.4) |
|
47 |
+ local full=$(snmpget -v 1 -c public $printer ${prtMarkerSuppliesMaxCapacity}.4) |
|
48 |
+ |
|
49 |
+ if test ${full#*:} -ne 0; then |
|
50 |
+ local step=$(((${left#*:}*100/${full#*:})/5)) |
|
51 |
+ if test $step -le ${#level[@]}; then |
|
52 |
+ echo "${level[$step]} toner black" |
|
53 |
+ fi |
|
54 |
+ fi |
|
55 |
+} |