测试接收邮件
首先需要将nagios监控主机的IP加入到邮件系统的信任主机列表中。否则必须使用外部邮件系统账号发送邮件。
新建/root/testmail文件
- /bin/mail -v -s "test" nagios@xxx.edu.cn < /root/testmail -- -f nagios@xxx.edu.cn -F nagios
- /usr/bin/printf "%b" "test" | /bin/mail -v -s "test Alert" nagios@xxx.edu.cn -- -f nagios@xxx.edu.cn -F nagios
修改commands.cfg
notify-host-by-email 和 notify-service-by-email 末尾均加上以下语句。为了便于通过学校邮箱转139邮箱时不被139邮箱过滤。
-- -f nagios@xxx.edu.cn -F nagios
check_http
- ./check_http -H www.xxx.edu.cn -w 5 -c 8 -u /index.php -s "www.xxx.edu.cn"
- define command{
- command_name check_http
- command_line $USER1$/check_http -H $ARG1$ -w $ARG2$ -c $ARG3$ -u $ARG4$ -s $ARG5$
- }
- define service{
- use generic-service
- host_name server-www-8
- service_description website-www-8
- check_command check_http!www.xxx.edu.cn!5!8!/index.php!"www.xxx.edu.cn"
- }
check_dns
- ./check_http -H www.xxx.edu.cn -a site's ip -w 5 -c 8
- define command {
- command_name check_dns
- command_line $USER1$/check_dns -s $HOSTADDRESS$ -H $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$
- }
- define service{
- use generic-service
- host_name server-dns-95
- service_description network-dns-95
- check_command check_dns!www.xxx.edu.cn!site's ip!5!8!
- }
check_squid
- ./check_squid.pl -u http://www.xxx.edu.cn -p proxy_server_ip -l 3128 -o username -m password -e 200
- ./check_squid.pl -u http://www.xxx.edu.cn -p proxy_server_ip -l 3128 -o username -m password -e 200
- ./check_squid.pl -u http://www.xxx.edu.cn -p proxy_server_ip -l 3128 -e 200
- define command {
- command_name check_squid
- command_line $USER1$/check_squid.pl -u $ARG1$ -p $ARG2$ -l $ARG3$ -o $ARG4$ -m $ARG5$ -e $ARG6$
- }
- define service{
- use generic-service
- host_name server-proxy-68
- service_description network-proxy-68
- check_command check_squid!http://www.xxx.edu.cn!proxy_server_ip!3128!username!password!200!
- }
check_dhcp
- /usr/local/nagios/libexec/check_dhcp -s dhcp_server_ip -i eth2 -u
- define command{
- command_name check_dhcp
- command_line $USER1$/check_dhcp -s $ARG1$ -i eth2 -u
- }
- define service{
- use generic-service
- host_name server-dhcp-13
- service_description network-dhcp-13
- check_command check_dhcp!dhcp_server_ip!
- }
DHCP服务器必须加上配置
- host nagios {
- hardware ethernet 00:d0:b7:c2:76:fd;
- fixed-address nagios_server_ip;
- }
- subnet nagios_server_net netmask 255.255.255.0 {
- }
check_smtp
- ./check_smtp -H mailserverip -A LOGIN -U username -P password
- define command{
- command_name check_smtp
- command_line $USER1$/check_smtp -H $HOSTADDRESS$ -A LOGIN -U $ARG1$ -P $ARG2$
- }
- define service{
- use generic-service
- host_name server-mail3-17
- service_description ecampus-mail3-smtp-17
- check_command check_smtp!username!password!
- }
