Nagios monitoring MySQL

Source: Internet
Author: User
Tags install perl

Deploy check_mysql_health on Nagios to monitor MySQL Blog Category:
    • Architecture

This monitoring is based on the Nagios server active monitoring method, using Check_mysql_health to implement a variety of monitoring modes:
Connection-time (time to connect to the server)
Uptime (time the server is running)
threads-connected (number of currently open connections) threads
Threadcache-hitrate (hit rate of the Thread-cache) slow query
Slave-lag (Seconds behind Master)
slave-io-running (slave io running:yes) master/slave hot Standby
slave-sql-running (Slave sql Running:yes) master/slave hot Standby
Qcache-hitrate (Query cache hitrate)
Qcache-lowmem-prunes (Query cache entries pruned because of low memory)
Keycache-hitrate (MyISAM key Cache hitrate)
Bufferpool-hitrate (InnoDB buffer pool hitrate)
Bufferpool-wait-free (InnoDB buffer pool waits for clean page available)
Log-waits (InnoDB log waits because of a too small log buffer)
Tablecache-hitrate (Table cache hitrate)
Table-lock-contention (Table lock contention) Lock example
Index-usage (usage of indices)
Tmp-disk-tables (Percent of temp tables created on disk)
Slow-queries (Slow queries)
Long-running-procs (long running processes)
Cluster-ndbd-running (NDND nodes is up and running)
SQL (any SQL command returning a single number)

The steps are as follows:
1, install
#wget  http://labs.consol.de/wp-content/uploads/2009/10/check_mysql_ health-2.1.tar.gz
#tar-zxvf check_mysql_health-2.1.tar.gz 
#cd check_mysql_health-2.1
#./configure --prefix=/usr/local/nagios--with-nagios-user=nagios--with-nagios-group=nagios--with-perl=/usr/bin/perl
# Make && make install
2, command test
#cd/usr/local/nagios/libexec
#./check_mysql_health--hostname 192.168.0.1--port 3306--username myname--password mypassword--mode threads-connected--warning (--critical)
When the can ' t locate dbi.pm error occurs:
#yum install perl-dbi perl-dbd-mysql-y
is executed again with the following result:
OK-607 Client Connection thread s | threads_connected=607;700;1000

Command parameters:
–hostname Der datenbankserver, Derüberwacht werden soll. Im Falle von "localhost" kann dieser Parameter weggelassen werden.
–username <username>
Der Datenbankuser.
–password <password>
Dessen Passwort.
–mode <modus>
Mit dem Mode-parameter teilt man dem Plugin mit, is Es tun soll.
–name <objektname>
Hier kann die Prüfung auf ein einziges Objekt begrenzt werden.
–name2 <string>
Verwendet Man–mode=sql, Dann erscheint das Sql-statement in der Ausgabe und den Performancedaten.
–warning <range>
–critical <range>
–environment <variable>=<wert>
–method <connectmethode>
Mit diesem Parameter teilt man dem Plugin mit, wie es sich zur Datenbank, Verbinden soll.
–units <%|kb| mb| Gb>

3. Nagios command, service configuration
#vi/usr/local/nagios/etc/objects/commands.cfg
...
# ' Check_mysql_health '
Define Command{
Command_name Check_mysql_health
Command_line $USER 1$/check_mysql_health--hostname $ARG 1$--port $ARG 2$--username $ARG 3$--password $ARG 4$--mode $ARG 5$
--warning $ARG 6$--critical $ARG 7$
}
...

#vi/usr/local/nagios/etc/objects/servers/localhost.cfg
...

Define service{
        use                               local-service        ; Name of service template to use
        host_name                        Myhostname
        service_description              check_mysql_connections
         check_command                    check_mysql_health!192.168.0.1!3306!myname!mypassword!threads-connected!1000!1500
        }

Define Service{
Use Local-service; Name of service template to use
HOST_NAME Myhostname
Service_description Check_mysql_table_lock
Check_command check_mysql_health!192.168.0.1!3306!myname!mypassword!table-lock-contention!1!2
}
...
4. Restart Nagios Service
#service Nagios Restart

Nagios monitoring MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.