diff --git a/munin/imprimante b/munin/imprimante index 62545b3f..14c9cf1c 100755 --- a/munin/imprimante +++ b/munin/imprimante @@ -6,31 +6,68 @@ sys.path.append("/usr/scripts/gestion") import hptools +dico_courbes_gen = { + 'car' : {'titre' : "Etat des cartouches", + 'lower-limit' : 0, + 'upper-limit' : 60000, + '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") + }}, + 'tam' : {'titre' : "Etat des tambours", + 'lower-limit' : 0, + 'upper-limit' : 60000, + '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"), + }}, + 'kit' : {'titre' : "Etat des kits images", + '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'] +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 Imprimante' - print 'graph_title État fournitures' - print "graph_args --base 30000 --lower-limit 0" + print 'host_name laserjet' + print "graph_args --base 1000 --lower-limit %i --upper-limit %i" % (lower_limit,upper_limit) + print 'graph_title %s' % titre print "graph_vlabel nb de pages restantes" - print "car_cya.label Cartouche cyan" - print "car_cya.draw LINE2" - print "kit_net.label Kit de nettoyage image" - print "kit_net.draw LINE2" + 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 - dico_oid = {'car_cya' : "enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.2.0", - 'kit_net' : "enterprises.11.2.3.9.4.2.1.4.1.10.5.1.1.10.0"} - - for fieldname in dico_oid.keys(): + + for fieldname in dico_courbes.keys(): try: - value = comm.get(dico_oid[fieldname]) + value = comm.get(dico_courbes[fieldname][0]) except Exception,err: value = 0