设为首页 收藏本站
查看: 1046|回复: 0

Nagios添加服务监控

[复制链接]

尚未签到

发表于 2019-1-14 08:52:05 | 显示全部楼层 |阅读模式

监控Web服务:
在window server2003上安装IIS
然后我们在nagios上做配置
命令配置里面默认有http
define 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.cfg
define service{
        use                     generic-service
        host_name               winserver
        service_description     Web_server
        check_command           check_http
        }
重启nagios服务
[root@node4 objects]#service nagios restart
Running configurationcheck...done.
Stopping nagios:done.
Starting nagios:done.
然后现在我们在nagios管理界面上看到新加入的web服务了



监控mysql服务
在node4上安装mysql-server
# yum install mysql-server -y
启动mysqld服务
# service mysqldstart
Initializing MySQLdatabase:  Installing MySQL systemtables...
OK
Filling helptables...
OK


To start mysqld atboot time you have to copy
support-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 test
databases andanonymous user created by default.  Thisis
strongly 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.pl
cd /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 #修改密码为wiker
Enter password:   #直接回车,默认的root密码是空
[root@node4 ~]# mysql -u root -pwiker #测试下登陆
Welcome to the MySQLmonitor.  Commands end with ; or \g.
Your MySQL connectionid is 11
Server 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]#ls
check_apt           check_imap         check_pop
check_breeze        check_ircd         check_procs
check_by_ssh        check_load         check_real
check_clamd         check_log          check_rpc
check_cluster       check_mailq        check_sensors
check_dhcp          check_mrtg         check_smtp
check_dig           check_mrtgtraf     check_ssh
check_disk          check_nagios       check_swap
check_disk_smb      check_nntp         check_tcp
check_dns           check_nrpe         check_time
check_dummy         check_nt           check_udp
check_file_age      check_ntp          check_ups
check_flexlm        check_ntp_peer     check_users
check_ftp           check_ntp_time     check_wave
check_http          check_nwstat       negate
check_icmp          check_oracle       process_perfdata.pl
check_ide_smart     check_overcr       urlize
check_ifoperstatus  check_ping         utils.pm
check_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]#ls
check_apt           check_load         check_real
check_breeze        check_log          check_rpc
check_by_ssh        check_mailq        check_sensors
check_clamd         check_mrtg         check_simap
check_cluster       check_mrtgtraf     check_smtp
check_dhcp          check_mysql        check_spop
check_dig           check_mysql_query  check_ssh
check_disk          check_nagios       check_ssmtp
check_disk_smb      check_nntp         check_swap
check_dns           check_nntps        check_tcp
check_dummy         check_nrpe         check_time
check_file_age      check_nt           check_udp
check_flexlm        check_ntp          check_ups
check_ftp           check_ntp_peer     check_users
check_http          check_ntp_time     check_wave
check_icmp          check_nwstat       negate
check_ide_smart     check_oracle       process_perfdata.pl
check_ifoperstatus  check_overcr       urlize
check_ifstatus      check_ping         utils.pm
check_imap          check_pnp_rrds.pl  utils.sh
check_ircd          check_pop
check_jabber        check_procs
首先我们定义commands
[root@node4 libexec]#cd /usr/local/nagios/etc/objects/
[root@node4 objects]#vim commands.cfg
define  command {
       command_name    check_mysql
       command_line    $USER1$/check_mysql -H $HOSTADDRESS$ -u$ARG1$ -p $ARG2$
}
然后定义主机上的服务
[root@node4 objects]#vim localhost.cfg
define 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: 0
Total Errors:   0
然后重启nagios服务
[root@node4 objects]#service nagios restart
Running configurationcheck...done.
Stopping nagios:done.
Starting nagios:done.
然后进入nagios界面,你就会看到我们加入的mysql服务

  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-662993-1-1.html 上篇帖子: Nagios的NSClient++插件配置 下篇帖子: Nagios、RRDTool和PNP整合
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表