There is a certain error which is always the same and I am getting in syslog, however I am not really sure what the error is being caused by so I would like to get alerted immediately whenever it occurs. Preferably I would like something like a script to monitor syslog for any lines containing that certain message, and if it is detected for it to immediately alert me through notify-send
and then to log it in a file. I am running Ubuntu GNOME 16.04 with GNOME 3.20. How can I achieve this through a script? Or is there some software that would allow me to do this?
Ubuntu – How to monitor syslog and get alerted when there is a certain entry
monitoringnotify-sendscriptssoftware-recommendationsyslog
Related Question
- Command Line – Start Multiple Apps in Split Console
- Ubuntu – How to monitor syslog and send notification based on events
- Ubuntu – How to search through all keyboard shortcuts that use a certain key
- How to Show Countdown Window Until Next Suspend on Ubuntu
- Ubuntu – I want to get a warning when apt installing from certain sources, like restricted and multiverse
Best Answer
Here, a script, in Python:
Checks file for changes every 5 seconds, if changed, it checks for the string. If string is found:
notify-send
Usage:
Optional arguments, to be put after the above
beep
and/ornotify
-- this will cause the script to beep and/or notify (usingnotify-send
) in addition to printing the messageSo, if I want to watch
/var/log/auth.log
for SSH and make a beep sound and notify me, I will:Raw download (Right Click → Save link as): GitHub Gist