Skip to content
Browse files

init.d script for RHEL-style distro added

  • Loading branch information...
1 parent 5526644 commit 371772152b82f2154a0da9db9dc6caf6d40320bd Alik Kurdyukov committed Nov 25, 2012
Showing with 49 additions and 0 deletions.
  1. +6 −0 README.asciidoc
  2. +43 −0 script/nagios-api
View
6 README.asciidoc
@@ -138,6 +138,12 @@ by daemon user set in -u option.
If case of daemon starting problems consult /var/log/nagios-api-daemon.log
file. If should contain start/stop errors.
+INIT.D
+------
+
+Init.d script supplied in script directory is example of script for RHEL-style
+distros.
+
API
---
This program currently supports only a subset of the Nagios API. More
View
43 script/nagios-api
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Nagios API init.s start script
+### BEGIN INIT INFO
+# Provides: nagios-api
+# Required-Start: $local_fs $network
+# Required-Stop: $local_fs $network
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: start and stop Nagios API service
+# Description: Nagios API is a REST-like, JSON interface to Nagios
+### END INIT INFO
+# Some things that run always
+. /etc/rc.d/init.d/functions
+
+NAGIOS_CONFIG=/etc/nagios/nagios.cfg
+COMMAND_FILE=`cat $NAGIOS_CONFIG | grep command_file | sed "s/command_file\s*=\s*//"`
+STATUS_FILE=`cat $NAGIOS_CONFIG | grep status_file | sed "s/status_file\s*=\s*//"`
+LOG_FILE=`cat $NAGIOS_CONFIG | grep log_file | sed "s/log_file\s*=\s*//"`
+NAGIOS_USER=nagios
+LOG_FILE=/var/log/nagios-api.log
+
+PIDFILE=/var/run/nagios/nagios-api.pid
+status -p $PIDFILE >/dev/null
+running=$?
+
+# Carry out specific functions when asked to by the system
+case "$1" in
+ start)
+ [ $running -eq 0 ] && exit 0
+ echo "Starting Nagios API"
+ /usr/bin/nagios-api -s $STATUS_FILE -c $COMMAND_FILE -l $LOG_FILE -u $NAGIOS_USER -w $LOG_FILE start
+ ;;
+ stop)
+ echo "Stopping Nagios API"
+ /usr/bin/nagios-api -s $STATUS_FILE -c $COMMAND_FILE -l $LOG_FILE -u $NAGIOS_USER -w $LOG_FILE stop
+ ;;
+ *)
+ echo "Usage: /etc/init.d/nagios-api {start|stop}"
+ exit 1
+ ;;
+esac
+
+exit 0

0 comments on commit 3717721

Please sign in to comment.
Something went wrong with that request. Please try again.