Ad Widget

Collapse

Issues getting text output from UserParameters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shaun666
    Junior Member
    • Jun 2015
    • 11

    #1

    Issues getting text output from UserParameters

    Hi,

    We are currently using Zabbix v2.0 and we have a number of UserParameter definitions which emit integers perfectly.

    Today I would like one to emit a text string instead: a Yes or a No:

    UserParameter=mysql.slave_status[*],mysql -u XXX -XXX -Bse "show slave status\G" | awk -F: -v var=$1 '{ if ( $1 ~ var ) {print "data:"$$2} }'

    If I run this in the command (with $1 as Slave_IO_Running) I get:
    data:Yes

    However if I execute zabbix_get -s testhost -k mysql.slave_status["Slave_IO_Running"] on my Zabbix server I get no output

    On the client I get this:

    [root@ams-mysqlwell-03 zabbix_agentd.d]# zabbix_agent -t mysql.slave_status[Slave_IO_Running]
    mysql.slave_status[Slave_IO_Running] [t|]

    My item configuration looks like this:


    Please could someone explain what I am doing wrong?
    Attached Files
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    Please try change second $1 to $$1.

    Code:
    UserParameter=mysql.slave_status[*],mysql -u XXX -XXX -Bse "show slave status\G" | awk -F: -v var=$1 '{ if ( $$1 ~ var ) {print "data:"$$2} }'

    Comment

    • shaun666
      Junior Member
      • Jun 2015
      • 11

      #3
      Hi,

      First of thanks for your advice...

      I tried your suggestion but still no luck.... There is still no response.

      For completeness here is the debug log output

      21984:20150929:171154.500 In zbx_popen() command:'mysql -u zabbix -pjku8765 -Bse "show slave status\G" | awk -F: -v var=Slave_IO_Running '{ if ( Slave_IO_Running ~ var ) {print "data:"$2} }''
      21984:20150929:171154.501 End of zbx_popen():7
      22444:20150929:171154.501 zbx_popen(): executing script
      21984:20150929:171154.507 In zbx_waitpid()
      21984:20150929:171154.507 zbx_waitpid() exited, status:0 # NB Here we can see the command terminated normally i.e. it was successful.
      21984:20150929:171154.508 End of zbx_waitpid():22444



      Here is why I used two dollar symbols:
      (From https://www.zabbix.com/documentation...userparameters)
      Attached Files

      Comment

      • shaun666
        Junior Member
        • Jun 2015
        • 11

        #4
        I've written a much simpler expressions which works fine:

        UserParameter=mysql.slave_status[*],mysql -u XXXXX -pXXXXX -Bse "show slave status\G" | grep -m 1 $1 | awk '{ print $$2 }'

        This produces a nice text string

        zabbix_get -s testhost -k mysql.slave_status["Last_IO_Errno"]
        Last_IO_Errno: 0

        This is sufficient for my purposes but could someone explain why the whole line is printed rather than the last field, which is what my awk snippet does when used on the command line. NB I get the same result with one dollar symbol

        TIA

        Shaun

        Comment

        Working...