Ad Widget

Collapse

How to get the exit code from python3 script in zabbix.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fujoubou
    Junior Member
    • Aug 2016
    • 1

    #1

    How to get the exit code from python3 script in zabbix.

    How can i catch that exit code within Zabbix. The script works like a charm but it seams i can't get any error code from anywhere... thanks for the help !


    here's the script

    #Importation des librairy nécessaire
    import xml.etree.ElementTree as ET
    import urllib.request
    import sys

    #Création des variable et lecture
    #Importation via download à l'intérieur de la variable XML
    url = 'WEBSITE ADRESS'
    response = urllib.request.urlopen(url)
    data = response.read()
    xml = data.decode('utf-8')

    #Création de ls string XML pour lecture
    doc = ET.fromstring(xml)

    #Lecture et validation de tous les veleurs Name trouvé dans le document
    for actor in doc.findall(".//VHost/Application"):
    #Extraction des valeurs trouvé pour ensuite valider les données
    result = actor.find("Name")
    result2 = actor.find("ApplicationInstance/Stream/Name")

    #Valider les bullets pour trouvé TVC9
    if result.text == "tvc9":
    #Si TVC9 trouvé alors nous validons si celui-ci comprend la section ou il a telethon
    if result2 is None:
    #Si téléthon non trouvé ont renvoie le code d'erreur 5 sinon tout est beau
    sys.exit(5)
    elif result2 is not None:
    #Si téléthon est trouvé ont renvoie le code d'erreur 0.
    sys.exit(0)
  • peatb
    Zabbix Certified Trainer
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Aug 2016
    • 36

    #2
    Zabbix doesn't do anything with the exit code but looks at the output of the script. So change sys.exit(5) to "print 5" and "sys.exit()" and you're done.

    Comment

    Working...