Ad Widget

Collapse

UserParamter Issue ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bdgregg
    Junior Member
    • Feb 2023
    • 2

    #1

    UserParamter Issue ?

    Hello,
    I am working on setting up a UserParameter to monitor our Cantaloupe IIIF server (v.4.1) by simply grabbing a localhost webpage via curl and looking for a string in the result. As the server (Zabbix 5.0.31 (Zabbix repo)) sits in a different firewall zone than the client (Zabbix agent 5.0.21 (EPEL repo)) we don't want to open up a firewall rule to allow direct monitoring of the Cantaloupe IIIF server via web requests from the Zabbix server. Instead we are looking to a real simple local script and UserParameter to achieve this. The simple script "check_url" is as follows and it takes two parameters, the URL to question (generally http://localhost:8182/health for the Cantaloupe health) and the string to look for - in our case the word "color". The output of the curl command results in JSON output as shown below:

    Cantaloupe /health output:
    Code:
    {"color":"RED","message":"FilesystemCache: /srv/cache/source","possibleColors":["GREEN","YELLOW","RED"]}
    check_url script:
    Code:
    #!/bin/bash
    RESULT=`curl -s $1 | grep $2`
    if [ -z "$RESULT" ]
    then
         echo 1
         exit 1
    else
         echo 0
         exit 0
    fi

    When run from the command line the exit and echo work as expected. The first value returned is from the script, the 2nd value returned is the return code from the script.
    Code:
    # ./check_url http://localhost:8182/health color; echo $?
    0
    0
    ​# ./check_url http://localhost:8182/health blue; echo $?
    1
    1
    ​
    When run from the zabbix_get command from the Zabbix server the cmd_result does not reflect either the exit value or the echo value of the script as captured in the zabbix_agentd.log file. The sending back code is always "1".

    Executed zabbix_get:
    Code:
    $ zabbix_get -s pa-iiif-01.library.pitt.edu -k "cantaloupe.check_url[http://localhost:8182/health,color]"
    1
    Result:
    Code:
    EXECUTE_STR() command:'/usr/local/bin/check_url http://localhost:8182/health color' len:1 cmd_result:'1'
    Sending back [1]
    Executed zabbix_get:
    Code:
    $ zabbix_get -s pa-iiif-01.library.pitt.edu -k "cantaloupe.check_url[http://localhost:8182/health,blue]"
    1


    Result:
    Code:
    EXECUTE_STR() command:'/usr/local/bin/check_url http://localhost:8182/health blue' len:1 cmd_result:'1'
    Sending back [1]
    What specifically is the value of the "cmd_result"? Is it the exit code of the command run or is the value output from the command? I'm suspecting the later due to being able to run a command that returns text seems to work correctly. However as indicated above the first example should IMO return "0" instead of "1".

    Is this maybe (far reach here IMO) due to the difference between versions on the server (5.0.31) vs. client (5.0.21) - or did I happen to stumble across a bug?

    Thanks,
    -Brian.
  • bdgregg
    Junior Member
    • Feb 2023
    • 2

    #2
    Follow up... Problem Solved...

    As we had SELinux enabled on the client, Zabbix was unable to execute a 'curl' network connection to access the web interface we were asking it to pull down. Once we discovered that SELinux was behind the issue, we adjusted the SELinux settings (see audit2allow to accomplish this) to allow the connection, we were then able to have the zabbix_get command to work as expected.

    Hope this helps someone that experiences the same issue.

    Thanks,
    -Brian.

    Comment

    Working...