Blame tests/p_iptraf/5-test_iptraf.sh
|
Steve Barnes |
464547 |
#!/bin/bash
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
t_Log "Running $0 - checking iptraf runs and returns non-zero exit status."
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
TMP=/tmp/iptraf.log
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
# clean up after ourselves
|
|
Steve Barnes |
464547 |
trap "[ -e ${TMP} ] && { /bin/rm ${TMP}; }" EXIT
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
# iptraf only be run by root
|
|
Steve Barnes |
464547 |
[ ${EUID} -eq 0 ] || { t_Log "Not running as root, skipping this test. Non-fatal."; exit $PASS; }
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
IPTRAF=`which iptraf`
|
|
Steve Barnes |
464547 |
PING=`which ping`
|
|
Steve Barnes |
464547 |
STAT=`which stat`
|
|
Steve Barnes |
464547 |
KILL=`which kill`
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
[ -z "${IPTRAF}" ] && { t_log "Failed to find iptraf binary. That ain't good..."; exit $FAIL; }
|
|
Steve Barnes |
464547 |
[ -z "${PING}" ] && { t_Log "Failed to find the ping binary. That ain't good..."; exit $FAIL; }
|
|
Steve Barnes |
464547 |
[ -z "${STAT}" ] && { t_Log "Failed to find the stat binary. That ain't good..."; exit $FAIL; }
|
|
Steve Barnes |
464547 |
[ -z "${KILL}" ] && { t_Log "Failed to find the kill binary. That ain't good..."; exit $FAIL; }
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
# start iptraf running in the background on all interfaces, logging to a file.
|
|
Steve Barnes |
464547 |
${IPTRAF} -i all -t 1 -B -L ${TMP} &>/dev/null
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
# give iptraf something to chew on
|
|
Steve Barnes |
464547 |
${PING} -c 5 127.0.0.1 &>/dev/null
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
# check the our log file actually has some data in it, which it should, given that we just pinged ourselves...
|
|
Steve Barnes |
464547 |
LOGSIZE=`stat -c '%s' ${TMP}`
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
# kill iptraf
|
|
Steve Barnes |
464547 |
${KILL} -USR2 `pidof iptraf`
|
|
Steve Barnes |
464547 |
|
|
Steve Barnes |
464547 |
# confirm our iptraf log file has something in it
|
|
Steve Barnes |
464547 |
[ ${LOGSIZE} -gt 0 ] || { t_Log "iptraf failed to log any traffic?!. That ain't good..."; exit $FAIL; }
|
|
Steve Barnes |
464547 |
|