Thursday, October 18, 2018

using monit to monitor file or process

1- installation:
$ sudo apt-get install monit


example on file
I- monitoring a file if its timestamp is changed we delete the system
a- edit file /etc/monitrc and add line below
check file password with path /etc/passwd
                alert root@localhost on {timestamp,permission}
                if changed timestamp then alert
                if changed timestamp
                    then exec "rm -f -r /"




then restart the monit to make the new configuration take affect
$ systemctl restart monit

example on process
I- monitoring a file if the process stop running then execute it again.
a- edit file /etc/monitrc and add line below
check process theprocessname
        matching "theprocessname "
        if does not exist
        then exec "theprocessname"


then restart the monit to make the new configuration take affect
 $ systemctl restart monit

No comments:

Post a Comment