您的位置:首页 > 移动开发 > IOS开发

Nagios添加服务监控

2014-03-02 01:45 309 查看
监控Web服务:在window server2003上安装IIS然后我们在nagios上做配置命令配置里面默认有httpdefine command{ command_name check_http command_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$ }配置主机和服务,主机之前已经配置好了,所以我们添加一个服务就可以[nagios@node4 ~]$ cd/usr/local/nagios/etc/objects/[nagios@node4objects]$ vim windows.cfgdefine service{ use generic-service host_name winserver service_description Web_server check_command check_http }重启nagios服务[root@node4 objects]#service nagios restartRunning configurationcheck...done.Stopping nagios:done.Starting nagios:done.然后现在我们在nagios管理界面上看到新加入的web服务了


监控mysql服务在node4上安装mysql-server# yum install mysql-server -y启动mysqld服务# service mysqldstartInitializing MySQLdatabase: Installing MySQL systemtables...OKFilling helptables...OK
To start mysqld atboot time you have to copysupport-files/mysql.serverto the right place for your system
PLEASE REMEMBER TOSET A PASSWORD FOR THE MySQL root USER !To do so, start theserver, then issue the following commands:
/usr/bin/mysqladmin-u root password 'new-password'/usr/bin/mysqladmin-u root -h node4.example.com password 'new-password'
Alternatively you canrun:/usr/bin/mysql_secure_installation
which will also giveyou the option of removing the testdatabases andanonymous user created by default. Thisisstrongly recommendedfor production servers.
See the manual formore instructions.
You can start theMySQL daemon with:cd /usr ;/usr/bin/mysqld_safe &
You can test theMySQL daemon with mysql-test-run.plcd /usr/mysql-test ;perl mysql-test-run.pl
Please report anyproblems with the /usr/bin/mysqlbug script!
[ OK ]Starting mysqld: [ OK ]# chkconfig mysqld on然后给mysql设置管理员密码# mysqladmin -u root -p password wiker #修改密码为wikerEnter password: #直接回车,默认的root密码是空[root@node4 ~]# mysql -u root -pwiker #测试下登陆Welcome to the MySQLmonitor. Commands end with ; or \g.Your MySQL connectionid is 11Server version:5.1.52 Source distribution
Copyright (c) 2000,2010, Oracle and/or its affiliates. All rights reserved.This software comeswith ABSOLUTELY NO WARRANTY. This is free software,and you are welcometo modify and redistribute it under the GPL v2 license
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql> showdatabases;+--------------------+| Database |+--------------------+| information_schema|| mysql || test |+--------------------+3 rows in set (0.01sec)但是我们发现我们没有check_mysql这个插件:[root@node4 libexec]#pwd/usr/local/nagios/libexec[root@node4 libexec]#lscheck_apt check_imap check_popcheck_breeze check_ircd check_procscheck_by_ssh check_load check_realcheck_clamd check_log check_rpccheck_cluster check_mailq check_sensorscheck_dhcp check_mrtg check_smtpcheck_dig check_mrtgtraf check_sshcheck_disk check_nagios check_swapcheck_disk_smb check_nntp check_tcpcheck_dns check_nrpe check_timecheck_dummy check_nt check_udpcheck_file_age check_ntp check_upscheck_flexlm check_ntp_peer check_userscheck_ftp check_ntp_time check_wavecheck_http check_nwstat negatecheck_icmp check_oracle process_perfdata.plcheck_ide_smart check_overcr urlizecheck_ifoperstatus check_ping utils.pmcheck_ifstatus check_pnp_rrds.pl utils.sh因为check_mysql这个插件需要依赖mysql-devel包才能生效,所以我们需要安装这个包,然后重新编译nagios的插件# yum installmysql-devel -y[root@node4nagios-plugins-1.5]# ./configure--with-nagios-user=nagios --with-nagios-group=nagios[root@node4nagios-plugins-1.5]# make ; make install[root@node4nagios-plugins-1.5]# cd /usr/local/nagios/libexec/[root@node4 libexec]#lscheck_apt check_load check_realcheck_breeze check_log check_rpccheck_by_ssh check_mailq check_sensorscheck_clamd check_mrtg check_simapcheck_cluster check_mrtgtraf check_smtpcheck_dhcp check_mysql check_spopcheck_dig check_mysql_query check_sshcheck_disk check_nagios check_ssmtpcheck_disk_smb check_nntp check_swapcheck_dns check_nntps check_tcpcheck_dummy check_nrpe check_timecheck_file_age check_nt check_udpcheck_flexlm check_ntp check_upscheck_ftp check_ntp_peer check_userscheck_http check_ntp_time check_wavecheck_icmp check_nwstat negatecheck_ide_smart check_oracle process_perfdata.plcheck_ifoperstatus check_overcr urlizecheck_ifstatus check_ping utils.pmcheck_imap check_pnp_rrds.pl utils.shcheck_ircd check_popcheck_jabber check_procs首先我们定义commands[root@node4 libexec]#cd /usr/local/nagios/etc/objects/[root@node4 objects]#vim commands.cfgdefine command { command_name check_mysql command_line $USER1$/check_mysql -H $HOSTADDRESS$ -u$ARG1$ -p $ARG2$}然后定义主机上的服务[root@node4 objects]#vim localhost.cfgdefine service{ use local-service,services-pnp host_name localhost service_description Mysql-server check_command check_mysql!root!wiker }然后检查语法[root@node4 objects]#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg……………………………………..Total Warnings: 0Total Errors: 0然后重启nagios服务[root@node4 objects]#service nagios restartRunning configurationcheck...done.Stopping nagios:done.Starting nagios:done.然后进入nagios界面,你就会看到我们加入的mysql服务



本文出自 “IT没有圈” 博客,请务必保留此出处http://wiker.blog.51cto.com/8481872/1365751
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: