monit-general
[Top][All Lists]
Advanced

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

Re: monit ignores match pattern commnad


From: Anthony Griffiths
Subject: Re: monit ignores match pattern commnad
Date: Mon, 7 Apr 2014 19:34:28 +0100

ok I'm getting more positive results now but exec "/root/sendemail.sh" doesn't trigger anything. Nothing happens. I'm watching the tail of monit.log and it is matching the pattern and showing 'exec: /root/sendemail.sh' but nothing happens.
If I do /root/sendemail.sh in a terminal the script sends an email just as it should.
I did chown monit.monit /root/sendemail.sh to make sure of now ownership problems, and I also did:
chmod 777 /root/sendemail.sh to make sure of all permissions but still nothing happens when monit matches a pattern and does /root/sendemail.sh. I've also watched the tail of var/log/maillog and that shows that nothing is being emailed. What's further puzzling is I don't get any error message. Any ideas?


On Mon, Apr 7, 2014 at 4:39 PM, Martin Pala <address@hidden> wrote:
The character "^" means start of the line => pattern didn't match. The alternative pattern (behind "|") didn't match too.

The following pattern should work:

check file openvpn-client.log with path /home/share/openvpn-client.log
      if match "Initialization Sequence Completed" then exec "/root/sendemail.sh"

The proc file error may show up if the process exit before Monit collected details about it (for a moment it was visible in the process table). You can ignore this message (harmless and suppressed in non-debug mode).


On 07 Apr 2014, at 17:33, Anthony Griffiths <address@hidden> wrote:

yeah here are several lines from openvpn-client.log
Sun Apr  6 00:14:39 2014 us=887909 /sbin/ip route add 128.0.0.0/1 via 10.8.0.229
Sun Apr  6 00:14:39 2014 us=890100 /sbin/ip route add 10.8.0.1/32 via 10.8.0.229
Sun Apr  6 00:14:39 2014 us=892228 Initialization Sequence Completed
Sun Apr  6 01:14:37 2014 us=8351 TLS: soft reset sec=0 bytes=151768170/0 pkts=209813/0

'Initialization Sequence Completed' is the pattern I want monit to look for and respond to. I've deleted the line
ignore match "^monit" from monit.conf as per your instruction.

btw, for no reason I can see the the monit.log file has suddenly started showing:
 debug    : monit: Cannot open proc file /proc/4945/stat -- No such file or directory
 debug    : system statistic error -- cannot read /proc/4945/stat
every time I start monit. Do you know why this is?

This is my monit.conf file:

set daemon  60
set logfile /home/share/monit.log
set idfile /var/monit/id
set statefile /var/monit/state
include /etc/monit.d/*
check file openvpn-client.log with path /home/share/openvpn-client.log
     if match "^Initialization Sequence Completed | /home/share/openvpn-client.log"
     then exec "/root/sendemail.sh"

thanks for your further help btw...


On Mon, Apr 7, 2014 at 4:09 PM, Martin Pala <address@hidden> wrote:
Please can you send few sample lines from the logfile to which the pattern should match?

The following line is most probably not necessary, as monit doesn't log to the same file most probably:
ignore match "^monit"


On 07 Apr 2014, at 16:55, Anthony Griffiths <address@hidden> wrote:

any help on this mailing list? I'm kinda stuck here....


---------- Forwarded message ----------
From: Anthony Griffiths <address@hidden>
Date: Sun, Apr 6, 2014 at 9:51 AM
Subject: monit ignores match pattern commnad
To: This is the general mailing list for monit <address@hidden>


using the example IF [NOT] MATCH {regex|path} THEN action I'm trying to get monit to watch a logfile for a pattern and then trigger a script. The logfile is /home/share/openvpn/log and the relevant test string in the file is 'Initialization Sequence Completed'.
In monitor.conf I have:

check file openvpn-client.log with path /home/share/openvpn-client.log
     ignore match "^monit"
     if match "^Initialization Sequence Completed | /home/share/openvpn-client.log"
     then exec "/root/sendemail.sh"

however in the monit log all I get (every minute) is:
[BST Apr  6 00:05:52] debug    : 'openvpn-client.log' file exists check succeeded
[BST Apr  6 00:05:52] debug    : 'openvpn-client.log' is a regular file
[BST Apr  6 00:06:52] debug    : 'openvpn-client.log' file exists check succeeded
[BST Apr  6 00:06:52] debug    : 'openvpn-client.log' is a regular file
[BST Apr  6 00:07:52] debug    : 'openvpn-client.log' file exists check succeeded
[BST Apr  6 00:07:52] debug    : 'openvpn-client.log' is a regular file
[BST Apr  6 00:08:52] debug    : 'openvpn-client.log' file exists check succeeded
[BST Apr  6 00:08:52] debug    : 'openvpn-client.log' is a regular file
[BST Apr  6 00:09:52] debug    : 'openvpn-client.log' file exists check succeeded
[BST Apr  6 00:09:52] debug    : 'openvpn-client.log' is a regular file
[BST Apr  6 00:10:52] debug    : 'openvpn-client.log' file exists check succeeded
[BST Apr  6 00:10:52] debug    : 'openvpn-client.log' is a regular file

monit is not looking for the pattern. What am I doing wrong?

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


reply via email to

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