Ad Widget

Collapse

system.run

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • esawyja
    Member
    Zabbix Certified Specialist
    • Dec 2011
    • 54

    #1

    system.run

    Hi All,
    I execute the following command
    [root@xxxsvr1 sbin]# ./zabbix_agentd -t system.run["$JAVA_HOME/bin/jps -l | grep xxx | wc -l"]
    zabbix_agentd [1801]: Warning: Executing command '/usr/java/bin/jps -l | grep xxx | wc -l'
    system.run[/usr/java/bin/jps -l | grep xxx | wc -l] [t| 9]
    [root@xxxsvr1 sbin]#

    Does that mean the count is 9? SO I have 9 xxx processes running, if I do it in bash I get the same
    [root@xxxsvr1 sbin]# $JAVA_HOME/bin/jps -l | grep xxx | wc -l
    9
    [root@xxxsvr1 sbin]#

    The problem I have is that zabbix is triggering even though I've set it to only trigger when the process count is below 5, problem is that it seems that Zabbix is getting the value 0 all the time, see my item and trigger definitions below. From the log I get this

    25956:20111208:233206.076 Requested [vfs.fs.size[/,free]]
    25956:20111208:233206.076 Sending back [104122097664]
    25957:20111208:233206.136 Processing request.
    25957:20111208:233206.136 Requested [system.run[$JAVA_HOME/bin/jps -l | grep xxx | wc -l ]]
    25957:20111208:233206.137 Executing command '$JAVA_HOME/bin/jps -l | grep xxx | wc -l '
    25957:20111208:233206.137 In zbx_popen() command:'$JAVA_HOME/bin/jps -l | grep xxx | wc -l '
    10345:20111208:233206.139 zbx_popen() executing script
    25957:20111208:233206.139 End of zbx_popen():7
    25958:20111208:233206.158 Processing request.
    25958:20111208:233206.158 Requested [vfs.fs.size[/tmp,pfree]]
    25

    Can someone please indicate what I'm doing wrong, PLEASE!!
    Last edited by esawyja; 02-11-2012, 08:54.
  • richlv
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2005
    • 3112

    #2
    don't use zabbix_* -t/-p, use zabbix_get against a running daemon to test this. when you run zabbix like this, it most likely is not as a zabbix user (in this case it's root), thus different permission affecting things (like selinux) affect the outcome
    Zabbix 3.0 Network Monitoring book

    Comment

    • esawyja
      Member
      Zabbix Certified Specialist
      • Dec 2011
      • 54

      #3
      Man..... Zabbix is doing my head in, I'm sending zabbix_get as you suggested, from the zabbix server I get
      zabbix:~ # zabbix_get -s 41.203.65.189 -p 10050 -k system.run["/etc/zabbix/scripts/test.sh"]
      0
      zabbix:~ #

      On the actual server
      dt:/etc/zabbix/scripts # /etc/zabbix/scripts/test.sh
      9
      dt:/etc/zabbix/scripts #

      From the logfile
      24592:20111220:071045.758 Sleeping for 1 seconds
      24589:20111220:071046.144 Processing request.
      24589:20111220:071046.446 Requested [system.run[/etc/zabbix/scripts/test.sh]]
      24589:20111220:071046.446 Executing command '/etc/zabbix/scripts/test.sh'
      24589:20111220:071046.691 Before
      24589:20111220:071046.691 Run remote command [/etc/zabbix/scripts/test.sh] Result [1] [0]...
      24589:20111220:071046.691 Sending back [0]
      24592:20111220:071046.758 In send_buffer() host:'196.26.207.89' port:10051 values:0/100
      24592:20111220:071046.758 End of send_buffer():SUCCEED
      24592:20111220:071046.758 Sleeping for 1 seconds

      dt:/etc/zabbix/scripts # cat /etc/zabbix/scripts/test.sh
      #!/bin/bash
      $JAVA_HOME/bin/jps -l | grep xxx | wc -l
      dt:/etc/zabbix/scripts #

      Why is Zabbix doing this to me..........

      Comment

      • richlv
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Oct 2005
        • 3112

        #4
        Originally posted by esawyja
        On the actual server
        dt:/etc/zabbix/scripts # /etc/zabbix/scripts/test.sh
        9
        why are you running that command as root ? did you try running it as zabbix user ?
        Zabbix 3.0 Network Monitoring book

        Comment

        • esawyja
          Member
          Zabbix Certified Specialist
          • Dec 2011
          • 54

          #5
          Originally posted by richlv
          why are you running that command as root ? did you try running it as zabbix user ?
          Yes, did run it as zabbix user as well, get the same. I have finally figured out that it is the Java process that is causing it. I've changed my script to use ps and now it is working, thanks for the help

          Comment

          Working...