Это старая версия документа.
C:\> cd "C:\Program Files\ICW\etc\nagios\nagwin"
[server:~] # pkg install nagios [server:~] # cd /usr/local/etc/nagios/ [server:local/etc/nagios] # sh # for i in *sample; do cp -v $i ${i%-sample}; done # cd objects/ # for i in *sample; do cp -v $i ${i%-sample}; done <Ctrl-D>
# a2enmod auth_digest # a2enmod authz_groupfile # apt install nagios4 # cd /etc/nagios4/conf.d/
Готового пакета нет
root@server:~# apt install nagios3
Пароль: nagios
root@server:~# cd /etc/nagios3/conf.d/
shell> notepad++ C:\Program Files\ICW\etc\nginx\nginx.conf
... listen 81; ...
server# more cgi.cfg
... use_authentication=1 ...
[server:~] # cat /usr/local/etc/apache24/Includes/nagios.conf
<Directory /usr/local/www/nagios> AllowOverride AuthConfig Require all granted DirectoryIndex index.php php_flag engine on php_admin_value open_basedir /usr/local/www/nagios/:/var/spool/nagios/ </Directory> <Directory /usr/local/www/nagios/cgi-bin> Options ExecCGI </Directory> ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/ Alias /nagios/ /usr/local/www/nagios/
# cat /usr/local/www/nagios/.htaccess
AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/etc/nagios/htpasswd.users require valid-user
htpasswd -c /usr/local/etc/nagios/htpasswd.users nagiosadmin
C:\Program Files\ICW\etc\nagios\nagwin>notepad++ contacts.cfg
... email userX@isp.un ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** ...
C:\Program Files\ICW\etc\nagios\nagwin>notepad++ commands.cfg
... # 'notify-host-by-email' command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf ... -f nagios@corpX.un ... -server mail.isp.un } # 'notify-service-by-email' command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf ... -f nagios@corpX.un ... -server mail.isp.un } ...
[server:local/etc/nagios] # cat nagios.cfg
... cfg_file=/usr/local/etc/nagios/objects/corpX.cfg
[server:~] # cd /usr/local/etc/nagios/objects/ [server:etc/nagios/objects] # cat commands.cfg
... # может не нужно command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5 -4 ...
server# cat corpX.cfg
define host{ use generic-host name my-templ-host register 0 max_check_attempts 1 # For Ubuntu (mail send to user root) # contacts root # check_command check-host-alive_4 # For Debian, Windows and Freebsd (mail send to user nagios) # contacts nagiosadmin # check_command check-host-alive } #--------------------------------- define host{ use my-templ-host host_name yandex alias yandex web site address ya.ru } define service{ use generic-service host_name yandex service_description www check_command check_http normal_check_interval 5 retry_check_interval 1 } #--------------------------------- define host{ use my-templ-host host_name switch alias core switch address switch } define service{ use generic-service host_name switch service_description ping # check_command check_winping # может понадобиться ключ -4 в описание команды # check_command check_ping!100.0,20%!500.0,60% normal_check_interval 5 retry_check_interval 1 } #--------------------------------- define servicedependency{ host_name switch service_description ping dependent_host_name yandex dependent_service_description www execution_failure_criteria o notification_failure_criteria w,u }
l/p: nagiosadmin/nagios
root@server:~# nagios4 -v /etc/nagios3/nagios.cfg root@server:~# service nagios4 restart
Все через кнопку «Пуск»
root@server:~# nagios3 -v /etc/nagios3/nagios.cfg root@server:~# /etc/init.d/nagios3 restart
[server:~] # nagios -v /usr/local/etc/nagios/nagios.cfg [server:~] # sysrc nagios_enable=yes [server:~] # service nagios start
root# sudo -u nagios sh
nagios$ cat .ssh/id_rsa.pub ... nagios$ cat .ssh/config ... nagios$ /usr/local/libexec/nagios/check_by_ssh -H server2 -C "/usr/lib/nagios/plugins/check_disk -w '10' -c '20' -e -p '/'" server# cat corpX.cfg
define host{ use my-templ-host host_name server2 address server2 } define service{ use generic-service host_name server2 } define command{ command_name ssh_disk_linux command_line $USER1$/check_by_ssh -H '$HOSTADDRESS$' -C "/usr/lib/nagios/plugins/check_disk -w '$ARG1$' -c '$ARG2$' -e -p '$ARG3$'" } define service{ use generic-service service_description disk host_name server2 check_command ssh_disk_bsd_linux!20%!10%!/ }
shell> snmpwalk -c public -v2c router ifDescr
[server:~] # cd /usr/ports/net-mgmt/nagios-plugins [server:~] # make config
... OPTIONS_FILE_SET+=NETSNMP ...
[server:~] # cd /usr/local/libexec/nagios/
root@server:~# cd /usr/lib/nagios/plugins
# ./check_snmp -H router -C public -o ifInOctets.2,ifOutOctets.2 --rate -w 1000,1000 -c 10000,10000
# rm -r /usr/var/* # chown -R nagios /usr/var/
server# cat corpX.cfg
... define command { command_name check_snmp_band command_line $USER1$/check_snmp --rate -H $HOSTADDRESS$ -C $ARG1$ -o $ARG2$ -w $ARG3$ -c $ARG4$ } define host{ use my-templ-host host_name cisco-router alias Cisco 7200 address router } define service{ use generic-service host_name cisco-router service_description int_if_bandwidth check_command check_snmp_band!public!ifInOctets.2,ifOutOctets.2!1000,1000!10000,10000 }
[server:~] # pkg install nagios-snmp-plugins-extras [server:~] # cd /usr/local/libexec/nagios/
root@server:~# apt install nagios-snmp-plugins root@server:~# cd /usr/lib/nagios/plugins
По умолчанию значения в KBytes/s
# ./check_snmp_int.pl -H router -C public -n FastEthernet1/0 -k -w 10,10 -c 100,100 # ./check_snmp_int.pl --help ... -k, --perfcheck ; -q, --extperfcheck -k check the input/ouput bandwidth of the interface -q also check the error and discard input/output -w, --warning=input,output[,error in,error out,discard in,discard out] warning level for input / output bandwidth (0 for no warning) unit depends on B,M,G,u options warning for error & discard input / output in error/min (need -q) -c, --critical=input,output[,error in,error out,discard in,discard out] critical level for input / output bandwidth (0 for no critical) unit depends on B,M,G,u options critical for error & discard input / output in error/min (need -q) ...
# cat /var/tmp/tmp_Nagios_int.router.FastEthernet1_0 # rm /var/tmp/tmp_Nagios_int.router.*
# cat /tmp/tmp_Nagios_int.router.FastEthernet1_0 # rm /tmp/tmp_Nagios_int.router.*
server# cat corpX.cfg
... define command { command_name check_snmp_int_band command_line $USER1$/check_snmp_int.pl -H $HOSTADDRESS$ -C $ARG1$ -n $ARG2$ -k -w $ARG3$ -c $ARG4$ } define service{ use generic-service host_name cisco-router service_description int_if_bandwidth check_command check_snmp_int_band!public!FastEthernet1/0!10,10!100,100 }
# /usr/local/libexec/nagios/check_mrtg -h # /usr/local/libexec/nagios/check_mrtgtraf -h
# cat /etc/nagios-dhcp-stat.sh
#!/bin/sh #CMD='rsh router show ip dhcp binding | grep 192.168 | wc -l' #MAX=99 #CUR=`eval $CMD` #CMD='/usr/bin/dhcpd-pools -l /var/lib/dhcp/dhcpd.leases -c /etc/dhcp/dhcpd.conf -f c | grep 192.168.X.' #CMD='/usr/local/bin/dhcpd-pools -l /var/db/dhcpd/dhcpd.leases -c /usr/local/etc/dhcpd.conf -f c | grep 192.168.X.' #MAX=`eval $CMD | cut -d'"' -f8` #CUR=`eval $CMD | cut -d'"' -f10` echo CUR:$CUR MAX:$MAX test $CUR -eq $MAX && exit 2 exit 0
# cat corpX.cfg
... define command { command_name check_dhcp_stat command_line /etc/nagios-dhcp-stat.sh } define service{ use generic-service host_name localhost service_description check dhcp stat check_command check_dhcp_stat }