Ero sivun ”Monit” versioiden välillä
Rivi 48: | Rivi 48: | ||
Kaikki esimerkit löytyy Monitin dokumentaatiosta: https://mmonit.com/wiki/Monit/ConfigurationExamples | Kaikki esimerkit löytyy Monitin dokumentaatiosta: https://mmonit.com/wiki/Monit/ConfigurationExamples | ||
+ | |||
+ | ==== Apache2 ==== | ||
+ | |||
+ | <pre> | ||
+ | check process apache with pidfile /run/apache2.pid | ||
+ | start program = "/etc/init.d/apache2 start" with timeout 60 seconds | ||
+ | stop program = "/etc/init.d/apache2 stop" | ||
+ | </pre> | ||
+ | |||
+ | ==== Mysql ==== | ||
+ | |||
+ | <pre> | ||
+ | check process mysqld with pidfile /var/run/mysqld/mysqld.pid | ||
+ | start program = "/etc/init.d/mysql start" | ||
+ | stop program = "/etc/init.d/mysql stop" | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | ==== Nginx ==== | ||
+ | |||
+ | <pre> | ||
+ | check process nginx with pidfile /var/run/nginx.pid | ||
+ | start program = "/etc/init.d/nginx start" | ||
+ | stop program = "/etc/init.d/nginx stop" | ||
+ | group www-data | ||
+ | </pre> | ||
+ | |||
+ | ==== Postfix ==== | ||
+ | |||
+ | <pre> | ||
+ | check process postfix with pidfile /var/spool/postfix/pid/master.pid | ||
+ | group mail | ||
+ | start program = "/etc/init.d/postfix start" | ||
+ | stop program = "/etc/init.d/postfix stop" | ||
+ | if failed port 25 protocol smtp then restart | ||
+ | </pre> | ||
+ | |||
+ | ==== SNMP ==== | ||
+ | |||
+ | <pre> | ||
+ | check process snmpd with pidfile /var/run/snmpd.pid | ||
+ | start program = "/etc/init.d/snmpd start" | ||
+ | stop program = "/etc/init.d/snmpd stop" | ||
+ | if failed host 192.168.1.1 port 161 type udp then restart | ||
+ | </pre> | ||
+ | |||
+ | ==== SSH ==== | ||
+ | |||
+ | <pre> | ||
+ | check process sshd with pidfile /var/run/sshd.pid | ||
+ | start program "/etc/init.d/ssh start" | ||
+ | stop program "/etc/init.d/ssh stop" | ||
+ | if failed port 22 protocol ssh then restart | ||
+ | |||
+ | </pre> | ||
=== Ilmoitukset === | === Ilmoitukset === |
Versio 31. toukokuuta 2015 kello 19.44
Monit on avoilella lähdekoodilla varustettu helppokäyttöinen valvontatyökalu Unixille. Tällä pystyy tekemään automaattisia toimenpiteitä palvelimelle jos ilmenee jonkinlaista vikaa sovelluksissa.
Sisällysluettelo
Asennus
Monitin asennus onnistuu kätevästi pakettihallinnasta
aptitude install monit
Konfigurointi
nano /etc/mun/munitrc
Poista risuaita:
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
Lataa konfigurointi tiedostot uudelleen
monit reload
Näytä palvelimen tika:
monit status
Ja tulostuu esimerkiksi
The Monit daemon 5.4 uptime: 6m System 'myhost.mydomain.tld' status Running monitoring status Monitored load average [0.45] [0.34] [0.60] cpu 11.5%us 3.1%sy 1.2%wa memory usage 477148 kB [5.9%] swap usage 0 kB [0.0%] data collected Sun, 31 May 2015 13:30:46
Esimerkkejä
Kaikki esimerkit löytyy Monitin dokumentaatiosta: https://mmonit.com/wiki/Monit/ConfigurationExamples
Apache2
check process apache with pidfile /run/apache2.pid start program = "/etc/init.d/apache2 start" with timeout 60 seconds stop program = "/etc/init.d/apache2 stop"
Mysql
check process mysqld with pidfile /var/run/mysqld/mysqld.pid start program = "/etc/init.d/mysql start" stop program = "/etc/init.d/mysql stop"
Nginx
check process nginx with pidfile /var/run/nginx.pid start program = "/etc/init.d/nginx start" stop program = "/etc/init.d/nginx stop" group www-data
Postfix
check process postfix with pidfile /var/spool/postfix/pid/master.pid group mail start program = "/etc/init.d/postfix start" stop program = "/etc/init.d/postfix stop" if failed port 25 protocol smtp then restart
SNMP
check process snmpd with pidfile /var/run/snmpd.pid start program = "/etc/init.d/snmpd start" stop program = "/etc/init.d/snmpd stop" if failed host 192.168.1.1 port 161 type udp then restart
SSH
check process sshd with pidfile /var/run/sshd.pid start program "/etc/init.d/ssh start" stop program "/etc/init.d/ssh stop" if failed port 22 protocol ssh then restart
Ilmoitukset
Konfiguroi sähköpostipalvelin, poista risuaita ja kirjoita s.postipalvelin
set mailserver mail.bar.baz
Määritä kuka lähettää postin palvelimelta, postamalla risuaita ja kirjoittamalla s.posti osoitteen.
set mail-format munitfoo.bar
Ota käyttöön ilmoitukset omaan sähköpostiisi, postamalla risuaita ja merkitsemään tähän oma sähköpostisi jonne lähetetään
set alert [email protected]
Lisää ilmoituksista: https://mmonit.com/monit/documentation/#ALERT-MESSAGES
Lähteet
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-monit