Author Archives: admin

Мониторинг Windows серверов с Nagios + NSClient++

Мониторить Windows сервера будем с помощью агента NSClient++, у которого есть модуль NRPEListener.dll nrpe:

Часть проверок мы будем собирать через модуль Nagios check_nt часть через модуль check_nrpe.

1. Установим агент NSClient++ на Windows сервер
32x битная версия 0.3.9
64x битная версия 0.3.9







2. Настраиваем NSClient++
Конфигурационный файл C:\Program Files\NSClient++\NSC.ini
При установке мы уже активировали часть необходимых параметров для работы агента, осталось активировать следующие параметры в разделе [NRPE] и сохранить изменения:

   port=5666
   allow_arguments=1
   

3. Заходим в Services и устанавливаем галочку в закладке Log On (Allow service to interact with desktop) и запускаем сервис NSClient++

Необходимые действия на стороне Windows сервера завершены. Переходим к Nagios серверу.

1. Определяем проверки в файле commands.cfg
Проверка с помощью плагина check_nt -s Password Пароль который мы указывали при установке

define command{
command_name    check_nt
command_line    $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s Password -v $ARG1$ $ARG2$
}

Проверка памяти с помощью плагина check_nrpe и CheckMem
type=physical The amount of physical memory currently available, in bytes. This is the amount of physical memory that can be immediately reused without having to write its contents to disk first. It is the sum of the size of the standby, free, and zero lists.

define command{
command_name check_memory_physical
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckMEM -a MaxWarn=$ARG1$% MaxCrit=$ARG2$% ShowAll=long type=physical
}

type=page The maximum amount of memory the current process can commit, in bytes. This value is equal to or smaller than the system-wide available commit value.

define command{
command_name check_memory_page
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckMEM -a MaxWarn=$ARG1$% MaxCrit=$ARG2$% ShowAll=long type=page
}

type=virtual Number of pages of swap currently in use (note – it does NOT = (physical + swap) as on *nix boxes) According to M$ this is: Size of unreserved and uncommitted memory in the user mode portion of the virtual address space of the calling process, in bytes.

define command{
command_name check_memory_virtual
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckMEM -a MaxWarn=$ARG1$% MaxCrit=$ARG2$% ShowAll=long type=virtual
}

2. Определяем Host Definition и Service definition в файле /etc/nagios/hosts/Windows1.cfg

# Host Definition
define host{
# Name of host template to use
               use                           generic-host
               host_name                     Windows1
               address                       192.168.1.105
               check_command                 check-host-alive
               contact_groups                admins
               max_check_attempts            10
               notification_interval         120
               notification_period           24x7
               notification_options          d,u,r
}
# Service definition
define service{
# Name of service template to use
               use                           generic-service
               host_name                     Windows1
               service_description           PING
               is_volatile                   0
               check_period                  24x7
               max_check_attempts            3
               normal_check_interval         1
               retry_check_interval          1
               contact_groups                admins
               notification_interval         120
               notification_period           24x7
               notification_options          c,r
               check_command                 check_ping!250.0,20%!500.0,60%
}
define service{
               use                           generic-service
               host_name                     Windows1
               service_description           Uptime
               is_volatile                   0
               check_period                  24x7
               max_check_attempts            3
               normal_check_interval         1
               retry_check_interval          1
               contact_groups                admins
               notification_interval         120
               notification_period           24x7
               notification_options          c,r
               check_command                 check_nt!UPTIME
}
define service{
               use                           generic-service
               host_name                     Windows1
               service_description           CPU Load
               is_volatile                   0
               check_period                  24x7
               max_check_attempts            3
               normal_check_interval         1
               retry_check_interval          1
               contact_groups                admins
               notification_interval         120
               notification_period           24x7
               notification_options          c,r
               check_command                 check_nt!CPULOAD!-l 5,80,90
}
define service{
               use                           generic-service
               host_name                     Windows1
               service_description           SWAP
               is_volatile                   0
               check_period                  24x7
               max_check_attempts            3
               normal_check_interval         1
               retry_check_interval          1
               contact_groups                admins
               notification_interval         120
               notification_period           24x7
               notification_options          c,r
               check_command                 check_nt!MEMUSE!-w 80 -c 90
}
define service{
               use                           generic-service
               host_name                     Windows1
               service_description           Memory Physical
               is_volatile                   0
               check_period                  24x7
               max_check_attempts            3
               normal_check_interval         1
               retry_check_interval          1
               contact_groups                admins
               notification_interval         120
               notification_period           24x7
               notification_options          c,r  
               check_command                 check_memory_physical!80!90!
}
define service{
               use                           generic-service
               host_name                     Windows1
               service_description           Memory Page
               is_volatile                   0
               check_period                  24x7
               max_check_attempts            3
               normal_check_interval         1
               retry_check_interval          1
               contact_groups                admins
               notification_interval         120
               notification_period           24x7
               notification_options          c,r  
               check_command                 check_memory_page!80!90!
}
define service{
               use                           generic-service
               host_name                     Windows1
               service_description           Memory Virtual
               is_volatile                   0
               check_period                  24x7
               max_check_attempts            3
               normal_check_interval         1
               retry_check_interval          1
               contact_groups                admins
               notification_interval         120
               notification_period           24x7
               notification_options          c,r  
               check_command                 check_memory_virtual!80!90!
}

3. Добавляем данный файл в nagios.cfg

cfg_file=/etc/nagios/hosts/Windows1.cfg

Проверяем конфигурацию и перезагружаем Nagios

# nagios -v /etc/nagios/nagios.cfg
# service nagios restart

4. В результате получаем проверку Windows сервера: