add Makefile and systemd/rc service files
This commit is contained in:
parent
59c42e7c2c
commit
4b6e8af69e
39
Makefile
Normal file
39
Makefile
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# configuration area:
|
||||||
|
|
||||||
|
PREFIX = /usr/local
|
||||||
|
NAGIOS_DIR = ${PREFIX}/nagios
|
||||||
|
# for OpenBSD, change to ${PREFIX}/libexec/nagios below:
|
||||||
|
NAGIOS_EXEC = ${NAGIOS_DIR}/libexec
|
||||||
|
SYSTEMD_UNIT_DIR = /lib/systemd/system
|
||||||
|
|
||||||
|
rc: install
|
||||||
|
@echo installing ircbot to /etc/rc.d
|
||||||
|
@cf -f services/rc/ircbot /etc/rc.d
|
||||||
|
@echo enabling ircbot
|
||||||
|
@rcctl enable ircbot
|
||||||
|
@echo not starting ircbot -- configure it then run `rcctl start ircbot` as root
|
||||||
|
|
||||||
|
systemd: install
|
||||||
|
@echo installing ircbot.service to ${SYSTEMD_UNIT_DIR}
|
||||||
|
@cf -f services/systemd/ircbot.service ${SYSTEMD_UNIT_DIR}
|
||||||
|
@echo enabling ircbot.service
|
||||||
|
@systemctl enable ircbot.service
|
||||||
|
@echo not starting ircbot.service -- configure it then run `systemctl start ircbot.service` as root
|
||||||
|
|
||||||
|
install:
|
||||||
|
@echo installing service checking scripts to ${NAGIOS_EXEC}
|
||||||
|
@cp -f check_senderscore check_ircd ${NAGIOS_EXEC}
|
||||||
|
@chmod 755 ${NAGIOS_EXEC}/check_senderscore
|
||||||
|
@chmod 755 ${NAGIOS_EXEC}/check_ircd
|
||||||
|
@echo installing ircbot.sh to ${PREFIX}/bin
|
||||||
|
@cp -f ircbot.sh ${PREFIX}/bin
|
||||||
|
@chmod 755 ${PREFIX}/bin/ircbot.sh
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
@echo removing service checking scripts from ${NAGIOS_EXEC}
|
||||||
|
@rm -f ${NAGIOS_EXEC}/check_senderscore ${NAGIOS_EXEC}/check_ircd
|
||||||
|
@echo removing ircbot.sh from ${PREFIX}/bin
|
||||||
|
@rm -f ${PREFIX}/bin/ircbot.sh
|
||||||
|
@echo removing ircbot.service from ${SYSTEMD_UNIT_DIR}
|
||||||
|
@systemctl disable ircbot.service
|
||||||
|
@rm -f ${SYSTEMD_UNIT_DIR}/ircbot.service
|
20
README.md
20
README.md
@ -9,9 +9,15 @@ tends to send spam email) of an IP address.
|
|||||||
IRC server and channel, keeps the connection open, and relays messages from
|
IRC server and channel, keeps the connection open, and relays messages from
|
||||||
nagios to the channel.
|
nagios to the channel.
|
||||||
|
|
||||||
## Setting up `notify_irc`
|
## Installing
|
||||||
|
|
||||||
Change the configuration parameters in the script itself.
|
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
|
Edit your nagios commands configuration (eg
|
||||||
`/usr/local/nagios/etc/commands.cfg`) and define a new host and service
|
`/usr/local/nagios/etc/commands.cfg`) and define a new host and service
|
||||||
@ -30,14 +36,18 @@ commands that write to the file `/tmp/ircmsg`. For example:
|
|||||||
|
|
||||||
Then create a contact with parameters:
|
Then create a contact with parameters:
|
||||||
|
|
||||||
|
```
|
||||||
service_notification_commands notify-service-by-irc
|
service_notification_commands notify-service-by-irc
|
||||||
host_notification_commands notify-host-by-irc
|
host_notification_commands notify-host-by-irc
|
||||||
|
```
|
||||||
|
|
||||||
Check that the new configuration is valid:
|
Check that the new configuration is valid, eg with:
|
||||||
|
|
||||||
|
```
|
||||||
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
|
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
|
||||||
|
```
|
||||||
|
|
||||||
And then restart nagios with `systemctl` or `rcctl`.
|
And then restart nagios with `systemctl` or `rcctl`.
|
||||||
|
|
||||||
Register `ircbot.sh` as a service with `systemd` or `rc`. (TODO: write service
|
If you followed the install instructions, a service file was installed for
|
||||||
files for these.)
|
systemd or rc. Start it with `systemctl start ircbot` or `rcctl start ircbot`.
|
||||||
|
8
services/rc/ircbot
Normal file
8
services/rc/ircbot
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/ksh
|
||||||
|
|
||||||
|
daemon="/usr/local/bin/ircbot.sh"
|
||||||
|
daemon_user="_nagios"
|
||||||
|
|
||||||
|
. /etc/rc.d/rc.subr
|
||||||
|
|
||||||
|
rc_cmd $1
|
10
services/systemd/ircbot.service
Normal file
10
services/systemd/ircbot.service
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Anarchyplanet IRC Bot
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=nagios
|
||||||
|
Group=nagios
|
||||||
|
ExecStart=/usr/local/bin/ircbot.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Reference in New Issue
Block a user