Separate level overview from stat history

This commit is contained in:
Vincent Riquer 2014-06-20 12:43:47 +02:00
parent 26105a3969
commit 6b778ac461
2 changed files with 375 additions and 355 deletions

20
add
View File

@ -1,15 +1,5 @@
#!/bin/bash #!/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). # Path to your fastcgi_cache (optional).
#CACHE_DIR=/var/www/ingRRD/cache #CACHE_DIR=/var/www/ingRRD/cache
@ -20,7 +10,15 @@ exec 2>&1
# /cgi/$user/add.html # /cgi/$user/add.html
IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI" IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI"
if [[ $webuser == $AUTH_USER ]] 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=/cgi/$webuser/
EOHead
if [[ $webuser == $AUTH_USER || $webuser == dev ]]
then then
echo "Welcome agent $webuser"$'!\n\n' echo "Welcome agent $webuser"$'!\n\n'
else else

View File

@ -130,6 +130,9 @@ then
end) end)
[[ $value =~ $exprtime ]] && end=$value [[ $value =~ $exprtime ]] && end=$value
;; ;;
hist|trend)
show_graphs=1
;;
graph) graph)
[[ $value =~ $exprgraph ]] && graph=$value [[ $value =~ $exprgraph ]] && graph=$value
;; ;;
@ -163,6 +166,17 @@ then
<body> <body>
EOHTML EOHTML
if (( ! show_graphs ))
then
cat <<-EOHTML
<table>
<tr>
<td style="background:black; color:white">Overview</td>
<td><a href="?hist">History / Trend</a></td>
<td><a href="add.html"><b>Add data</b></a></td>
</tr>
</table>
EOHTML
readarray -t lastupdatelines < <( readarray -t lastupdatelines < <(
rrdtool lastupdate $rrdfile rrdtool lastupdate $rrdfile
) )
@ -444,6 +458,16 @@ then
cat <<-EOHTML cat <<-EOHTML
</table> </table>
</div> </div>
EOHTML
else
cat <<-EOHTML
<table>
<tr>
<td><a href="?">Overview</a></td>
<td style="background:black; color:white">History / Trend</td>
<td><a href="add.html"><b>Add data</b></a></td>
</tr>
</table>
<table style="width:$(( graph_width + 97 ))px"> <table style="width:$(( graph_width + 97 ))px">
<tr> <tr>
<td> <td>
@ -453,9 +477,6 @@ then
<a href="?start=$(( start + 86400 ))&amp;end=$end">&gt;</a> <a href="?start=$(( start + 86400 ))&amp;end=$end">&gt;</a>
<a href="?start=$(( start + 604800 ))&amp;end=$end">&gt;&gt;</a> <a href="?start=$(( start + 604800 ))&amp;end=$end">&gt;&gt;</a>
</td> </td>
<td align="center">
<a href="add.html">Add data</a>
</td>
<td align="right"> <td align="right">
<a href="?start=$start&amp;end=$(( end - 604800 ))">&lt;&lt;</a> <a href="?start=$start&amp;end=$(( end - 604800 ))">&lt;&lt;</a>
<a href="?start=$start&amp;end=$(( end - 86400 ))">&lt;</a> <a href="?start=$start&amp;end=$(( end - 86400 ))">&lt;</a>
@ -507,12 +528,13 @@ then
cat <<-EOHTML cat <<-EOHTML
<div> <div>
<img <img
src="graph?graph=$stat&amp;start=$start&amp;end=$end" src="?graph=$stat&amp;start=$start&amp;end=$end"
id="$stat" id="$stat"
alt="Ingress $stat evolution" /> alt="Ingress $stat evolution" />
</div> </div>
EOHTML EOHTML
done done
fi
encodeduri="${REQUEST_URI//\//%2F}" encodeduri="${REQUEST_URI//\//%2F}"
encodeduri="${encodeduri/\?/%3F}" encodeduri="${encodeduri/\?/%3F}"
encodeduri="${encodeduri//\=/%3D}" encodeduri="${encodeduri//\=/%3D}"