SlideShare una empresa de Scribd logo
1 de 14
Monit
Keeping UNIX Deployments
Monitor & Manage
   System Resources
       Processes
         Files
      Directories
        Devices
   Network Services
Take Action!
alert   Send an alert
restart Stop then start a
        process
start   Start a process
stop    Stop a process
exec    Execute arbitrary
        program
unmonit Disable monitoring
or
timeout Disable monitoring
Prerequisites
             UN*X
Start/Stop Scripts for Processes
     Mail Server for Alerts
Configure
~/.monitrc
/etc/monitrc
/usr/local/etc/monitrc
~/monitrc


$ monit -c /etc/monit/monitrc
$ monit -t
Configure
## /etc/monit/monitrc
set daemon 120
set logfile /var/log/monit.log


set alert alert@brianturnbull.com


set mail-format {
    from: monit@brianturnbull.com
    subject: $SERVICE service - $EVENT
    message: $ACTION $SERVICE on $HOST: $DESCRIPTION
}


set mailserver localhost port 25


set httpd port 8877
    allow monit:passwd


include /etc/monit/monit.d/*
Monitor
## /etc/monit/monit.d/apache
check process apache with pidfile /var/run/apache2.pid
 start program = quot;/etc/init.d/apache2 startquot;
 stop program   = quot;/etc/init.d/apache2 stopquot;
 if failed host localhost port 80 protocol http then restart
 if 2 restarts within 3 cycles then timeout


## /etc/monit/monit.d/sshd
check process sshd with pidfile /var/run/sshd.pid
 start program = quot;/etc/init.d/ssh startquot;
 stop program   = quot;/etc/init.d/ssh stopquot;
 if failed port 22 protocol ssh then restart
 if 5 restarts within 5 cycles then timeout
Monitor Files
## /etc/monit/monit.d/apache_log
check file access.log with path /var/log/apache2/access.log
  if size > 100Mb
    then exec quot;/usr/sbin/logrotate -f /etc/logrotate.d/apache2quot;


check file error.log with path /var/log/apache2/error.log
  if size > 100Mb
    then exec quot;/usr/sbin/logrotate -f /etc/logrotate.d/apache2quot;
Monitor Directories
## /etc/monit/monit.d/sbin
check directory sbin with path /sbin
  if changed timestamp then alert


check directory sbin-usr with path /usr/sbin
  if changed timestamp then alert
Monitor Devices
## /etc/monit/monit.d/disks
check device sda1 with path /dev/sda1
 if space usage > 90% then alert
 if inode usage > 90% then alert
Monitor Resources
## /etc/monit/monit.d/system
check system brianturnbull.com
 if loadavg (1min) > 4 then alert
 if loadavg (5min) > 2 then alert
 if memory usage > 75% then alert
 if cpu usage (user) > 70% then alert
 if cpu usage (system) > 30% then alert
 if cpu usage (wait) > 20% then alert
Monitor Services
## /etc/monit/monit.d/apache
check process apache with pidfile /var/run/apache2.pid
  start program = quot;/etc/init.d/apache2 startquot;
  stop program   = quot;/etc/init.d/apache2 stopquot;
  if failed host localhost port 80 protocol http then restart
  if 2 restarts within 3 cycles then timeout


## /etc/monit/monit.d/mail
check host mail.brianturnbull.com with address mail.brianturnbull.com
  if failed port 25
    expect “^220.*rn”
    send “HELO brianturnbull.com
    expect “^250.*rn”
    send “QUIT.*rn”
    expect “^221.*rn”
      then alert
Dependancies
## /etc/monit/monit.d/apache
check process apache with pidfile /var/run/apache2.pid
  group www
  start program = quot;/etc/init.d/apache2 startquot;
  stop program   = quot;/etc/init.d/apache2 stopquot;
  if 2 restarts within 3 cycles then timeout
  if failed host localhost port 80 protocol http then restart
  depends on apache_bin
  depends on apache_rc


check file apache_bin with path /usr/sbin/apache2
  group www
  if failed checksum then unmonitor
  if failed permission 755 then unmonitor
  if failed uid root then unmonitor
  if failed gid root then unmonitor


check file apache_rc with path /etc/init.d/apache2
  group www
  if failed checksum then unmonitor
  if failed permission 755 then unmonitor
  if failed uid root then unmonitor
  if failed gid root then unmonitor
More Info
 & Examples
http://mmonit.com/monit




  Thank You
http://brianturnbull.com

Más contenido relacionado

La actualidad más candente

How Danga::Socket handles asynchronous processing and how to write asynchrono...
How Danga::Socket handles asynchronous processing and how to write asynchrono...How Danga::Socket handles asynchronous processing and how to write asynchrono...
How Danga::Socket handles asynchronous processing and how to write asynchrono...Gosuke Miyashita
 
Any event intro
Any event introAny event intro
Any event introqiang
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)xSawyer
 
NSClient Workshop: 04 Protocols
NSClient Workshop: 04 ProtocolsNSClient Workshop: 04 Protocols
NSClient Workshop: 04 ProtocolsMichael Medin
 
Linux processes control and monitoring
Linux processes control and monitoringLinux processes control and monitoring
Linux processes control and monitoringalex_schemelev
 
NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin Davide Cioccia
 
NSClient++ Workshop: 01 Introduction
NSClient++ Workshop: 01 IntroductionNSClient++ Workshop: 01 Introduction
NSClient++ Workshop: 01 IntroductionMichael Medin
 
Безопасность интернет-приложений осень 2013 лекция 7
Безопасность интернет-приложений осень 2013 лекция 7Безопасность интернет-приложений осень 2013 лекция 7
Безопасность интернет-приложений осень 2013 лекция 7Technopark
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous Shmuel Fomberg
 
Study2study#4 nginx conf_1_24
Study2study#4 nginx conf_1_24Study2study#4 nginx conf_1_24
Study2study#4 nginx conf_1_24Naoya Nakazawa
 
Lamp configuration u buntu 10.04
Lamp configuration   u buntu 10.04Lamp configuration   u buntu 10.04
Lamp configuration u buntu 10.04mikehie
 
5 Vampir Configuration At IU
5 Vampir Configuration At IU5 Vampir Configuration At IU
5 Vampir Configuration At IUPTIHPA
 
A little systemtap
A little systemtapA little systemtap
A little systemtapyang bingwu
 
Sockets in nach0s
Sockets in nach0sSockets in nach0s
Sockets in nach0snaniix21_3
 
Cell processor lab
Cell processor labCell processor lab
Cell processor labcoolmirza143
 

La actualidad más candente (20)

How Danga::Socket handles asynchronous processing and how to write asynchrono...
How Danga::Socket handles asynchronous processing and how to write asynchrono...How Danga::Socket handles asynchronous processing and how to write asynchrono...
How Danga::Socket handles asynchronous processing and how to write asynchrono...
 
Any event intro
Any event introAny event intro
Any event intro
 
Monit
MonitMonit
Monit
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
 
NSClient Workshop: 04 Protocols
NSClient Workshop: 04 ProtocolsNSClient Workshop: 04 Protocols
NSClient Workshop: 04 Protocols
 
Linux processes control and monitoring
Linux processes control and monitoringLinux processes control and monitoring
Linux processes control and monitoring
 
Puppet Camp 2012
Puppet Camp 2012Puppet Camp 2012
Puppet Camp 2012
 
NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin
 
NSClient++ Workshop: 01 Introduction
NSClient++ Workshop: 01 IntroductionNSClient++ Workshop: 01 Introduction
NSClient++ Workshop: 01 Introduction
 
Безопасность интернет-приложений осень 2013 лекция 7
Безопасность интернет-приложений осень 2013 лекция 7Безопасность интернет-приложений осень 2013 лекция 7
Безопасность интернет-приложений осень 2013 лекция 7
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
 
Study2study#4 nginx conf_1_24
Study2study#4 nginx conf_1_24Study2study#4 nginx conf_1_24
Study2study#4 nginx conf_1_24
 
Lamp configuration u buntu 10.04
Lamp configuration   u buntu 10.04Lamp configuration   u buntu 10.04
Lamp configuration u buntu 10.04
 
5 Vampir Configuration At IU
5 Vampir Configuration At IU5 Vampir Configuration At IU
5 Vampir Configuration At IU
 
Docker: ao vivo e a cores
Docker: ao vivo e a coresDocker: ao vivo e a cores
Docker: ao vivo e a cores
 
Ethical hacking with Python tools
Ethical hacking with Python toolsEthical hacking with Python tools
Ethical hacking with Python tools
 
A little systemtap
A little systemtapA little systemtap
A little systemtap
 
59
5959
59
 
Sockets in nach0s
Sockets in nach0sSockets in nach0s
Sockets in nach0s
 
Cell processor lab
Cell processor labCell processor lab
Cell processor lab
 

Destacado (6)

Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009
 
Peer Advising Wiki Tutorial
Peer Advising Wiki TutorialPeer Advising Wiki Tutorial
Peer Advising Wiki Tutorial
 
Go Ahead, Get Close; Commit to Customer Relationships through Direct Response
Go Ahead, Get Close; Commit to Customer Relationships through Direct ResponseGo Ahead, Get Close; Commit to Customer Relationships through Direct Response
Go Ahead, Get Close; Commit to Customer Relationships through Direct Response
 
Four Bear Advisors Presentation, Spring 2012
Four Bear Advisors Presentation, Spring 2012Four Bear Advisors Presentation, Spring 2012
Four Bear Advisors Presentation, Spring 2012
 
RVM - NHRuby Nov 2009
RVM - NHRuby Nov 2009RVM - NHRuby Nov 2009
RVM - NHRuby Nov 2009
 
OOP Intro in Ruby for NHRuby Feb 2010
OOP Intro in Ruby for NHRuby Feb 2010OOP Intro in Ruby for NHRuby Feb 2010
OOP Intro in Ruby for NHRuby Feb 2010
 

Similar a Monit - NHRuby May 2009

Proactive monitoring with Monit
Proactive monitoring with MonitProactive monitoring with Monit
Proactive monitoring with MonitOSOCO
 
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...addame
 
A journey through the years of UNIX and Linux service management
A journey through the years of UNIX and Linux service managementA journey through the years of UNIX and Linux service management
A journey through the years of UNIX and Linux service managementLubomir Rintel
 
Document Management: Opendocman and LAMP installation on Cent OS
Document Management: Opendocman and LAMP installation on Cent OSDocument Management: Opendocman and LAMP installation on Cent OS
Document Management: Opendocman and LAMP installation on Cent OSSiddharth Ram Dinesh
 
OpenStack Swift - MSST 2011 Tutorial Day
OpenStack Swift - MSST 2011 Tutorial DayOpenStack Swift - MSST 2011 Tutorial Day
OpenStack Swift - MSST 2011 Tutorial DayJoshua McKenty
 

Similar a Monit - NHRuby May 2009 (20)

Proactive monitoring with Monit
Proactive monitoring with MonitProactive monitoring with Monit
Proactive monitoring with Monit
 
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
 
A journey through the years of UNIX and Linux service management
A journey through the years of UNIX and Linux service managementA journey through the years of UNIX and Linux service management
A journey through the years of UNIX and Linux service management
 
Document Management: Opendocman and LAMP installation on Cent OS
Document Management: Opendocman and LAMP installation on Cent OSDocument Management: Opendocman and LAMP installation on Cent OS
Document Management: Opendocman and LAMP installation on Cent OS
 
OpenStack Swift - MSST 2011 Tutorial Day
OpenStack Swift - MSST 2011 Tutorial DayOpenStack Swift - MSST 2011 Tutorial Day
OpenStack Swift - MSST 2011 Tutorial Day
 
Toby3
Toby3Toby3
Toby3
 
xxxx
xxxxxxxx
xxxx
 
yyyyxxxdd
yyyyxxxddyyyyxxxdd
yyyyxxxdd
 
new title
new titlenew title
new title
 
yyyyxxx
yyyyxxxyyyyxxx
yyyyxxx
 
Tinoub1
Tinoub1Tinoub1
Tinoub1
 
yyyyxxxdd
yyyyxxxddyyyyxxxdd
yyyyxxxdd
 
Tinoub1
Tinoub1Tinoub1
Tinoub1
 
Toby5
Toby5Toby5
Toby5
 
Monit a2
Monit a2Monit a2
Monit a2
 
yyyyxxx
yyyyxxxyyyyxxx
yyyyxxx
 
Toby7
Toby7Toby7
Toby7
 
Tinoub1
Tinoub1Tinoub1
Tinoub1
 
Toby10
Toby10Toby10
Toby10
 
Toby7
Toby7Toby7
Toby7
 

Último

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Monit - NHRuby May 2009

  • 2. Monitor & Manage System Resources Processes Files Directories Devices Network Services
  • 3. Take Action! alert Send an alert restart Stop then start a process start Start a process stop Stop a process exec Execute arbitrary program unmonit Disable monitoring or timeout Disable monitoring
  • 4. Prerequisites UN*X Start/Stop Scripts for Processes Mail Server for Alerts
  • 6. Configure ## /etc/monit/monitrc set daemon 120 set logfile /var/log/monit.log set alert alert@brianturnbull.com set mail-format { from: monit@brianturnbull.com subject: $SERVICE service - $EVENT message: $ACTION $SERVICE on $HOST: $DESCRIPTION } set mailserver localhost port 25 set httpd port 8877 allow monit:passwd include /etc/monit/monit.d/*
  • 7. Monitor ## /etc/monit/monit.d/apache check process apache with pidfile /var/run/apache2.pid start program = quot;/etc/init.d/apache2 startquot; stop program = quot;/etc/init.d/apache2 stopquot; if failed host localhost port 80 protocol http then restart if 2 restarts within 3 cycles then timeout ## /etc/monit/monit.d/sshd check process sshd with pidfile /var/run/sshd.pid start program = quot;/etc/init.d/ssh startquot; stop program = quot;/etc/init.d/ssh stopquot; if failed port 22 protocol ssh then restart if 5 restarts within 5 cycles then timeout
  • 8. Monitor Files ## /etc/monit/monit.d/apache_log check file access.log with path /var/log/apache2/access.log if size > 100Mb then exec quot;/usr/sbin/logrotate -f /etc/logrotate.d/apache2quot; check file error.log with path /var/log/apache2/error.log if size > 100Mb then exec quot;/usr/sbin/logrotate -f /etc/logrotate.d/apache2quot;
  • 9. Monitor Directories ## /etc/monit/monit.d/sbin check directory sbin with path /sbin if changed timestamp then alert check directory sbin-usr with path /usr/sbin if changed timestamp then alert
  • 10. Monitor Devices ## /etc/monit/monit.d/disks check device sda1 with path /dev/sda1 if space usage > 90% then alert if inode usage > 90% then alert
  • 11. Monitor Resources ## /etc/monit/monit.d/system check system brianturnbull.com if loadavg (1min) > 4 then alert if loadavg (5min) > 2 then alert if memory usage > 75% then alert if cpu usage (user) > 70% then alert if cpu usage (system) > 30% then alert if cpu usage (wait) > 20% then alert
  • 12. Monitor Services ## /etc/monit/monit.d/apache check process apache with pidfile /var/run/apache2.pid start program = quot;/etc/init.d/apache2 startquot; stop program = quot;/etc/init.d/apache2 stopquot; if failed host localhost port 80 protocol http then restart if 2 restarts within 3 cycles then timeout ## /etc/monit/monit.d/mail check host mail.brianturnbull.com with address mail.brianturnbull.com if failed port 25 expect “^220.*rn” send “HELO brianturnbull.com expect “^250.*rn” send “QUIT.*rn” expect “^221.*rn” then alert
  • 13. Dependancies ## /etc/monit/monit.d/apache check process apache with pidfile /var/run/apache2.pid group www start program = quot;/etc/init.d/apache2 startquot; stop program = quot;/etc/init.d/apache2 stopquot; if 2 restarts within 3 cycles then timeout if failed host localhost port 80 protocol http then restart depends on apache_bin depends on apache_rc check file apache_bin with path /usr/sbin/apache2 group www if failed checksum then unmonitor if failed permission 755 then unmonitor if failed uid root then unmonitor if failed gid root then unmonitor check file apache_rc with path /etc/init.d/apache2 group www if failed checksum then unmonitor if failed permission 755 then unmonitor if failed uid root then unmonitor if failed gid root then unmonitor
  • 14. More Info & Examples http://mmonit.com/monit Thank You http://brianturnbull.com