83 lines
1.3 KiB
Bash
Executable File
83 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
cat <<-EOHead
|
|
Content-type: text/plain
|
|
Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
|
|
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
|
|
refresh: 0,url=graph
|
|
|
|
EOHead
|
|
|
|
exec 2>&1
|
|
|
|
# Path to your fastcgi_cache (optional).
|
|
#CACHE_DIR=/var/www/ingRRD/cache
|
|
|
|
## FIXME change this according to your URLs:
|
|
#
|
|
# /$user/add.html
|
|
#IFS=/ read garbage webuser garbage <<<"$REQUEST_URI"
|
|
# /cgi/$user/add.html
|
|
IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI"
|
|
|
|
if [[ $webuser == $AUTH_USER ]]
|
|
then
|
|
echo "Welcome agent $webuser"$'!\n\n'
|
|
else
|
|
echo 'Nice try!'
|
|
exit
|
|
fi
|
|
declare -A POST
|
|
exprdsname='^[[:upper:][:lower:]_]+$'
|
|
exprvalue='^[[:digit:]]+$'
|
|
while read dsname value
|
|
do
|
|
if [[ $dsname =~ $exprdsname ]] \
|
|
&& [[ $value =~ $exprvalue ]]
|
|
then
|
|
POST["$dsname"]="$value"
|
|
fi
|
|
done < <(
|
|
sed 's/&/\n/g;s/=/ /g'
|
|
)
|
|
|
|
dsnames=(
|
|
AP
|
|
Explorer
|
|
Seer
|
|
XM
|
|
Hacker
|
|
Builder
|
|
Connector
|
|
Mind_Controller
|
|
MU
|
|
Longest_Link
|
|
Largest_Field
|
|
Recharger
|
|
Liberator
|
|
Pioneer
|
|
Purifier
|
|
Neutralized
|
|
Links_Destroyed
|
|
Fields_Destroyed
|
|
Walked
|
|
Guardian
|
|
Link_Maintained
|
|
Link_Length_x_Days
|
|
Field_Held
|
|
Field_x_Days
|
|
)
|
|
data=N
|
|
for dsname in "${dsnames[@]}"
|
|
do
|
|
data+=:${POST["$dsname"]}
|
|
echo "$dsname....${POST["$dsname"]}"
|
|
done
|
|
rrdtool update ingress.rrd "$data"
|
|
|
|
if [ -n "$CACHE_DIR" ]
|
|
then
|
|
find "$CACHE_DIR" -type f -delete
|
|
echo $'\nCache cleared!'
|
|
fi
|