Ad Widget

Collapse

external checks with python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sebd44
    Junior Member
    • Apr 2020
    • 8

    #1

    external checks with python

    hi experts, i'm new to zabbix but i knew that with external link i can monitor api rest aps
    so i want to start simple and get something basic like http code with a python scripts


    import requests
    try:
    r = requests.head("http://show.cl")
    print(r.status_code)
    codigo_http = r.status_code
    if codigo_http == 200:
    print("1")
    else:
    print("0")
    # prints the int of the status code. Find more at httpstatusrappers.com
    except requests.ConnectionError:
    print("failed to connect")


    i read this https://www.zabbix.com/documentation...types/external but is not a howto, can you help me to connect the dots

    after this, create a host
    host > items : external check and key the name of the script
    admin > scripts > and i added this get_test Script Agent usr/lib/zabbix/externalscripts/test.sh

    now i'm i dont know if can i use a python or bash?
    when you running i think in the background the user zabbix runs it ans get the exit code of the script and decide if it's ok or not?
    or print in the if 1 or 0 it's works? or i have to create a bash scrip and get: echo $?


  • sebd44
    Junior Member
    • Apr 2020
    • 8

    #2
    or something like this in bash?

    while true
    do
    STATUS=$(curl -s -o /dev/null -w '%{http_code}' http://show.cl)
    if [ $STATUS -eq 200 ]; then
    echo 0
    break
    else
    echo 1
    fi
    sleep 10
    done

    Comment

    • sebd44
      Junior Member
      • Apr 2020
      • 8

      #3
      sup, hope you are doing well
      i get it to work

      1.- create a bash scripting and returning some value, can be multiples values?
      2.- add host and item as external and the name of the script and value as numeric(float)
      3.- add the script in the administration > script : zabbix server
      4.- create the graph, shut your eyes and hope it works

      please closed this thread,
      feedback: more howto focused documentation please
      i haved followed and matched pieces like in the 90'
      best regards

      Comment

      Working...