[munin/] ajout de canon_
Ignore-this: 5aeb5f9111a944ca191083c4acbeebb1 darcs-hash:20090519003036-bd074-7681cf3904143cdd515c8c95352d098069524ae3.gz
This commit is contained in:
parent
ab547caf80
commit
f05d9405c9
3 changed files with 109 additions and 1 deletions
103
munin/canon_
Executable file
103
munin/canon_
Executable file
|
@ -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)
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
sys.path.append("/usr/scripts/gestion")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue