Skip to content

Commit

Permalink
moving files to init dir for organization
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn Sterling committed Oct 14, 2014
1 parent 6e98e12 commit e78cb12
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 0 deletions.
64 changes: 64 additions & 0 deletions init/debian/graphios.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#! /bin/bash
### BEGIN INIT INFO
# Provides: graphios
# Required-Start: $local_fs $remote_fs $syslog $named $network $time nagios3
# Required-Stop: $local_fs $remote_fs $syslog $named $network
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: graphios bridge between nagios and graphite
# Description: graphios feeds nagios performance data to graphite
### END INIT INFO
# File : graphios

# Source function library.
. /lib/lsb/init-functions

prog="/usr/local/bin/graphios"
# or use the command line options:
#prog="/opt/nagios/bin/graphios.py --log-file=/dir/mylog.log --spool-directory=/dir/my/sool"
GRAPHIOS_USER="nagios"
RETVAL=0

start () {
log_daemon_msg "Starting $DESC" "$NAME"
/usr/bin/sudo -u $GRAPHIOS_USER "$prog" &
log_end_msg $?
echo
}

stop () {
log_daemon_msg "Stopping $DESC" "$NAME"
killproc graphios.py
log_end_msg $?
echo
}

restart () {
stop
start
}

# See how we are called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
status)
status $prog
RETVAL=$?
;;
*)
echo "Usage: service graphios {start|stop|restart|reload}"
RETVAL=2
;;
esac

exit $RETVAL
69 changes: 69 additions & 0 deletions init/rhel/graphios.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#! /bin/bash
#
# graphios start the graphios script
#
#
# chkconfig: 345 99 01
# description: graphios nagios -> graphite script
#
# File : graphios

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

prog="/usr/bin/graphios"
# or use the command line options:
#prog="/usr/bin/graphios --log-file=/dir/mylog.log --spool-directory=/dir/my/sool"
GRAPHIOS_USER="nagios"
RETVAL=0

start () {
echo -n "Starting $prog"
/usr/bin/sudo -u $GRAPHIOS_USER "$prog" &
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
}

stop () {
echo -n "Stopping $prog"
killproc graphios.py
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
}

restart () {
stop
start
}


# See how we are called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
status)
status $prog
RETVAL=$?
;;
*)
echo "Usage: service graphios {start|stop|restart|reload}"
RETVAL=2
;;
esac

exit $RETVAL
1 change: 1 addition & 0 deletions init/rhel/install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python setup.py install --optimize 1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
11 changes: 11 additions & 0 deletions init/rhel/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# add symlink
ln -s /usr/bin/graphios.py /usr/bin/graphios

# add graphios service
if [ ! -d /etc/systemd ]; then
# we are running init
if ! chkconfig --add graphios; then
logger -p user.err -s -t %name -- "Error adding graphios service."
exit 1
fi
fi
9 changes: 9 additions & 0 deletions init/rhel/postuninstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if [ ! -d /etc/systemd ]; then
# we are running init
service graphios stop
else
# we are running systemd
systemctl stop graphios.service
fi

unlink /usr/bin/graphios
9 changes: 9 additions & 0 deletions init/systemd/graphios.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=graphios - a script to emit nagios perfdata to various backends

[Service]
ExecStart=/usr/bin/graphios
restart=on-abort

[Install]
WantedBy=multi-user.target
7 changes: 7 additions & 0 deletions init/ubuntu/graphios.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description "Graphios"
author "Shawn Sterling"

start on runlevel [234]
stop on runlevel [016]

exec /usr/local/bin/graphios.py

0 comments on commit e78cb12

Please sign in to comment.