Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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