ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"<Directory "/usr/local/nagios/sbin"># SSLRequireSSL Options ExecCGI AllowOverride None Order allow,deny Allow from all# Order deny,allow# Deny from all# Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user</Directory>Alias /nagios "/usr/local/nagios/share"<Directory "/usr/local/nagios/share"># SSLRequireSSL Options None AllowOverride None Order allow,deny Allow from all# Order deny,allow# Deny from all# Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user</Directory>
创建apache目录验证文件并得启apache
/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadminNew password:Re-type new password: Adding password for user nagiosadminservice httpd restart #重启apache
vi /usr/local/nagios/etc/nagios.cfg# Definitions for monitoring the local (Linux) hostcfg_file=/usr/local/nagios/etc/objects/localhost.cfg# Definitions for monitoring a Windows machinecfg_file=/usr/local/nagios/etc/objects/windows.cfg #去掉这句话的注释
打开模块后配置windows.cfg
vi /usr/local/nagios/etc/objects/windows.cfgdefine host{ use windows-server host_name winserver #被监控主机名 alias My Windows Server address 192.168.0.8 ; 被监控的windows地址#把下面的host_name都改成winserverdefine service{ use generic-service host_name winserver service_description CPU Load check_command check_nt!CPULOAD!-l 5,80,90 #监控CPU使用 }define service{ use generic-service host_name winserver service_description Memory Usage check_command check_nt!MEMUSE!-w 80 -c 90 #监控内存 }
[root@cxy libexec]# pwd/usr/local/nagios/libexec[root@cxy libexec]# ./check_nt -hUsage:check_nt -H host -v variable [-p port] [-w warning] [-c critical][-l params] [-d SHOWALL] [-t timeout]#监控CPU写法CPULOAD = Average CPU load on last x minutes. Request a -l parameter with the following syntax: -l <minutes range>,<warning threshold>,<critical threshold>. <minute range> should be less than 24*60. Thresholds are percentage and up to 10 requests can be done in one shot. ie: -l 60,90,95,120,90,95#完整写法为check_nt!CPULOAD!-l 5,80,90check_nt调用cpuload,5分钟内负载平均达到80%为warning,负载达到90%为critical
监控磁盘使用
USEDDISKSPACE = Size and percentage of disk use. Request a -l parameter containing the drive letter only. Warning and critical thresholds can be specified with -w and -c.#如果要监控C盘,达到80%报警,达到90%为严重危险check_nt!USEDDISKSPACE!-l c -w 80 -c 90