62 lines
2.1 KiB
Markdown
62 lines
2.1 KiB
Markdown
Simple nagios monitoring and notification scripts.
|
|
|
|
`check_ircd` attempts to connect to an IRC server.
|
|
|
|
`check_senderscore` checks the senderscore (a metric for whether
|
|
an IP address tends to send spam email) of an IP address.
|
|
|
|
`check_onion` attempts to connect to a Tor Onion service via torsocks.
|
|
|
|
`ircbot.sh` runs as a daemon as the nagios user, connects to the
|
|
configured IRC server and channel, keeps the connection open, and
|
|
relays messages from nagios to the channel.
|
|
|
|
## Installing
|
|
|
|
To install, edit `Makefile` with the appropriate path to your nagios
|
|
directory and run `make install` as root. To install the systemd
|
|
service, run `make systemd`; for rc service (on OpenBSD), run `make
|
|
rc`.
|
|
|
|
## Setting up `ircbot`
|
|
|
|
Edit `ircbot` and change the configuration parameters as needed.
|
|
|
|
Edit your nagios commands configuration (eg
|
|
`/usr/local/nagios/etc/commands.cfg`) and define a new host and service
|
|
commands that write to the file `/tmp/ircmsg`. For example:
|
|
|
|
```
|
|
define command {
|
|
command_name notify-service-by-irc
|
|
command_line /usr/bin/printf "%b" "$NOTIFICATIONTYPE$ Service: $SERVICEDESC$ Host: $HOSTALIAS$ Address: $HOSTADDRESS$ State: $SERVICESTATE$ Additional Info: $SERVICEOUTPUT$\n" >> /tmp/ircmsg
|
|
}
|
|
define command {
|
|
command_name notify-host-by-irc
|
|
command_line /usr/bin/printf "%b" "$NOTIFICATIONTYPE$ Host: $HOSTNAME$ State: $HOSTSTATE$ Address: $HOSTADDRESS$ Info: $HOSTOUTPUT$\n" >> /tmp/ircmsg
|
|
}
|
|
```
|
|
|
|
Then create a contact with parameters:
|
|
|
|
```
|
|
service_notification_commands notify-service-by-irc
|
|
host_notification_commands notify-host-by-irc
|
|
```
|
|
|
|
Check that the new configuration is valid, eg with:
|
|
|
|
```
|
|
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
|
|
```
|
|
|
|
And then restart nagios with `systemctl` or `rcctl`.
|
|
|
|
If you followed the install instructions, a service file was installed for
|
|
systemd or rc. Start it with `systemctl start ircbot` or `rcctl start ircbot`.
|
|
|
|
## Bugs
|
|
|
|
The nagios IRC bot (ircbot.sh) does not automatically rejoin the
|
|
IRC server and channel after it loses the connection.
|