Ad Widget

Collapse

Monitoring whether a process is running using result of a folder discover rule

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stu
    Junior Member
    • Jun 2017
    • 12

    #1

    Monitoring whether a process is running using result of a folder discover rule

    Hi

    I would like to monitor whether a process is running where I get the process name from a text file.

    I have a bash command

    /usr/bin/find /home/user/*/current/config -name "sidekiq.yml"|awk -F"/" '{print $4}' that gives me


    app1
    app2
    app3
    app4


    There will be processes running which will be named app1, app2, app3 etc

    Zabbix will then alert if a process has failed.

    Is this possible?


    I have other proc.num commands, but have always hard coded the process name.
  • batchenr
    Senior Member
    • Sep 2016
    • 440

    #2
    Originally posted by stu
    Hi

    I would like to monitor whether a process is running where I get the process name from a text file.

    I have a bash command

    /usr/bin/find /home/user/*/current/config -name "sidekiq.yml"|awk -F"/" '{print $4}' that gives me


    app1
    app2
    app3
    app4


    There will be processes running which will be named app1, app2, app3 etc

    Zabbix will then alert if a process has failed.

    Is this possible?


    I have other proc.num commands, but have always hard coded the process name.
    you will have to create a script for checking that
    or check this :
    https://stackoverflow.com/questions/...ice-on-centos7

    Comment

    • stu
      Junior Member
      • Jun 2017
      • 12

      #3
      Thanks

      I've now configured the following script

      Code:
      #!/bin/bash
      files=$(/usr/bin/find /home/<user>/*/current/config -name "sidekiq.yml"|awk -F"/" '{print $4}')
      processes=$(ps -e -o command|grep [s]idekiq|awk '{ print $3 }')
      diff <(echo "$files" ) <(echo "$processes")|grep "<" > /tmp/sidekiq.txt
      I then use zabbix to alert if the file exists, but is there any way I can include the contents of the file if it does in the alert?
      Last edited by stu; 04-07-2017, 15:49.

      Comment

      • batchenr
        Senior Member
        • Sep 2016
        • 440

        #4
        Originally posted by stu
        Thanks

        I've now configured the following script

        Code:
        #!/bin/bash
        files=$(/usr/bin/find /home/<user>/*/current/config -name "sidekiq.yml"|awk -F"/" '{print $4}')
        processes=$(ps -e -o command|grep [s]idekiq|awk '{ print $3 }')
        diff <(echo "$files" ) <(echo "$processes")|grep "<" > /tmp/sidekiq.txt
        I then use zabbix to alert if the file exists, but is there any way I can include the contents of the file if it does in the alert?
        what do you mean if it doesn't alert ?
        how did you config your trigger and what do you want it to show ?

        Comment

        • stu
          Junior Member
          • Jun 2017
          • 12

          #5
          I've configured a trigger using the following

          Code:
          {Template App Sidekiq service:vfs.file.exists[/tmp/sidekiq.txt].last()}=1
          which generates an alert when the file exists, but how can I get the contents of the file that exists in the alert.

          Comment

          • batchenr
            Senior Member
            • Sep 2016
            • 440

            #6
            Originally posted by stu
            I've configured a trigger using the following

            Code:
            {Template App Sidekiq service:vfs.file.exists[/tmp/sidekiq.txt].last()}=1
            which generates an alert when the file exists, but how can I get the contents of the file that exists in the alert.
            your item olny check if file exsist if you want the contact of the file
            then make the script do it somthing like

            Code:
            VAR=$(cat /the/file/you/want.txt)
            if [[ -n $VAR]]; then
               echo $VAR
            else
            echo 1
            fi
            and then the item value will be $var which is the context of the file and
            in the trigger you should put
            alert! {ITEM.LASTVALUE}

            and it will show you this on the dash board
            or if it is a file with a big context and you want it only on the email then
            in the action message include the {ITEM.LASTVALUE} and not on the trigger.

            Comment

            Working...