Posted by: endsixth666 | May 29, 2009

Monitoring Server Debian Menggunakan Monit

By End Sixth

Monit merupakan sebuah utilitis yang berfungsi untuk mengelola dan memantau (monitoring), proses, file, direktori pada perangkat pada sistem UNIX.  Monit otomatis melakukan maintance kesalahan.

Monit Features

  • Daemon mode – poll programs at a specified interval
  • Monitoring modes – active, passive or manual
  • Start, stop and restart of programs
  • Group and manage groups of programs
  • Process dependency definition
  • Logging to syslog or own logfile
  • Configuration – comprehensive controlfile
  • Runtime and TCP/IP port checking (tcp and udp)
  • SSL support for port checking
  • Unix domain socket checking
  • Process status and process timeout
  • Process cpu usage
  • Process memory usage
  • Process zombie check
  • Check the systems load average
  • Check a file or directory timestamp
  • Alert, stop or restart a process based on its characteristics
  • MD5 checksum for programs started and stopped by monit
  • Alert notification for program timeout, restart, checksum, stop resource and timestamp error
  • Flexible and customizable email alert messages
  • Protocol verification. HTTP, FTP, SMTP, POP, IMAP, NNTP, SSH, DWP,LDAPv2 and LDAPv3
  • An http interface with optional SSL support to make monit accessible from a webbrowser

Langkah pertama (first step) – Instal Monit pada Debian

“ #apt-get install monit ”

Langah kedua (second step) – Konfigurasi Monit

Default file konfigurasi terletak pada ” /etc/monit/monitrc  “ pada file inilah kita melakukan proses edit

Sebagia contoh konfigurasi ada pada bagian bawah ini

## Start monit in background (run as daemon) and check the services at 2-minute

## intervals.


set daemon 120

## Set syslog logging with the ‘daemon’ facility. If the FACILITY option is

## omited, monit will use ‘user’ facility by default. You can specify the

## path to the file for monit native logging.


set logfile syslog facility log_daemon

## Set list of mailservers for alert delivery. Multiple servers may be

## specified using comma separator. By default monit uses port 25 – it is

## possible to override it with the PORT option.


set mailserver localhost # primary mailserver

## Monit by default uses the following alert mail format:

From: monit@$HOST # sender

Subject: monit alert — $EVENT $SERVICE # subject


Date: $DATE

Action: $ACTION

Host: $HOST # body

Description: $DESCRIPTION

Your faithful,


## You can override the alert message format or its parts such as subject

## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.

## are expanded on runtime. For example to override the sender:


set mail-format { from: }

## Monit has an embedded webserver, which can be used to view the

## configuration, actual services parameters or manage the services using the

## web interface.


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’

# Monitoring the apache2 web services.

# It will check process apache2 with given pid file.

# If process name or pidfile path is wrong then monit will

# give the error of failed. tough apache2 is running.

check process apache2 with pidfile /var/run/

#Below is actions taken by monit when service got stuck.

start program = “/etc/init.d/apache2 start”

stop program = “/etc/init.d/apache2 stop”

# Admin will notify by mail if below of the condition satisfied.

if cpu is greater than 60% for 2 cycles then alert

if cpu > 80% for 5 cycles then restart

if totalmem > 200.0 MB for 5 cycles then restart

if children > 250 then restart

if loadavg(5min) greater than 10 for 8 cycles then stop

if 3 restarts within 5 cycles then timeout

group server

#Monitoring Mysql Service

check process mysql with pidfile /var/run/mysqld/

group database

start program = “/etc/init.d/mysql start”

stop program = “/etc/init.d/mysql stop”

if failed host port 3306 then restart

if 5 restarts within 5 cycles then timeout

#Monitoring ssh Service

check process sshd with pidfile /var/run/

start program “/etc/init.d/ssh start”

stop program “/etc/init.d/ssh stop”

if failed port 22 protocol ssh then restart

if 5 restarts within 5 cycles then timeout

Kita dapat juga menyertakan file-file konfigurasi lainnya.

include /etc/monit/default.monitrc

include /etc/monit/mysql.monitrc

Ini hanya contoh konfigurasi file tersebut, agar lebih jelas dapat melihatnya pada situs di bawah

Setelah melakukan konfigurasi monit kita  dapat memeriksa file konfigurasi dengan menggunakan perintah sebagia berikut :

“ #monit –t “

Setela melakukan pemeriksaan, namun tidak ada kesalahan maka kita harus mengaktifkan layanan atau service dengan mengubah file yang terletak pada  “/ etc / default / monit “ .

# You must set this variable to for monit to start



# You must set this variable to for monit to start


Now you need to start the service using the following command

#/etc/init.d/monit start

Monit Web interface

Monit Web berjalan pada port number 2812.  Jika dalam jaringan terdapat firewall maka secara otomatis port number tersebut tertutup, maka kita harus mengaktifkan port number tersebut.

Selanjutnya yaitu mengarahkan browser ke http://yourserverip:2812/ (pastikan port number  2812 tidak diblokir oleh firewall), log in dengan admin monit. jika ingin login yang aman, ktia dapat menggunakan https cek disini. SEMOGA SUKSES

Daftar pustaka  :

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: