diff --git a/impression/impression_canon.py b/impression/impression_canon.py index 8db18a61..5f8bcad5 100755 --- a/impression/impression_canon.py +++ b/impression/impression_canon.py @@ -58,6 +58,11 @@ SNMP_BAC1 = "mib-2.43.8.2.1.10.1.2" SNMP_BAC2 = "mib-2.43.8.2.1.10.1.3" SNMP_BAC3 = "mib-2.43.8.2.1.10.1.4" SNMP_BAC4 = "mib-2.43.8.2.1.10.1.5" +SNMP_COUNT_A4 = "enterprises.1602.1.11.1.4.1.4.113" +SNMP_COUNT_A3 = "enterprises.1602.1.11.1.4.1.4.112" +SNMP_COUNT_A4c = "enterprises.1602.1.11.1.4.1.4.123" +SNMP_COUNT_A3c = "enterprises.1602.1.11.1.4.1.4.122" +SNMP_COUNT_TOT = "enterprises.1602.1.11.1.4.1.4.101" SNMP_ETAT = "hrPrinterStatus.1" SNMP_ERR = "hrPrinterDetectedErrorState.1" diff --git a/munin/canon_ b/munin/canon_ new file mode 100755 index 00000000..4fee75d1 --- /dev/null +++ b/munin/canon_ @@ -0,0 +1,103 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import sys +sys.path.append('/usr/scripts/gestion') +sys.path.append('/usr/scripts/impression') + +from impression_canon import SNMP_CAPA_B, SNMP_CAPA_C, SNMP_CAPA_M, SNMP_CAPA_Y, + SNMP_TON_B, SNMP_TON_C, SNMP_TON_M, SNMP_TON_Y, + SNMP_BAC1, SNMP_BAC2, SNMP_BAC3, SNMP_BAC4 + SNMP_COUNT_A4, SNMP_COUNT_A3, SNMP_COUNT_A4c, + SNMP_COUNT_A3c, SNMP_COUNT_TOT, COMM, LOG +dico_courbes_gen = { + 'ton' : { 'titre' : u"État des toner", + 'vlabel': u"Pourcentage restant", + 'lower-limit' : 0, + 'upper-limit' : 6000, + 'dico' : { 'ton_b' : (SNMP_TON_B, "Toner noir", "000000"), + 'ton_c' : (SNMP_TON_C, "Toner cyan", "00ffff"), + 'ton_m' : (SNMP_TON_M, "Toner magenta", "ff00ff"), + 'ton_y' : (SNMP_TON_Y, "Toner jaune", "ffff00") + }, + 'max' : { 'ton_b' : SNMP_CAPA_B, + 'ton_c' : SNMP_CAPA_C, + 'ton_m' : SNMP_CAPA_M, + 'ton_y' : SNMP_CAPA_Y } + }, + 'ton-p' : { 'titre' : u"État des toner", + 'vlabel': u"pages restantes", + 'lower-limit' : 0, + 'upper-limit' : 100, + 'dico' : { 'ton_b' : (SNMP_TON_B, "Toner noir", "000000"), + 'ton_c' : (SNMP_TON_C, "Toner cyan", "00ffff"), + 'ton_m' : (SNMP_TON_M, "Toner magenta", "ff00ff"), + 'ton_y' : (SNMP_TON_Y, "Toner jaune", "ffff00") } + }, + 'papier' : { 'titre' : 'Stock papier', + 'vlablel' : 'Feuilles restantes', + 'lower-limit' : 0, + 'upper-limit' : 550, + 'dico' : { 'Bac1' : (SNMP_BAC1, "Feuilles A4 (Bac 1)", '3333ff'), + 'Bac2' : (SNMP_BAC2, "Feuilles A4 (Bac 2)", '4444cc'), + 'Bac3' : (SNMP_BAC3, "Feuilles A4R (Bac 3)", "33ff33"), + 'Bac3' : (SNMP_BAC4, "Feuilles A4R (Bac 3)", "ff3333") } + }, + 'compteur' : { 'titre' : 'Pages imprimées', + 'vlabel' : 'Pages', + 'dico' : { 'nb_A4' : (SNMP_COUNT_A4, "Feuilles A4 n/b", '000000'), + (SNMP_COUNT_A3, "Feuilles A3 n/b", '333333'), + (SNMP_COUNT_A4c, "Feuilles A4 coul", '00ffff'), + (SNMP_COUNT_A3c, "Feuilles A3 coul", 'ff00ff'), + (SNMP_COUNT_TOT, "Total", 'ffff00') } + } + } + +#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].get('lower-limit', None) +upper_limit = dico_courbes_gen[arg].get('upper-limit', None) +max_courbes = dico_courbes_gen[arg].get('max', []) + +try : + arg = sys.argv[1] +except : + arg = '' +#Ecrit sur la sortie standard la configuration +if arg == "config" : + print 'host_name canon' + print 'graph_category consommables' + if lower_limit and upper_limit: + print "graph_args --lower-limit %i --upper-limit %i --rigid" % (lower_limit,upper_limit) + print 'graph_title %s' % titre + print "graph_vlabel %s" % vlabel + keys = dico_courbes.keys() + keys.sort() + for fieldname in keys: + print "%s.label %s" % (fieldname,dico_courbes[fieldname][1]) + if warning: + print "%s.warning %s" % (fieldname, warning) + if critical: + print "%s.critical %s" % (fieldname, critical) + if len(dico_courbes[fieldname]) == 3 : + print "%s.colour %s" % (fieldname,dico_courbes[fieldname][2]) + if len(dico_courbes[fieldname]) == 4 : + print "%s.draw %s" % (fieldname,dico_courbes[fieldname][3]) +else: +#Ecrit les valeurs actuelles sur la sortie standard + for fieldname in dico_courbes.keys(): + try: + if max_courbes : + max_val = int(COMM.get(max_courbes[fieldname])) + value = 100*int(COMM.get(dico_courbes[fieldname][0]))/max_val + else : + value = int(COMM.get(dico_courbes[fieldname][0])) + except Exception,err: + value = 0 + if value < 0 : value = 0 + + print "%s.value %s" % (fieldname,value) + diff --git a/munin/laserjet_ b/munin/laserjet_ index 5a85d97d..94367e62 100644 --- a/munin/laserjet_ +++ b/munin/laserjet_ @@ -1,5 +1,5 @@ #!/usr/bin/env python -# -*- coding: utf-8 -* +# -*- coding: utf-8 -*- import sys sys.path.append("/usr/scripts/gestion")