Ad Widget

Collapse

User Parameters to monitor a process

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dpeterson
    Junior Member
    • Apr 2014
    • 26

    #1

    User Parameters to monitor a process

    Hello all,

    I have set up a UserParameter in my zabbix_agentd.conf to monitor for a specific process. Here is how I have it set up:

    Code:
     UserParameter=ZabJob,ps -ef | grep xyz | wc -l
    I have set up the item in Zabbix and I am receiving data, however the returned value is +1 on every host.

    For example:

    Code:
    david@host:/etc/zabbix$ ps -ef |grep xyz
    5090     12354  3117  0 11:28 pts/0    00:00:00 grep xyz
    david  22807     1  5 Jul06 pts/4    01:23:04 xyz
    
    
    david@host:/etc/zabbix$ ps -ef |grep xyz |wc -l
    2
    Zabbix shows a value of 3 instead of 2. Any idea on why this might be happening?

    Cheers
    Last edited by dpeterson; 07-07-2014, 19:37.
  • aib
    Senior Member
    • Jan 2014
    • 1615

    #2
    You have at least two options:

    1) Use the command:
    UserParameter=ZabJob,ps -ef | grep xyz | grep -v grep | wc -l

    2) use proc.num[xyz] Item.
    Sincerely yours,
    Aleksey

    Comment

    • Udo
      Junior Member
      • Jul 2012
      • 6

      #3
      Originally posted by dpeterson
      Hello all,
      Code:
      david@host:/etc/zabbix$ ps -ef |grep xyz |wc -l
      2
      Zabbix shows a value of 3 instead of 2. Any idea on why this might be happening?
      Cheers
      I can not tell why Zabbix shows 3 in the above example.

      But I have another tip: to decrease the count by 1 - and to get the correct 1 instead of the 2 in the example - use a modified grep argument like this one:
      Code:
       ps -ef |grep [x]yz |wc -l
      This will avoid wc seing the line with the grep process itself.

      Best regards

      Comment

      • dpeterson
        Junior Member
        • Apr 2014
        • 26

        #4
        Originally posted by aib
        You have at least two options:

        1) Use the command:
        UserParameter=ZabJob,ps -ef | grep xyz | grep -v grep | wc -l

        2) use proc.num[xyz] Item.
        Thank you very much! This worked like a charm!

        Comment

        • dpeterson
          Junior Member
          • Apr 2014
          • 26

          #5
          Originally posted by Udo
          I can not tell why Zabbix shows 3 in the above example.

          But I have another tip: to decrease the count by 1 - and to get the correct 1 instead of the 2 in the example - use a modified grep argument like this one:
          Code:
           ps -ef |grep [x]yz |wc -l
          This will avoid wc seing the line with the grep process itself.

          Best regards
          Thank you for the reply!

          Comment

          • lasseoe
            Junior Member
            • Aug 2008
            • 15

            #6
            Or use pgrep (http://en.wikipedia.org/wiki/Pgrep)

            Comment

            Working...