scripts / printer /
Newer Older
95 lines | 2.532kb
commit initial
Sébastien MARQUE authored on 2016-10-31
1
#!/bin/bash
2
# http://www.oidview.com/mibs/0/Printer-MIB.html
3
# http://www.ietf.org/rfc/rfc1759.txt
4

            
5
printer=192.168.1.54
6

            
7
# COULEURS
8
echo Couleurs
9
prtMarkerColorantValue=1.3.6.1.2.1.43.12.1.1.4.1
10
prtMarkerSuppliesMaxCapacity=1.3.6.1.2.1.43.11.1.1.8.1
11
prtMarkerSuppliesLevel=1.3.6.1.2.1.43.11.1.1.9.1
12
for i in $(seq 4); do 
13
    snmpget -v 1 -c public $printer \
14
        ${prtMarkerColorantValue}.$i \
15
        ${prtMarkerSuppliesLevel}.$i \
16
        ${prtMarkerSuppliesMaxCapacity}.$i | awk '
17
        BEGIN{
18
            i=0
19
        }
20
        {
21
            a[i]=$NF
22
            i++
23
        }
24
        END{
25
            printf("%s: %d%%\n",a[0],a[1]/a[2]*100)
26
        }'
27
done
28
echo
29

            
30
# PAPIER
31
echo Papiers
32
prtInputMaxCapacity=1.3.6.1.2.1.43.8.2.1.9.1
33
prtInputCurrentLevel=1.3.6.1.2.1.43.8.2.1.10.1
34
prtInputMediaDimFeedDirChosen=1.3.6.1.2.1.43.8.2.1.6.1
35
prtInputMediaDimXFeedDirChosen=1.3.6.1.2.1.43.8.2.1.7.1
adapte les bacs à la nouvell...
seb authored on 2022-11-19
36
for i in 2 3; do
commit initial
Sébastien MARQUE authored on 2016-10-31
37
    snmpget -v 1 -c public $printer \
38
        ${prtInputMaxCapacity}.$i \
39
        ${prtInputCurrentLevel}.$i \
40
        ${prtInputMediaDimFeedDirChosen}.$i \
41
        ${prtInputMediaDimXFeedDirChosen}.$i | awk -v inputslot=$((i - 1)) '
42
        BEGIN {
43
            i = 0
44
            format["82667 x 116900"] = "A4 portrait / A5 paysage"
45
            format["116900 x 82667"] = "A4 paysage"
46
            format["165333 x 117000"] = "A3 paysage"
47
            is[1] = "A"
48
            is[2] = "B"
49
            is[3] = "C"
50
            is[4] = "D"
51
        }
52
        { 
53
            a[i] = $NF
54
            i++
55
        }
56
        END {
57
            size = a[2] " x " a[3]
58
            f = format[size] ? format[size] : "format inconnu : " a[2] " x " a[3]
59
            printf("bac %d (InputSlot=PF730%s): %d%% (%s)\n", inputslot, is[inputslot], a[1]/a[0]*100, f)
60
        }
61
    '
62
done
63
echo
64

            
65
echo Status
66
hrPrinterStatus=1.3.6.1.2.1.25.3.5.1.1.1
67
snmpget -v 1 -c public $printer $hrPrinterStatus | awk -v sq="'" '
68
    {
69
        switch ($NF) {
70
            case "3" :
71
                status = "en attente"
72
                break
73
            case "4" :
74
                status = "en cours d" sq "impression"
75
                break
76
            case "5" :
77
                status = "préchauffage"
78
                break
79
            case "1" :
80
            case "2" :
81
            default :
82
                status = "inconnu"
83
                break
84
        }
85
        print status
86
    }'
87
echo
88

            
89
prtAlertDescription=1.3.6.1.2.1.43.18.1.1.8
90
snmpwalk -v 1 -c public $printer $prtAlertDescription | awk -F '"' '
91
    {
92
     	if ($2 != "") print $2   
93
    }
94
'
95