mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add systemd unit file for the python poller service.
Move poller-service init scripts into to scripts directory and update the documentation.
This commit is contained in:
26
scripts/librenms-poller-service.conf
Normal file
26
scripts/librenms-poller-service.conf
Normal file
@@ -0,0 +1,26 @@
|
||||
# poller-service - SNMP polling service for LibreNMS
|
||||
|
||||
description "SNMP polling service for LibreNMS"
|
||||
author "Clint Armstrong <clint@clintarmstrong.net>"
|
||||
|
||||
# When to start the service
|
||||
start on runlevel [2345]
|
||||
|
||||
# When to stop the service
|
||||
stop on runlevel [016]
|
||||
|
||||
# Automatically restart process if crashed
|
||||
respawn
|
||||
|
||||
# Restart an unlimited amount of times
|
||||
respawn limit unlimited
|
||||
|
||||
chdir /opt/librenms
|
||||
setuid librenms
|
||||
setgid librenms
|
||||
|
||||
# Start the process
|
||||
exec /opt/librenms/poller-service.py
|
||||
|
||||
# Wait 60 seconds before restart
|
||||
post-stop exec sleep 60
|
||||
79
scripts/librenms-poller-service.init
Executable file
79
scripts/librenms-poller-service.init
Executable file
@@ -0,0 +1,79 @@
|
||||
### BEGIN INIT INFO
|
||||
# Provides: librenms-poller-service
|
||||
# Required-Start: networking
|
||||
# Required-Stop: networking
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: The LibreNMS poller-service daemon
|
||||
# Description: The LibreNMS poller-service daemon
|
||||
# This polls devices monitored by LibreNMS
|
||||
### END INIT INFO
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
NAME=librenms-poller-service
|
||||
|
||||
DAEMON=/opt/librenms/poller-service.py
|
||||
|
||||
USER=librenms
|
||||
|
||||
PIDFILE=/var/run/librenms-poller-service.pid
|
||||
|
||||
test -x $DAEMON || exit 5
|
||||
|
||||
case $1 in
|
||||
|
||||
start)
|
||||
# Checked the PID file exists and check the actual status of process
|
||||
if [ -e $PIDFILE ]; then
|
||||
status_of_proc -p $PIDFILE $DAEMON "$NAME process" && status="0" || status="$?"
|
||||
# If the status is SUCCESS then don't need to start again.
|
||||
if [ $status = "0" ]; then
|
||||
exit # Exit
|
||||
fi
|
||||
fi
|
||||
# Start the daemon.
|
||||
log_daemon_msg "Starting the process" "$NAME"
|
||||
# Start the daemon with the help of start-stop-daemon
|
||||
# Log the message appropriately
|
||||
if start-stop-daemon --start --quiet --oknodo --make-pidfile --pidfile $PIDFILE --exec $DAEMON --chuid $USER --background; then
|
||||
log_end_msg 0
|
||||
else
|
||||
log_end_msg 1
|
||||
fi
|
||||
;;
|
||||
|
||||
stop)
|
||||
# Stop the daemon.
|
||||
if [ -e $PIDFILE ]; then
|
||||
status_of_proc -p $PIDFILE $DAEMON "Stoppping the $NAME process" && status="0" || status="$?"
|
||||
if [ "$status" = 0 ]; then
|
||||
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
|
||||
/bin/rm -rf $PIDFILE
|
||||
fi
|
||||
else
|
||||
log_daemon_msg "$NAME process is not running"
|
||||
log_end_msg 0
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
# Restart the daemon.
|
||||
$0 stop && sleep 2 && $0 start
|
||||
;;
|
||||
|
||||
status)
|
||||
# Check the status of the process.
|
||||
if [ -e $PIDFILE ]; then
|
||||
status_of_proc -p $PIDFILE $DAEMON "$NAME process" && exit 0 || exit $?
|
||||
else
|
||||
log_daemon_msg "$NAME Process is not running"
|
||||
log_end_msg 0
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
# For invalid arguments, print the usage message.
|
||||
echo "Usage: $0 {start|stop|restart|reload|status}"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
14
scripts/librenms-poller-service.service
Normal file
14
scripts/librenms-poller-service.service
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=LibreNMS SNMP Poller Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/librenms/poller-service.py
|
||||
WorkingDirectory=/opt/librenms
|
||||
User=librenms
|
||||
Group=librenms
|
||||
RestartSec=2
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user