Monday, October 21, 2013

Mmonit and monit installation steps



Mmonit and monit installation steps

1. Make sure SElinux will allow both services ie SELinus is either turned off or in targeted mode so that a new installation of monit and mmonit will run straight away without being blocked. If SElinux is to be used figure out first how to configure things so that these services are not blocked. SELinux is much more complicated than mmonit/monit and will get in the way of you evaluating these tools quickly.


2. Make sure the iptables firewall is configured to allow these services through, if iptables firewall is to be used, first configure it correctly. Initially the firewall can be disabled to allow operation of monit and mmonit. Its easy to waste hours/days thinking you have monit not configured correctly when its just being blocked by iptables firewall.

3. Run ‘yum install monit’ This installs a version of monit into your linux environment. For me it installed an old version. This appears to set things up so that monit will restart when your system restarts but I haven’t tested this yet. When I’ve figured out how to install the latest version with yum I will update this blog.

4. On each server download the latest version of monit (latest version is 5.6 as of writing this blog). Make sure you have the latest version. I got it from https://mmonit.com/monit/download/ .

5. Unzip it with the following command into a suitable directory 'gunzip < monit-5.6-linux-x64.tar.gz | tar xvf -'.  I put the executable into /usr/bin/monit-5.6 ie 'cp monit-5.6/bin/monit /usr/bin/monit'

6. I edited the script file (/etc/init.d/monit) so that it calls monit with the –v option to that there’s lots of verbose output. This means that that initially when I start it I can see whats going on, and I have a better idea that its started correctly.

7. Create an email address with your favourite email server. I used gmail initially.

8. Edit /etc/monitrc. Edit as required. Below is a starting generic template: Things to change are in red bold font.

set daemon  60
set eventqueue basedir /var/tmp/mmonit/ slots 1000
set mmonit http://admin:swordfish@myhost:8080/collector
set logfile /var/log/monit
set alert noc@mycompany.com
set mailserver smtp.gmail.com username "mygmailaccount@gmail.com" password "mypassword" using TLSV1
set mail-format { from: mygmailaccount@gmail.com }
set httpd port 2812 and use address myhostsipaddress
  allow ipaddressofremoteadminusersdevice/netmask
  # eg
  # allow 192.168.1.25/255.255.255.0
  allow admin:swordfish
check process sshd with pidfile /var/run/sshd.pid
check host anotherhostname with address anotherhostname
  if failed icmp type echo count 5 with timeout 15 seconds then alert
check process sybase with pidfile /var/run/sybase.pid
check filesystem rootfs with path /
  if space < 10 % then alert

9. Make sure each process you want to monitor has a corresponding .pid in /var/run eg Sybase.pid. You can achieve this by  appending the following line ‘echo $! > /var/run/myproc.pid’ to a startup script, just after running your target process.Eg
/sybase/ASE-15_0/bin/dataserver \
-d/sybase_data/master \
-e/sybase/log/DBSERVER.log \
-c/sybase/ASE-15_0/DBSERVER.cfg \
-M/sybase/ASE-15_0 \
-sDBSERVER \
echo $! > /var/run/sybase.pid
 

10. Start monit with the command  

/etc/init.d/monit  start





11. Install mmonit from https://mmonit.com/download/

12. Unzip with the following command into a suitable directory 

‘gunzip < mmonit-3.0-linux-x64.tar.gz | tar xvf – 

 13. Run mmonit. I noticed that I had to cd to the bin directory under mmonit-3.0 and run it with ./mmonit. I haven’t yet figured out how to install in Linux so that it runs from startup from init.d. Watch this space for updates. If you have configured you hosts running monit correctly (added an ‘allow hostip/mask’ for the server running mmonit), mmonit will start communicating with these servers automatically.



14. To see the monit web page browse to http://mymonithost:2812 

 14. To see the mmonit web page browse to http://mymmonithost:8080

No comments:

Post a Comment