6 мая 2010 г.

Простой мониторинг наличия серверов в сети

Сделал простенький мониторинг наличия в сети различных сетевых устройств: серверов, принтеров, роутеров, etc. Сделал его на основе скрипта Брендана Грегга (Brendan Gregg).
Скрипт, или несколько его копий - если есть несколько наборов IP-адресов, которые нужно мониторить -, у меня запускается из /etc/rc.local.
Сам скрипт можно скачать здесь

Использование скрипта следующее:
watchping.sh [-vhES][-e addr][-s priority][-l logfile][-w website][-t secs][-C controlhost][-i infile | hosts ...]

Описание опций (копипаст):

-h Usage help.
-v Verbose info on startup. Use until familiar with options.
-e Email this address. By default it emails root.
-E Don't send email.
-t Seconds to sleep between pings. Default is 60.
-s Use this "facility.priority" for syslog. By default it uses the "priority" variable in the script below.
-S Don't send messages to syslog. Default is to use syslog.
-w Web site. Update this website with ping status (coloured).
-l Log file. Append status messages here.
hosts A list of hosts to ping. By default, the list is fetched from hosts discovered in /etc/hosts (specified in the "hosts" variable in the script).
-i In list file. A text file containing the host list mentioned above. Syntax is a list of hostnames and/or IPs. Useful if the host list grows to be large.
-C Address of host, wich must be online. If offline, believe than world is down.

В оригинальном скрипте я добавил параметр -C, который позволяет по наличию указанного эталонного хоста проверять наличие сети вообще. Если сети нет, то остальные ошибки уже не важны. Ну, и поправил парсер списка хостов, чтобы можно было справа от имени/IP-адреса хоста добавлять коментарий.

Использую скрипт так:


/opt/watchping/watchping.sh -C 192.168.0.1 -e support@mail.com -i /opt/watchping/servers.lst > /dev/null 2>&1 &
/opt/watchping/watchping.sh -C 192.168.0.1 -e support@mail.com -i /opt/watchping/provs.lst > /dev/null 2>&1 &
/opt/watchping/watchping.sh -C 192.168.0.1 -e support@mail.com -i /opt/watchping/devices.lst > /dev/null 2>&1 &

Комментариев нет:

Отправить комментарий