monitoring linux system

452 views

Published on

Linux monitoring

Published in: Education, Technology, Design
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
452
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

monitoring linux system

  1. 1. How to Install and Setup Monit (Linux Process and Services Monitoring) Program Monit is a small Open Source utility for managing and monitoring Unix systems. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. monit is a utility for managing and monitoring processes, files, directories and file systems on a Unix system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. E.g. Monit can start a process if it does not run, restart a process if it does not respond and stop a process if it uses too much resources. You may use Monit to monitor files, directories and file systems for changes, such as timestamps changes, checksum changes or size changes. Monit is controlled via an easy to configure control file based on a free-format, token-oriented syntax. Monit logs to syslog or to its own log file and notifies you about error conditions via customizable alert messages. Monit can perform various TCP/IP network checks, protocol checks and can utilize SSL for such checks. Monit provides a http(s) interface and you may use a browser to access the Monit program. Install and Setup Monit on Centos6 # yum install monit # vi /etc/monit.conf ## mailserver Setup ## Note:- I have Google mail Server. set mailserver smtp.gmail.com port 587 username "pawan.kumar@indianpetro.com" password "********" using tlsv1 with timeout 30 seconds ## You can set alert recipients whom will receive alerts if/when a ## set mail-format { from: monitor@indianpetro.com } set alert pawan.kumar@indianpetro.com mail-format { from: monitor@indianpetro.com subject: $SERVICE $EVENT at $DATE
  2. 2. message: Monit $ACTION $SERVICE at $DATE on $HOST, Yours sincerely, Pawan Kumar Linux System Administrator IndianPetro Group (A Division of 360 Analytics & Advisory Pvt. Ltd.) ## Monit has an embedded web server which can be used to view status of### set httpd port 2812 and use address localhost # only accept connection from localhost allow localhost # allow localhost to connect to the server and allow admin:monit # require user 'admin' with password 'monit' allow @monit # allow users of group 'monit' to connect (rw) allow @users readonly # allow users of group 'users' to connect readonly Monitoring Services Example #################################### Mysql ######################## check process mysqld with pidfile /var/run/mysqld/mysqld.pid group mysql start program = "/etc/init.d/mysqld start" stop program = "/etc/init.d/mysqld stop" if failed host 127.0.0.1 port 3306 then restart if 5 restarts within 5 cycles then timeout
  3. 3. #################################### SSH ############################ check process sshd with pidfile /var/run/sshd.pid start program "/etc/init.d/sshd start" stop program "/etc/init.d/sshd stop" if failed host 127.0.0.1 port 22 protocol ssh then restart if 5 restarts within 5 cycles then timeout ############################ Tomcat1 #################### check process tomcat with pidfile "/var/run/tomcat/tomcat.pid" start program = "/usr/local/tomcat6/bin/startup.sh" as uid root gid root stop program = "/usr/local/tomcat6/bin/shutdown.sh" as uid root gid root if failed port 7070 then alert if failed port 7070 for 5 cycles then restart ##################### Tomcat2 ########################### check process tomcat1 with pidfile "/var/run/tomcat1/tomcat1.pid" start program = "/usr/local/tomcat7/bin/startup.sh" as uid pawan gid pawan stop program = "/usr/local/tomcat7/bin/shutdown.sh" as uid pawan gid pawan if failed port 9090 then alert if failed port 9090 for 5 cycles then restart
  4. 4. #### Then edit your catalina.sh and set #### # vim /usr/local/tomcat/bin/catalina.sh CATALINA_PID to be /var/run/tomcat/tomcat.pid #mkdir /var/run/tomcat/ #chown root:root /var/run/tomcat/ Thanks P@w@n Kumar https://www.facebook.com/LinuxLiveScenarioClass

×