Commit e2e87ae3 authored by Daniel STAN's avatar Daniel STAN
Browse files

printer_watch: imprimante en fqdn (bis)

Parce que l'host était hardcodé à un deuxième endroit en cas de plantage. J'en
ai fait une variable globale, des fois que ça rechange.
parent 2eeac760
......@@ -9,6 +9,7 @@ from md5 import md5
STATUS_FILE = "/usr/scripts/var/impression/printer_watch_status.json"
STATUS_MESSAGE_FILE = "/usr/scripts/var/impression/error_message"
PRINTER_HOST = "imprimante.adm.crans.org"
successfuly_imported = False
try:
......@@ -25,7 +26,7 @@ except (IOError, ValueError, TypeError):
# On check le statut de l'imprimante
status_id = netsnmp.Varbind("hrDeviceStatus.1")
status = netsnmp.snmpget(status_id, Version=1, DestHost="imprimante.adm.crans.org", Community="public")
status = netsnmp.snmpget(status_id, Version=1, DestHost=PRINTER_HOST, Community="public")
if status == ('5',) and (not successfuly_imported or successfuly_imported and (last_status == '2' or last_status == '3')):
"""
......@@ -34,7 +35,7 @@ if status == ('5',) and (not successfuly_imported or successfuly_imported and (l
"""
# On récolte la liste des erreurs dans cette branche
errors = netsnmp.snmpwalk(netsnmp.Varbind("mib-2.43.18.1.1.8.1"), Version=1, DestHost="imprimante.adm", Community="public")
errors = netsnmp.snmpwalk(netsnmp.Varbind("mib-2.43.18.1.1.8.1"), Version=1, DestHost=PRINTER_HOST, Community="public")
errors_list = [error + '\n' for error in errors]
#On crée un joli message d'erreur contenant la liste des erreurs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment