LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-04-2009, 06:13 AM   #1
lusine
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
Disappointed from Monit, need advice


hi,
First of all i'm a little disappointed with Monit work, as this soft don't prevent my server from downtime, as during last 2 days, that i install this soft i have 2 downtimes.

Quote:
Monit is a utility for managing and monitoring, processes, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.
Now the history:

Few days ago i try to install Monit on my server. (Linux, CentOs 5.0; MySQL 5.0.67, Apache 2.2.11; DirectAdmin 1.33.0 )
First of all i check that i don't have my.cnf on my server.

So, i find my.cnf example and upload it (stop ->start Mysqld)

Here is my example
-------------------
Code:
# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /var/db/mysql) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password = your_password
port  = 3306
socket  = /var/lib/mysql/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port  = 3306
socket  = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 384M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
# 
#skip-networking

# Disable Federated by default
skip-federated

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin

# Point the following paths to different dedicated disks
#tmpdir  = /tmp/  
#log-update  = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/db/mysql/
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = /var/db/mysql/
#innodb_log_arch_dir = /var/db/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 384M
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 100M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
-------------------

Quote:
As i don't check any mysqld.pid inside /var/run/mysqld, i create mysqld.pid
# chown -R mysql:mysql mysqld.pid
# chmod g=rw mysqld.pid
# chmod o= mysqld.pid
# chown mysql:mysql /var/run/mysqld
# reboot
Stop mysqld
# /etc/rc.d/init.d/mysqld stop
Result : [ok]

Start mysqld
# /etc/rc.d/init.d/mysqld start
Result : [ok]

Check log
# vi /var/log/mysqld.log
---------------
Also put here my monitrc file

-----------------
Code:
set daemon  60
set logfile syslog facility log_daemon
set mailserver localhost
set mail-format { from: monit@localhost }
set alert &&&@&&&.com

set httpd port 2812
allow localhost
allow MyDomain.com
allow 208.94.240.50
allow admin:password

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 port 22 protocol ssh then restart
   if 5 restarts within 5 cycles then timeout

check process mysql with pidfile /var/run/mysqld/mysqld.pid
   group database
   start program = "/etc/init.d/mysqld start"
   stop program = "/etc/init.d/mysqld stop"
   if failed host 208.94.240.50 port 3306 then restart
   if 5 restarts within 5 cycles then timeout

check file mysql_bin with path /usr/sbin/mysqld
   group database
   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 mysql_rc with path /etc/init.d/mysqld
   group database
   if failed checksum then unmonitor
   if failed permission 755 then unmonitor
   if failed uid root then unmonitor
   if failed gid root then unmonitor



check process apache with pidfile /var/run/httpd.pid
start program = "/etc/init.d/httpd start" with timeout 60 seconds
stop program  = "/etc/init.d/httpd stop"
   if failed host 208.94.240.50 port 80 protocol http
      and request "/" then alert
   if cpu is greater than 60% for 2 cycles then alert
   if cpu > 80% for 5 cycles then restart
   if children > 250 then restart
   if loadavg(5min) greater than 10 for 8 cycles then alert
   if 3 restarts within 5 cycles then timeout

# copy the above for each mongrel port to monitor, and adjust the pid file name/location
# take a look at the running processes, and the above start/stop program lines should match it.
# for example, if you run mongrel_cluster than you'll need to replicate the command that mongrel
# cluster used to start it.

check process postfix with pidfile /var/run/dovecot/master.pid
   group mail
   start program = "/etc/init.d/dovecot start"
   stop  program = "/etc/init.d/dovecot stop"
   if failed port 25 protocol smtp then restart
   if 5 restarts within 5 cycles then timeout
-----------------

in this output i change this 3 lines
----
allow MyDomain.com
allow adminassword
set alert &&&@&&&.com

----

check Monit status ->

--------------
Quote:
The Monit daemon 5.0_beta6 uptime: 15h 6m

Process 'sshd'
status running
monitoring status monitored
pid 13389
parent pid 1
uptime 39m
children 2
memory kilobytes 932
memory kilobytes total 3404
memory percent 0.0%
memory percent total 0.1%
cpu percent 0.0%
cpu percent total 0.0%
port response time 0.002s to localhost:22 [SSH via TCP]
data collected Wed Feb 4 05:34:05 2009

Process 'mysql'
status running
monitoring status monitored
pid 13482
parent pid 13452
uptime 39m
children 0
memory kilobytes 69928
memory kilobytes total 69928
memory percent 3.3%
memory percent total 3.3%
cpu percent 0.0%
cpu percent total 0.0%
port response time 0.000s to 208.94.240.50:3306 [DEFAULT via TCP]
data collected Wed Feb 4 05:34:05 2009

File 'mysql_bin'
status accessible
monitoring status monitored
permission 755
uid 0
gid 0
timestamp Tue Dec 23 18:28:00 2008
size 6633560 B
checksum 55e9161d0b69a0ca9af14228d1d598be(MD5)
data collected Wed Feb 4 05:34:05 2009

File 'mysql_rc'
status accessible
monitoring status monitored
permission 755
uid 0
gid 0
timestamp Tue Dec 23 18:28:09 2008
size 11948 B
checksum ec77cbeb2c7d67a9540faed8470bc485(MD5)
data collected Wed Feb 4 05:34:05 2009

Process 'apache'
status Execution failed
monitoring status monitored
pid 13590
parent pid 1
uptime 37m
children 14
memory kilobytes 10588
memory kilobytes total 170580
memory percent 0.5%
memory percent total 8.2%
cpu percent 0.0%
cpu percent total 0.1%
port response time 0.001s to 208.94.240.50:80/ [HTTP via TCP]
data collected Wed Feb 4 05:34:05 2009

Process 'postfix'
status running
monitoring status monitored
pid 4628
parent pid 1
uptime 14h 31m
children 33
memory kilobytes 468
memory kilobytes total 9112
memory percent 0.0%
memory percent total 0.4%
cpu percent 0.0%
cpu percent total 0.0%
port response time 0.002s to localhost:25 [SMTP via TCP]
data collected Wed Feb 4 05:34:05 2009

System 'server.MYDOMAIN.com'
status running
monitoring status monitored
load average [0.13] [0.48] [9.00]
cpu 1.7%us 0.6%sy 0.0%wa
memory usage 205816 kB [9.9%]
data collected Wed Feb 4 05:34:05 2009
-------------------

changed lines ->System 'server.MYDOMAIN.com'

Looks like that everything is OK.
Relax and go to sleep.

When i stand up i check that server is DOWN, Looks like that mysql goes out of memory, but why monit cann't restart it ?
If monit cann't prevent this, any sense to setup it ?

Or may be i'm doing something wrong ?



----------


So what i'm doing wrong?
Or may monit isn't for me ?


Any advice will be appreciated
 
Old 02-07-2009, 06:09 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by lusine View Post
First of all i'm a little disappointed with Monit work, as this soft don't prevent my server from downtime, as during last 2 days, that i install this soft i have 2 downtimes.
If you want to CPU and memory check the MySQL process you have to add the checks there (see your httpd entry). You could also easily add a check for the system itself. Stupid example:
Code:
check system hostname.domain every 10 cycles
  if loadavg (5min) > 30 for 10 cycles then alert
  if memory usage > 99% for 10 cycles then alert
  if cpu usage (user) > 50% for 10 cycles then alert
  if cpu usage (system) > 50% for 10 cycles alert
  if cpu usage (wait) > 50% for 10 cycles then alert
  group system
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Setting up monit helptonewbie Linux - Software 2 07-29-2007 04:24 PM
Disappointed syg00 SUSE / openSUSE 25 02-22-2005 06:35 AM
Disappointed in Distro's UltimaGuy General 24 01-24-2004 07:46 PM
monitoring daemons, filesystems and more (Monit v4.0B) markus1982 Linux - Software 2 09-14-2003 08:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration