Nagios add host and write MySQL plugin

Source: Internet
Author: User

in the Nagios add monitored hosts and services on the server:

Nagios configuration file:

[Email protected] etc]# CD objects/

[[email protected] objects]# ls

commands.cfg (define monitoring commands) localhost.cfg (define what to monitor) switch.cfg (define switch) timeperiods.cfg (template file)

contacts.cfg (define a contact) printer.cfg (definition of printer template) templates.cfg (template customization file) windows.cfg (Monitoring Windows and their templates)

[Email protected] objects]# pwd

/usr/local/nagios/etc/objects

Add a host: [email protected] objects]# vim localhost.cfg

650) this.width=650; "title=" 1 "src=" http://s3.51cto.com/wyfs02/M00/59/A1/wKioL1TaE0DBg5BeAAGVdXszSe0350.jpg "alt= "Wkiol1tae0dbg5beaagvdxszse0350.jpg"/>

Check the configuration file for errors:

650) this.width=650; "title=" 2 "src=" Http://s3.51cto.com/wyfs02/M00/59/A5/wKiom1TaEnPDFT2QAADCzZXGQgA619.jpg "alt= "Wkiom1taenpdft2qaadczzxgqga619.jpg"/>

Restart the service and view (click Host ):

650) this.width=650; "style=" Float:none; "title=" 3 "src=" http://s3.51cto.com/wyfs02/M01/59/A1/ Wkiol1tae4qton75aabd0s3kkta534.jpg "alt=" Wkiol1tae4qton75aabd0s3kkta534.jpg "/>

650) this.width=650; "style=" Float:none; "title=" 4 "src=" http://s3.51cto.com/wyfs02/M01/59/A5/ Wkiom1taepeblp83aadck0yomhu386.jpg "alt=" Wkiom1taepeblp83aadck0yomhu386.jpg "/>

Monitoring Services ( SSH ): [email protected] objects]# vim localhost.cfg

650) this.width=650; "title=" 5 "src=" Http://s3.51cto.com/wyfs02/M02/59/A5/wKiom1TaEq_CK1OPAAEieBlH5-s954.jpg "alt= "Wkiom1taeq_ck1opaaeieblh5-s954.jpg"/>

[Email protected] objects]#/etc/init.d/nagios Reload

Running Configuration Check ...

Reloading Nagios configuration ...

Done

650) this.width=650; "title=" 6 "src=" Http://s3.51cto.com/wyfs02/M01/59/A5/wKiom1TaEsXQcj9TAACeglbffLY619.jpg "alt= "Wkiom1taesxqcj9taaceglbffly619.jpg"/>

Write plugin:

0 Normal

1 Warning

2 Critical Warning

One: Write a monitor this machine MySQL The plugin:

[Email protected] libexec]# vim Check_mysql

#!/bin/bash

MYSQL-E "Show Databases" &>/dev/null

If [$?-eq 0]

Then

echo "MySQL runing ..."

Exit 0

Else

echo "MySQL Stop"

Exit 2

Fi

Test Plug-ins ;

[Email protected] libexec]# chmod 755 check_mysql

650) this.width=650; "title=" 7 "src=" Http://s3.51cto.com/wyfs02/M02/59/A2/wKioL1TaE9HwFeenAACjjpVqjrg927.jpg "alt= "Wkiol1tae9hwfeenaacjjpvqjrg927.jpg"/>

Two: Write a command to invoke the plugin

650) this.width=650; "title=" 8 "src=" Http://s3.51cto.com/wyfs02/M02/59/A5/wKiom1TaEu_TIhaOAACMEXaRJuc218.jpg "alt= "Wkiom1taeu_tihaoaacmexarjuc218.jpg"/>

Test Plug-ins:

[Email protected] objects]#/usr/local/nagios/libexec/check_mysql-h localhost

MySQL Stop

[[email protected] objects]#/etc/init.d/mysqld start

Start MySQL : [ OK ]

[Email protected] objects]#/usr/local/nagios/libexec/check_mysql-h localhost

MySQL runing .....

Write localhost.cfg file ;

[Email protected] objects]# vim localhost.cfg

650) this.width=650; "title=" 9 "src=" Http://s3.51cto.com/wyfs02/M00/59/A2/wKioL1TaFF7gRv6vAADeAqk2hIY662.jpg "alt= "Wkiol1taff7grv6vaadeaqk2hiy662.jpg"/>

Test the configuration file for errors:

[Email protected] objects]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg

[Email protected] objects]#/etc/init.d/nagios Reload

Running Configuration Check ...

Reloading Nagios configuration ...

Done

650) this.width=650; "title=" src= "Http://s3.51cto.com/wyfs02/M00/59/A5/wKiom1TaE4WDqUhYAAA6Z2m5NEM645.jpg" alt = "Wkiom1tae4wdquhyaaa6z2m5nem645.jpg"/>

This article is from the Cisco Experimental Linux blog, so be sure to keep this source http://1054054.blog.51cto.com/1044054/1613489

Nagios add host and write MySQL plugin

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.