1 contributor
#!/bin/bash
# http://www.oidview.com/mibs/0/Printer-MIB.html
# http://www.ietf.org/rfc/rfc1759.txt
printer=192.168.1.54
# COULEURS
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 -v dq='"' '
BEGIN{
i=0
}
{
a[i]=$NF
i++
}
END{
printf("%s: %d%%\n",gensub(dq, "", "g", a[0]),a[1]/a[2]*100)
}'
done
echo
# PAPIER
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 2 3; 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
}
'