Here is a new version of mailFredStatus. The main change is it sends the last 5 hourly accumulations of outputBytesTrailingAttempted (a new statistic) and outputBytes. Toad would like to see some of this data.
The diagnostics sent are configurable from the command line and are remembered if you use --writedefaults. 64cebb4d7a27cf40008b003d81c5c9bf mailFredStatus 9f6bf2ca856f2e0ec61cf3d083a98414 mailFredStatus.asc -- Edward J. Huff <[EMAIL PROTECTED]>
#!/bin/bash
# if you edit your copy of this script, change the version.
VERSION='$Id: mailFredStatus,v 1.4 2003/11/06 03:51:13 ejhuff Exp $'
printMailHeaders() {
echo "To: $TO"
echo "From: $FROM"
echo "Errors-To: $FROM"
echo "Bcc: $BCC"
echo "Subject: Success probabilities $(date --utc)"
echo
}
printAssortedData() {
echo $VERSION
echo SERVLET=$SERVLET
date --utc
wget -O - "http://$SERVLET/servlet/nodeinfo/performance/general" 2>/dev/null \
| tr -d "\n" \
| sed 's/<tr>/@<tr>/g' \
| sed 's|</tr>|</tr>@|' \
| sed 's/<[^>]*>/ /g; s/ * @/@/g; s/@ */@/g; s/ */ /g' \
| sed 's/Uptime[@ ]* /Uptime /g' \
| tr '@' "\n" \
| egrep 'Version|Build|Uptime|Current|Active' \
| grep -v 'README'
wget -O - "http://$SERVLET/servlet/nodeinfo/networking/ocm?setLevel=1&setMode=new" 2>/dev/null \
| egrep '^<tr><td>[^<]' \
| sed 's/<[^>]*>/ /g; s/^ *//g; s/ */ /g; s/ / /g'
echo
echo "Network Load:"
wget -O - "http://$SERVLET/servlet/nodeinfo/networking/loadstats" 2>/dev/null \
| sed 's/<[^>]*>/ /g; s/^ *//g; s/ */ /g; s/ / /g' \
| grep '^[A-Za-z() ]*:'
echo
echo "Frost, etc. status:"
echo "$FROST_ETC_STATUS"
echo
echo "Traffic shaping:"
echo $TC '-s qdisc show dev eth0 | head -3'
$TC -s qdisc show dev eth0 | head -3
echo Non-default non-bookmark freenet.conf lines
grep '^[a-zA-Z]' freenet.conf | grep -v bookmark
echo
echo Parameters to last startup:
ls -l --full-time freenet.last-startup
cat freenet.last-startup
echo
echo "$NETSTAT -n --inet | egrep -v :6000\|:8888\|\^tcp\ \*0\ \*0\ | grep ESTAB | sort -k 2nr,2 -k 3nr,3"
$NETSTAT -n --inet | head -2
$NETSTAT -n --inet | egrep -v :6000\|:8888\|\^tcp\ \*0\ \*0\ | grep ESTAB | sort -k 2nr,2 -k 3nr,3
echo
wget -O - http://$SERVLET/servlet/nodestatus/psuccess_data.txt 2>/dev/null
echo
wget -O - http://$SERVLET/servlet/nodeinfo/internal/env 2>/dev/null \
| grep '^<tr><td>' \
| sed 's/<[^>]*>/ /g; s/^ *//g; s/ */ /g' \
| egrep 'Architecture|processors|Operating|Version|JVM|Maximum|Percent|Total'
echo
wget -O - http://$SERVLET/servlet/nodestatus/nodestatus.html 2>/dev/null \
| grep '^<tr><td>' \
| grep -v '<b>' \
| sed 's/<[^>]*>/ /g; s/^ *//g; s/ */ /g'
echo
for diag in $DIAGNOSTICS ; do
echo
echo "$diag"
wget -O - \
http://$SERVLET/servlet/nodestatus/diagnostics/$diag/raw \
2>/dev/null | grep '#'
wget -O - \
http://$SERVLET/servlet/nodestatus/diagnostics/$diag/raw \
2>/dev/null | grep hour | tail -6
done
date --utc
}
[ -z "$TO" ] && TO="Toad <[EMAIL PROTECTED]>"
[ -z "$FROM" ] && FROM="[EMAIL PROTECTED]:-localhost}"
[ -z "$BCC" ] && BCC="[EMAIL PROTECTED]:-localhost}"
[ -z "$INTERVAL" ] && INTERVAL=3600
[ -z "$SERVLET" ] && SERVLET=127.0.0.1:8888
[ -z "$FREENETHOME" ] && FREENETHOME=$HOME/freenet/
[ -z "$VERBOSE" ] && VERBOSE=
[ -z "$GOLIVE" ] && GOLIVE=
[ -z "$SENDMAIL" ] && SENDMAIL=/usr/sbin/sendmail
[ -z "$TC" ] && TC=/sbin/tc
[ -z "$NETSTAT" ] && NETSTAT=/bin/netstat
[ -z "$FROST_ETC_STATUS" ] && FROST_ETC_STATUS="Frost, etc. status unknown."
[ -z "$DIAGNOSTICS" ] && DIAGNOSTICS="requestSuccessRatio routingSuccessRatio localQueryTraffic outputBytes outputBytesTrailingAttempted"
HELP=
WRITEDEFAULTS=
if [ -f ~/.mailFredStatus ] ; then
source ~/.mailFredStatus
fi
while [[ $# > 0 ]] ; do
case "$1" in
--to)
TO=$2
shift;;
--from)
FROM=$2
shift;;
--BCC)
BCC=$2
shift;;
--interval)
INTERVAL=$2
shift;;
--servlet)
SERVLET=$2
shift;;
--FreenetHOME|--freenetHOME|--FreeNetHOME|--freenethome)
FREENETHOME=$2
shift;;
--verbose)
VERBOSE=-v
;;
--sendmail)
SENDMAIL=$2
shift;;
--tc)
TC=$2
shift;;
--netstat)
NETSTAT=$2
shift;;
--frost*)
FROST_ETC_STATUS="$2"
shift;;
--add-diag*)
DIAGNOSTICS="$DIAGNOSTICS $2"
shift;;
--set-diag*)
DIAGNOSTICS="$2"
shift;;
--dryrun)
GOLIVE=
;;
--golive)
GOLIVE=TRUE
;;
--v*|--V*|-v|-V)
echo $VERSION
echo mailFredStatus --help for help.
exit 0
;;
--write*|-w*)
WRITEDEFAULTS=TRUE
;;
--h*|-h*)
HELP=TRUE
;;
*)
HELP=TRUE
echo "$1 interpreted as --help"
;;
esac
shift
done
if [ ! -z "$WRITEDEFAULTS" ] ; then
echo "Making current options the defaults in ~/.mailFredStatus"
(cat <<EOF
TO="$TO"
FROM="$FROM"
BCC="$BCC"
INTERVAL="$INTERVAL"
SERVLET="$SERVLET"
FREENETHOME="$FREENETHOME"
VERBOSE="$VERBOSE"
SENDMAIL="$SENDMAIL"
TC="$TC"
NETSTAT="$NETSTAT"
FROST_ETC_STATUS="$FROST_ETC_STATUS"
DIAGNOSTICS="$DIAGNOSTICS"
GOLIVE="$GOLIVE"
EOF
) > ~/.mailFredStatus
echo New contents of ~/.mailFredStatus:
cat ~/.mailFredStatus
echo
echo Done.
exit 0
fi
if [ ! -z "$HELP" ] ; then
# will do $VAR substitution in the text.
cat <<EOF
NAME
mailFredStatus - Mail Freenet REference Daemon status to Toad
SYNOPSIS
mailFredStatus [ --help | -h | --version | -v ]
mailFredStatus [ --to '$TO' ]
[ --from '$FROM' ]
[ --BCC '$BCC' ]
[ --interval '$INTERVAL' ]
[ --servlet '$SERVLET' ]
[ --FreenetHOME '$FREENETHOME' ]
[ --dryrun | --golive ]
[ --sendmail '$SENDMAIL' ]
[ --tc '$TC' ]
[ --netstat '$NETSTAT' ]
[ --frost '$FROST_ETC_STATUS' ]
[ --append-diag 'additional_diagnostic_name(s)' ]
[ --set-diag '$DIAGNOSTICS' ]
[ --verbose ]
[ --writedefaults ]
DESCRIPTION
mailFredStatus will collect status information from
the Fred FProxy server at localhost:8888, from freenet.conf,
and from netstat, and mail it to Toad once an hour.
The command never exits unless interrupted or killed.
Uses sleep to delay, so intervals are approximate.
The --golive option must be specified to actually
send any mail. To make --golive the default, use
this command, with desired defaults specified.
mailFredStatus [defaults] --golive --writedefaults
This will not actually go live, but the next time
mailFredStatus is invoked, it will start running.
--verbose will cause the -v option to be passed
to $SENDMAIL.
--frost "Frost, etc. status (running or not)" will
include the string in the email stating your normal
configuration. If you sometimes run Frost and sometimes
don't, either say "maybe maybe not" or fix the script
to find out.
--append-diag will add a diagnostic to the list of
diagnostic statistics for which the last 4 hours
of hourly accumulations are included. These are at
http://IP:PORT/servlet/nodestatus/diagnostics/theDiagName/raw
--set-diag will set a new list of diagnostic names.
FILES
~/.mailFredStatus
If ~/.mailFredStatus exists then this script
sources it. It should assign default values to
the environment variables. The --writedefaults
will overwrite any existing ~/.mailFredStatus
specifying the options from the command line as
the new defaults. Remove the file to use the
original defaults.
ENVIRONMENT
PATH must include wget head egrep grep sort sed date
If exported to the environment, these environment variables
will be used as the defaults for the corresponding options.
Or, if defined in ~/.mailFredStatus, then those values
will override environment or script defaults.
They do not override command line options.
Shown are the values which were in effect after
processing the command line which caused this printout.
TO="$TO"
FROM="$FROM"
BCC="$BCC"
INTERVAL="$INTERVAL"
SERVLET="$SERVLET"
FREENETHOME="$FREENETHOME"
VERBOSE="$VERBOSE"
SENDMAIL="$SENDMAIL"
TC="$TC"
NETSTAT="$NETSTAT"
FROST_ETC_STATUS="$FROST_ETC_STATUS"
DIAGNOSTICS="$DIAGNOSTICS"
GOLIVE="$GOLIVE"
AUTHOR
Edward J. Huff <[EMAIL PROTECTED]> ejhuff on sourceforge.
Report problems on the Freenet devloment list:
Discussion of development issues <[EMAIL PROTECTED]>
FEATURES
Only works on Linux. Uses bash-isms.
Uses wget to read data from servlet. IP and port are configurable.
BUGS
Extracts data from web pages, so that innocent changes
to fproxy formatting may break this script.
Isn't written in [ perl | java | /bin/sh | ... ]
Uses sendmail to send mail.
VERSION
$VERSION
EOF
exit 0
fi
echo Changing directory to $FREENETHOME
cd $FREENETHOME
if [[ -z "$GOLIVE" ]] ; then
echo This is a dry run.
echo To go live, you must specify --golive.
echo To make --golive the default, specify --golive --writedefaults.
echo Mail headers would be:
printMailHeaders
echo
echo The mail body would be:
printAssortedData
exit 0
fi
echo
echo Mail headers will be:
printMailHeaders
echo
echo "Type ^C to abort. First mail goes out in about $INTERVAL seconds."
echo -n "That will be about "
date --date "today $INTERVAL seconds"
while true; do
sleep $INTERVAL
(
printMailHeaders
printAssortedData
echo '.'
) | $SENDMAIL $VERBOSE -t -f "$FROM"
done
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQA/qcXwJfKDstX6FxkRAuWAAJ4j3UVdMedx6QgCmYP/Yj2mfbGQ8gCgrdeE HbA2um+0EpxCgg5dyli83OI= =r8wP -----END PGP SIGNATURE-----
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Devl mailing list [EMAIL PROTECTED] http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/devl
