环境:Ubuntu11.04 VirtualBOX4.0.6r71344 Ubuntu10.10 Server
要求:对网络内的二台DHCP服务器监测
第一步:安装nagios3、apache2
$sudo apt-get install apache2
$sudo apt-get install nagios3 //nagios Version 3.2.1。
第二步:安装过程中设置nagios3
1、管理员警报邮箱设置(这次我直接选择 No configruation)
No configuration:
Should be chosen to leave the current configuration unchanged.
Internet site:
Mail is sent and received directly using SMTP.
Internet with smarthost:
Mail is received directly using SMTP or by running a utility such as fetchmail. Outgoing mail is sent using a smarthost.
Satellite system:
All mail is sent to another machine, called a 'smarthost', for delivery.
Local only:
The only delivered mail is the mail for local users. There is no network.
General type of mail configuration:
No configuration
Internet Site
Internet with smarthost
Satellite system
Local only
<确定> <取消>
2、nagios的web管理页用户认证要用的密码设置(上一步没有设置报警邮箱,所以直接到这一步)
Please provide the password to be created with the "nagiosadmin" user.
This is the username and password you will use to log in to your nagios installation after configuration is complete. If you do not provide a password, you will have to configure access to nagios yourself.
Nagios web administration password:
输入后会要求再次确认密码,确认后回车
在这里最好就创建了nagiosadmin的密码,要不然还要在后面创建,不过也不麻烦用下面的命令就可以了:
htpasswd -C /etc/nagios3/htpasswd.users nagiosadmin
以后再添加用户就不用“-C”了
例如:htpasswd /etc/nagios3/htpasswd.users test
系统提示:
New password: //输入新密码
Re-type new password: //确认密码
Adding password for user test
其实在这时在浏览器里输入http://localhost/nagios3/就可以看到nagios的管理页面了,当然里面还没有什么东西
第三步:配置监测设备
1、创建被监测设备的配置文件
$sudo vim /etc/nagios3/conf.d/host.cfg
#add dhcp server
define host{
use generic-host
host_name dhcp1
alias dhcp1
address 192.168.0.1
}
2、在主机定义模板里加入要监测的设备
$sudo vim /etc/nagios3/conf.d/hostgroups_nagios2.cfg
(紫色部分为后加的,绿色字为原有的)
#check dhcp server runing
define hostgroup{
hostgroup_name dhcp-server
alias dhcp1
members dhcp1
}
# A list of your web servers
define hostgroup {
hostgroup_name http-servers
alias HTTP servers
members localhost,dhcp1
}
# A list of your ssh-accessible servers
define hostgroup {
hostgroup_name ssh-servers
alias SSH servers
members localhost,dhcp1
}
3、定义要监测的主机的服务
$sudo vim /etc/nagios3/conf.d/services_nagios2.cfg
(因为在这两台DHCP上装有webmin,就对这个做个监测吧,紫色部分为后加的,绿色字为原有的)
# check that web services are running
define service {
hostgroup_name http-servers
service_description HTTP
check_command check_http
use generic-service
notification_interval 0 ; set > 0 if you want to be renotified
}
# check that ssh services are running
define service {
hostgroup_name ssh-servers
service_description SSH
check_command check_ssh
use generic-service
notification_interval 0 ; set > 0 if you want to be renotified
}
# check that webmin services are running
define service {
hostgroup_name dhcp-server
service_description webmin
check_command check_tcp!10000!
use generic-service
notification_interval 0 ; set > 0 if you want to be renotified
}
第四步:测试
$sudo nagios3 –v /etc/nagios3/nagios.cfg
系统提示:
Total Warnings: 0
Total Errors: 0
这时再进入nagios的管理页面就可以看到相应的管理服务项目。到此对服务器的监控配置就完成了,下面就做对交换机的监控配置
重启nagios
$sudo /etc/init.d/nagios3 restart
本来还要对交换机做个监测,但一直配置有问题,现在对交换机的ping是没有问题,但snmp和mrtg的出图一直有问题,先做个记录,下一步再做更新
转载于:https://blog.51cto.com/icedot/562062