Compare commits
2 Commits
10ef216171
...
9ee47146db
Author | SHA1 | Date |
---|---|---|
|
9ee47146db | |
|
0dc57b2e6b |
33
stats.html
33
stats.html
|
@ -76,28 +76,31 @@
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const labels = [
|
const labels = [
|
||||||
'Sunday',
|
'day_date_1',
|
||||||
'Monday',
|
'day_date_2',
|
||||||
'Tuesday',
|
'day_date_3',
|
||||||
'Wednesday',
|
'day_date_4',
|
||||||
'Thursday',
|
'day_date_5',
|
||||||
'Friday',
|
'day_date_6',
|
||||||
'Saturday',
|
'day_date_7',
|
||||||
];
|
];
|
||||||
const data = {
|
const data = {
|
||||||
labels: labels,
|
labels: labels,
|
||||||
datasets: [{
|
datasets: [
|
||||||
|
{
|
||||||
label: 'Hours we had electricity from government',
|
label: 'Hours we had electricity from government',
|
||||||
backgroundColor: 'rgb(255, 99, 132)',
|
backgroundColor: 'rgb(255, 99, 132)',
|
||||||
borderColor: 'rgb(255, 99, 132)',
|
borderColor: 'rgb(255, 99, 132)',
|
||||||
data: [offtime_1, offtime_2, offtime_3, offtime_4, offtime_5, offtime_6, offtime_7],
|
data: [offtime_1, offtime_2, offtime_3, offtime_4, offtime_5, offtime_6, offtime_7],
|
||||||
fill: {
|
fill: true,
|
||||||
target: 'origin',
|
// fill: {
|
||||||
above: 'rgb(255, 0, 0)', // Area will be red above the origin
|
// target: 'origin',
|
||||||
below: 'rgb(0, 0, 255)' // And blue below the origin
|
// above: 'rgb(255, 0, 0)', // Area will be red above the origin
|
||||||
|
// below: 'rgb(0, 0, 255)' // And blue below the origin
|
||||||
},
|
//
|
||||||
}]
|
// },
|
||||||
|
},
|
||||||
|
]
|
||||||
};
|
};
|
||||||
const config = {
|
const config = {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
|
|
23
stats.sh
23
stats.sh
|
@ -68,7 +68,7 @@ do
|
||||||
fi
|
fi
|
||||||
if [[ $line = $lines ]]
|
if [[ $line = $lines ]]
|
||||||
then
|
then
|
||||||
time_decimal=$(echo $(date -d "$total_time" +'%H').$(($(date -d "$total_time" +'%M') * 100 / 60)))
|
time_decimal=$(echo $(date -d "$total_time" +'%H' | bc).$(($(date -d "$total_time" +'%M' | bc) * 100 / 60)))
|
||||||
echo "$current_date,$time_decimal" >> days.csv
|
echo "$current_date,$time_decimal" >> days.csv
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -83,17 +83,22 @@ while read in
|
||||||
do
|
do
|
||||||
hours=$(echo $in | cut -d, -f2)
|
hours=$(echo $in | cut -d, -f2)
|
||||||
line=$(( $line + 1 ))
|
line=$(( $line + 1 ))
|
||||||
|
date_var=$(echo $in | cut -d, -f1)
|
||||||
if [[ $line > $line_start ]]
|
if [[ $line > $line_start ]]
|
||||||
then
|
then
|
||||||
day_num=$(( $day_num + 1 ))
|
day_num=$(( $day_num + 1 ))
|
||||||
if [[ $day_num = 1 ]]; then day_1=$(echo $hours | sed "s/0//"); fi
|
if [[ $day_num = 1 ]]; then day_1=$(echo $hours | sed "s/0//"); day_date_1=$(echo $date_var | sed 's/\//\\\//g'); fi
|
||||||
if [[ $day_num = 2 ]]; then day_2=$(echo $hours | sed "s/0//"); fi
|
if [[ $day_num = 2 ]]; then day_2=$(echo $hours | sed "s/0//"); day_date_2=$(echo $date_var | sed 's/\//\\\//g'); fi
|
||||||
if [[ $day_num = 3 ]]; then day_3=$(echo $hours | sed "s/0//"); fi
|
if [[ $day_num = 3 ]]; then day_3=$(echo $hours | sed "s/0//"); day_date_3=$(echo $date_var | sed 's/\//\\\//g'); fi
|
||||||
if [[ $day_num = 4 ]]; then day_4=$(echo $hours | sed "s/0//"); fi
|
if [[ $day_num = 4 ]]; then day_4=$(echo $hours | sed "s/0//"); day_date_4=$(echo $date_var | sed 's/\//\\\//g'); fi
|
||||||
if [[ $day_num = 5 ]]; then day_5=$(echo $hours | sed "s/0//"); fi
|
if [[ $day_num = 5 ]]; then day_5=$(echo $hours | sed "s/0//"); day_date_5=$(echo $date_var | sed 's/\//\\\//g'); fi
|
||||||
if [[ $day_num = 6 ]]; then day_6=$(echo $hours | sed "s/0//"); fi
|
if [[ $day_num = 6 ]]; then day_6=$(echo $hours | sed "s/0//"); day_date_6=$(echo $date_var | sed 's/\//\\\//g'); fi
|
||||||
if [[ $day_num = 7 ]]; then day_7=$(echo $hours | sed "s/0//"); fi
|
if [[ $day_num = 7 ]]; then day_7=$(echo $hours | sed "s/0//"); day_date_7=$(echo $date_var | sed 's/\//\\\//g'); fi
|
||||||
fi
|
fi
|
||||||
done < days.csv
|
done < days.csv
|
||||||
|
|
||||||
cat stats.html | sed "s/offtime_1/$day_1/" | sed "s/offtime_2/$day_2/"| sed "s/offtime_3/$day_3/" | sed "s/offtime_4/$day_4/" | sed "s/offtime_5/$day_5/" | sed "s/offtime_6/$day_6/" | sed "s/offtime_7/$day_7/" > stats/index.html
|
hours_so_far=$(($(TZ='Asia/Beirut' date +'%H') - $(echo $day_7. | cut -d. -f1)))
|
||||||
|
|
||||||
|
cat stats.html | sed "s/offtime_1/$day_1/" | sed "s/offtime_2/$day_2/"| sed "s/offtime_3/$day_3/" | sed "s/offtime_4/$day_4/" | sed "s/offtime_5/$day_5/" | sed "s/offtime_6/$day_6/" | sed "s/offtime_7/$day_7/" | sed "s/hours_so_far_day/$hours_so_far/" | sed "s/day_date_1/$day_date_1/" | sed "s/day_date_2/$day_date_2/" | sed "s/day_date_3/$day_date_3/" | sed "s/day_date_4/$day_date_4/" | sed "s/day_date_5/$day_date_5/" | sed "s/day_date_6/$day_date_6/" | sed "s/day_date_7/$day_date_7/" > /usr/local/apache2/htdocs/stats/index.html
|
||||||
|
|
||||||
|
chown daemon:daemon /usr/local/apache2/htdocs/stats/index.html
|
||||||
|
|
Loading…
Reference in New Issue