User Tools

Site Tools


сервис_nagios

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
сервис_nagios [2022/02/25 20:43]
val
сервис_nagios [2022/03/11 13:50]
val [Настройка nagios на использование check_snmp]
Line 26: Line 26:
  
   * [[https://​assets.nagios.com/​downloads/​nagioscore/​docs/​nagioscore/​3/​en/​dependencies.html|Host and Service Dependencies]]   * [[https://​assets.nagios.com/​downloads/​nagioscore/​docs/​nagioscore/​3/​en/​dependencies.html|Host and Service Dependencies]]
 +  * [[https://​www.zarrelli.org/​blog/​nagios-notification-escalations-made-easy/​comment-page-1/​|Nagios notification escalations made easy]]
  
 <​code>​ <​code>​
Line 133: Line 134:
 ==== Тестирование конфигурации и запуск ==== ==== Тестирование конфигурации и запуск ====
  
-  * [[http://server/nagios4/]]+  * [[http://192.168.X.10/nagios4/]]
  
 <​code>​ <​code>​
Line 201: Line 202:
 # /​usr/​lib/​nagios/​plugins/​check_snmp -H router -C public -o ifInOctets.2,​ifOutOctets.2 --rate -w 62500,62500 -c 125000,​125000 # /​usr/​lib/​nagios/​plugins/​check_snmp -H router -C public -o ifInOctets.2,​ifOutOctets.2 --rate -w 62500,62500 -c 125000,​125000
  
-# rm -r /​usr/​var/​* +# chown -R nagios:nagios /usr/var/
- +
-# chown -R nagios /usr/var/+
 </​code>​ </​code>​
  
Line 215: Line 214:
         command_name check_snmp_band         command_name check_snmp_band
         command_line $USER1$/​check_snmp --rate -H $HOSTADDRESS$ -C $ARG1$ -o $ARG2$ -w $ARG3$ -c $ARG4$         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 
 } }
  
Line 229: Line 221:
         service_description ​    int LAN bandwidth         service_description ​    int LAN bandwidth
         check_command check_snmp_band!public!ifInOctets.2,​ifOutOctets.2!62500,​62500!125000,​125000         check_command check_snmp_band!public!ifInOctets.2,​ifOutOctets.2!62500,​62500!125000,​125000
 +#        check_command check_snmp_band!public!ifInOctets.5,​ifOutOctets.5!62500,​62500!125000,​125000
 } }
 </​code>​ </​code>​
Line 241: Line 234:
  
 server# less /​etc/​nagios4/​objects/​commands.cfg server# less /​etc/​nagios4/​objects/​commands.cfg
 +
 +server# /​usr/​lib/​nagios/​plugins/​check_mrtg -F /​var/​www/​html/​mrtg/​dhcp-stat.log -a MAX -v 2 -w 6 -c 8
  
 server# cat corpX.cfg server# cat corpX.cfg
 </​code><​code>​ </​code><​code>​
 ... ...
 +
 +# --- int WAN bandwidth MRTG ---
 +
 define service{ define service{
         use                     ​generic-service         use                     ​generic-service
Line 250: Line 248:
         service_description ​    int WAN bandwidth MRTG         service_description ​    int WAN bandwidth MRTG
         check_command check_local_mrtgtraf!/​var/​www/​html/​mrtg/​router_fa0_0.log!AVG!62500,​62500!125000,​125000!10         check_command check_local_mrtgtraf!/​var/​www/​html/​mrtg/​router_fa0_0.log!AVG!62500,​62500!125000,​125000!10
 +}
 +
 +# --- check dhcp stat ---
 +
 +define command {
 +        command_name my-check_mrtg
 +        command_line $USER1$/​check_mrtg -F $ARG1$ -a $ARG2$ -v $ARG3$ -w $ARG4$ -c $ARG5$
 +}
 +
 +define service{
 +        use                     ​generic-service
 +        host_name ​              ​cisco-router
 +        service_description ​    check dhcp stat
 +        check_command ​          ​my-check_mrtg!/​var/​www/​html/​mrtg/​dhcp-stat.log!MAX!2!6!8
 } }
 </​code>​ </​code>​
  
-===== Использование ​plugin check_snmp_int ​=====+===== Использование ​скриптов ​=====
  
-==== Установка ​plugin ​====+  * [[https://​www.howtoforge.com/​tutorial/​write-a-custom-nagios-check-plugin/|How to Write a Custom Nagios Check Plugin]]
  
-=== Debian/​Ubuntu ​===+<​code>​ 
 +# cat /​etc/​nagios-dhcp-stat.sh 
 +</​code><​code>​ 
 +#!/bin/sh 
 + 
 +#CMD='rsh router show ip dhcp binding | grep 192.168 | wc -l' 
 +#MAX=9 
 +#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 
 +</​code><​code>​ 
 +# cat corpX.cfg 
 +</​code><​code>​ 
 +... 
 +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 
 +
 +</​code>​ 
 + 
 +===== Установка Web-интерфейса Nagios ===== 
 + 
 +  * [[https://​www.itstuff.info/​linux_unix/​install-web-interface-nagvis-for-nagios/​|Установка Web-интерфейса NagVis для системы мониторинга Nagios]] 
 + 
 +===== Дополнительные материалы ===== 
 + 
 +==== Использование plugin check_snmp_int ==== 
 + 
 +=== Установка plugin === 
 + 
 +== Debian/​Ubuntu ==
 <​code>​ <​code>​
 root@server:​~#​ apt install nagios-snmp-plugins root@server:​~#​ apt install nagios-snmp-plugins
Line 264: Line 322:
 </​code>​ </​code>​
  
-==== Тестирование plugin ​====+=== Тестирование plugin ===
  
 По умолчанию значения в KBytes/s По умолчанию значения в KBytes/s
  
-=== FreeBSD/​Ubuntu ​===+== FreeBSD/​Ubuntu ==
 <​code>​ <​code>​
 # ./​check_snmp_int.pl -H router -C public -n FastEthernet1/​0 -k -w 10,10 -c 100,100 # ./​check_snmp_int.pl -H router -C public -n FastEthernet1/​0 -k -w 10,10 -c 100,100
Line 290: Line 348:
 </​code>​ </​code>​
  
-=== Ubuntu ​===+== Ubuntu ==
 <​code>​ <​code>​
 # cat /​tmp/​tmp_Nagios_int.router.FastEthernet1_0 # cat /​tmp/​tmp_Nagios_int.router.FastEthernet1_0
Line 297: Line 355:
 </​code>​ </​code>​
  
-==== Настройка nagios на использование plugin ​====+=== Настройка nagios на использование plugin ===
  
-=== FreeBSD/​Ubuntu ​===+== FreeBSD/​Ubuntu ==
 <​code>​ <​code>​
 server# cat corpX.cfg server# cat corpX.cfg
Line 316: Line 374:
 } }
 </​code>​ </​code>​
- 
-===== Интеграция с MRTG ===== 
- 
-  * [[https://​www.experts-exchange.com/​questions/​27056704/​how-to-enable-MRTG-in-nagios.html|how to enable MRTG in nagios]] 
- 
-<​code>​ 
-# /​usr/​local/​libexec/​nagios/​check_mrtg -h 
- 
-# /​usr/​local/​libexec/​nagios/​check_mrtgtraf -h 
-</​code>​ 
- 
-===== Использование скриптов ===== 
- 
-  * [[https://​www.howtoforge.com/​tutorial/​write-a-custom-nagios-check-plugin/​|How to Write a Custom Nagios Check Plugin]] 
- 
-<​code>​ 
-# cat /​etc/​nagios-dhcp-stat.sh 
-</​code><​code>​ 
-#!/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 
-</​code><​code>​ 
-# cat corpX.cfg 
-</​code><​code>​ 
-... 
-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 
-} 
-</​code>​ 
- 
-===== Установка Web-интерфейса Nagios ===== 
- 
-  * [[https://​www.itstuff.info/​linux_unix/​install-web-interface-nagvis-for-nagios/​|Установка Web-интерфейса NagVis для системы мониторинга Nagios]] 
сервис_nagios.txt · Last modified: 2022/03/11 13:52 by val