1 contributor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
printer=192.168.1.54
echo Couleurs
prtMarkerColorantValue=1.3.6.1.2.1.43.12.1.1.4.1
prtMarkerSuppliesMaxCapacity=1.3.6.1.2.1.43.11.1.1.8.1
prtMarkerSuppliesLevel=1.3.6.1.2.1.43.11.1.1.9.1
for i in $(seq 4); do
snmpget -v 1 -c public $printer \
${prtMarkerColorantValue}.$i \
${prtMarkerSuppliesLevel}.$i \
${prtMarkerSuppliesMaxCapacity}.$i | awk '
BEGIN{
i=0
}
{
a[i]=$NF
i++
}
END{
printf("%s: %d%%\n",a[0],a[1]/a[2]*100)
}'
done
echo
echo Papiers
prtInputMaxCapacity=1.3.6.1.2.1.43.8.2.1.9.1
prtInputCurrentLevel=1.3.6.1.2.1.43.8.2.1.10.1
prtInputMediaDimFeedDirChosen=1.3.6.1.2.1.43.8.2.1.6.1
prtInputMediaDimXFeedDirChosen=1.3.6.1.2.1.43.8.2.1.7.1
for i in $(seq 2 5); do
snmpget -v 1 -c public $printer \
${prtInputMaxCapacity}.$i \
${prtInputCurrentLevel}.$i \
${prtInputMediaDimFeedDirChosen}.$i \
${prtInputMediaDimXFeedDirChosen}.$i | awk -v inputslot=$((i - 1)) '
BEGIN {
i = 0
format["82667 x 116900"] = "A4 portrait / A5 paysage"
format["116900 x 82667"] = "A4 paysage"
format["165333 x 117000"] = "A3 paysage"
is[1] = "A"
is[2] = "B"
is[3] = "C"
is[4] = "D"
}
{
a[i] = $NF
i++
}
END {
size = a[2] " x " a[3]
f = format[size] ? format[size] : "format inconnu : " a[2] " x " a[3]
printf("bac %d (InputSlot=PF730%s): %d%% (%s)\n", inputslot, is[inputslot], a[1]/a[0]*100, f)
}
'
done
echo
echo Status
hrPrinterStatus=1.3.6.1.2.1.25.3.5.1.1.1
snmpget -v 1 -c public $printer $hrPrinterStatus | awk -v sq="'" '
{
switch ($NF) {
case "3" :
status = "en attente"
break
case "4" :
status = "en cours d" sq "impression"
break
case "5" :
status = "préchauffage"
break
case "1" :
case "2" :
default :
status = "inconnu"
break
}
print status
}'
echo
prtAlertDescription=1.3.6.1.2.1.43.18.1.1.8
snmpwalk -v 1 -c public $printer $prtAlertDescription | awk -F '"' '
{
if ($2 != "") print $2
}
'