Ad Widget

Collapse

userparamter multiple commands or setting bash variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • registration_is_lame
    Senior Member
    • Nov 2007
    • 148

    #1

    userparamter multiple commands or setting bash variable

    Is it possible to pass multiple commands in userparamters?


    UserParameter=item,port=`netstat -plntu 2>/dev/null | grep process_name | awk '{print $4}' | awk -F":" '{print $2}'`; echo $port;

    or

    UserParameter=item,bash -c "port=`netstat -plntu 2>/dev/null | grep process_name | awk '{print $4}' | awk -F":" '{print $2}'`; echo $port;"
    or

    UserParameter=item,bash -c "port=`netstat -plntu 2>/dev/null | grep process_name | awk '{print $4}' | awk -F":" '{print $2}'` && echo $port;"


    None of these echo the port number. It returns empty.

    Similar question with no answer - https://www.zabbix.com/forum/zabbix-...-part-commands
    Last edited by registration_is_lame; 26-06-2019, 13:50.
  • lagavazzz
    Junior Member
    • Apr 2019
    • 21

    #2
    Hello,

    Multiple commands are possible, as can be seen here.



    Do you see any errors in the zabbix server logs? Perhaps the error is seen also in the frontend?

    Comment

    • registration_is_lame
      Senior Member
      • Nov 2007
      • 148

      #3
      Figured it out. Zabbix needed sudoers access. echo "zabbix ALL=(ALL:ALL) NOPASSWD:/usr/bin/netstat" >> /etc/sudoers

      Comment

      Working...