Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eae26057f | ||
|
|
469c4a660a | ||
|
|
c99f70da58 | ||
|
|
3e976e643d | ||
|
|
408e11348d | ||
|
|
5a14e0a099 | ||
|
|
3c6796cff1 | ||
|
|
c2a57943f2 | ||
|
|
5ddb147317 | ||
|
|
78e49dd841 | ||
|
|
daa4fb8a13 | ||
|
|
8457708829 | ||
|
|
5e9a1cc52d | ||
|
|
3312a78028 | ||
|
|
b8e8b8395b | ||
|
|
951c2a2bac | ||
|
|
412fcfad37 | ||
|
|
c688a46f74 | ||
|
|
a181718b86 | ||
|
|
7482c81b31 | ||
|
|
187bd18058 | ||
|
|
1b67f9fd39 | ||
|
|
3ee152c31e | ||
|
|
4b2e535678 | ||
|
|
293c337f27 | ||
|
|
da162f3690 | ||
|
|
648dfe8cdc | ||
|
|
522f29e6d7 | ||
|
|
dc6ca9f073 | ||
|
|
1d04dec062 | ||
|
|
b969488ac6 | ||
|
|
a7c2b63dbe | ||
|
|
4968e925fb | ||
|
|
38c9949dd7 | ||
|
|
3fc1a4c679 | ||
|
|
6c2f3bd95a | ||
|
|
b3463f0ea5 | ||
|
|
050c3949fd | ||
|
|
a8e01a37ed | ||
|
|
8964230c5b | ||
|
|
c94c990ad0 | ||
|
|
338209ed31 | ||
|
|
d6115e9f73 | ||
|
|
0318d46625 | ||
|
|
8490562d9b | ||
|
|
9269541e0a | ||
|
|
c43877b8ad | ||
|
|
7fc9376478 | ||
|
|
b18133089f | ||
|
|
c1aa8aad00 | ||
|
|
966244cb08 | ||
|
|
3d6f9bc4d0 | ||
|
|
fe7329e78f | ||
|
|
f7c44260b1 | ||
|
|
4b5c0af3a8 | ||
|
|
0754138bc0 | ||
|
|
07135f0c14 | ||
|
|
67b0823520 | ||
|
|
1d9cba737e | ||
|
|
e4209d388b | ||
|
|
4082b7c753 | ||
|
|
849bf65548 | ||
|
|
e436559928 | ||
|
|
f6e2c43832 | ||
|
|
38e0b40eeb | ||
|
|
c27543c000 | ||
|
|
36649a6c1e | ||
|
|
85c5a09e57 | ||
|
|
3ca3ab35a0 |
16
add
16
add
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014 Vincent Riquer
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
@ -64,13 +64,13 @@ do
|
||||
ds="${ds//ds[/}"
|
||||
ds="${ds//]*/}"
|
||||
datasets+=("$ds")
|
||||
done < <(rrdtool info ingress.rrd |grep index)
|
||||
done < <(rrdtool info "$rrdfile" |grep index)
|
||||
for ds in ${dsnames[@]}
|
||||
do
|
||||
if [[ ! ${datasets[@]} =~ $ds ]]
|
||||
then
|
||||
cp -f ingress.rrd ingress.rrd.bak_add_$ds
|
||||
./dsaddtor.pl ingress.rrd $ds GAUGE $((48*60*60)) 0 NaN
|
||||
cp -f "$rrdfile" "$rrdfile".bak_add_$ds
|
||||
./dsaddtor.pl "$rrdfile" $ds GAUGE $((48*60*60)) 0 NaN
|
||||
fi
|
||||
done
|
||||
data=N
|
||||
@ -82,10 +82,4 @@ do
|
||||
done
|
||||
|
||||
echo ${POST["innovator"]} > .innovator
|
||||
rrdtool update ingress.rrd -t $template "$data"
|
||||
|
||||
if [ -n "$CACHE_DIR" ]
|
||||
then
|
||||
find "$CACHE_DIR" -type f -delete
|
||||
echo $'\nCache cleared!'
|
||||
fi
|
||||
rrdtool update "$rrdfile" -t $template "$data"
|
||||
|
||||
54
add.html
54
add.html
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014 Vincent Riquer
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
@ -22,13 +22,13 @@ for lib in lib/*
|
||||
do
|
||||
source $lib
|
||||
done
|
||||
import_images &
|
||||
read_query_string
|
||||
|
||||
cat <<-EOHTML
|
||||
send_headers <<-EOHead
|
||||
content-type: text/xml
|
||||
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')
|
||||
|
||||
EOHead
|
||||
cat <<-EOHTML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
@ -42,45 +42,10 @@ Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
|
||||
EOHTML
|
||||
if ! [ -w "$rrdfile" ]
|
||||
then
|
||||
rrdtool create ingress.rrd -s $((60*60)) \
|
||||
DS:AP:GAUGE:$((2*24*60*60)):0:NaN \
|
||||
DS:Explorer:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Seer:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:XM:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Hacker:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Builder:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Connector:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Mind_Controller:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:MU:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Longest_Link:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Largest_Field:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Recharger:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Liberator:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Pioneer:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Purifier:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Neutralized:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Links_Destroyed:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Fields_Destroyed:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Walked:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Guardian:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Link_Maintained:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Link_Length_x_Days:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Field_Held:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Field_x_Days:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Mercenary:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Engineer:GAUGE:$((48*60*60)):0:NaN \
|
||||
RRA:HWPREDICT:8760:8e-1:8e-1:$((24)) \
|
||||
RRA:AVERAGE:99e-2:1:$((24*15)) \
|
||||
RRA:MAX:99e-2:1:$((24*15)) \
|
||||
RRA:AVERAGE:99e-2:4:$((24*180)) \
|
||||
RRA:MAX:99e-2:4:$((24*180)) \
|
||||
RRA:AVERAGE:99e-2:24:$(((4*365)+1)) \
|
||||
RRA:MAX:99e-2:24:$(((4*365)+1)) \
|
||||
RRA:AVERAGE:99e-2:$((24*30)):$(((32*365)+8)) \
|
||||
RRA:MAX:99e-2:$((24*30)):$(((32*365)+8)) \
|
||||
|| {
|
||||
rrdcreate || {
|
||||
cat <<-EOHTML
|
||||
<h1 style="color:red">Cannot create $rrdfile</h1>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
EOHTML
|
||||
@ -152,9 +117,10 @@ cat <<-EOHTML
|
||||
<ul>
|
||||
EOHTML
|
||||
|
||||
for indice in ${!uinames[@]}
|
||||
for indice in ${dsnames[@]}
|
||||
do
|
||||
echo "<li><input type=\"text\" name=\"${dsnames[indice]}\" value=\"${last["${dsnames[indice]}"]}\" /> ${uinames[indice]}</li>"
|
||||
[[ -z "${uinames[$indice]}" ]] && continue
|
||||
echo "<li><input type=\"text\" name=\"$indice\" value=\"${last["$indice"]}\" /> ${uinames[$indice]}</li>"
|
||||
done
|
||||
|
||||
cat <<-EOHTML
|
||||
|
||||
125
import
125
import
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014 Vincent Riquer
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
@ -24,43 +24,10 @@ do
|
||||
done
|
||||
read_query_string
|
||||
|
||||
template=AP:Explorer:Seer:XM:Walked:Builder:Connector:Mind_Controller:MU:Longest_Link:Largest_Field:Recharger:Liberator:Pioneer:Engineer:Purifier:Neutralized:Links_Destroyed:Fields_Destroyed:Guardian:Link_Maintained:Link_Length_x_Days:Field_Held:Field_x_Days:Mercenary:Hacker
|
||||
template=AP:Explorer:Seer:XM:Walked:Builder:Connector:Mind_Controller:MU:Longest_Link:Largest_Field:Recharger:Liberator:Pioneer:Engineer:Purifier:Neutralized:Links_Destroyed:Fields_Destroyed:Guardian:Link_Maintained:Link_Length_x_Days:Field_Held:Field_x_Days:Mercenary:Hacker:Translator:Hackaton:Recruiter
|
||||
|
||||
if [[ $REQUEST_METHOD == POST ]]
|
||||
then
|
||||
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')
|
||||
|
||||
EOHead
|
||||
cat <<-EOHead >/dev/null
|
||||
refresh: 0,url=/cgi/$webuser/?start=${POST["start"]}&end=${POST["end"]}
|
||||
|
||||
EOHead
|
||||
if [[ $webuser == $AUTH_USER || $webuser == dev ]]
|
||||
then
|
||||
echo "Welcome agent $webuser"$'!\n\n'
|
||||
else
|
||||
echo 'Nice try!'
|
||||
exit
|
||||
fi
|
||||
|
||||
while read ds junk
|
||||
do
|
||||
ds="${ds//ds[/}"
|
||||
ds="${ds//]*/}"
|
||||
datasets+=("$ds")
|
||||
done < <(rrdtool info ingress.rrd |grep index)
|
||||
for ds in ${dsnames[@]}
|
||||
do
|
||||
if [[ ! ${datasets[@]} =~ $ds ]]
|
||||
then
|
||||
cp -f ingress.rrd ingress.rrd.bak_add_$ds
|
||||
./dsaddtor.pl ingress.rrd $ds GAUGE $((48*60*60)) 0 NaN
|
||||
fi
|
||||
done
|
||||
|
||||
declare -A POST
|
||||
exprdsname='^[[:upper:][:lower:]_]+$'
|
||||
while read dsname value
|
||||
@ -76,24 +43,51 @@ then
|
||||
}"
|
||||
POST["data"]="${POST["data"]//%3A/:}"
|
||||
POST["data"]="${POST["data"]//+/ }"
|
||||
echo "${POST["data"]}"
|
||||
|
||||
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')
|
||||
EOHead
|
||||
cat <<-EOHead
|
||||
refresh: 0,url=/cgi/$webuser/?start=${POST["start"]}&end=${POST["end"]}
|
||||
EOHead
|
||||
echo
|
||||
if [[ $webuser == $AUTH_USER || $webuser == dev ]]
|
||||
then
|
||||
echo "Welcome agent $webuser"$'!\n\n'
|
||||
else
|
||||
echo 'Nice try!'
|
||||
exit
|
||||
fi
|
||||
|
||||
while read ds junk
|
||||
do
|
||||
ds="${ds//ds[/}"
|
||||
ds="${ds//]*/}"
|
||||
datasets+=("$ds")
|
||||
done < <(rrdtool info "$rrdfile" |grep index)
|
||||
for ds in ${dsnames[@]}
|
||||
do
|
||||
if [[ ! ${datasets[@]} =~ $ds ]]
|
||||
then
|
||||
cp -f "$rrdfile" "$rrdfile".bak_add_$ds
|
||||
./dsaddtor.pl "$rrdfile" $ds GAUGE $((48*60*60)) 0 NaN
|
||||
fi
|
||||
done
|
||||
|
||||
while read date hour data
|
||||
do
|
||||
data=$(date -d "$date $hour" +%s):${data// /:}
|
||||
rrdtool update ingress.rrd -t $template "$data" 2>&1
|
||||
rrdtool update "$rrdfile" -t $template "${data//:0/:U}" 2>&1
|
||||
done <<<"${POST["data"]}"
|
||||
|
||||
if [ -n "$CACHE_DIR" ]
|
||||
then
|
||||
find "$CACHE_DIR" -type f -delete
|
||||
echo $'\nCache cleared!'
|
||||
fi
|
||||
else
|
||||
cat <<-EOHTML
|
||||
import_images &
|
||||
send_headers <<-EOHead
|
||||
content-type: text/xml
|
||||
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')
|
||||
EOHead
|
||||
|
||||
cat <<-EOHTML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
@ -107,43 +101,7 @@ else
|
||||
EOHTML
|
||||
if ! [ -w "$rrdfile" ]
|
||||
then
|
||||
rrdtool create ingress.rrd -s $((60*60)) \
|
||||
DS:AP:GAUGE:$((2*24*60*60)):0:NaN \
|
||||
DS:Explorer:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Seer:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:XM:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Hacker:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Builder:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Connector:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Mind_Controller:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:MU:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Longest_Link:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Largest_Field:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Recharger:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Liberator:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Pioneer:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Purifier:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Neutralized:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Links_Destroyed:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Fields_Destroyed:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Walked:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Guardian:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Link_Maintained:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Link_Length_x_Days:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Field_Held:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Field_x_Days:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Mercenary:GAUGE:$((48*60*60)):0:NaN \
|
||||
DS:Engineer:GAUGE:$((48*60*60)):0:NaN \
|
||||
RRA:HWPREDICT:8760:8e-1:8e-1:$((24)) \
|
||||
RRA:AVERAGE:99e-2:1:$((24*15)) \
|
||||
RRA:MAX:99e-2:1:$((24*15)) \
|
||||
RRA:AVERAGE:99e-2:4:$((24*180)) \
|
||||
RRA:MAX:99e-2:4:$((24*180)) \
|
||||
RRA:AVERAGE:99e-2:24:$(((4*365)+1)) \
|
||||
RRA:MAX:99e-2:24:$(((4*365)+1)) \
|
||||
RRA:AVERAGE:99e-2:$((24*30)):$(((32*365)+8)) \
|
||||
RRA:MAX:99e-2:$((24*30)):$(((32*365)+8)) \
|
||||
|| {
|
||||
rrdcreate || {
|
||||
cat <<-EOHTML
|
||||
<h1 style="color:red">Cannot create $rrdfile</h1>
|
||||
</body>
|
||||
@ -160,6 +118,7 @@ else
|
||||
<p>Import data from e.g. https://www.agent-stats.com/ <br/>
|
||||
<small>Expected format: <tt>YYYY-MM-DD hh:mm:ss
|
||||
${template[@]//:/ }</tt></small></p>
|
||||
<p>Latest data: $(date +"%Y-%m-%d %H:%M:%S" -d @${last[time]%:})</p>
|
||||
<form method="post" action="import">
|
||||
<input type="hidden" name="start" value="$start" />
|
||||
<input type="hidden" name="end" value="$end" />
|
||||
|
||||
430
index
430
index
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014 Vincent Riquer
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
@ -22,26 +22,25 @@ for lib in lib/*
|
||||
do
|
||||
source $lib
|
||||
done
|
||||
if [ ! -w "$rrdfile" ]
|
||||
then
|
||||
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/add.html
|
||||
|
||||
EOHead
|
||||
exit
|
||||
fi
|
||||
|
||||
read_query_string
|
||||
(( start >= end)) && (( end = start + 604800 ))
|
||||
|
||||
if [ -z "$graph" ]
|
||||
then
|
||||
import_images &
|
||||
refresh=300
|
||||
[[ -r .importing ]] && refresh=5
|
||||
send_headers $(( refresh - 1 )) <<-EOHead
|
||||
content-type: application/xhtml+xml
|
||||
refresh: $refresh
|
||||
EOHead
|
||||
|
||||
readlast
|
||||
medals
|
||||
get_current_level
|
||||
readold "${last[time]}-$prevperiod"
|
||||
get_next_level
|
||||
if (( show_all ))
|
||||
then
|
||||
title="IngRRD - $webuser [L$curlevel] - History & Trend: All stats"
|
||||
@ -52,15 +51,6 @@ then
|
||||
title="IngRRD - $webuser [L$curlevel] - Overview"
|
||||
fi
|
||||
cat <<-EOHTML
|
||||
content-type: application/xhtml+xml
|
||||
Last-Modified: $(
|
||||
LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' \
|
||||
-d @$(rrdtool last ingress.rrd)
|
||||
)
|
||||
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' -d '1 hour')
|
||||
Cache-Control: max-age=0, must-revalidate
|
||||
refresh: 600
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
@ -70,6 +60,12 @@ then
|
||||
<link rel="stylesheet" type="text/css" href="/ingrrd.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div style="font-size:10px; color:#606060; text-align:right; position:absolute; top:12px; right:0px;">
|
||||
EOHTML
|
||||
times
|
||||
date '+%Y-%m-%d %H:%M:%S'
|
||||
cat <<-EOHTML
|
||||
</div>
|
||||
<div style="width:$(( graph_width + 97 ))px" class="container">
|
||||
EOHTML
|
||||
|
||||
@ -116,6 +112,9 @@ then
|
||||
</table>
|
||||
EOHTML
|
||||
show_current_level
|
||||
[[ -r .importing ]] && cat <<-EOHTML
|
||||
<div class="updating">Importing $(<.importing)</div>
|
||||
EOHTML
|
||||
cat <<-EOHTML
|
||||
</div>
|
||||
<div class="main">
|
||||
@ -132,150 +131,217 @@ then
|
||||
<th class="badge">Black</th>
|
||||
</tr>
|
||||
EOHTML
|
||||
|
||||
for level in {1..16}
|
||||
do
|
||||
prevtimestamp=$maxtimestamp
|
||||
never=0
|
||||
maxtimestamp=0
|
||||
tableline=()
|
||||
if (( last["AP"] >= lvl[level] ))
|
||||
then
|
||||
tableline+=( '<td class="AP" style="background:lightgreen">'
|
||||
$(printf "%'li" ${lvl[level]})
|
||||
'</td>' )
|
||||
else
|
||||
#FIXME
|
||||
readable=$(printf "%'li" ${lvl[level]})
|
||||
tableline+=( '<td class="AP" style="background:lightgrey">'"${readable// / }" )
|
||||
readable=$(printf "%'li" $(( last["AP"] - lvl[level] )))
|
||||
tableline+=( "<br />(<span class=\"missing\">${readable// / }</span>)" )
|
||||
if (( timestamp ))
|
||||
then
|
||||
tableline+=( "<br />$(date +%Y-%m-%d -d @${nextlevels[level]})</td>" )
|
||||
(( nextlevels[level] > maxtimestamp )) \
|
||||
&& maxtimestamp=${nextlevels[level]}
|
||||
else
|
||||
tableline+=( "<br />(maybe some day)</td>" )
|
||||
never=1
|
||||
fi
|
||||
fi
|
||||
if (( silvercount >= lvlsilver[level] ))
|
||||
then
|
||||
tableline+=( '<td class="badge" style="background:lightgreen">'${lvlsilver[level]}'</td>' )
|
||||
else
|
||||
tableline+=( "<td class=\"badge\" style=\"background:lightgrey\">${lvlsilver[level]} (<span class=\"missing\">$(( silvercount - lvlsilver[level] ))</span>)<br />" )
|
||||
count=0
|
||||
for timestamp in ${!nextsilver[@]}
|
||||
do
|
||||
if (( timestamp ))
|
||||
then
|
||||
thisdate=$(date +%Y-%m-%d -d @$timestamp)
|
||||
(( timestamp > maxtimestamp )) \
|
||||
&& maxtimestamp=$timestamp
|
||||
for stat in ${nextsilver[timestamp]}
|
||||
do
|
||||
if ! (( shown["$stat silver"] ))
|
||||
then
|
||||
tableline+=( "$(print_medal $timestamp $stat ${upsilver[$stat]:-0} silver)" )
|
||||
tableline+=( '<br />' )
|
||||
shown["$stat silver"]=1
|
||||
fi
|
||||
(( ++count == lvlsilver[level] - silvercount )) && break 2
|
||||
done
|
||||
fi
|
||||
done
|
||||
for stat in ${nextsilver[0]}
|
||||
do
|
||||
(( count >= lvlsilver[level] - silvercount )) && break 1
|
||||
(( count < lvlsilver[level] - silvercount )) && never=1
|
||||
if ! (( shown["$stat silver"] ))
|
||||
then
|
||||
tableline+=( "$(print_medal $timestamp $stat ${upsilver[$stat]:-0} silver)" )
|
||||
tableline+=( '<br />' )
|
||||
shown["$stat silver"]=1
|
||||
fi
|
||||
(( count++ ))
|
||||
done
|
||||
tableline+=( '</td>' )
|
||||
fi
|
||||
if (( goldcount >= lvlgold[level] ))
|
||||
then
|
||||
tableline+=( '<td class="badge" style="background:lightgreen">'${lvlgold[level]}'</td>' )
|
||||
else
|
||||
tableline+=( "<td class=\"badge\" style=\"background:lightgrey\">${lvlgold[level]} (<span class=\"missing\">$(( goldcount - lvlgold[level] ))</span>)<br />" )
|
||||
count=0
|
||||
for timestamp in ${!nextgold[@]}
|
||||
do
|
||||
if (( timestamp ))
|
||||
then
|
||||
thisdate=$(date +%Y-%m-%d -d @$timestamp)
|
||||
(( timestamp > maxtimestamp )) \
|
||||
&& maxtimestamp=$timestamp
|
||||
for stat in ${nextgold[timestamp]}
|
||||
do
|
||||
if ! (( shown["$stat gold"] ))
|
||||
then
|
||||
tableline+=( "$(print_medal $timestamp $stat ${upgold[$stat]:-0} gold)" )
|
||||
tableline+=( '<br />' )
|
||||
shown["$stat gold"]=1
|
||||
fi
|
||||
(( ++count == lvlgold[level] - goldcount )) && break 2
|
||||
done
|
||||
fi
|
||||
done
|
||||
for stat in ${nextgold[0]}
|
||||
do
|
||||
(( count >= lvlgold[level] - goldcount )) && break 1
|
||||
(( count < lvlgold[level] - goldcount )) && never=1
|
||||
if ! (( shown["$stat gold"] ))
|
||||
then
|
||||
tableline+=( "$(print_medal $timestamp $stat ${upgold[$stat]:-0} gold)" )
|
||||
tableline+=( '<br />' )
|
||||
shown["$stat gold"]=1
|
||||
fi
|
||||
(( count++ ))
|
||||
done
|
||||
tableline+=( '</td>' )
|
||||
fi
|
||||
if (( platinumcount >= lvlplatinum[level] ))
|
||||
then
|
||||
tableline+=( '<td class="badge" style="background:lightgreen">'${lvlplatinum[level]}'</td>' )
|
||||
else
|
||||
tableline+=( "<td class=\"badge\" style=\"background:lightgrey\">${lvlplatinum[level]} (<span class=\"missing\">$(( platinumcount - lvlplatinum[level] ))</span>)<br />" )
|
||||
count=0
|
||||
for timestamp in ${!nextplatinum[@]}
|
||||
do
|
||||
if (( timestamp ))
|
||||
then
|
||||
thisdate=$(date +%Y-%m-%d -d @$timestamp)
|
||||
(( timestamp > maxtimestamp )) \
|
||||
&& maxtimestamp=$timestamp
|
||||
for stat in ${nextplatinum[timestamp]}
|
||||
do
|
||||
if ! (( shown["$stat platinum"] ))
|
||||
then
|
||||
tableline+=( "$(print_medal $timestamp $stat ${upplatinum[$stat]:-0} platinum)" )
|
||||
tableline+=( '<br />' )
|
||||
shown["$stat platinum"]=1
|
||||
fi
|
||||
(( ++count == lvlplatinum[level] - platinumcount )) && break 2
|
||||
done
|
||||
fi
|
||||
done
|
||||
for stat in ${nextplatinum[0]}
|
||||
do
|
||||
(( count >= lvlplatinum[level] - platinumcount )) && break 1
|
||||
(( count < lvlplatinum[level] - platinumcount )) && never=1
|
||||
if ! (( shown["$stat platinum"] ))
|
||||
then
|
||||
tableline+=( "$(print_medal $timestamp $stat ${upplatinum[$stat]:-0} platinum)" )
|
||||
tableline+=( '<br />' )
|
||||
shown["$stat platinum"]=1
|
||||
fi
|
||||
(( count++ ))
|
||||
done
|
||||
tableline+=( '</td>' )
|
||||
fi
|
||||
if (( blackcount >= lvlblack[level] ))
|
||||
then
|
||||
tableline+=( '<td class="badge" style="background:lightgreen">'${lvlblack[level]}'</td>' )
|
||||
else
|
||||
tableline+=( "<td class=\"badge\" style=\"background:lightgrey\">${lvlblack[level]} (<span class=\"missing\">$(( blackcount - lvlblack[level] ))</span>)<br />" )
|
||||
count=0
|
||||
for timestamp in ${!nextblack[@]}
|
||||
do
|
||||
if (( timestamp ))
|
||||
then
|
||||
thisdate=$(date +%Y-%m-%d -d @$timestamp)
|
||||
(( timestamp > maxtimestamp )) \
|
||||
&& maxtimestamp=$timestamp
|
||||
for stat in ${nextblack[timestamp]}
|
||||
do
|
||||
if ! (( shown["$stat black"] ))
|
||||
then
|
||||
tableline+=( "$(print_medal $timestamp $stat ${upblack[$stat]:-0} black)" )
|
||||
tableline+=( '<br />' )
|
||||
shown["$stat black"]=1
|
||||
fi
|
||||
(( ++count == lvlblack[level] - blackcount )) && break 2
|
||||
done
|
||||
fi
|
||||
done
|
||||
for stat in ${nextblack[0]}
|
||||
do
|
||||
(( count >= lvlblack[level] - blackcount )) && break 1
|
||||
(( count < lvlblack[level] - blackcount )) && never=1
|
||||
if ! (( shown["$stat black"] ))
|
||||
then
|
||||
tableline+=( "$(print_medal $timestamp $stat ${upblack[$stat]:-0} black)" )
|
||||
tableline+=( '<br />' )
|
||||
shown["$stat black"]=1
|
||||
fi
|
||||
(( count++ ))
|
||||
done
|
||||
tableline+=( '</td>' )
|
||||
fi
|
||||
if (( level <= curlevel ))
|
||||
then
|
||||
echo "<tr class=\"curlevel\"><th class=\"level\">$level</th>"
|
||||
else
|
||||
echo "<tr class=\"nextlevel\"><th class=\"level\">$level</th>"
|
||||
fi
|
||||
if (( last["AP"] >= lvl[level] ))
|
||||
then
|
||||
echo '<td class="AP" style="background:lightgreen">'
|
||||
printf "%'li" ${lvl[level]}
|
||||
echo '</td>'
|
||||
else
|
||||
readable=$(printf "%'li" ${lvl[level]})
|
||||
echo '<td class="AP" style="background:lightgrey">'"${readable// / }"
|
||||
readable=$(printf "%'li" $(( last["AP"] - lvl[level] )))
|
||||
echo "<br />(<span class=\"missing\">${readable// / }</span>)</td>"
|
||||
fi
|
||||
if (( silvercount >= lvlsilver[level] ))
|
||||
then
|
||||
echo '<td class="badge" style="background:lightgreen">'${lvlsilver[level]}'</td>'
|
||||
else
|
||||
echo "<td class=\"badge\" style=\"background:lightgrey\">${lvlsilver[level]} (<span class=\"missing\">$(( silvercount - lvlsilver[level] ))</span>)<br />"
|
||||
count=0
|
||||
for id in {100..0}
|
||||
do
|
||||
[ -z "${upsilver[id]}" ] && continue
|
||||
(( greenlevel = id * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
for stat in ${upsilver[id]}
|
||||
do
|
||||
img=${stat,,}
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="badge"
|
||||
src="/${img//_/-}-silver.png"
|
||||
title="$stat $id%"
|
||||
alt="$stat silver" />
|
||||
</a>
|
||||
<tr class="nextlevel">
|
||||
<th class="level">$level</th>
|
||||
EOHTML
|
||||
(( count++ == lvlsilver[level] - silvercount )) && break 2
|
||||
done
|
||||
done
|
||||
echo '</td>'
|
||||
fi
|
||||
if (( goldcount >= lvlgold[level] ))
|
||||
echo "${tableline[@]}"
|
||||
if (( level > curlevel ))
|
||||
then
|
||||
(( maxtimestamp < prevtimestamp )) \
|
||||
&& maxtimestamp=$prevtimestamp
|
||||
if (( maxtimestamp ))
|
||||
then
|
||||
echo '<td class="badge" style="background:lightgreen">'${lvlgold[level]}'</td>'
|
||||
else
|
||||
echo "<td class=\"badge\" style=\"background:lightgrey\">${lvlgold[level]} (<span class=\"missing\">$(( goldcount - lvlgold[level] ))</span>)<br />"
|
||||
count=0
|
||||
for id in {100..0}
|
||||
do
|
||||
[ -z "${upgold[id]}" ] && continue
|
||||
(( greenlevel = id * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
for stat in ${upgold[id]}
|
||||
do
|
||||
img=${stat,,}
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="badge"
|
||||
src="/${img//_/-}-gold.png"
|
||||
title="$stat $id%"
|
||||
alt="$stat gold" />
|
||||
</a>
|
||||
<td class="date">$(date +%Y-%m-%d -d @$maxtimestamp)</td>
|
||||
EOHTML
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<td class="date">In more than 5 years</td>
|
||||
EOHTML
|
||||
(( count++ == lvlgold[level] - goldcount )) && break 2
|
||||
done
|
||||
done
|
||||
echo '</td>'
|
||||
fi
|
||||
if (( platinumcount >= lvlplatinum[level] ))
|
||||
then
|
||||
echo '<td class="badge" style="background:lightgreen">'${lvlplatinum[level]}'</td>'
|
||||
else
|
||||
echo "<td class=\"badge\" style=\"background:lightgrey\">${lvlplatinum[level]} (<span class=\"missing\">$(( platinumcount - lvlplatinum[level] ))</span>)<br />"
|
||||
count=0
|
||||
for id in {100..0}
|
||||
do
|
||||
[ -z "${upplatinum[id]}" ] && continue
|
||||
(( greenlevel = id * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
for stat in ${upplatinum[id]}
|
||||
do
|
||||
img=${stat,,}
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="badge"
|
||||
src="/${img//_/-}-platinum.png"
|
||||
title="$stat $id%"
|
||||
alt="$stat platinum" />
|
||||
</a>
|
||||
EOHTML
|
||||
(( count++ == lvlplatinum[level] - platinumcount )) && break 2
|
||||
done
|
||||
done
|
||||
echo '</td>'
|
||||
fi
|
||||
if (( blackcount >= lvlblack[level] ))
|
||||
then
|
||||
echo '<td class="badge" style="background:lightgreen">'${lvlblack[level]}'</td>'
|
||||
else
|
||||
echo "<td class=\"badge\" style=\"background:lightgrey\">${lvlblack[level]} (<span class=\"missing\">$(( blackcount - lvlblack[level] ))</span>)<br />"
|
||||
count=0
|
||||
for id in {100..0}
|
||||
do
|
||||
[ -z "${upblack[id]}" ] && continue
|
||||
(( greenlevel = id * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
for stat in ${upblack[id]}
|
||||
do
|
||||
img=${stat,,}
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="badge"
|
||||
src="/${img//_/-}-black.png"
|
||||
title="$stat $id%"
|
||||
alt="$stat black" />
|
||||
</a>
|
||||
EOHTML
|
||||
(( count++ == lvlblack[level] - blackcount )) && break 2
|
||||
done
|
||||
done
|
||||
echo '</td>'
|
||||
fi
|
||||
echo '</tr>'
|
||||
prevtimestamp=$maxtimestamp
|
||||
done
|
||||
cat <<-EOHTML
|
||||
</table>
|
||||
@ -341,21 +407,35 @@ then
|
||||
<table style="width:$(( graph_width + 97 ))px">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="?hist&start=$(( start - 604800 ))&end=$end"><<</a>
|
||||
<a href="?hist&start=$(( start - 86400 ))&end=$end"><</a>
|
||||
<a href="?hist&start=$default_start&end=$end">R</a>
|
||||
<a href="?hist&start=$(( start + 86400 ))&end=$end">></a>
|
||||
<a href="?hist&start=$(( start + 604800 ))&end=$end">>></a>
|
||||
<a href="?hist&start=$(rrdtool first "$rrdfile")&end=$end">First</a>
|
||||
<a href="?hist&start=$(( start - 365 * 86400 ))&end=$end">-Y</a>
|
||||
<a href="?hist&start=$(( start - 30 * 86400 ))&end=$end">-M</a>
|
||||
<a href="?hist&start=$(( start - 604800 ))&end=$end">-W</a>
|
||||
<a href="?hist&start=$(( start - 86400 ))&end=$end">-D</a>
|
||||
<a href="?hist&start=$now&end=$end">Now</a>
|
||||
<a href="?hist&start=$(( start + 86400 ))&end=$end">+D</a>
|
||||
<a href="?hist&start=$(( start + 604800 ))&end=$end">+W</a>
|
||||
<a href="?hist&start=$(( start + 30 * 86400 ))&end=$end">+M</a>
|
||||
<a href="?hist&start=$(( start + 365 * 86400 ))&end=$end">+Y</a>
|
||||
</td>
|
||||
<td align="right">
|
||||
<a href="?hist&start=$start&end=$(( end - 604800 ))"><<</a>
|
||||
<a href="?hist&start=$start&end=$(( end - 86400 ))"><</a>
|
||||
<a href="?hist&start=$start&end=$default_end">R</a>
|
||||
<a href="?hist&start=$start&end=$(( end + 86400 ))">></a>
|
||||
<a href="?hist&start=$start&end=$(( end + 604800 ))">>></a>
|
||||
<a href="?hist&start=$start&end=$(( end - 365 * 86400 ))">-Y</a>
|
||||
<a href="?hist&start=$start&end=$(( end - 30 * 86400 ))">-M</a>
|
||||
<a href="?hist&start=$start&end=$(( end - 604800 ))">-W</a>
|
||||
<a href="?hist&start=$start&end=$(( end - 86400 ))">-D</a>
|
||||
<a href="?hist&start=$start&end=$now">Now</a>
|
||||
<a href="?hist&start=$start&end=$(( end + 86400 ))">+D</a>
|
||||
<a href="?hist&start=$start&end=$(( end + 604800 ))">+W</a>
|
||||
<a href="?hist&start=$start&end=$(( end + 30 * 86400 ))">+M</a>
|
||||
<a href="?hist&start=$start&end=$(( end + 365 * 86400 ))">+Y</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
EOHTML
|
||||
[[ -r .importing ]] && cat <<-EOHTML
|
||||
<div class="updating">Importing $(<.importing)</div>
|
||||
EOHTML
|
||||
cat <<-EOHTML
|
||||
</div>
|
||||
<div class="maingraph">
|
||||
EOHTML
|
||||
@ -374,6 +454,7 @@ then
|
||||
|
||||
for stat in "${stats[@]}"
|
||||
do
|
||||
[[ -z "${uinames[$stat]}" ]] && continue
|
||||
if [[ $stat == AP ]] || (( bronze["$stat"] ))
|
||||
then
|
||||
height=169
|
||||
@ -415,7 +496,7 @@ then
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
Generated by <a href="https://forge.riquer.fr/p/ingrrd/">IngRRD</a> © 2014 Vincent Riquer
|
||||
Generated by <a href="https://forge.riquer.fr/p/ingrrd/">IngRRD</a> © 2014-2015 Vincent Riquer
|
||||
</td>
|
||||
<td style="text-align:right; width:180px">
|
||||
<a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">
|
||||
@ -426,21 +507,20 @@ then
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div style="font-size:10px; color:#606060; text-align:right; position:absolute; top:24px; right:0px;">
|
||||
EOHTML
|
||||
times
|
||||
date '+%Y-%m-%d %H:%M:%S'
|
||||
cat <<-EOHTML
|
||||
</div>
|
||||
</body></html>
|
||||
EOHTML
|
||||
else
|
||||
now=$(date +%s)
|
||||
cat <<-EOHEAD
|
||||
send_headers <<-EOHead
|
||||
content-type: image/png
|
||||
Last-Modified: $(
|
||||
LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' \
|
||||
-d @$(rrdtool last ingress.rrd)
|
||||
)
|
||||
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' -d '1 hour')
|
||||
Cache-Control: max-age=0, must-revalidate
|
||||
|
||||
EOHEAD
|
||||
EOHead
|
||||
|
||||
now=$(date +%s)
|
||||
if [[ $graph == AP ]]
|
||||
then
|
||||
thresholds=(
|
||||
@ -580,16 +660,14 @@ else
|
||||
next=('COMMENT:\n')
|
||||
fi
|
||||
|
||||
(( start > -1209600 )) && datastart=-1209600
|
||||
(( end < 157680001 )) && dataend="+157680001"
|
||||
(( start > 0 )) && start="+$start"
|
||||
(( end > 0 )) && end="+$end"
|
||||
(( start - now > -1209600 )) && datastart=-1209600
|
||||
(( end - now < 157680001 )) && dataend="+157680001"
|
||||
(( datastart > 0 )) && datastart="+$datastart"
|
||||
|
||||
rrdtool graph - \
|
||||
-a PNG \
|
||||
-w $graph_width \
|
||||
-v $graph \
|
||||
-v "${uinames[$graph]}" \
|
||||
-s $start -e $end \
|
||||
DEF:data=$rrdfile:$graph:AVERAGE:step=3600${datastart+:start=$datastart}${dataend+:end=$dataend} \
|
||||
DEF:fail=$rrdfile:$graph:FAILURES \
|
||||
|
||||
56169
ingress.xml
Normal file
56169
ingress.xml
Normal file
File diff suppressed because it is too large
Load Diff
11
ingrrd.css
11
ingrrd.css
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
* Copyright (C) 2014 Vincent Riquer
|
||||
* Copyright (C) 2014-2015 Vincent Riquer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
@ -59,6 +59,13 @@ td.submenu-inv {
|
||||
background: #444;
|
||||
color: white
|
||||
}
|
||||
div.updating {
|
||||
position: relative;
|
||||
background: orange;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
div.main {
|
||||
position: absolute;
|
||||
@ -113,7 +120,7 @@ th.AP,td.AP {
|
||||
}
|
||||
|
||||
th.badge,td.badge {
|
||||
width: 170px;
|
||||
/* width: 170px;*/
|
||||
}
|
||||
|
||||
a.badge {
|
||||
|
||||
@ -1,5 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
get_current_level() {
|
||||
for level in {1..16}
|
||||
do
|
||||
|
||||
127
lib/get_next_level
Normal file
127
lib/get_next_level
Normal file
@ -0,0 +1,127 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
get_next_level() {
|
||||
local level
|
||||
local now=$(date +%s)
|
||||
next=()
|
||||
for (( level = curlevel + 1; level <= 16; level++))
|
||||
do
|
||||
if (( lvl[level] > last["AP"] ))
|
||||
then
|
||||
next+=(
|
||||
CDEF:nextcross$level=pred,${lvl[level]},GE,pred,UNKN,IF
|
||||
VDEF:nexttime$level=nextcross$level,FIRST
|
||||
"PRINT:nexttime$level:$level %s:strftime"
|
||||
)
|
||||
fi
|
||||
done
|
||||
{
|
||||
read
|
||||
while read level timestamp
|
||||
do
|
||||
(( timestamp && timestamp < now )) && timestamp=$now
|
||||
nextlevels[level]=$timestamp
|
||||
done
|
||||
} < <(
|
||||
rrdtool graph /dev/null -s -$prevperiod -e +5y \
|
||||
DEF:data=$rrdfile:AP:AVERAGE:step=3600 \
|
||||
VDEF:intercept=data,LSLINT \
|
||||
VDEF:growth=data,LSLSLOPE \
|
||||
CDEF:trend=data,POP,COUNT,growth,*,intercept,+ \
|
||||
CDEF:pred=TIME,NOW,GE,trend,UNKN,IF \
|
||||
"${next[@]}"
|
||||
)
|
||||
|
||||
for stat in ${medals[@]}
|
||||
do
|
||||
next=()
|
||||
if ! (( hasbronze[$stat] ))
|
||||
then
|
||||
next+=(
|
||||
CDEF:nextcrossbronze=pred,${bronze[$stat]},GE,pred,UNKN,IF
|
||||
VDEF:nexttimebronze=nextcrossbronze,FIRST
|
||||
"PRINT:nexttimebronze:bronze %s:strftime"
|
||||
)
|
||||
fi
|
||||
if ! (( hassilver[$stat] ))
|
||||
then
|
||||
next+=(
|
||||
CDEF:nextcrosssilver=pred,${silver[$stat]},GE,pred,UNKN,IF
|
||||
VDEF:nexttimesilver=nextcrosssilver,FIRST
|
||||
"PRINT:nexttimesilver:silver %s:strftime"
|
||||
)
|
||||
fi
|
||||
if ! (( hasgold[$stat] ))
|
||||
then
|
||||
next+=(
|
||||
CDEF:nextcrossgold=pred,${gold[$stat]},GE,pred,UNKN,IF
|
||||
VDEF:nexttimegold=nextcrossgold,FIRST
|
||||
"PRINT:nexttimegold:gold %s:strftime"
|
||||
)
|
||||
fi
|
||||
if ! (( hasplatinum[$stat] ))
|
||||
then
|
||||
next+=(
|
||||
CDEF:nextcrossplatinum=pred,${platinum[$stat]},GE,pred,UNKN,IF
|
||||
VDEF:nexttimeplatinum=nextcrossplatinum,FIRST
|
||||
"PRINT:nexttimeplatinum:platinum %s:strftime"
|
||||
)
|
||||
fi
|
||||
if ! (( hasblack[$stat] ))
|
||||
then
|
||||
next+=(
|
||||
CDEF:nextcrossblack=pred,${black[$stat]},GE,pred,UNKN,IF
|
||||
VDEF:nexttimeblack=nextcrossblack,FIRST
|
||||
"PRINT:nexttimeblack:black %s:strftime"
|
||||
)
|
||||
fi
|
||||
{
|
||||
read
|
||||
while read matter timestamp
|
||||
do
|
||||
(( timestamp && timestamp < now )) && timestamp=$now
|
||||
case $matter in
|
||||
bronze)
|
||||
nextbronze[timestamp]+="$stat "
|
||||
;;
|
||||
silver)
|
||||
nextsilver[timestamp]+="$stat "
|
||||
;;
|
||||
gold)
|
||||
nextgold[timestamp]+="$stat "
|
||||
;;
|
||||
platinum)
|
||||
nextplatinum[timestamp]+="$stat "
|
||||
;;
|
||||
black)
|
||||
nextblack[timestamp]+="$stat "
|
||||
;;
|
||||
esac
|
||||
done
|
||||
} < <(
|
||||
rrdtool graph /dev/null -s -$prevperiod -e +5y \
|
||||
DEF:data=$rrdfile:$stat:AVERAGE:step=600 \
|
||||
VDEF:intercept=data,LSLINT \
|
||||
VDEF:growth=data,LSLSLOPE \
|
||||
CDEF:trend=data,POP,COUNT,growth,*,intercept,+ \
|
||||
CDEF:pred=TIME,NOW,GE,trend,UNKN,IF \
|
||||
"${next[@]}"
|
||||
)
|
||||
done
|
||||
}
|
||||
39
lib/globals
39
lib/globals
@ -1,11 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
declare -A \
|
||||
last \
|
||||
nosilver \
|
||||
nogold \
|
||||
noplatinum \
|
||||
noblack \
|
||||
upbronze \
|
||||
upsilver \
|
||||
upgold \
|
||||
upplatinum \
|
||||
upblack \
|
||||
hasbronze \
|
||||
hassilver \
|
||||
hasgold \
|
||||
hasplatinum \
|
||||
hasblack \
|
||||
first \
|
||||
shown \
|
||||
|
||||
declare -a \
|
||||
bronzes \
|
||||
@ -13,11 +41,11 @@ declare -a \
|
||||
golds \
|
||||
platinums \
|
||||
blacks \
|
||||
upbronze \
|
||||
upsilver \
|
||||
upgold \
|
||||
upplatinum \
|
||||
upblack \
|
||||
nextbronze \
|
||||
nextsilver \
|
||||
nextgold \
|
||||
nextplatinum \
|
||||
nextblack \
|
||||
|
||||
declare -i \
|
||||
bronzecount \
|
||||
@ -33,6 +61,7 @@ declare \
|
||||
graph \
|
||||
start \
|
||||
end \
|
||||
prevperiod \
|
||||
|
||||
want_ds=(
|
||||
AP
|
||||
|
||||
238
lib/image
Executable file
238
lib/image
Executable file
@ -0,0 +1,238 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
image() {
|
||||
exec 2>&1
|
||||
local timestamp=$2
|
||||
declare -A values
|
||||
|
||||
tmpfile=$(mktemp --suffix=.tiff)
|
||||
transform='-resize 350%x200% -contrast -channel green -threshold 50%'
|
||||
|
||||
if (( debug_import >= 3 ))
|
||||
then
|
||||
readarray -t tactout < <(convert $transform "$1" -format tiff - | tee "${1%.png}.tiff" | tesseract -l eng -psm 4 stdin stdout)
|
||||
else
|
||||
readarray -t tactout < <(convert $transform "$1" -format tiff - | tesseract -l eng -psm 4 stdin stdout)
|
||||
fi
|
||||
if ((debug_import >=2 ))
|
||||
then
|
||||
for index in ${!tactout[@]}
|
||||
do
|
||||
echo "${tactout[index]}"
|
||||
done > "${1%.png}.txt"
|
||||
fi
|
||||
rm "$tmpfile"
|
||||
|
||||
for line in "${tactout[@]}"
|
||||
do
|
||||
case "$line" in
|
||||
'Error, please try again.')
|
||||
# Ingress failed when generating image, ignore file.
|
||||
echo $'\tFailed capture, file removed.'
|
||||
rm "$1"
|
||||
return 3
|
||||
;;
|
||||
#14,522,411 AP 144mm AP
|
||||
*' AP'*)
|
||||
read value junk <<<"$line"
|
||||
value=${value//_/}
|
||||
values[AP]=${value//,/}
|
||||
;;
|
||||
#Unique Portals Visited 718
|
||||
'Unique Portals Visited'*)
|
||||
value="${line#Unique Portals Visited }"
|
||||
value=${value//_/}
|
||||
read values[Explorer] junk <<<"${value//,}"
|
||||
;;
|
||||
#Portals Discovered 9
|
||||
'Portals Discovered'*)
|
||||
value="${line#Portals Discovered }"
|
||||
value=${value//_/}
|
||||
read values[Seer] junk <<<"${value//,/}"
|
||||
;;
|
||||
#XM Collected 130,908,527 XM
|
||||
'XM Collected'*)
|
||||
value="${line#XM Collected}"
|
||||
value=${value//_/}
|
||||
read values[XM] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Distance Walked 1,785 km
|
||||
'Distance Walked'*)
|
||||
value="${line#Distance Walked }"
|
||||
value=${value//_/}
|
||||
read values[Walked] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Resonators Deployed 24,451
|
||||
'Resonators Deployed'*)
|
||||
value="${line#Resonators Deployed }"
|
||||
value=${value//_/}
|
||||
read values[Builder] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Links Created 4,479
|
||||
'Links Created'*)
|
||||
value="${line#Links Created }"
|
||||
value=${value//_/}
|
||||
read values[Connector] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Control Fields Created 2,340
|
||||
'Control Fields Created'*)
|
||||
value="${line#Control Fields Created }"
|
||||
value=${value//_/}
|
||||
read values[Mind_Controller] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Mind Units Captured 155,815 MUs
|
||||
'Mind Units Captured'*)
|
||||
value="${line#Mind Units Captured }"
|
||||
value=${value//_/}
|
||||
read values[MU] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Longest Link Ever Created 3 km
|
||||
'Longest Link Ever Created'*)
|
||||
value="${line#Longest Link Ever Created }"
|
||||
value=${value//_/}
|
||||
read values[Longest_Link] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Largest Control Field 11,588 MUs
|
||||
'Largest Control Field'*)
|
||||
value="${line#Largest Control Field }"
|
||||
value=${value//_/}
|
||||
read values[Largest_Field] junk <<<"${value//,/}"
|
||||
;;
|
||||
#XM Recharged 92,120,959 XM
|
||||
'XM Recharged'*)
|
||||
value="${line#XM Recharged }"
|
||||
value=${value//_/}
|
||||
read values[Recharger] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Portals Captured 2,022
|
||||
'Portals Captured'*)
|
||||
value="${line#Portals Captured }"
|
||||
value=${value//_/}
|
||||
read values[Liberator] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Unique Portals Captured 375
|
||||
'Unique Portals Captured'*)
|
||||
value="${line#Unique Portals Captured }"
|
||||
value=${value//_/}
|
||||
read values[Pioneer] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Mods Deployed 995
|
||||
'Mods Deployed'*)
|
||||
value="${line#Mods Deployed }"
|
||||
value=${value//_/}
|
||||
read values[Engineer] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Resonators Destroyed 15,855
|
||||
'Resonators Destroyed'*)
|
||||
value="${line#Resonators Destroyed }"
|
||||
value=${value//_/}
|
||||
read values[Purifier] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Portals Neutralized 2,145
|
||||
'Portals Neutralized'*)
|
||||
value="${line#Portals Neutralized }"
|
||||
value=${value//_/}
|
||||
read values[Neutralized] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Enemy Links Destroyed 2,725
|
||||
'Enemy Links Destroyed'*)
|
||||
value="${line#Enemy Links Destroyed }"
|
||||
value=${value//_/}
|
||||
read values[Links_Destroyed] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Enemy Control Fields Destroyed 1,418
|
||||
'Enemy Control Fields Destroyed'*)
|
||||
value="${line#Enemy Control Fields Destroyed }"
|
||||
value=${value//_/}
|
||||
read values[Fields_Destroyed] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Max Time Portal Held 105 days
|
||||
'Max '*' Portal Held'*)
|
||||
value="${line#Max * Portal Held }"
|
||||
value=${value//_/}
|
||||
read values[Guardian] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Max Time Link Maintained 75 days
|
||||
'Max Time Link Maintained'*)
|
||||
value="${line#Max Time Link Maintained }"
|
||||
value=${value//_/}
|
||||
read values[Link_Maintained] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Max Link Length x Days 89 km-days
|
||||
'Max Link Length x Days'*)
|
||||
value="${line#Max Link Length x Days }"
|
||||
value=${value//_/}
|
||||
read values[Link_Length_x_Days] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Max Time Field Held 55 days
|
||||
'Max Time Field Held'*)
|
||||
value="${line#Max Time Field Held }"
|
||||
value=${value//_/}
|
||||
read values[Field_Held] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Largest Field MUs x Days 58,959 MU-days
|
||||
'Largest Field MU'[Ss]' x Days'*)
|
||||
value="${line#Largest Field MUs x Days }"
|
||||
value=${value//_/}
|
||||
read values[Field_x_Days] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Unique Missions Completed 1
|
||||
'Unique Missions Completed'*)
|
||||
value="${line#Unique Missions Completed }"
|
||||
value=${value//_/}
|
||||
read values[Mercenary] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Hacks 25,741
|
||||
'Hacks'*)
|
||||
value="${line#Hacks }"
|
||||
value=${value//_/}
|
||||
read values[Hacker] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Glyph Hack Points 1,022
|
||||
'Glyph Hack Points'*)
|
||||
value="${line#Glyph Hack Points }"
|
||||
value=${value//_/}
|
||||
read values[Translator] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Agents Recruited 1
|
||||
'Agents Recruited'*)
|
||||
value="${line#Agents Recruited }"
|
||||
value=${value//_/}
|
||||
read values[Recruiter] junk <<<"${value//,/}"
|
||||
;;
|
||||
#Agents Recruited 1
|
||||
'Consecutive Days Hacking'*)
|
||||
value="${line#Consecutive Days Hacking }"
|
||||
value=${value//_/}
|
||||
read values[Hackaton] junk <<<"${value//,/}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
template="${!values[@]}"
|
||||
updatevalues="${values[@]}"
|
||||
|
||||
if ((debug_import))
|
||||
then
|
||||
echo $'\t'"$template"
|
||||
echo $'\t'"$updatevalues"
|
||||
fi
|
||||
|
||||
rrdtool update "$rrdfile" -t "${template// /:}" "$timestamp:${updatevalues// /:}"
|
||||
}
|
||||
49
lib/import_images
Normal file
49
lib/import_images
Normal file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import_images() {
|
||||
local starttime=$(date +%s) imagetime timestamp elapsed lasttime now
|
||||
exec >> images.log
|
||||
exec 2>> images.log
|
||||
declare -r oldIFS="$IFS"
|
||||
[[ -r .importing ]] && return 2
|
||||
[[ -w "$rrdfile" ]] || rrdcreate
|
||||
readlast
|
||||
for file in dav/profile_*.png
|
||||
do
|
||||
[[ -r "$file" ]] || continue
|
||||
IFS=_.
|
||||
read junk date time junk <<<"$file"
|
||||
IFS="$oldIFS"
|
||||
if (( $(date '+%Y%m%d%H%M%S' -d "@${last[time]}") < $date$time ))
|
||||
then
|
||||
(( count++ ))
|
||||
lasttime=${now:-$starttime}
|
||||
echo "${file##*/}" > .importing
|
||||
imagetime="${date:0:4}/${date:4:2}/${date:6:2} ${time:0:2}:${time:2:2}:${time:4:2}"
|
||||
echo "$(date +"%Y/%m/%d:%H:%M:%S") - $file: $imagetime"
|
||||
timestamp=$(date +%s -d "$imagetime")
|
||||
image "$file" $timestamp
|
||||
now=$(date +%s)
|
||||
echo $'\tDuration: '$(( now - lasttime ))
|
||||
fi
|
||||
done
|
||||
elapsed=$(( $(date +%s) - starttime ))
|
||||
(( count )) && echo "$(date +"%Y/%m/%d:%H:%M:%S"): Imported $count file(s) in $elapsed seconds."
|
||||
rm -f .importing
|
||||
}
|
||||
31
lib/medals
31
lib/medals
@ -1,5 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
medals() {
|
||||
local \
|
||||
stat \
|
||||
@ -51,16 +67,18 @@ medals() {
|
||||
then
|
||||
(( bronzecount++ ))
|
||||
bronzes+=( "$stat" )
|
||||
hasbronze["$stat"]=1
|
||||
else
|
||||
upbronze[last["$stat"] * 100 / bronze["$stat"]]+="$stat "
|
||||
(( upbronze["$stat"]=last["$stat"] * 100 / bronze["$stat"]))
|
||||
fi
|
||||
if (( last["$stat"] >= silver["$stat"] ))
|
||||
then
|
||||
(( silvercount++ ))
|
||||
silvers+=( "$stat" )
|
||||
hassilver["$stat"]=1
|
||||
elif (( last["$stat"] >= bronze["$stat"] ))
|
||||
then
|
||||
upsilver[( last["$stat"] - bronze["$stat"] ) * 100 / ( silver["$stat"] - bronze["$stat"] )]+="$stat "
|
||||
(( upsilver["$stat"]=( last["$stat"] - bronze["$stat"] ) * 100 / ( silver["$stat"] - bronze["$stat"] ) ))
|
||||
else
|
||||
nosilver["$stat"]=1
|
||||
fi
|
||||
@ -68,9 +86,10 @@ medals() {
|
||||
then
|
||||
(( goldcount++ ))
|
||||
golds+=( "$stat" )
|
||||
hasgold["$stat"]=1
|
||||
elif (( last["$stat"] >= silver["$stat"] ))
|
||||
then
|
||||
upgold[( last["$stat"] - silver["$stat"] ) * 100 / ( gold["$stat"] - silver["$stat"] )]+="$stat "
|
||||
(( upgold["$stat"]=( last["$stat"] - silver["$stat"] ) * 100 / ( gold["$stat"] - silver["$stat"] ) ))
|
||||
else
|
||||
nogold["$stat"]=1
|
||||
fi
|
||||
@ -78,9 +97,10 @@ medals() {
|
||||
then
|
||||
(( platinumcount++ ))
|
||||
platinums+=( "$stat" )
|
||||
hasplatinum["$stat"]=1
|
||||
elif (( last["$stat"] >= gold["$stat"] ))
|
||||
then
|
||||
upplatinum[( last["$stat"] - gold["$stat"] ) * 100 / ( platinum["$stat"] - gold["$stat"] )]+="$stat "
|
||||
(( upplatinum["$stat"]=( last["$stat"] - gold["$stat"] ) * 100 / ( platinum["$stat"] - gold["$stat"] ) ))
|
||||
else
|
||||
noplatinum["$stat"]=1
|
||||
fi
|
||||
@ -88,9 +108,10 @@ medals() {
|
||||
then
|
||||
(( blackcount++ ))
|
||||
blacks+=( "$stat" )
|
||||
hasblack["$stat"]=1
|
||||
elif (( last["$stat"] >= platinum["$stat"] ))
|
||||
then
|
||||
upblack[( last["$stat"] - platinum["$stat"] ) * 100 / ( black["$stat"] - platinum["$stat"] )]+="$stat "
|
||||
(( upblack["$stat"]=( last["$stat"] - platinum["$stat"]) * 100 / ( black["$stat"] - platinum["$stat"] ) ))
|
||||
else
|
||||
noblack["$stat"]=1
|
||||
fi
|
||||
|
||||
47
lib/print_medal
Normal file
47
lib/print_medal
Normal file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
print_medal() {
|
||||
local \
|
||||
timestamp=$1 \
|
||||
stat=$2 \
|
||||
percent=$3 \
|
||||
level=$4 \
|
||||
|
||||
if (( timestamp ))
|
||||
then
|
||||
thisdate=$(date +%Y-%m-%d -d @$timestamp)
|
||||
else
|
||||
thisdate="maybe some day..."
|
||||
fi
|
||||
img=${stat,,}
|
||||
(( greenlevel = percent * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="badge"
|
||||
src="/${img//_/-}-$level.png"
|
||||
title="$stat $percent%"
|
||||
alt="$stat $level" />
|
||||
</a> ($thisdate)
|
||||
EOHTML
|
||||
}
|
||||
@ -1,5 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
read_query_string() {
|
||||
local \
|
||||
exprgraph \
|
||||
@ -14,6 +30,7 @@ read_query_string() {
|
||||
}"
|
||||
exprtime='[[:alnum:]-]+'
|
||||
exprgraph='[[:alpha:]_]+'
|
||||
exprprev='[[:digit:]]+[(d(ay)?)(w(eek)?)(month)(y(ear)?)]'
|
||||
while read name value
|
||||
do
|
||||
case $name in
|
||||
@ -32,6 +49,9 @@ read_query_string() {
|
||||
show)
|
||||
[[ $value == all ]] && show_all=1
|
||||
;;
|
||||
prevperiod)
|
||||
[[ $value =~ $exprprev ]] && prevperiod=$value
|
||||
;;
|
||||
esac
|
||||
done <<<"${query_data//=/ }"
|
||||
fi
|
||||
|
||||
19
lib/readlast
19
lib/readlast
@ -1,16 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
readlast() {
|
||||
local \
|
||||
index \
|
||||
indices \
|
||||
lastupdatelines \
|
||||
time \
|
||||
values \
|
||||
|
||||
readarray -t lastupdatelines < <(
|
||||
rrdtool lastupdate $rrdfile
|
||||
)
|
||||
indices=( ${lastupdatelines[0]} )
|
||||
time=${lastupdatelines[2]%:*}
|
||||
last["time"]=${time:-0}
|
||||
values=( ${lastupdatelines[2]#*:} )
|
||||
for index in ${!indices[@]}
|
||||
do
|
||||
|
||||
39
lib/readold
Normal file
39
lib/readold
Normal file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
readold() {
|
||||
local when=$1 \
|
||||
line \
|
||||
dataindex \
|
||||
empty \
|
||||
id \
|
||||
LANG=C
|
||||
{
|
||||
read line
|
||||
dataindex=( $line )
|
||||
read empty
|
||||
read first['time'] $(
|
||||
for id in ${dataindex[@]}
|
||||
do
|
||||
echo "first['"$id"']"
|
||||
done
|
||||
)
|
||||
} < <(
|
||||
rrdtool fetch -s "$when" "$rrdfile" AVERAGE | sed '/: nan/d'
|
||||
)
|
||||
}
|
||||
21
lib/rrdcreate
Normal file
21
lib/rrdcreate
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
rrdcreate() {
|
||||
rrdtool restore ingress.xml "$rrdfile"
|
||||
}
|
||||
38
lib/send_headers
Normal file
38
lib/send_headers
Normal file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
send_headers() {
|
||||
local timestamp do_exit header thisdate expiredate
|
||||
read timestamp < <(stat -c %Y $0 settings "$rrdfile" lib/* dav/* .importing 2>/dev/null|sort -r)
|
||||
thisdate=$(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' -d @$timestamp)
|
||||
expiredate=$(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' -d "+${1:-5} second")
|
||||
if [[ $thisdate == $HTTP_IF_MODIFIED_SINCE ]]
|
||||
then
|
||||
echo "Status: 304 Not Modified"
|
||||
do_exit=1
|
||||
fi
|
||||
echo "Last-Modified: $thisdate"
|
||||
echo "Expires: $expiredate"
|
||||
echo "Cache-Control: must-revalidate, max-age=${1:-5}"
|
||||
while read header
|
||||
do
|
||||
echo "$header"
|
||||
done
|
||||
echo
|
||||
(( do_exit )) && exit
|
||||
}
|
||||
@ -1,5 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
show_current_level() {
|
||||
cat <<-EOHTML
|
||||
<table class="curlevel" style="width:$(( graph_width + 97 ))px">
|
||||
@ -22,13 +38,15 @@ show_current_level() {
|
||||
</a>
|
||||
EOHTML
|
||||
done
|
||||
for id in {100..0}
|
||||
for timestamp in ${!nextbronze[@]}
|
||||
do
|
||||
[ -z "${upbronze[id]}" ] && continue
|
||||
(( greenlevel = id * 255 / 100 ))
|
||||
(( timestamp )) || continue
|
||||
for stat in ${nextbronze[timestamp]}
|
||||
do
|
||||
if (( upbronze[$stat] ))
|
||||
then
|
||||
(( greenlevel = upbronze[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
for stat in ${upbronze[id]}
|
||||
do
|
||||
img=${stat,,}
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
@ -38,12 +56,50 @@ show_current_level() {
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-bronze.png"
|
||||
title="$stat $id%"
|
||||
title="$stat ${upbronze[$stat]}%
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat bronze" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
done
|
||||
for stat in ${nextbronze[0]}
|
||||
do
|
||||
img=${stat,,}
|
||||
if (( upbronze[$stat] ))
|
||||
then
|
||||
(( greenlevel = upbronze[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-bronze.png"
|
||||
title="$stat ${upbronze[$stat]}%
|
||||
(maybe one day)"
|
||||
alt="$stat bronze" />
|
||||
</a>
|
||||
EOHTML
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#ff0000"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-bronze.png"
|
||||
title="$stat 0%
|
||||
(maybe one day)"
|
||||
alt="$stat bronze" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
cat <<-EOHTML
|
||||
</td>
|
||||
<td class="curbadge">
|
||||
@ -62,14 +118,16 @@ show_current_level() {
|
||||
</a>
|
||||
EOHTML
|
||||
done
|
||||
for id in {100..0}
|
||||
for timestamp in ${!nextsilver[@]}
|
||||
do
|
||||
[ -z "${upsilver[id]}" ] && continue
|
||||
(( greenlevel = id * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
for stat in ${upsilver[id]}
|
||||
(( timestamp )) || continue
|
||||
for stat in ${nextsilver[timestamp]}
|
||||
do
|
||||
img=${stat,,}
|
||||
if (( upsilver[$stat] ))
|
||||
then
|
||||
(( greenlevel = upsilver[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
@ -78,15 +136,12 @@ show_current_level() {
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-silver.png"
|
||||
title="$stat $id%"
|
||||
title="$stat ${upsilver[$stat]}%
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat silver" />
|
||||
</a>
|
||||
EOHTML
|
||||
done
|
||||
done
|
||||
for stat in ${!nosilver[@]}
|
||||
do
|
||||
img=${stat,,}
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
@ -94,10 +149,48 @@ show_current_level() {
|
||||
<img
|
||||
class="nominibadge"
|
||||
src="/${img//_/-}-silver.png"
|
||||
title="$stat $id%"
|
||||
title="$stat
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat silver" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
done
|
||||
for stat in ${nextsilver[0]}
|
||||
do
|
||||
img=${stat,,}
|
||||
if (( upsilver[$stat] ))
|
||||
then
|
||||
(( greenlevel = upsilver[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-silver.png"
|
||||
title="$stat ${upsilver[$stat]}%
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat silver" />
|
||||
</a>
|
||||
EOHTML
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="nominibadge"
|
||||
src="/${img//_/-}-silver.png"
|
||||
title="$stat
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat silver" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
cat <<-EOHTML
|
||||
</td>
|
||||
@ -117,14 +210,16 @@ show_current_level() {
|
||||
</a>
|
||||
EOHTML
|
||||
done
|
||||
for id in {100..0}
|
||||
for timestamp in ${!nextgold[@]}
|
||||
do
|
||||
[ -z "${upgold[id]}" ] && continue
|
||||
(( greenlevel = id * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
for stat in ${upgold[id]}
|
||||
(( timestamp )) || continue
|
||||
for stat in ${nextgold[timestamp]}
|
||||
do
|
||||
img=${stat,,}
|
||||
if (( upgold[$stat] ))
|
||||
then
|
||||
(( greenlevel = upgold[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
@ -133,15 +228,12 @@ show_current_level() {
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-gold.png"
|
||||
title="$stat $id%"
|
||||
title="$stat ${upgold[$stat]}%
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat gold" />
|
||||
</a>
|
||||
EOHTML
|
||||
done
|
||||
done
|
||||
for stat in ${!nogold[@]}
|
||||
do
|
||||
img=${stat,,}
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
@ -149,10 +241,48 @@ show_current_level() {
|
||||
<img
|
||||
class="nominibadge"
|
||||
src="/${img//_/-}-gold.png"
|
||||
title="$stat $id%"
|
||||
title="$stat
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat gold" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
done
|
||||
for stat in ${nextgold[0]}
|
||||
do
|
||||
img=${stat,,}
|
||||
if (( upgold[$stat] ))
|
||||
then
|
||||
(( greenlevel = upgold[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-gold.png"
|
||||
title="$stat ${upgold[$stat]}%
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat gold" />
|
||||
</a>
|
||||
EOHTML
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="nominibadge"
|
||||
src="/${img//_/-}-gold.png"
|
||||
title="$stat
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat gold" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
cat <<-EOHTML
|
||||
</td>
|
||||
@ -172,14 +302,16 @@ show_current_level() {
|
||||
</a>
|
||||
EOHTML
|
||||
done
|
||||
for id in {100..0}
|
||||
for timestamp in ${!nextplatinum[@]}
|
||||
do
|
||||
[ -z "${upplatinum[id]}" ] && continue
|
||||
(( greenlevel = id * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
for stat in ${upplatinum[id]}
|
||||
(( timestamp )) || continue
|
||||
for stat in ${nextplatinum[timestamp]}
|
||||
do
|
||||
img=${stat,,}
|
||||
if (( upplatinum[$stat] ))
|
||||
then
|
||||
(( greenlevel = upplatinum[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
@ -188,15 +320,12 @@ show_current_level() {
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-platinum.png"
|
||||
title="$stat $id%"
|
||||
title="$stat ${upplatinum[$stat]}%
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat platinum" />
|
||||
</a>
|
||||
EOHTML
|
||||
done
|
||||
done
|
||||
for stat in ${!noplatinum[@]}
|
||||
do
|
||||
img=${stat,,}
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
@ -204,10 +333,48 @@ show_current_level() {
|
||||
<img
|
||||
class="nominibadge"
|
||||
src="/${img//_/-}-platinum.png"
|
||||
title="$stat $id%"
|
||||
title="$stat
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat platinum" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
done
|
||||
for stat in ${nextplatinum[0]}
|
||||
do
|
||||
img=${stat,,}
|
||||
if (( upplatinum[$stat] ))
|
||||
then
|
||||
(( greenlevel = upplatinum[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-platinum.png"
|
||||
title="$stat ${upplatinum[$stat]}%
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat platinum" />
|
||||
</a>
|
||||
EOHTML
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="nominibadge"
|
||||
src="/${img//_/-}-platinum.png"
|
||||
title="$stat
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat platinum" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
cat <<-EOHTML
|
||||
</td>
|
||||
@ -227,14 +394,16 @@ show_current_level() {
|
||||
</a>
|
||||
EOHTML
|
||||
done
|
||||
for id in {100..0}
|
||||
for timestamp in ${!nextblack[@]}
|
||||
do
|
||||
[ -z "${upblack[id]}" ] && continue
|
||||
(( greenlevel = id * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
for stat in ${upblack[id]}
|
||||
(( timestamp )) || continue
|
||||
for stat in ${nextblack[timestamp]}
|
||||
do
|
||||
img=${stat,,}
|
||||
if (( upblack[$stat] ))
|
||||
then
|
||||
(( greenlevel = upblack[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
@ -243,15 +412,12 @@ show_current_level() {
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-black.png"
|
||||
title="$stat $id%"
|
||||
title="$stat ${upblack[$stat]}%
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat black" />
|
||||
</a>
|
||||
EOHTML
|
||||
done
|
||||
done
|
||||
for stat in ${!noblack[@]}
|
||||
do
|
||||
img=${stat,,}
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
@ -259,10 +425,48 @@ show_current_level() {
|
||||
<img
|
||||
class="nominibadge"
|
||||
src="/${img//_/-}-black.png"
|
||||
title="$stat $id%"
|
||||
title="$stat
|
||||
($(date -d @$timestamp +%Y-%m-%d))"
|
||||
alt="$stat black" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
done
|
||||
for stat in ${nextblack[0]}
|
||||
do
|
||||
img=${stat,,}
|
||||
if (( upblack[$stat] ))
|
||||
then
|
||||
(( greenlevel = upblack[$stat] * 255 / 100 ))
|
||||
(( redlevel = 255 - greenlevel ))
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="minibadge"
|
||||
src="/${img//_/-}-black.png"
|
||||
title="$stat ${upblack[$stat]}%
|
||||
(maybe one day)"
|
||||
alt="$stat black" />
|
||||
</a>
|
||||
EOHTML
|
||||
else
|
||||
cat <<-EOHTML
|
||||
<a
|
||||
class="badge"
|
||||
href="?hist&start=$start&end=$end#$stat">
|
||||
<img
|
||||
class="nominibadge"
|
||||
src="/${img//_/-}-black.png"
|
||||
title="$stat
|
||||
(maybe one day)"
|
||||
alt="$stat black" />
|
||||
</a>
|
||||
EOHTML
|
||||
fi
|
||||
done
|
||||
cat <<-EOHTML
|
||||
</td>
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
128
settings
128
settings
@ -1,5 +1,21 @@
|
||||
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
||||
# Copyright (C) 2014-2015 Vincent Riquer
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Path to your fastcgi_cache (optional).
|
||||
#CACHE_DIR=/var/www/ingRRD/cache
|
||||
CACHE_DIR=/web/ingress-stats.riquer.fr/cache/
|
||||
|
||||
## FIXME change this according to your URLs:
|
||||
#
|
||||
@ -8,6 +24,8 @@
|
||||
# /cgi/$user/add.html
|
||||
IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI"
|
||||
|
||||
debug_import=3
|
||||
|
||||
rrdfile=ingress.rrd
|
||||
|
||||
graph_width=800
|
||||
@ -29,39 +47,46 @@ L14color=8B1479
|
||||
L15color=6B127D
|
||||
L16color=591494
|
||||
|
||||
default_start=-604800
|
||||
default_end=1209600
|
||||
default_prevperiod=1month
|
||||
now=$(date +%s)
|
||||
|
||||
(( default_start = now - 604800 ))
|
||||
(( default_end = now + 1209600 ))
|
||||
|
||||
start=$default_start
|
||||
end=$default_end
|
||||
prevperiod=$default_prevperiod
|
||||
|
||||
uinames=(
|
||||
AP
|
||||
"Unique Portals Visited"
|
||||
"Portals Discovered"
|
||||
"XM Collected"
|
||||
"Distance Walked"
|
||||
"Resonators Deployed"
|
||||
"Links Created"
|
||||
"Control Fields Created"
|
||||
"Mind Units Captured"
|
||||
"Longest Link Ever Created"
|
||||
"Largest Control Field"
|
||||
"XM Recharged"
|
||||
"Portals Captured"
|
||||
"Unique Portals Captured"
|
||||
"Mods Deployed"
|
||||
"Resonators Destroyed"
|
||||
"Portals Neutralized"
|
||||
"Enemy Links Destroyed"
|
||||
"Enemy Control Fields Destroyed"
|
||||
"Max Time Portal Held"
|
||||
"Max Time Link Maintained"
|
||||
"Max Link Length x Days"
|
||||
"Max Time Field Held"
|
||||
"Largest Field MUs x Days"
|
||||
"Unique missions completed"
|
||||
Hacks
|
||||
declare -A uinames=(
|
||||
[AP]=AP
|
||||
[Explorer]="Unique Portals Visited"
|
||||
[Seer]="Portals Discovered"
|
||||
[XM]="XM Collected"
|
||||
[Walked]="Distance Walked"
|
||||
[Builder]="Resonators Deployed"
|
||||
[Connector]="Links Created"
|
||||
[Mind_Controller]="Control Fields Created"
|
||||
[MU]="Mind Units Captured"
|
||||
[Longest_Link]="Longest Link Ever Created"
|
||||
[Largest_Field]="Largest Control Field"
|
||||
[Recharger]="XM Recharged"
|
||||
[Liberator]="Portals Captured"
|
||||
[Pioneer]="Unique Portals Captured"
|
||||
[Engineer]="Mods Deployed"
|
||||
[Purifier]="Resonators Destroyed"
|
||||
[Neutralized]="Portals Neutralized"
|
||||
[Links_Destroyed]="Enemy Links Destroyed"
|
||||
[Fields_Destroyed]="Enemy Control Fields Destroyed"
|
||||
[Guardian]="Max Time Portal Held"
|
||||
[Link_Maintained]="Max Time Link Maintained"
|
||||
[Link_Length_x_Days]="Max Link Length x Days"
|
||||
[Field_Held]="Max Time Field Held"
|
||||
[Field_x_Days]="Largest Field MUs x Days"
|
||||
[Mercenary]="Unique missions completed"
|
||||
[Hacker]=Hacks
|
||||
[Translator]="Glyph Hack Points"
|
||||
[Recruiter]="Agents Recruited"
|
||||
[Hackaton]="Consecutive Days Hacking"
|
||||
)
|
||||
dsnames=(
|
||||
AP
|
||||
@ -90,22 +115,29 @@ dsnames=(
|
||||
Field_x_Days
|
||||
Mercenary
|
||||
Hacker
|
||||
Translator
|
||||
Recruiter
|
||||
Hackaton
|
||||
)
|
||||
medals=(
|
||||
Explorer
|
||||
Seer
|
||||
Hacker
|
||||
Walked
|
||||
Builder
|
||||
Connector
|
||||
Mind_Controller
|
||||
MU
|
||||
Recharger
|
||||
Liberator
|
||||
Pioneer
|
||||
Purifier
|
||||
Guardian
|
||||
Mercenary
|
||||
Engineer
|
||||
Walked
|
||||
Hacker
|
||||
Translator
|
||||
Recruiter
|
||||
Hackaton
|
||||
Mercenary
|
||||
)
|
||||
|
||||
## (0) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
@ -199,3 +231,33 @@ silver["Mercenary"]=25
|
||||
gold["Mercenary"]=100
|
||||
platinum["Mercenary"]=200
|
||||
black["Mercenary"]=500
|
||||
|
||||
bronze["Recruiter"]=2
|
||||
silver["Recruiter"]=10
|
||||
gold["Recruiter"]=25
|
||||
platinum["Recruiter"]=50
|
||||
black["Recruiter"]=100
|
||||
|
||||
bronze["Translator"]=200
|
||||
silver["Translator"]=2000
|
||||
gold["Translator"]=6000
|
||||
platinum["Translator"]=20000
|
||||
black["Translator"]=50000
|
||||
|
||||
bronze["MU"]=5000
|
||||
silver["MU"]=50000
|
||||
gold["MU"]=250000
|
||||
platinum["MU"]=1000000
|
||||
black["MU"]=4000000
|
||||
|
||||
bronze["Hackaton"]=15
|
||||
silver["Hackaton"]=30
|
||||
gold["Hackaton"]=60
|
||||
platinum["Hackaton"]=180
|
||||
black["Hackaton"]=365
|
||||
|
||||
#bronze[""]=
|
||||
#silver[""]=
|
||||
#gold[""]=
|
||||
#platinum[""]=
|
||||
#black[""]=
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user