monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Monitoring File not executing script....


From: Daniel Cook
Subject: Monitoring File not executing script....
Date: Sat, 10 Mar 2012 07:16:52 +0000

I am trying to get monit to alert when a file is modified on the file system.

I don't want to email anybody, I just want to run a simple script which in this case echoes the date to a file in /tmp

 

[root etc]# cat /usr/foo/bin/dan

#!/usr/bin/env bash

echo "$(date): Network Start file changed." > /tmp/dan.out

 

When I start monit and then touch the file I don't see any activity. 

My poll activity is set for 5 seconds.  What am I missing here?

 

Dan

 

+++++++++++++++

File before monit:

+++++++++++++++

[root etc]# ls -al /dev/shm/net_started

-rw-r--r--. 1 root root 0 Mar 10 06:51 /dev/shm/net_started

 

+++++++++++++++++++++++

Start Monit in the forground

and in another window touch

the file. /dev/shm/net_started

+++++++++++++++++++++++

[root etc]# monit -vv -c /etc/monitrc -I

monit: Debug: Adding credentials for user 'admin'.   

monit: Debug: Adding host allow 'localhost'          

monit: Debug: Skipping redundant host 'localhost'    

monit: Debug: Skipping redundant host 'localhost'    

monit: Debug: Skipping redundant host 'localhost'    

monit: Debug: Skipping redundant host 'localhost'    

monit: Debug: Skipping redundant host 'localhost'    

Runtime constants:                                   

 Control file       = /etc/monitrc                   

 Log file           = /var/log/monit.log             

 Pid file           = /var/run/monit.pid             

 Debug              = True

Log                = True

Use syslog         = False

Is Daemon          = True

Use process engine = True

Poll time          = 5 seconds with start delay 0 seconds

Expect buffer      = 256 bytes

Mail from          = (not defined)

Mail subject       = (not defined)

Mail message       = (not defined)

Start monit httpd  = True

httpd bind address = Any/All

httpd portnumber   = 3500

httpd signature    = True

Use ssl encryption = False

httpd auth. style  = Basic Authentication and Host/Net allow list

 

The service list contains the following entries:

 

File Name             = net_started

Path                 = /dev/shm/net_started

Monitoring mode      = active

Existence            = if does not exist 1 times within 1 cycle(s) then restart else if succeeded 1 times within 1 cycle(s) then alert

Timestamp            = if changed 1 times within 1 cycle(s) then exec '/usr/foo/bin/dan' timeout 0 cycle(s)

 

System Name           = system_localhost

Monitoring mode      = active

 

-------------------------------------------------------------------------------

monit: pidfile '/var/run/monit.pid' does not exist

Starting monit daemon with http interface at [*:3500]

Starting monit HTTP server at [*:3500]

monit HTTP server started

'system_localhost' Monit started

^C

++++++++++++++++++++++++++++

Stopped here after touching file and

waiting 30 seconds.

++++++++++++++++++++++++++++

 

Shutting down monit HTTP server

monit HTTP server stopped

monit daemon with pid [1520] killed

'system_localhost' Monit stopped

 

++++++++++++++++++++

File date after touching it

++++++++++++++++++++

[root etc]# ls -al /dev/shm/net_started

-rw-r--r--. 1 root root 0 Mar 10 07:01 /dev/shm/net_started

 

+++++++++++++++++++

Contents of monit file

+++++++++++++++++++

rootr monit.d]# cat test_file.cfg

check file net_started with path /dev/shm/net_started

 if changed timestamp then exec "/usr/foo/bin/dan"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]