Created
August 5, 2014 10:51
-
-
Save vicendominguez/4fab383d6e01a434f9d3 to your computer and use it in GitHub Desktop.
iperf server as a daemon for bandwidth checking in RHEL6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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