scripts / printer /
Newer Older
96 lines | 2.663kb
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 \
améliore la sortie
seb authored on 2022-11-19
16
        ${prtMarkerSuppliesMaxCapacity}.$i | awk -v dq='"' '
commit initial
Sébastien MARQUE authored on 2016-10-31
17
        BEGIN{
18
            i=0
19
        }
20
        {
21
            a[i]=$NF
22
            i++
23
        }
24
        END{
améliore la sortie
seb authored on 2022-11-19
25
            printf("%s: %d%%\n",gensub(dq, "", "g", a[0]),a[1]/a[2]*100)
commit initial
Sébastien MARQUE authored on 2016-10-31
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
adapate à la nouvelle imprim...
Sébastien Marque 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 \
adapate à la nouvelle imprim...
Sébastien Marque authored on 2022-11-19
41
        ${prtInputMediaDimXFeedDirChosen}.$i | awk -v inputslot=$((i - 1)) -v output=${1:-normal} '
commit initial
Sébastien MARQUE authored on 2016-10-31
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"
adapate à la nouvelle imprim...
Sébastien Marque authored on 2022-11-19
47
            is[1] = "B"
48
            is[2] = "A"
commit initial
Sébastien MARQUE authored on 2016-10-31
49
        }
50
        { 
51
            a[i] = $NF
52
            i++
53
        }
54
        END {
55
            size = a[2] " x " a[3]
56
            f = format[size] ? format[size] : "format inconnu : " a[2] " x " a[3]
adapate à la nouvelle imprim...
Sébastien Marque authored on 2022-11-19
57
	    if (output == "normal")
58
                printf("bac %d (InputSlot=PF500%s): %d%% (%s)\n", inputslot, is[inputslot], a[1]/a[0]*100, f)
59
            else
60
                printf("bac %d (%s): %d%%\n", inputslot, f, a[1]/a[0]*100)
commit initial
Sébastien MARQUE authored on 2016-10-31
61
        }
62
    '
63
done
64
echo
65

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

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