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
сервис_nagios [2022/02/25 19:47]
val [Установка]
сервис_nagios [2022/03/11 13:52] (current)
val [Настройка объектов мониторинга]
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 31: Line 32:
  
 server# less /​etc/​nagios-plugins/​config/​http.cfg server# less /​etc/​nagios-plugins/​config/​http.cfg
- 
-server# /​usr/​lib/​nagios/​plugins/​check_mrtgtraf -F /​var/​www/​html/​mrtg/​router_fa0_0.log -a MAX -w 100000,​100000 -c 50000,50000 
- 
-server# less /​etc/​nagios-plugins/​config/​mrtg.cfg 
 </​code><​code>​ </​code><​code>​
 server# cat /​etc/​nagios4/​conf.d/​corpX.cfg server# cat /​etc/​nagios4/​conf.d/​corpX.cfg
Line 132: Line 129:
         use                     ​my-templ-service-ping         use                     ​my-templ-service-ping
         host_name ​              ​switch3         host_name ​              ​switch3
 +}
 +
 +#--- For next labs ---
 +
 +define host{
 +        use             ​my-templ-host
 +        host_name ​      ​cisco-router
 +        alias           Cisco 7200
 +        address ​        ​router
 } }
 </​code>​ </​code>​
Line 137: Line 143:
 ==== Тестирование конфигурации и запуск ==== ==== Тестирование конфигурации и запуск ====
  
-  * [[http://server/nagios4/]]+  * [[http://192.168.X.10/nagios4/]]
  
 <​code>​ <​code>​
Line 201: Line 207:
  
 <​code>​ <​code>​
 +# mkdir /usr/var
 +
 # /​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 217: Line 223:
         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 231: Line 230:
         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>​
  
-===== Использование plugin check_snmp_int ​=====+===== Интеграция с MRTG =====
  
-==== Установка plugin ====+  * [[https://​www.monitoring-plugins.org/​doc/​man/​check_mrtg.html|The check_mrtg Plugin]] 
 +  * [[https://​www.monitoring-plugins.org/​doc/​man/​check_mrtgtraf.html|The check_mrtgtraf Plugin]]
  
-=== Debian/​Ubuntu === 
 <​code>​ <​code>​
-root@server:~apt install ​nagios-snmp-plugins+server# ​/usr/lib/nagios/​plugins/​check_mrtgtraf ​-F /​var/​www/​html/​mrtg/​router_fa0_0.log ​-a MAX -w 125000,​125000 -c 62500,62500 -e 10
  
-root@server:~cd /usr/lib/nagios/plugins +server# ​less /etc/nagios4/objects/commands.cfg
-</​code>​+
  
-==== Тестирование plugin ====+server# /​usr/​lib/​nagios/​plugins/​check_mrtg -F /​var/​www/​html/​mrtg/​dhcp-stat.log -a MAX -v 2 -w 6 -c 8
  
-По умолчанию значения в KBytes/s +server# cat corpX.cfg 
- +</code><​code>​
-=== FreeBSD/Ubuntu === +
-<​code>​ +
-# ./​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] +--- int WAN bandwidth ​MRTG ---
-   ​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] +define service{ 
-   critical level for input / output ​bandwidth ​(0 for no critical) +        use                     ​generic-service 
-     unit depends on B,M,G,u options +        host_name ​              cisco-router 
-   ​critical for error & discard input output in error/min (need -q) +        ​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 
-</​code>​+}
  
-=== Ubuntu === +--- check dhcp stat ---
-<​code>​ +
-cat /​tmp/​tmp_Nagios_int.router.FastEthernet1_0+
  
-# rm /​tmp/​tmp_Nagios_int.router.* 
-</​code>​ 
- 
-==== Настройка nagios на использование plugin ==== 
- 
-=== FreeBSD/​Ubuntu === 
-<​code>​ 
-server# cat corpX.cfg 
-</​code><​code>​ 
-... 
 define command { define command {
-        command_name ​check_snmp_int_band +        command_name ​my-check_mrtg 
-        command_line $USER1$/check_snmp_int.pl ​-$HOSTADDRESS$ -$ARG1$ -$ARG2-k -w $ARG3$ -c $ARG4$+        command_line $USER1$/check_mrtg ​-$ARG1$ -$ARG2$ -$ARG3$ -w $ARG4$ -c $ARG5$
 } }
  
Line 293: Line 269:
         use                     ​generic-service         use                     ​generic-service
         host_name ​              ​cisco-router         host_name ​              ​cisco-router
-        service_description ​    int_if_bandwidth +        service_description ​    check dhcp stat 
-        check_command ​check_snmp_int_band!public!FastEthernet1/0!10,10!100,100+        check_command ​          my-check_mrtg!/var/​www/​html/​mrtg/​dhcp-stat.log!MAX!2!6!8
 } }
-</​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>​ </​code>​
  
Line 318: Line 284:
  
 #​CMD='​rsh router show ip dhcp binding | grep 192.168 | wc -l' #​CMD='​rsh router show ip dhcp binding | grep 192.168 | wc -l'
-#MAX=99+#MAX=9
 #CUR=`eval $CMD` #CUR=`eval $CMD`
  
Line 351: Line 317:
  
   * [[https://​www.itstuff.info/​linux_unix/​install-web-interface-nagvis-for-nagios/​|Установка Web-интерфейса NagVis для системы мониторинга Nagios]]   * [[https://​www.itstuff.info/​linux_unix/​install-web-interface-nagvis-for-nagios/​|Установка Web-интерфейса NagVis для системы мониторинга Nagios]]
 +
 +===== Дополнительные материалы =====
 +
 +==== Использование plugin check_snmp_int ====
 +
 +=== Установка plugin ===
 +
 +== Debian/​Ubuntu ==
 +<​code>​
 +root@server:​~#​ apt install nagios-snmp-plugins
 +
 +root@server:​~#​ cd /​usr/​lib/​nagios/​plugins
 +</​code>​
 +
 +=== Тестирование plugin ===
 +
 +По умолчанию значения в KBytes/s
 +
 +== FreeBSD/​Ubuntu ==
 +<​code>​
 +# ./​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)
 +...
 +</​code>​
 +
 +== Ubuntu ==
 +<​code>​
 +# cat /​tmp/​tmp_Nagios_int.router.FastEthernet1_0
 +
 +# rm /​tmp/​tmp_Nagios_int.router.*
 +</​code>​
 +
 +=== Настройка nagios на использование plugin ===
 +
 +== FreeBSD/​Ubuntu ==
 +<​code>​
 +server# cat corpX.cfg
 +</​code><​code>​
 +...
 +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
 +}
 +</​code>​
сервис_nagios.1645807657.txt.gz · Last modified: 2022/02/25 19:47 by val