По умолчанию Nagios проверяет домен SSH на порту 22.
Но — его часто меняют, и требуется изменить настройки мониторинга для этой службы.
Проверка SSH выполняется командой check_ssh в файле с описанием хоста, в данном случае это /etc/nagios/objects/localhost.cfg:
define service{
use local-service ; Name of service template to use
host_name localhost
service_description SSH
check_command check_ssh
notifications_enabled 1
}
Которая вызывает команду check_ssh из скрипта /etc/nagios/objects/commands.cfg:
# 'check_ssh' command definition
define command{
command_name check_ssh
command_line $USER1$/check_ssh $ARG1$ $HOSTADDRESS$
}
А она, в свою очередь, использует скрипт /usr/lib64/nagios/plugins/check_ssh.
Получить подсказку по нему можно так:
# /usr/lib64/nagios/plugins/check_ssh --help check_ssh v1.4.16 (nagios-plugins 1.4.16) Copyright (c) 1999 Remi Paulmier <[email protected]> Copyright (c) 2000-2007 Nagios Plugin Development Team <[email protected]> Try to connect to an SSH server at specified server and port ... -p, --port=INTEGER Port number (default: 22) ...
Теперь — изменим вызов команды check_ssh в файле /etc/nagios/objects/commands.cfg, добавив ему вызов с опцией -p:
define command{
command_name check_ssh
command_line $USER1$/check_ssh -p $ARG1$ $HOSTADDRESS$
}
$ARG1$, как вы догадались — первый переданный при вызове аргумент.
Редактируем настройки хоста — и добавляем вызов check_ssh, передавая первым аргументом номер порта 2222:
define service{
use local-service ; Name of service template to use
host_name localhost
service_description SSH
check_command check_ssh!2222
notifications_enabled 1
}
check_ssh!2222 — аргументы передаются после знака «!«.
Готово:
# head -n 50 /var/vmail/domain.com/[email protected]/cur/1417436587.M889791P27954.venti.domain.com,S=1040,W=1075:2,a ... Subject: ** RECOVERY Service Alert: localhost/SSH is OK ** ... ***** Nagios ***** Notification Type: RECOVERY Service: SSH Host: localhost Address: 127.0.0.1 State: OK




