Minor changes, fixed unimplemented switches. 2acb5d588ed859061622592c8d13dc61 /home/ejhuff/freenet/mailFredStatus 190cfc8db9ce41b6f9e71970a82e07eb /home/ejhuff/freenet/mailFredStatus.asc 5d71baf9ed089e0a115d066222187ec0 /home/ejhuff/freenet/gpg-key-D5FA1719
#!/bin/bash
# if you edit your copy of this script, change the version.
VERSION='$Id: mailFredStatus,v 1.2 2003/10/14 19:23:08 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() ]*:'
# FIXME: how to tell re: Frost etc.
echo "Frost etc. are not running."
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 "$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'
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
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;;
--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"
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' ]
[ --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.
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"
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 on port 8888.
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/jE5OJfKDstX6FxkRAodVAJ9+EF8A7C1dhbWiQbEDKqqhqVRCigCfRDIH Ff6nFrDu5l9DP4tHpOyXyEk= =aAsj -----END PGP SIGNATURE-----
-----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1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ushllKD3RWESztlIBsFDJNHIxFWp3EDaJoZX TjSRgPR1ADKtcXmdYKyX05A1MmRVL+pjUiDRmzfbpSgoTfyMXzTMLpY/CU+Rp4hD 6ZfAxmQ5fbyJkWbl8FVscVXXHjzwK1ZMzWlyHZPu+3kvmXgK9YhGBBgRAgAGBQI+ ubYIAAoJECXyg7LV+hcZA4EAn1WzZeXPgB1V/MOifyGu7sAlEeJEAJwKKjdEErWX qLvO3ruE3lhzjRimWg== =j5BM -----END PGP PUBLIC KEY BLOCK-----
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Devl mailing list [EMAIL PROTECTED] http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/devl
