Perhaps run a daily cron to link the file so it's easier to use with monit.
crontab 0 0 * * * /some/script.sh contents of script.sh #!/bin/bash rm /path/to/file-current ln /path/to/real-file-YYYY-MM-DD /path/to/file-current And have Monit always watches linked file. I guess the inode will change but it was going to change the old way too. On Mon, May 15, 2017 at 1:43 PM, Dimitri Yioulos <[email protected]> wrote: > Hello, all. > > > > I’m trying to have Monit restart a service based on a keyword in a > particular file. That file changes name by appending today’s date at the > end, as in “myprogram-server.log.processed-2017-05-13”. So, I have to > craft a check that takes the changing date into account. Here’s what I’ve > created: > > > > check file messages with path > /data1/myprogram/log/myprogram-server.log.processed-($date > +"%Y-%m-%d") > > if match "FATAL" then exec "/data1/myprogram/myprogram-mta/sm-server > server restart" > > > > The problem is in how to do the date part. I’ve tried every combination > of parens, quotes, back ticks, etc., but Monit won’t start because it > doesn’t like the date part. Can anyone help with this? > > > > Also, I’d like an email alert to say that the that the service has been > restarted. As the check is presently written, it sends an email with e.g. > “May 15 13:36:30 satest03 systemd: Stopped The Apache HTTP Server.” > Here’s that check (and it’s only a test): > > > > check file messages with path /var/log/messages > > if match "Stopped The Apache HTTP Server" then exec "/bin/systemctl > restart httpd" <- note that the match is what appears in the email > message. Can you help with this, too. > > > > Many thanks. > > > > Diggy > > -- > To unsubscribe: > https://lists.nongnu.org/mailman/listinfo/monit-general >
-- To unsubscribe: https://lists.nongnu.org/mailman/listinfo/monit-general
