Compare commits

..

No commits in common. "prod" and "master" have entirely different histories.
prod ... master

21 changed files with 454 additions and 57573 deletions

16
add
View File

@ -1,7 +1,7 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
# Copyright (C) 2014 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 "$rrdfile" |grep index)
done < <(rrdtool info ingress.rrd |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
cp -f ingress.rrd ingress.rrd.bak_add_$ds
./dsaddtor.pl ingress.rrd $ds GAUGE $((48*60*60)) 0 NaN
fi
done
data=N
@ -82,4 +82,10 @@ do
done
echo ${POST["innovator"]} > .innovator
rrdtool update "$rrdfile" -t $template "$data"
rrdtool update ingress.rrd -t $template "$data"
if [ -n "$CACHE_DIR" ]
then
find "$CACHE_DIR" -type f -delete
echo $'\nCache cleared!'
fi

View File

@ -1,7 +1,7 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
# Copyright (C) 2014 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
send_headers <<-EOHead
content-type: text/xml
EOHead
cat <<-EOHTML
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')
<?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,10 +42,45 @@ cat <<-EOHTML
EOHTML
if ! [ -w "$rrdfile" ]
then
rrdcreate || {
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)) \
|| {
cat <<-EOHTML
<h1 style="color:red">Cannot create $rrdfile</h1>
</div>
</body>
</html>
EOHTML
@ -117,10 +152,9 @@ cat <<-EOHTML
<ul>
EOHTML
for indice in ${dsnames[@]}
for indice in ${!uinames[@]}
do
[[ -z "${uinames[$indice]}" ]] && continue
echo "<li><input type=\"text\" name=\"$indice\" value=\"${last["$indice"]}\" /> ${uinames[$indice]}</li>"
echo "<li><input type=\"text\" name=\"${dsnames[indice]}\" value=\"${last["${dsnames[indice]}"]}\" /> ${uinames[indice]}</li>"
done
cat <<-EOHTML

127
import
View File

@ -1,7 +1,7 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
# Copyright (C) 2014 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,10 +24,43 @@ 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:Translator:Hackaton:Recruiter
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
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
@ -43,51 +76,24 @@ then
}"
POST["data"]="${POST["data"]//%3A/:}"
POST["data"]="${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
echo "${POST["data"]}"
while read date hour data
do
data=$(date -d "$date $hour" +%s):${data// /:}
rrdtool update "$rrdfile" -t $template "${data//:0/:U}" 2>&1
rrdtool update ingress.rrd -t $template "$data" 2>&1
done <<<"${POST["data"]}"
else
import_images &
send_headers <<-EOHead
content-type: text/xml
EOHead
if [ -n "$CACHE_DIR" ]
then
find "$CACHE_DIR" -type f -delete
echo $'\nCache cleared!'
fi
else
cat <<-EOHTML
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')
<?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">
@ -101,7 +107,43 @@ else
EOHTML
if ! [ -w "$rrdfile" ]
then
rrdcreate || {
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)) \
|| {
cat <<-EOHTML
<h1 style="color:red">Cannot create $rrdfile</h1>
</body>
@ -118,7 +160,6 @@ 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" />

442
index
View File

@ -1,7 +1,7 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
# Copyright (C) 2014 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,25 +22,26 @@ 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 &amp; Trend: All stats"
@ -51,6 +52,15 @@ 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">
@ -60,12 +70,6 @@ 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
@ -112,9 +116,6 @@ then
</table>
EOHTML
show_current_level
[[ -r .importing ]] && cat <<-EOHTML
<div class="updating">Importing $(<.importing)</div>
EOHTML
cat <<-EOHTML
</div>
<div class="main">
@ -131,217 +132,150 @@ 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// /&nbsp;}" )
readable=$(printf "%'li" $(( last["AP"] - lvl[level] )))
tableline+=( "<br />(<span class=\"missing\">${readable// /&nbsp;}</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
cat <<-EOHTML
<tr class="nextlevel">
<th class="level">$level</th>
EOHTML
echo "<tr class=\"nextlevel\"><th class=\"level\">$level</th>"
fi
echo "${tableline[@]}"
if (( level > curlevel ))
if (( last["AP"] >= lvl[level] ))
then
(( maxtimestamp < prevtimestamp )) \
&& maxtimestamp=$prevtimestamp
if (( maxtimestamp ))
then
cat <<-EOHTML
<td class="date">$(date +%Y-%m-%d -d @$maxtimestamp)</td>
EOHTML
else
cat <<-EOHTML
<td class="date">In more than 5 years</td>
EOHTML
fi
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// /&nbsp;}"
readable=$(printf "%'li" $(( last["AP"] - lvl[level] )))
echo "<br />(<span class=\"missing\">${readable// /&nbsp;}</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&amp;start=$start&amp;end=$end#$stat">
<img
class="badge"
src="/${img//_/-}-silver.png"
title="$stat $id%"
alt="$stat silver" />
</a>
EOHTML
(( count++ == lvlsilver[level] - silvercount )) && break 2
done
done
echo '</td>'
fi
if (( goldcount >= lvlgold[level] ))
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&amp;start=$start&amp;end=$end#$stat">
<img
class="badge"
src="/${img//_/-}-gold.png"
title="$stat $id%"
alt="$stat gold" />
</a>
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&amp;start=$start&amp;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&amp;start=$start&amp;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>
@ -407,35 +341,21 @@ then
<table style="width:$(( graph_width + 97 ))px">
<tr>
<td>
<a href="?hist&amp;start=$(rrdtool first "$rrdfile")&amp;end=$end">First</a>
<a href="?hist&amp;start=$(( start - 365 * 86400 ))&amp;end=$end">-Y</a>
<a href="?hist&amp;start=$(( start - 30 * 86400 ))&amp;end=$end">-M</a>
<a href="?hist&amp;start=$(( start - 604800 ))&amp;end=$end">-W</a>
<a href="?hist&amp;start=$(( start - 86400 ))&amp;end=$end">-D</a>
<a href="?hist&amp;start=$now&amp;end=$end">Now</a>
<a href="?hist&amp;start=$(( start + 86400 ))&amp;end=$end">+D</a>
<a href="?hist&amp;start=$(( start + 604800 ))&amp;end=$end">+W</a>
<a href="?hist&amp;start=$(( start + 30 * 86400 ))&amp;end=$end">+M</a>
<a href="?hist&amp;start=$(( start + 365 * 86400 ))&amp;end=$end">+Y</a>
<a href="?hist&amp;start=$(( start - 604800 ))&amp;end=$end">&lt;&lt;</a>
<a href="?hist&amp;start=$(( start - 86400 ))&amp;end=$end">&lt;</a>
<a href="?hist&amp;start=$default_start&amp;end=$end">R</a>
<a href="?hist&amp;start=$(( start + 86400 ))&amp;end=$end">&gt;</a>
<a href="?hist&amp;start=$(( start + 604800 ))&amp;end=$end">&gt;&gt;</a>
</td>
<td align="right">
<a href="?hist&amp;start=$start&amp;end=$(( end - 365 * 86400 ))">-Y</a>
<a href="?hist&amp;start=$start&amp;end=$(( end - 30 * 86400 ))">-M</a>
<a href="?hist&amp;start=$start&amp;end=$(( end - 604800 ))">-W</a>
<a href="?hist&amp;start=$start&amp;end=$(( end - 86400 ))">-D</a>
<a href="?hist&amp;start=$start&amp;end=$now">Now</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 86400 ))">+D</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 604800 ))">+W</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 30 * 86400 ))">+M</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 365 * 86400 ))">+Y</a>
<a href="?hist&amp;start=$start&amp;end=$(( end - 604800 ))">&lt;&lt;</a>
<a href="?hist&amp;start=$start&amp;end=$(( end - 86400 ))">&lt;</a>
<a href="?hist&amp;start=$start&amp;end=$default_end">R</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 86400 ))">&gt;</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 604800 ))">&gt;&gt;</a>
</td>
</tr>
</table>
EOHTML
[[ -r .importing ]] && cat <<-EOHTML
<div class="updating">Importing $(<.importing)</div>
EOHTML
cat <<-EOHTML
</div>
<div class="maingraph">
EOHTML
@ -454,7 +374,6 @@ then
for stat in "${stats[@]}"
do
[[ -z "${uinames[$stat]}" ]] && continue
if [[ $stat == AP ]] || (( bronze["$stat"] ))
then
height=169
@ -496,7 +415,7 @@ then
</a>
</td>
<td style="text-align:center">
Generated by <a href="https://forge.riquer.fr/p/ingrrd/">IngRRD</a> &copy; 2014-2015 Vincent Riquer
Generated by <a href="https://forge.riquer.fr/p/ingrrd/">IngRRD</a> &copy; 2014 Vincent Riquer
</td>
<td style="text-align:right; width:180px">
<a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">
@ -507,20 +426,21 @@ 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
send_headers <<-EOHead
content-type: image/png
EOHead
now=$(date +%s)
cat <<-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
if [[ $graph == AP ]]
then
thresholds=(
@ -660,14 +580,16 @@ else
next=('COMMENT:\n')
fi
(( start - now > -1209600 )) && datastart=-1209600
(( end - now < 157680001 )) && dataend="+157680001"
(( start > -1209600 )) && datastart=-1209600
(( end < 157680001 )) && dataend="+157680001"
(( start > 0 )) && start="+$start"
(( end > 0 )) && end="+$end"
(( datastart > 0 )) && datastart="+$datastart"
rrdtool graph - \
-a PNG \
-w $graph_width \
-v "${uinames[$graph]}" \
-v $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

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/*
* IngRRD (https://forge.riquer.fr/p/ingrrd/)
* Copyright (C) 2014-2015 Vincent Riquer
* Copyright (C) 2014 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,13 +59,6 @@ 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;
@ -120,7 +113,7 @@ th.AP,td.AP {
}
th.badge,td.badge {
/* width: 170px;*/
width: 170px;
}
a.badge {

View File

@ -1,21 +1,5 @@
#!/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

View File

@ -1,127 +0,0 @@
#!/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
}

View File

@ -1,39 +1,11 @@
#!/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 \
@ -41,11 +13,11 @@ declare -a \
golds \
platinums \
blacks \
nextbronze \
nextsilver \
nextgold \
nextplatinum \
nextblack \
upbronze \
upsilver \
upgold \
upplatinum \
upblack \
declare -i \
bronzecount \
@ -61,7 +33,6 @@ declare \
graph \
start \
end \
prevperiod \
want_ds=(
AP

238
lib/image
View File

@ -1,238 +0,0 @@
#!/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// /:}"
}

View File

@ -1,49 +0,0 @@
#!/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
}

View File

@ -1,21 +1,5 @@
#!/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 \
@ -67,18 +51,16 @@ medals() {
then
(( bronzecount++ ))
bronzes+=( "$stat" )
hasbronze["$stat"]=1
else
(( upbronze["$stat"]=last["$stat"] * 100 / bronze["$stat"]))
upbronze[last["$stat"] * 100 / bronze["$stat"]]+="$stat "
fi
if (( last["$stat"] >= silver["$stat"] ))
then
(( silvercount++ ))
silvers+=( "$stat" )
hassilver["$stat"]=1
elif (( last["$stat"] >= bronze["$stat"] ))
then
(( upsilver["$stat"]=( last["$stat"] - bronze["$stat"] ) * 100 / ( silver["$stat"] - bronze["$stat"] ) ))
upsilver[( last["$stat"] - bronze["$stat"] ) * 100 / ( silver["$stat"] - bronze["$stat"] )]+="$stat "
else
nosilver["$stat"]=1
fi
@ -86,10 +68,9 @@ medals() {
then
(( goldcount++ ))
golds+=( "$stat" )
hasgold["$stat"]=1
elif (( last["$stat"] >= silver["$stat"] ))
then
(( upgold["$stat"]=( last["$stat"] - silver["$stat"] ) * 100 / ( gold["$stat"] - silver["$stat"] ) ))
upgold[( last["$stat"] - silver["$stat"] ) * 100 / ( gold["$stat"] - silver["$stat"] )]+="$stat "
else
nogold["$stat"]=1
fi
@ -97,10 +78,9 @@ medals() {
then
(( platinumcount++ ))
platinums+=( "$stat" )
hasplatinum["$stat"]=1
elif (( last["$stat"] >= gold["$stat"] ))
then
(( upplatinum["$stat"]=( last["$stat"] - gold["$stat"] ) * 100 / ( platinum["$stat"] - gold["$stat"] ) ))
upplatinum[( last["$stat"] - gold["$stat"] ) * 100 / ( platinum["$stat"] - gold["$stat"] )]+="$stat "
else
noplatinum["$stat"]=1
fi
@ -108,10 +88,9 @@ medals() {
then
(( blackcount++ ))
blacks+=( "$stat" )
hasblack["$stat"]=1
elif (( last["$stat"] >= platinum["$stat"] ))
then
(( upblack["$stat"]=( last["$stat"] - platinum["$stat"]) * 100 / ( black["$stat"] - platinum["$stat"] ) ))
upblack[( last["$stat"] - platinum["$stat"] ) * 100 / ( black["$stat"] - platinum["$stat"] )]+="$stat "
else
noblack["$stat"]=1
fi

View File

@ -1,47 +0,0 @@
#!/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&amp;start=$start&amp;end=$end#$stat">
<img
class="badge"
src="/${img//_/-}-$level.png"
title="$stat $percent%"
alt="$stat $level" />
</a>&nbsp;($thisdate)
EOHTML
}

View File

@ -1,21 +1,5 @@
#!/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 \
@ -30,7 +14,6 @@ read_query_string() {
}"
exprtime='[[:alnum:]-]+'
exprgraph='[[:alpha:]_]+'
exprprev='[[:digit:]]+[(d(ay)?)(w(eek)?)(month)(y(ear)?)]'
while read name value
do
case $name in
@ -49,9 +32,6 @@ read_query_string() {
show)
[[ $value == all ]] && show_all=1
;;
prevperiod)
[[ $value =~ $exprprev ]] && prevperiod=$value
;;
esac
done <<<"${query_data//=/ }"
fi

View File

@ -1,35 +1,16 @@
#!/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

View File

@ -1,39 +0,0 @@
#!/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'
)
}

View File

@ -1,21 +0,0 @@
#!/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"
}

View File

@ -1,38 +0,0 @@
#!/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
}

View File

@ -1,21 +1,5 @@
#!/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">
@ -38,15 +22,13 @@ show_current_level() {
</a>
EOHTML
done
for timestamp in ${!nextbronze[@]}
do
(( timestamp )) || continue
for stat in ${nextbronze[timestamp]}
for id in {100..0}
do
if (( upbronze[$stat] ))
then
(( greenlevel = upbronze[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
[ -z "${upbronze[id]}" ] && continue
(( greenlevel = id * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
for stat in ${upbronze[id]}
do
img=${stat,,}
cat <<-EOHTML
<a
@ -56,50 +38,12 @@ show_current_level() {
<img
class="minibadge"
src="/${img//_/-}-bronze.png"
title="$stat ${upbronze[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
title="$stat $id%"
alt="$stat bronze" />
</a>
EOHTML
fi
done
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&amp;start=$start&amp;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&amp;start=$start&amp;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">
@ -118,16 +62,14 @@ show_current_level() {
</a>
EOHTML
done
for timestamp in ${!nextsilver[@]}
do
(( timestamp )) || continue
for stat in ${nextsilver[timestamp]}
for id in {100..0}
do
img=${stat,,}
if (( upsilver[$stat] ))
then
(( greenlevel = upsilver[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
[ -z "${upsilver[id]}" ] && continue
(( greenlevel = id * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
for stat in ${upsilver[id]}
do
img=${stat,,}
cat <<-EOHTML
<a
class="badge"
@ -136,48 +78,15 @@ show_current_level() {
<img
class="minibadge"
src="/${img//_/-}-silver.png"
title="$stat ${upsilver[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
title="$stat $id%"
alt="$stat silver" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;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
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&amp;start=$start&amp;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
for stat in ${!nosilver[@]}
do
img=${stat,,}
cat <<-EOHTML
<a
class="badge"
@ -185,13 +94,11 @@ show_current_level() {
<img
class="nominibadge"
src="/${img//_/-}-silver.png"
title="$stat
($(date -d @$timestamp +%Y-%m-%d))"
title="$stat $id%"
alt="$stat silver" />
</a>
EOHTML
fi
done
done
cat <<-EOHTML
</td>
<td class="curbadge">
@ -210,52 +117,14 @@ show_current_level() {
</a>
EOHTML
done
for timestamp in ${!nextgold[@]}
for id in {100..0}
do
(( timestamp )) || continue
for stat in ${nextgold[timestamp]}
[ -z "${upgold[id]}" ] && continue
(( greenlevel = id * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
for stat in ${upgold[id]}
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&amp;start=$start&amp;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&amp;start=$start&amp;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
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"
@ -264,25 +133,26 @@ show_current_level() {
<img
class="minibadge"
src="/${img//_/-}-gold.png"
title="$stat ${upgold[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
title="$stat $id%"
alt="$stat gold" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;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
done
for stat in ${!nogold[@]}
do
img=${stat,,}
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="nominibadge"
src="/${img//_/-}-gold.png"
title="$stat $id%"
alt="$stat gold" />
</a>
EOHTML
done
cat <<-EOHTML
</td>
@ -302,52 +172,14 @@ show_current_level() {
</a>
EOHTML
done
for timestamp in ${!nextplatinum[@]}
for id in {100..0}
do
(( timestamp )) || continue
for stat in ${nextplatinum[timestamp]}
[ -z "${upplatinum[id]}" ] && continue
(( greenlevel = id * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
for stat in ${upplatinum[id]}
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&amp;start=$start&amp;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&amp;start=$start&amp;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
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"
@ -356,25 +188,26 @@ show_current_level() {
<img
class="minibadge"
src="/${img//_/-}-platinum.png"
title="$stat ${upplatinum[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
title="$stat $id%"
alt="$stat platinum" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;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
done
for stat in ${!noplatinum[@]}
do
img=${stat,,}
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="nominibadge"
src="/${img//_/-}-platinum.png"
title="$stat $id%"
alt="$stat platinum" />
</a>
EOHTML
done
cat <<-EOHTML
</td>
@ -394,52 +227,14 @@ show_current_level() {
</a>
EOHTML
done
for timestamp in ${!nextblack[@]}
for id in {100..0}
do
(( timestamp )) || continue
for stat in ${nextblack[timestamp]}
[ -z "${upblack[id]}" ] && continue
(( greenlevel = id * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
for stat in ${upblack[id]}
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&amp;start=$start&amp;end=$end#$stat">
<img
class="minibadge"
src="/${img//_/-}-black.png"
title="$stat ${upblack[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat black" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="nominibadge"
src="/${img//_/-}-black.png"
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"
@ -448,25 +243,26 @@ show_current_level() {
<img
class="minibadge"
src="/${img//_/-}-black.png"
title="$stat ${upblack[$stat]}%
(maybe one day)"
title="$stat $id%"
alt="$stat black" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="nominibadge"
src="/${img//_/-}-black.png"
title="$stat
(maybe one day)"
alt="$stat black" />
</a>
EOHTML
fi
done
done
for stat in ${!noblack[@]}
do
img=${stat,,}
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="nominibadge"
src="/${img//_/-}-black.png"
title="$stat $id%"
alt="$stat black" />
</a>
EOHTML
done
cat <<-EOHTML
</td>

View File

@ -1,19 +1,3 @@
# 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
View File

@ -1,21 +1,5 @@
# 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=/web/ingress-stats.riquer.fr/cache/
#CACHE_DIR=/var/www/ingRRD/cache
## FIXME change this according to your URLs:
#
@ -24,8 +8,6 @@ CACHE_DIR=/web/ingress-stats.riquer.fr/cache/
# /cgi/$user/add.html
IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI"
debug_import=3
rrdfile=ingress.rrd
graph_width=800
@ -47,46 +29,39 @@ L14color=8B1479
L15color=6B127D
L16color=591494
default_prevperiod=1month
now=$(date +%s)
(( default_start = now - 604800 ))
(( default_end = now + 1209600 ))
default_start=-604800
default_end=1209600
start=$default_start
end=$default_end
prevperiod=$default_prevperiod
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"
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
)
dsnames=(
AP
@ -115,29 +90,22 @@ dsnames=(
Field_x_Days
Mercenary
Hacker
Translator
Recruiter
Hackaton
)
medals=(
Explorer
Seer
Walked
Hacker
Builder
Connector
Mind_Controller
MU
Recharger
Liberator
Pioneer
Purifier
Guardian
Engineer
Hacker
Translator
Recruiter
Hackaton
Mercenary
Engineer
Walked
)
## (0) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
@ -231,33 +199,3 @@ 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[""]=