51 lines
1.4 KiB
Python
Executable file
51 lines
1.4 KiB
Python
Executable file
#!/usr/bin/env python
|
|
# -*- coding: iso-8859-15 -*
|
|
|
|
import sys
|
|
sys.path.append("/usr/scripts/gestion")
|
|
|
|
import hptools
|
|
|
|
dico = {
|
|
"PrÁt": 1,
|
|
"Pr menus, appuy \x1e": 0,
|
|
"Powersave activÅ": 3,
|
|
"Verification": 2,
|
|
"imprimante": 0,
|
|
"PrÅchauffage": 1,
|
|
"Traitement de la": 0,
|
|
"tÀche du bac 4": 0,
|
|
"tÀche du bac 3": 0,
|
|
"COMMANDER CARTOUCHE": 0,
|
|
"": 0,
|
|
}
|
|
|
|
def etat():
|
|
""" Renvoie une liste des differents ecrans actuels du display de l'imprimante """
|
|
liste_oid = ["mib-2.43.16.5.1.2.1.1","mib-2.43.16.5.1.2.1.2","mib-2.43.16.5.1.2.1.3","mib-2.43.16.5.1.2.1.4","mib-2.43.16.5.1.2.1.5"]
|
|
total = 0
|
|
try:
|
|
comm = hptools.snmp(host="laserjet.adm.crans.org", version="1", community="public")
|
|
for oid in liste_oid:
|
|
total += dico.get(comm.get_string(oid), 4)
|
|
except Exception, err:
|
|
total += 24
|
|
return total
|
|
|
|
if len(sys.argv) > 1:
|
|
arg = sys.argv[1]
|
|
else:
|
|
arg = ''
|
|
|
|
if arg == "config":
|
|
# Ecrit sur la sortie standard la configuration
|
|
print 'host_name laserjet'
|
|
print "graph_args --lower-limit 0 --upper-limit 10"
|
|
print "graph_title Etat de l'imprimante"
|
|
print "graph_vlabel 0: no problem, 40: ragnarok"
|
|
print "etat.label Estimation des embrouilles"
|
|
print "etat.warning 4"
|
|
print "etat.critical 8"
|
|
else:
|
|
# Ecrit les valeurs actuelles sur la sortie standard
|
|
print "etat.value %s" % etat()
|