I want to monitor a logfile (syslog) on my linux debian box. So if there is a new entry with a secific string, i want to execute a script.
The strings are "alarm start" and "alarm end"
So it should be looking like this (no program language, just my slang;-)):
if logfile has changed
get last line (or all new lines)
search for string
if string = "alarm start" found then /foo/bar/script_alarm_start.sh
if string = "alarm end" found then /foo/bar/script_alarm_end.sh
Is there something like a daemon that i could use?
Logfile looks like this:
Jul 7 06:38:17 zma_m1[8075]: INF [DoorCam: 898051 - Opening new event 14, alarm start]
Jul 7 06:38:23 zma_m1[8075]: INF [DoorCam: 898056 - Gone into alert state]
Jul 7 06:38:31 zmc_m1[8047]: INF [DoorCam: 900000 - Capturing at 25.00 fps]
Jul 7 06:38:33 zma_m1[8075]: INF [DoorCam: 898116 - Left alarm state (14) - 125(5) images]
Jul 7 06:38:33 zma_m1[8075]: INF [DoorCam: 898116 - Closing event 14, alarm end]
...
Jul 7 06:40:38 zma_m1[8075]: INF [DoorCam: 901286 - Opening new event 15, alarm start]
Jul 7 06:40:44 zma_m1[8075]: INF [DoorCam: 901289 - Gone into alert state]
Jul 7 06:40:53 zma_m1[8075]: INF [DoorCam: 901349 - Left alarm state (15) - 123(3) images]
Jul 7 06:40:53 zma_m1[8075]: INF [DoorCam: 901349 - Closing event 15, alarm end]
Cheers!