Ad Widget

Collapse

zabbix_get and zabbix_agentd -t produce different results

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • insertcoin
    Junior Member
    • Jan 2014
    • 16

    #1

    zabbix_get and zabbix_agentd -t produce different results

    Hi,

    I have a script that tests to see if there is any process running on port 80 (this isn't apache)

    On the server my script is as follows:

    Code:
    #!/bin/bash
    
    if [ -z "$(lsof -i :80)" ]; then
      echo 0
    else
      echo 1
    fi
    If I run this with the service that uses that port running it returns 1, if its stopped it returns 0.

    Running this from the zabbix server gives a blank result:

    Code:
    root@zabbix:~# /usr/bin/zabbix_get -I{zabbix server} -s {target IP} -p 10050 -k test
    
    root@zabbix:~#
    I added another userparameter as follows:

    Code:
    UserParameter=test2,[[ -z "$(lsof -i :80)" ]] && echo 1 || echo 0
    This produces the correct result on the server if run via bash, giving 1 if their is a process on that port and 0 if not.

    Running it from the remote zabbix server I get:

    Code:
    root@zabbix:~# /usr/bin/zabbix_get -I{zabbix server} -s {target IP} -p 10050 -k test2
    1
    root@zabbix:~#
    Not sure what I am missing, any advice?
  • BDiE8VNy
    Senior Member
    • Apr 2010
    • 680

    #2
    Why not using the native Zabbix agent item net.tcp.listen[port]?

    Comment

    • insertcoin
      Junior Member
      • Jan 2014
      • 16

      #3
      Honestly I did try that first and it wasn't working....

      But it does appear to be now, so all is ok.

      Comment

      Working...