Skip to content

Commit d5bfc80

Browse files
committed
Merge branch 'devel' for version 2.10
2 parents 51d314b + b088d7c commit d5bfc80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4034
-3301
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.9.1
1+
2.10

rpimonitor/rpimonitord

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
#
1818

19-
#print encode_json \%{$configuration->{'config'}->{'web'}};
19+
#print to_json \%{$configuration->{'config'}->{'web'}};
2020
#print Data::Dumper->Dump([$configuration]);
2121

2222
#use diagnostics;
@@ -41,10 +41,6 @@ sub new
4141
$this->Debug(3,"");
4242
$this->{'rrd'}=();
4343
$this->{'daemon'}->{'confFiles'} = [];
44-
#$this->{'counter'}->{'static'} = 0;
45-
#$this->{'counter'}->{'dynamic'} = 0;
46-
#$this->{'counter'}->{'status'} = 0;
47-
#$this->{'counter'}->{'statistics'} = 0;
4844
return $this;
4945
}
5046

@@ -65,13 +61,14 @@ sub Load
6561
$_ = abs_path($0);
6662
my ($path,$file) = /(.*)\/([^\/]*)$/;
6763

68-
if ( scalar(@{$this->{'daemon'}->{'confFiles'}}) == 0 ) {
69-
@{$this->{'daemon'}->{'confFiles'}} = ( @{$this->{'daemon'}->{'confFiles'}}, glob "/etc/rpimonitor/*.conf" ) ;
70-
}
64+
push(@{$this->{'daemon'}->{'confFiles'}},"/etc/rpimonitor/data.conf");
65+
push(@{$this->{'daemon'}->{'confFiles'}},"/etc/rpimonitor/daemon.conf");
7166

7267
foreach ( @{$this->{'daemon'}->{'confFiles'}} ) {
68+
#print "$_\n";
7369
$this->LoadFile($_);
7470
}
71+
delete($this->{'daemon'}->{'confFiles'});
7572

7673
# Set version (used by web pagescache mechanism)
7774
$this->{'version'} = localtime();
@@ -123,10 +120,13 @@ sub Load
123120

124121
# manage menu
125122
foreach (@{$this->{'web'}->{'status'}}) {
126-
$_->{'name'} and push(@{$this->{'menu'}->{'status'}}, $_->{'name'});
123+
$_->{'name'} and push(@{$this->{'web'}->{'menu'}->{'status'}}, $_->{'name'});
127124
}
128125
foreach (@{$this->{'web'}->{'statistics'}}) {
129-
$_->{'name'} and push(@{$this->{'menu'}->{'statistics'}}, $_->{'name'});
126+
$_->{'name'} and push(@{$this->{'web'}->{'menu'}->{'statistics'}}, $_->{'name'});
127+
}
128+
foreach (@{$this->{'web'}->{'addons'}}) {
129+
$_->{'name'} and push(@{$this->{'web'}->{'menu'}->{'addons'}}, $_->{'name'});
130130
}
131131

132132
$this->{'sharedmem'} = IPC::ShareLite->new(
@@ -267,7 +267,7 @@ use POSIX;
267267
use IO::Handle;
268268
use HTTP::Daemon;
269269
use HTTP::Status;
270-
use JSON;
270+
use JSON -convert_blessed_universally;
271271
#use Data::Dumper;
272272

273273
sub new
@@ -278,6 +278,8 @@ sub new
278278
# List of files to be delivered
279279
my @paths = (
280280
"/",
281+
"/all.json",
282+
"/addons.json",
281283
"/static.json",
282284
"/dynamic.json",
283285
"/status.json",
@@ -289,9 +291,9 @@ sub new
289291
"/favicon.ico",
290292

291293
"/index.html",
294+
"/addons.html",
292295
"/statistics.html",
293296
"/status.html",
294-
"/shellinabox.html",
295297
"/cacert.pem",
296298
"/certificate.p12",
297299
"/shellinabox",
@@ -311,6 +313,8 @@ sub new
311313
"/js/rpimonitor.shellinabox.js",
312314
"/js/rpimonitor.statistics.js",
313315
"/js/rpimonitor.status.js",
316+
"/js/rpimonitor.utils.js",
317+
"/js/rpimonitor.addons.js",
314318
"/js/rpimonitor.index.js",
315319
"/js/rpimonitor.js",
316320
"/js/jsqrencode.min.js",
@@ -443,12 +447,14 @@ sub DoGET
443447
#The file need to be known or we return an error
444448
my $isvalid;
445449
foreach(@{$this->{'paths'}}) {
446-
if ( $path =~ /$_$/) {
450+
if ( $path =~ /$_$/ ){
447451
$isvalid=1;
448452
$path=$_;
449453
last;
450454
}
451455
}
456+
$isvalid ||= ( $path =~ /\/addons\// );
457+
452458
#$isvalid or $connection->send_error(404,"<br><b>$path</b> not in <br>". join ('<br>',@{$this->{'paths'}} )) and return;
453459
$isvalid or $this->SendError(404);
454460

@@ -485,12 +491,17 @@ sub Run
485491
unshift ( @{$this->{'paths'}}, $1);
486492
}
487493
@{$this->{'paths'}} = ( @{ $configuration->{'rrdlist'}}, @{$this->{'paths'}} );
488-
$this->{'status'} = encode_json(\@{$configuration->{'web'}->{'status'}});
489-
$this->{'statistics'} = encode_json(\@{$configuration->{'web'}->{'statistics'}});
490-
$this->{'friends'} = encode_json(\@{$configuration->{'web'}->{'friends'}});
491-
$this->{'page'} = encode_json(\%{$configuration->{'web'}->{'page'}});
492-
$this->{'static'} = encode_json(\%{$monitor->{'static'}});
493-
$this->{'menu'} = encode_json(\%{$configuration->{'menu'}});
494+
$this->{'status'} = to_json(\@{$configuration->{'web'}->{'status'}});
495+
$this->{'statistics'} = to_json(\@{$configuration->{'web'}->{'statistics'}});
496+
$this->{'friends'} = to_json(\@{$configuration->{'web'}->{'friends'}});
497+
$this->{'page'} = to_json(\%{$configuration->{'web'}->{'page'}});
498+
$this->{'static'} = to_json(\%{$monitor->{'static'}});
499+
$this->{'menu'} = to_json(\%{$configuration->{'web'}->{'menu'}});
500+
$this->{'addons'} = to_json(\@{$configuration->{'web'}->{'addons'}});
501+
my $json = JSON->new;
502+
$json = $json->allow_blessed([$configuration]);
503+
$json = $json->convert_blessed([$configuration]);
504+
$this->{'all'} = $json->encode( \%{$configuration} );
494505
$this->{'version'} = "{\"version\":\"$configuration->{'version'}\"}";
495506
#print Data::Dumper->Dump([$this->{'paths'}]);
496507

@@ -563,27 +574,31 @@ sub Run
563574
# write json if server is not running
564575
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/static.json")
565576
or warn $!;
566-
print FILE encode_json \%{$this->{'static'}} ;
577+
print FILE to_json \%{$this->{'static'}} ;
567578
close(FILE);
568579
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/status.json")
569580
or warn $!;
570-
print FILE encode_json \@{$configuration->{'web'}->{'status'}} ;
581+
print FILE to_json \@{$configuration->{'web'}->{'status'}} ;
571582
close(FILE);
572583
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/page.json")
573584
or warn $!;
574-
print FILE encode_json \%{$configuration->{'web'}->{'page'}} ;
585+
print FILE to_json \%{$configuration->{'web'}->{'page'}} ;
575586
close(FILE);
576587
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/statistics.json")
577588
or warn $!;
578-
print FILE encode_json \@{$configuration->{'web'}->{'statistics'}} ;
589+
print FILE to_json \@{$configuration->{'web'}->{'statistics'}} ;
579590
close(FILE);
580591
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/friends.json")
581592
or warn $!;
582-
print FILE encode_json(\@{$configuration->{'web'}->{'friends'}});
593+
print FILE to_json(\@{$configuration->{'web'}->{'friends'}});
583594
close(FILE);
584595
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/menu.json")
585596
or warn $!;
586-
print FILE encode_json(\%{$configuration->{'menu'}});
597+
print FILE to_json(\%{$configuration->{'web'}->{'menu'}});
598+
close(FILE);
599+
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/addons.json")
600+
or warn $!;
601+
print FILE to_json(\@{$configuration->{'web'}->{'addons'}});
587602
close(FILE);
588603
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/version.json")
589604
or warn $!;
@@ -668,7 +683,7 @@ sub Status
668683
my ($sec,$min,$hour,$mday,$mon,$year) = (localtime)[0,1,2,3,4,5];
669684
@{$this->{'dynamic'}->{'localtime'}}=($year+1900,$mon+1,$mday,$hour,$min,$sec);
670685
671-
my $json=encode_json \%{$this->{'dynamic'}};
686+
my $json=to_json \%{$this->{'dynamic'}};
672687
$this->Debug(4,"\n$json");
673688
674689
# if embeded server is not used, we write the json file else the

rpimonitor/template/bananian.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
web.page.icon='img/logo.png'
2+
web.page.menutitle='BPi-Monitor <sub>('+data.hostname+')</sub>'
3+
web.page.pagetitle='BPi-Monitor ('+data.hostname+')'
4+
5+
web.status.1.name=Banana Pi
6+
web.statistics.1.name=Banana Pi
7+
8+
include=/etc/rpimonitor/template/version.conf
9+
include=/etc/rpimonitor/template/uptime.conf
10+
include=/etc/rpimonitor/template/cpu_bananian.conf
11+
include=/etc/rpimonitor/template/pmu_bananian.conf
12+
include=/etc/rpimonitor/template/temperature_bananian.conf
13+
include=/etc/rpimonitor/template/memory.conf
14+
include=/etc/rpimonitor/template/swap.conf
15+
include=/etc/rpimonitor/template/sdcard.conf
16+
include=/etc/rpimonitor/template/network.conf

rpimonitor/template/cpu.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ web.status.1.content.1.icon=cpu.png
3737
web.status.1.content.1.line.1=JustGageBar("Load", "1min", 0, data.load1, 3, 100, 80)+" "+JustGageBar("Load", "5min", 0, data.load5, 3, 100, 80)+" "+JustGageBar("Load", "15min", 0, data.load15, 3, 100, 80)
3838
web.status.1.content.1.line.2="CPU frequency: <b>" + data.cpu_frequency + "MHz</b> Voltage: <b>" + data.cpu_voltage + "V</b>"
3939
web.status.1.content.1.line.3="Scaling governor: <b>" + data.scaling_governor + "</b>"
40+
#web.status.1.content.1.line.4=InsertHTML("/addons/top3/top3.html")
4041

4142
web.statistics.1.content.1.name=CPU Loads
4243
web.statistics.1.content.1.graph.1=load1
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
########################################################################
2+
# Extract CPU information
3+
# Page: 1
4+
# Information Status Statistics
5+
# - cpu frequency - yes - yes
6+
# - pmu voltage - no - yes
7+
# - cpu load 1, 5, 15 - yes - yes
8+
# - cpu scaling governor - yes - no
9+
# - pmu current - yes - yes
10+
# - pmu consumption (V * A) - no - yes
11+
########################################################################
12+
dynamic.1.name=cpu_frequency
13+
dynamic.1.source=/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
14+
dynamic.1.regexp=(.*)
15+
dynamic.1.postprocess=$1/1000
16+
dynamic.1.rrd=GAUGE
17+
18+
dynamic.2.name=pmu_voltage
19+
dynamic.2.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now
20+
dynamic.2.regexp=(.*)
21+
dynamic.2.postprocess=$1/1000000
22+
dynamic.2.rrd=GAUGE
23+
24+
dynamic.3.name=load1,load5,load15
25+
dynamic.3.source=/proc/loadavg
26+
dynamic.3.regexp=^(\S+)\s(\S+)\s(\S+)
27+
dynamic.3.postprocess=
28+
dynamic.3.rrd=GAUGE
29+
30+
dynamic.4.name=scaling_governor
31+
dynamic.4.source=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
32+
dynamic.4.regexp=(.*)
33+
dynamic.4.postprocess=
34+
dynamic.4.rrd=
35+
36+
dynamic.5.name=pmu_current
37+
dynamic.5.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now
38+
dynamic.5.regexp=(.*)
39+
dynamic.5.postprocess=$1/1000
40+
dynamic.5.rrd=GAUGE
41+
42+
dynamic.6.name=pmu_consumption
43+
dynamic.6.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now
44+
dynamic.6.regexp=(.*)
45+
dynamic.6.postprocess=$1/1000000 * $this->{'dynamic'}->{'pmu_voltage'}
46+
dynamic.6.rrd=GAUGE
47+
48+
web.status.1.content.1.name=CPU / PMU
49+
web.status.1.content.1.icon=cpu.png
50+
web.status.1.content.1.line.1="Loads: <b>" + data.load1 + "</b> [1min] - <b>" + data.load5 + "</b> [5min] - <b>" + data.load15 + "</b> [15min]"
51+
web.status.1.content.1.line.2="CPU frequency: <b>" + data.cpu_frequency + "MHz</b> PMU Current: <b>" + data.pmu_current + "mA</b>"
52+
web.status.1.content.1.line.3="Scaling governor: <b>" + data.scaling_governor + "</b>"
53+
54+
web.statistics.1.content.1.name=Load / Clock speed / PMU
55+
web.statistics.1.content.1.graph.1=load1
56+
web.statistics.1.content.1.graph.2=load5
57+
web.statistics.1.content.1.graph.3=load15
58+
web.statistics.1.content.1.graph.4=pmu_consumption
59+
web.statistics.1.content.1.graph.5=cpu_frequency
60+
web.statistics.1.content.1.graph.6=pmu_current
61+
web.statistics.1.content.1.ds_graph_options.load1.label=Load 1 min
62+
web.statistics.1.content.1.ds_graph_options.load5.label=Load 5 min
63+
web.statistics.1.content.1.ds_graph_options.load15.label=Load 15 min
64+
web.statistics.1.content.1.ds_graph_options.pmu_consumption.label=PMU consumption (W)
65+
web.statistics.1.content.1.ds_graph_options.cpu_frequency.label=Clock speed (MHz)
66+
web.statistics.1.content.1.ds_graph_options.pmu_current.label=PMU Current (mA)
67+
web.statistics.1.content.1.ds_graph_options.cpu_frequency.yaxis=2
68+
web.statistics.1.content.1.ds_graph_options.pmu_current.yaxis=2
69+
web.statistics.1.content.1.graph_options.y2axis={ position: "right" }
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
########################################################################
2+
# Extract PMU information
3+
# Page: 1
4+
# Information Status Statistics
5+
# - pmu usb voltage - no - yes
6+
# - pmu pwr voltage - no - yes
7+
# - pmu usb current - no - yes
8+
# - pmu pwr current - no - yes
9+
# - PWR consumption - yes - no
10+
# - USB consumption - yes - no
11+
#
12+
# logo from http://www.apkdad.com/wp-content/uploads/2013/01/Battery-Icon1.png
13+
########################################################################
14+
dynamic.1.name=pmu_usb_voltage
15+
dynamic.1.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/usb/voltage_now
16+
dynamic.1.regexp=(.*)
17+
dynamic.1.postprocess=$1/1000000
18+
dynamic.1.rrd=GAUGE
19+
20+
dynamic.2.name=pmu_ac_voltage
21+
dynamic.2.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now
22+
dynamic.2.regexp=(.*)
23+
dynamic.2.postprocess=$1/1000000
24+
dynamic.2.rrd=GAUGE
25+
26+
dynamic.3.name=pmu_usb_current
27+
dynamic.3.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/usb/current_now
28+
dynamic.3.regexp=(.*)
29+
dynamic.3.postprocess=$1/1000
30+
dynamic.3.rrd=GAUGE
31+
32+
dynamic.4.name=pmu_ac_current
33+
dynamic.4.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now
34+
dynamic.4.regexp=(.*)
35+
dynamic.4.postprocess=$1/1000
36+
dynamic.4.rrd=GAUGE
37+
38+
dynamic.5.name=pmu_usb_consumption
39+
dynamic.5.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/usb/current_now
40+
dynamic.5.regexp=(.*)
41+
dynamic.5.postprocess=$this->{'dynamic'}->{'pmu_usb_voltage'} * $1 / 1000
42+
dynamic.5.rrd=GAUGE
43+
44+
dynamic.6.name=pmu_ac_consumption
45+
dynamic.6.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now
46+
dynamic.6.regexp=(.*)
47+
dynamic.6.postprocess=$this->{'dynamic'}->{'pmu_ac_voltage'} * $1 / 1000
48+
dynamic.6.rrd=GAUGE
49+
50+
dynamic.7.name=pmu_cur_temp
51+
dynamic.7.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input
52+
dynamic.7.regexp=(.*)
53+
dynamic.7.postprocess=$1/1000
54+
dynamic.7.rrd=GAUGE
55+
56+
web.status.1.content.1.name=Consumption
57+
web.status.1.content.1.icon=pmu.png
58+
web.status.1.content.1.line.1="PWR in: <b>" + data.pmu_ac_consumption + " mW</b> USB OTG in: <b>" + data.pmu_usb_consumption + " mW</b>"
59+
60+
web.statistics.1.content.1.name=PMU current/voltage
61+
web.statistics.1.content.1.graph.1=pmu_ac_voltage
62+
web.statistics.1.content.1.graph.2=pmu_usb_voltage
63+
web.statistics.1.content.1.graph.3=pmu_ac_current
64+
web.statistics.1.content.1.graph.4=pmu_usb_current
65+
web.statistics.1.content.1.ds_graph_options.pmu_ac_voltage.label=Voltage PWR in (V)
66+
web.statistics.1.content.1.ds_graph_options.pmu_usb_voltage.label=Voltage USB in (V)
67+
web.statistics.1.content.1.ds_graph_options.pmu_ac_current.label=Current PWR in (mA)
68+
web.statistics.1.content.1.ds_graph_options.pmu_usb_current.label=Current USB in (mA)
69+
web.statistics.1.content.1.ds_graph_options.pmu_ac_voltage.yaxis=1
70+
web.statistics.1.content.1.ds_graph_options.pmu_usb_voltage.yaxis=1
71+
web.statistics.1.content.1.ds_graph_options.pmu_ac_current.yaxis=2
72+
web.statistics.1.content.1.ds_graph_options.pmu_usb_current.yaxis=2
73+
web.statistics.1.content.1.graph_options.y1axis={ position: "left", min: 4.5, max: 5.5 }
74+
web.statistics.1.content.1.graph_options.y2axis={ position: "right" }
75+
76+
web.statistics.1.content.2.name=Consumption / temperature
77+
web.statistics.1.content.2.graph.1=pmu_ac_consumption
78+
web.statistics.1.content.2.graph.2=pmu_usb_consumption
79+
web.statistics.1.content.2.graph.3=pmu_cur_temp
80+
web.statistics.1.content.2.ds_graph_options.pmu_ac_consumption.label=Consumption (W)
81+
web.statistics.1.content.2.ds_graph_options.pmu_usb_consumption.label=USB devices (W)
82+
web.statistics.1.content.2.ds_graph_options.pmu_cur_temp.label="Current PMU temp (&#176;C)"
83+
web.statistics.1.content.2.ds_graph_options.pmu_cur_temp.yaxis=2
84+
web.statistics.1.content.2.graph_options.y2axis={ position: "right" }

0 commit comments

Comments
 (0)