Deleting laserjet and changing cat name
This commit is contained in:
parent
5c6386abae
commit
ea4d25f597
5 changed files with 2 additions and 11 deletions
154
archive/munin/laserjet_
Executable file
154
archive/munin/laserjet_
Executable file
|
@ -0,0 +1,154 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
sys.path.append("/usr/scripts/gestion")
|
||||
|
||||
import hptools
|
||||
|
||||
dico_courbes_gen = {
|
||||
'car' : {'titre' : u"Etat des cartouches",
|
||||
'vlabel' : "nb de pages restantes",
|
||||
'lower-limit' : 0,
|
||||
'upper-limit' : 30000,
|
||||
'warning' : "2000:",
|
||||
'critical' : "500:",
|
||||
'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' : u"Etat des cartouches (pourcentage)",
|
||||
'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' : u"Etat des tambours",
|
||||
'vlabel' : "nb de pages restantes",
|
||||
'lower-limit' : 0,
|
||||
'upper-limit' : 40000,
|
||||
'warning' : "2000:",
|
||||
'critical' : "500:",
|
||||
'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' : u"Etat des tambours (pourcentage)",
|
||||
'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"),
|
||||
}},
|
||||
'stock-papier' : {'titre' : "Stock papier",
|
||||
'vlabel' : "nb de pages restantes",
|
||||
'lower-limit' : 0,
|
||||
'upper-limit' : 2000,
|
||||
'dico' : {
|
||||
'tray6' : ("1.3.6.1.2.1.43.8.2.1.10.1.6","Feuilles A4","3333ff"),
|
||||
'tray6_max' : ("1.3.6.1.2.1.43.8.2.1.9.1.6","Feuilles A4 (max)","0000cc"),
|
||||
'tray3' : ("1.3.6.1.2.1.43.8.2.1.10.1.3","Feuilles A3","33ff33"),
|
||||
'tray3_max' : ("1.3.6.1.2.1.43.8.2.1.9.1.3","Feuilles A3 (max)","00cc00"),
|
||||
'tray2' : ("1.3.6.1.2.1.43.8.2.1.10.1.2","Cartons","ff3333"),
|
||||
'tray2_max' : ("1.3.6.1.2.1.43.8.2.1.9.1.2","Cartons (max)","cc0000"),
|
||||
'tray1' : ("1.3.6.1.2.1.43.8.2.1.10.1.1","Transparents","ffff33"),
|
||||
'tray1_max' : ("1.3.6.1.2.1.43.8.2.1.9.1.1","Transparents (max)","cccc00"),
|
||||
}},
|
||||
'stock-papier-p' : {'titre' : "Stock papier (pourcentage)",
|
||||
'vlabel' : "Pourcentage restant",
|
||||
'lower-limit' : 0,
|
||||
'upper-limit' : 100,
|
||||
'dico' : {
|
||||
'tray6' : ("1.3.6.1.2.1.43.8.2.1.10.1.6","Feuilles A4","3333ff"),
|
||||
'tray3' : ("1.3.6.1.2.1.43.8.2.1.10.1.3","Feuilles A3","33ff33"),
|
||||
'tray2' : ("1.3.6.1.2.1.43.8.2.1.10.1.2","Cartons","ff3333"),
|
||||
'tray1' : ("1.3.6.1.2.1.43.8.2.1.10.1.1","Transparents","ffff33"),
|
||||
},
|
||||
'max' : {
|
||||
'tray6' : "1.3.6.1.2.1.43.8.2.1.9.1.6",
|
||||
'tray3' : "1.3.6.1.2.1.43.8.2.1.9.1.3",
|
||||
'tray2' : "1.3.6.1.2.1.43.8.2.1.9.1.2",
|
||||
'tray1' : "1.3.6.1.2.1.43.8.2.1.9.1.1",
|
||||
}},
|
||||
'kit' : {'titre' : u"Etat des kits images",
|
||||
'vlabel' : "nb de pages restantes",
|
||||
'lower-limit' : 0,
|
||||
'upper-limit' : 150000,
|
||||
'warning' : "2000:",
|
||||
'critical' : "500:",
|
||||
'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']
|
||||
warning = dico_courbes_gen[arg].get("warning")
|
||||
critical = dico_courbes_gen[arg].get("critical")
|
||||
#########
|
||||
try :
|
||||
max_courbes = dico_courbes_gen[arg]['max']
|
||||
except :
|
||||
max_courbes = []
|
||||
|
||||
|
||||
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 --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
|
||||
try:
|
||||
comm = hptools.snmp(host="laserjet.adm.crans.org",version="1",community="public")
|
||||
except Exception,err:
|
||||
exit
|
||||
|
||||
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)
|
70
archive/munin/laserjet__etat
Executable file
70
archive/munin/laserjet__etat
Executable file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*
|
||||
|
||||
import sys, os
|
||||
sys.path.append("/usr/scripts/gestion")
|
||||
|
||||
import hptools
|
||||
|
||||
dico = {
|
||||
"READY": 1,
|
||||
"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,
|
||||
"COMMANDER KIT NETTOY": 0,
|
||||
"COMMANDER FOURNIT.": 0,
|
||||
"CYAN": 0,
|
||||
"MAGENTA": 0,
|
||||
"JAUNE": 0,
|
||||
"NOIR": 0,
|
||||
'COMM TAMB. NOIR': 0,
|
||||
'PAGES REST.': 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:
|
||||
msg = comm.get_string(oid)
|
||||
diff = dico.get(msg, None)
|
||||
if diff == None:
|
||||
for k in dico.keys():
|
||||
if k in msg and k != "": diff = dico[k]
|
||||
if diff == None:
|
||||
diff = 4
|
||||
total += diff
|
||||
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 u'host_name laserjet'
|
||||
print u"graph_category État"
|
||||
print u"graph_args --lower-limit 0 --upper-limit 10"
|
||||
print u"graph_title Etat de l'imprimante"
|
||||
print u"graph_vlabel nb"
|
||||
print u"etat.label Estimation des embrouilles (>3=problemes)"
|
||||
print u"etat.warning 4"
|
||||
print u"etat.critical 8"
|
||||
print u"lpq.label Taille de la file d'attente"
|
||||
else:
|
||||
# Ecrit les valeurs actuelles sur la sortie standard
|
||||
print "etat.value %s" % etat()
|
||||
print "lpq.value %d" % (int(os.popen("lpq|wc -l").read())-2)
|
30
archive/munin/laserjet__pages
Executable file
30
archive/munin/laserjet__pages
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*
|
||||
|
||||
import sys, os
|
||||
sys.path.append("/usr/scripts/gestion")
|
||||
|
||||
import hptools
|
||||
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
arg = sys.argv[1]
|
||||
else:
|
||||
arg = ''
|
||||
|
||||
if arg == "config":
|
||||
# Ecrit sur la sortie standard la configuration
|
||||
print u'host_name laserjet'
|
||||
print u"graph_category État"
|
||||
print "graph_title Pages imprimees"
|
||||
print u"graph_vlabel nb"
|
||||
print u"total.label Total"
|
||||
else:
|
||||
# Ecrit les valeurs actuelles sur la sortie standard
|
||||
oid = "1.3.6.1.2.1.43.10.2.1.4.1.1"
|
||||
try :
|
||||
comm = hptools.snmp(host="laserjet.adm.crans.org", version="1", community="public")
|
||||
print "total.value %s" % comm.get(oid)
|
||||
except :
|
||||
print ""
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue