scripts/munin/laserjet_
salles 9990966cf2 Changement cohérent du nom du plugin et ajout de _ pour etre conforme
a l'utilisation habituelle de munin quand un plugin necessite un argument
dans son nom
--
Nicolas

darcs-hash:20061017084623-72cb0-0c364854e2cc6022130237fb52c1ee7ebc5c8283.gz
2006-10-17 10:46:23 +02:00

99 lines
4.6 KiB
Python
Executable file

#!/usr/bin/env python
# -*- coding: iso-8859-15 -*
import sys
sys.path.append("/usr/scripts/gestion")
import hptools
dico_courbes_gen = {
'car' : {'titre' : "Etat des cartouches",
'vlabel' : "nb de pages restantes",
'lower-limit' : 0,
'upper-limit' : 30000,
'dico' : {
'car_bla' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.1.0","Cartouche noir","000000"),
'car_cya' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.2.0","Cartouche cyan","00ffff"),
'car_mag' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.3.0","Cartouche magenta","ff00ff"),
'car_yel' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.4.0","Cartouche jaune","ffff00")
}},
'car-p' : {'titre' : "Etat des cartouches",
'vlabel' : "pourcentage restant",
'lower-limit' : 0,
'upper-limit' : 100,
'dico' : {
'car_p_bla' : ("enterprises.11.2.3.9.4.2.1.4.1.10.1.1.18.1.0","Cartouche noir","000000"),
'car_p_cya' : ("enterprises.11.2.3.9.4.2.1.4.1.10.1.1.18.2.0","Cartouche cyan","00ffff"),
'car_p_mag' : ("enterprises.11.2.3.9.4.2.1.4.1.10.1.1.18.3.0","Cartouche magenta","ff00ff"),
'car_p_yel' : ("enterprises.11.2.3.9.4.2.1.4.1.10.1.1.18.4.0","Cartouche jaune","ffff00")
}},
'tam' : {'titre' : "Etat des tambours",
'vlabel' : "nb de pages restantes",
'lower-limit' : 0,
'upper-limit' : 40000,
'dico' : {
'tam_bla' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.5.0","Tambour d'imagerie noir","000000"),
'tam_cya' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.6.0","Tambour d'imagerie cyan","00ffff"),
'tam_mag' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.7.0","Tambour d'imagerie magenta","ff00ff"),
'tam_yel' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.8.0","Tambour d'imagerie jaune","ffff00"),
}},
'tam-p' : {'titre' : "Etat des tambours",
'vlabel' : "Pourcentage restant",
'lower-limit' : 0,
'upper-limit' : 100,
'dico' : {
'tam_p_bla' : ("enterprises.11.2.3.9.4.2.1.4.1.10.1.1.37.5.0","Tambour d'imagerie noir","000000"),
'tam_p_cya' : ("enterprises.11.2.3.9.4.2.1.4.1.10.1.1.37.6.0","Tambour d'imagerie cyan","00ffff"),
'tam_p_mag' : ("enterprises.11.2.3.9.4.2.1.4.1.10.1.1.37.7.0","Tambour d'imagerie magenta","ff00ff"),
'tam_p_yel' : ("enterprises.11.2.3.9.4.2.1.4.1.10.1.1.37.8.0","Tambour d'imagerie jaune","ffff00"),
}},
'kit' : {'titre' : "Etat des kits images",
'vlabel' : "nb de pages restantes",
'lower-limit' : 0,
'upper-limit' : 150000,
'dico' : {
'kit_tra' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.9.0","Kit de transfert image"),
'kit_net' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.10.0","Kit de nettoyage image"),
'kit_fus' : ("enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.11.0","Kit de fusion image")
}}
}
#Initialisation du dictionnaire des courbes
arg = sys.argv[0].split('_')[1]
dico_courbes = dico_courbes_gen[arg]['dico']
titre = dico_courbes_gen[arg]['titre']
vlabel = dico_courbes_gen[arg]['vlabel']
lower_limit = dico_courbes_gen[arg]['lower-limit']
upper_limit = dico_courbes_gen[arg]['upper-limit']
#########
try :
arg = sys.argv[1]
except :
arg = ''
#Ecrit sur la sortie standard la configuration
if arg == "config" :
print 'host_name laserjet'
print 'graph_category consommables'
print "graph_args --lower-limit %i --upper-limit %i" % (lower_limit,upper_limit)
print 'graph_title %s' % titre
print "graph_vlabel %s" % vlabel
for fieldname in dico_courbes.keys():
#print "%s.draw LINE2" % fieldname
print "%s.label %s" % (fieldname,dico_courbes[fieldname][1])
if len(dico_courbes[fieldname])>2 :
print "%s.colour %s" % (fieldname,dico_courbes[fieldname][2])
else:
#Ecrit les valeurs actuelles sur la sortie standard
try:
comm = hptools.snmp(host="laserjet.adm.crans.org",version="1",community="public")
except Exception,err:
exit
for fieldname in dico_courbes.keys():
try:
value = comm.get(dico_courbes[fieldname][0])
except Exception,err:
value = 0
print "%s.value %s" % (fieldname,value)