Skip to content

Instantly share code, notes, and snippets.

@vicendominguez
Created August 5, 2014 10:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicendominguez/4fab383d6e01a434f9d3 to your computer and use it in GitHub Desktop.
Save vicendominguez/4fab383d6e01a434f9d3 to your computer and use it in GitHub Desktop.
iperf server as a daemon for bandwidth checking in RHEL6
#! /bin/bash
#
# iperf advanced bandwidth test tool
#
# chkconfig: - 90 60
# description: iperf is an advanced bandwidth test tool
# processname: iperf
# pidfile: /var/run/iperf.pid
# Source function library.
. /etc/init.d/functions
RETVAL=0
# See how we were called.
prog="iperf"
port="11111"
logfile="/var/log/iperf"
start() {
echo -n $"Starting $prog: "
iperf -s -p $port -D > $logfile
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/iperf
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc iperf 2>/dev/null
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/iperf
return $RETVAL
}
rhstatus() {
status iperf
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading iperf daemon configuration: "
killproc iperf -HUP
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
status)
rhstatus
;;
condrestart)
[ -f /var/lock/subsys/iperf ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
exit 1
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment