Skip to content

Commit

Permalink
Merge branch 'devel' for version 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierBerger committed Jan 6, 2015
2 parents 51d314b + b088d7c commit d5bfc80
Show file tree
Hide file tree
Showing 48 changed files with 4,034 additions and 3,301 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.9.1
2.10
67 changes: 41 additions & 26 deletions rpimonitor/rpimonitord
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

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

#use diagnostics;
Expand All @@ -41,10 +41,6 @@ sub new
$this->Debug(3,"");
$this->{'rrd'}=();
$this->{'daemon'}->{'confFiles'} = [];
#$this->{'counter'}->{'static'} = 0;
#$this->{'counter'}->{'dynamic'} = 0;
#$this->{'counter'}->{'status'} = 0;
#$this->{'counter'}->{'statistics'} = 0;
return $this;
}

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

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

foreach ( @{$this->{'daemon'}->{'confFiles'}} ) {
#print "$_\n";
$this->LoadFile($_);
}
delete($this->{'daemon'}->{'confFiles'});

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

# manage menu
foreach (@{$this->{'web'}->{'status'}}) {
$_->{'name'} and push(@{$this->{'menu'}->{'status'}}, $_->{'name'});
$_->{'name'} and push(@{$this->{'web'}->{'menu'}->{'status'}}, $_->{'name'});
}
foreach (@{$this->{'web'}->{'statistics'}}) {
$_->{'name'} and push(@{$this->{'menu'}->{'statistics'}}, $_->{'name'});
$_->{'name'} and push(@{$this->{'web'}->{'menu'}->{'statistics'}}, $_->{'name'});
}
foreach (@{$this->{'web'}->{'addons'}}) {
$_->{'name'} and push(@{$this->{'web'}->{'menu'}->{'addons'}}, $_->{'name'});
}

$this->{'sharedmem'} = IPC::ShareLite->new(
Expand Down Expand Up @@ -267,7 +267,7 @@ use POSIX;
use IO::Handle;
use HTTP::Daemon;
use HTTP::Status;
use JSON;
use JSON -convert_blessed_universally;
#use Data::Dumper;

sub new
Expand All @@ -278,6 +278,8 @@ sub new
# List of files to be delivered
my @paths = (
"/",
"/all.json",
"/addons.json",
"/static.json",
"/dynamic.json",
"/status.json",
Expand All @@ -289,9 +291,9 @@ sub new
"/favicon.ico",

"/index.html",
"/addons.html",
"/statistics.html",
"/status.html",
"/shellinabox.html",
"/cacert.pem",
"/certificate.p12",
"/shellinabox",
Expand All @@ -311,6 +313,8 @@ sub new
"/js/rpimonitor.shellinabox.js",
"/js/rpimonitor.statistics.js",
"/js/rpimonitor.status.js",
"/js/rpimonitor.utils.js",
"/js/rpimonitor.addons.js",
"/js/rpimonitor.index.js",
"/js/rpimonitor.js",
"/js/jsqrencode.min.js",
Expand Down Expand Up @@ -443,12 +447,14 @@ sub DoGET
#The file need to be known or we return an error
my $isvalid;
foreach(@{$this->{'paths'}}) {
if ( $path =~ /$_$/) {
if ( $path =~ /$_$/ ){
$isvalid=1;
$path=$_;
last;
}
}
$isvalid ||= ( $path =~ /\/addons\// );

#$isvalid or $connection->send_error(404,"<br><b>$path</b> not in <br>". join ('<br>',@{$this->{'paths'}} )) and return;
$isvalid or $this->SendError(404);

Expand Down Expand Up @@ -485,12 +491,17 @@ sub Run
unshift ( @{$this->{'paths'}}, $1);
}
@{$this->{'paths'}} = ( @{ $configuration->{'rrdlist'}}, @{$this->{'paths'}} );
$this->{'status'} = encode_json(\@{$configuration->{'web'}->{'status'}});
$this->{'statistics'} = encode_json(\@{$configuration->{'web'}->{'statistics'}});
$this->{'friends'} = encode_json(\@{$configuration->{'web'}->{'friends'}});
$this->{'page'} = encode_json(\%{$configuration->{'web'}->{'page'}});
$this->{'static'} = encode_json(\%{$monitor->{'static'}});
$this->{'menu'} = encode_json(\%{$configuration->{'menu'}});
$this->{'status'} = to_json(\@{$configuration->{'web'}->{'status'}});
$this->{'statistics'} = to_json(\@{$configuration->{'web'}->{'statistics'}});
$this->{'friends'} = to_json(\@{$configuration->{'web'}->{'friends'}});
$this->{'page'} = to_json(\%{$configuration->{'web'}->{'page'}});
$this->{'static'} = to_json(\%{$monitor->{'static'}});
$this->{'menu'} = to_json(\%{$configuration->{'web'}->{'menu'}});
$this->{'addons'} = to_json(\@{$configuration->{'web'}->{'addons'}});
my $json = JSON->new;
$json = $json->allow_blessed([$configuration]);
$json = $json->convert_blessed([$configuration]);
$this->{'all'} = $json->encode( \%{$configuration} );
$this->{'version'} = "{\"version\":\"$configuration->{'version'}\"}";
#print Data::Dumper->Dump([$this->{'paths'}]);

Expand Down Expand Up @@ -563,27 +574,31 @@ sub Run
# write json if server is not running
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/static.json")
or warn $!;
print FILE encode_json \%{$this->{'static'}} ;
print FILE to_json \%{$this->{'static'}} ;
close(FILE);
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/status.json")
or warn $!;
print FILE encode_json \@{$configuration->{'web'}->{'status'}} ;
print FILE to_json \@{$configuration->{'web'}->{'status'}} ;
close(FILE);
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/page.json")
or warn $!;
print FILE encode_json \%{$configuration->{'web'}->{'page'}} ;
print FILE to_json \%{$configuration->{'web'}->{'page'}} ;
close(FILE);
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/statistics.json")
or warn $!;
print FILE encode_json \@{$configuration->{'web'}->{'statistics'}} ;
print FILE to_json \@{$configuration->{'web'}->{'statistics'}} ;
close(FILE);
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/friends.json")
or warn $!;
print FILE encode_json(\@{$configuration->{'web'}->{'friends'}});
print FILE to_json(\@{$configuration->{'web'}->{'friends'}});
close(FILE);
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/menu.json")
or warn $!;
print FILE encode_json(\%{$configuration->{'menu'}});
print FILE to_json(\%{$configuration->{'web'}->{'menu'}});
close(FILE);
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/addons.json")
or warn $!;
print FILE to_json(\@{$configuration->{'web'}->{'addons'}});
close(FILE);
open(FILE, "> $configuration->{'daemon'}->{'webroot'}/version.json")
or warn $!;
Expand Down Expand Up @@ -668,7 +683,7 @@ sub Status
my ($sec,$min,$hour,$mday,$mon,$year) = (localtime)[0,1,2,3,4,5];
@{$this->{'dynamic'}->{'localtime'}}=($year+1900,$mon+1,$mday,$hour,$min,$sec);
my $json=encode_json \%{$this->{'dynamic'}};
my $json=to_json \%{$this->{'dynamic'}};
$this->Debug(4,"\n$json");
# if embeded server is not used, we write the json file else the
Expand Down
16 changes: 16 additions & 0 deletions rpimonitor/template/bananian.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
web.page.icon='img/logo.png'
web.page.menutitle='BPi-Monitor <sub>('+data.hostname+')</sub>'
web.page.pagetitle='BPi-Monitor ('+data.hostname+')'

web.status.1.name=Banana Pi
web.statistics.1.name=Banana Pi

include=/etc/rpimonitor/template/version.conf
include=/etc/rpimonitor/template/uptime.conf
include=/etc/rpimonitor/template/cpu_bananian.conf
include=/etc/rpimonitor/template/pmu_bananian.conf
include=/etc/rpimonitor/template/temperature_bananian.conf
include=/etc/rpimonitor/template/memory.conf
include=/etc/rpimonitor/template/swap.conf
include=/etc/rpimonitor/template/sdcard.conf
include=/etc/rpimonitor/template/network.conf
1 change: 1 addition & 0 deletions rpimonitor/template/cpu.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ web.status.1.content.1.icon=cpu.png
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)
web.status.1.content.1.line.2="CPU frequency: <b>" + data.cpu_frequency + "MHz</b> Voltage: <b>" + data.cpu_voltage + "V</b>"
web.status.1.content.1.line.3="Scaling governor: <b>" + data.scaling_governor + "</b>"
#web.status.1.content.1.line.4=InsertHTML("/addons/top3/top3.html")

web.statistics.1.content.1.name=CPU Loads
web.statistics.1.content.1.graph.1=load1
Expand Down
69 changes: 69 additions & 0 deletions rpimonitor/template/cpu_bananian.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
########################################################################
# Extract CPU information
# Page: 1
# Information Status Statistics
# - cpu frequency - yes - yes
# - pmu voltage - no - yes
# - cpu load 1, 5, 15 - yes - yes
# - cpu scaling governor - yes - no
# - pmu current - yes - yes
# - pmu consumption (V * A) - no - yes
########################################################################
dynamic.1.name=cpu_frequency
dynamic.1.source=/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
dynamic.1.regexp=(.*)
dynamic.1.postprocess=$1/1000
dynamic.1.rrd=GAUGE

dynamic.2.name=pmu_voltage
dynamic.2.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now
dynamic.2.regexp=(.*)
dynamic.2.postprocess=$1/1000000
dynamic.2.rrd=GAUGE

dynamic.3.name=load1,load5,load15
dynamic.3.source=/proc/loadavg
dynamic.3.regexp=^(\S+)\s(\S+)\s(\S+)
dynamic.3.postprocess=
dynamic.3.rrd=GAUGE

dynamic.4.name=scaling_governor
dynamic.4.source=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
dynamic.4.regexp=(.*)
dynamic.4.postprocess=
dynamic.4.rrd=

dynamic.5.name=pmu_current
dynamic.5.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now
dynamic.5.regexp=(.*)
dynamic.5.postprocess=$1/1000
dynamic.5.rrd=GAUGE

dynamic.6.name=pmu_consumption
dynamic.6.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now
dynamic.6.regexp=(.*)
dynamic.6.postprocess=$1/1000000 * $this->{'dynamic'}->{'pmu_voltage'}
dynamic.6.rrd=GAUGE

web.status.1.content.1.name=CPU / PMU
web.status.1.content.1.icon=cpu.png
web.status.1.content.1.line.1="Loads: <b>" + data.load1 + "</b> [1min] - <b>" + data.load5 + "</b> [5min] - <b>" + data.load15 + "</b> [15min]"
web.status.1.content.1.line.2="CPU frequency: <b>" + data.cpu_frequency + "MHz</b> PMU Current: <b>" + data.pmu_current + "mA</b>"
web.status.1.content.1.line.3="Scaling governor: <b>" + data.scaling_governor + "</b>"

web.statistics.1.content.1.name=Load / Clock speed / PMU
web.statistics.1.content.1.graph.1=load1
web.statistics.1.content.1.graph.2=load5
web.statistics.1.content.1.graph.3=load15
web.statistics.1.content.1.graph.4=pmu_consumption
web.statistics.1.content.1.graph.5=cpu_frequency
web.statistics.1.content.1.graph.6=pmu_current
web.statistics.1.content.1.ds_graph_options.load1.label=Load 1 min
web.statistics.1.content.1.ds_graph_options.load5.label=Load 5 min
web.statistics.1.content.1.ds_graph_options.load15.label=Load 15 min
web.statistics.1.content.1.ds_graph_options.pmu_consumption.label=PMU consumption (W)
web.statistics.1.content.1.ds_graph_options.cpu_frequency.label=Clock speed (MHz)
web.statistics.1.content.1.ds_graph_options.pmu_current.label=PMU Current (mA)
web.statistics.1.content.1.ds_graph_options.cpu_frequency.yaxis=2
web.statistics.1.content.1.ds_graph_options.pmu_current.yaxis=2
web.statistics.1.content.1.graph_options.y2axis={ position: "right" }
84 changes: 84 additions & 0 deletions rpimonitor/template/pmu_bananian.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
########################################################################
# Extract PMU information
# Page: 1
# Information Status Statistics
# - pmu usb voltage - no - yes
# - pmu pwr voltage - no - yes
# - pmu usb current - no - yes
# - pmu pwr current - no - yes
# - PWR consumption - yes - no
# - USB consumption - yes - no
#
# logo from http://www.apkdad.com/wp-content/uploads/2013/01/Battery-Icon1.png
########################################################################
dynamic.1.name=pmu_usb_voltage
dynamic.1.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/usb/voltage_now
dynamic.1.regexp=(.*)
dynamic.1.postprocess=$1/1000000
dynamic.1.rrd=GAUGE

dynamic.2.name=pmu_ac_voltage
dynamic.2.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/voltage_now
dynamic.2.regexp=(.*)
dynamic.2.postprocess=$1/1000000
dynamic.2.rrd=GAUGE

dynamic.3.name=pmu_usb_current
dynamic.3.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/usb/current_now
dynamic.3.regexp=(.*)
dynamic.3.postprocess=$1/1000
dynamic.3.rrd=GAUGE

dynamic.4.name=pmu_ac_current
dynamic.4.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now
dynamic.4.regexp=(.*)
dynamic.4.postprocess=$1/1000
dynamic.4.rrd=GAUGE

dynamic.5.name=pmu_usb_consumption
dynamic.5.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/usb/current_now
dynamic.5.regexp=(.*)
dynamic.5.postprocess=$this->{'dynamic'}->{'pmu_usb_voltage'} * $1 / 1000
dynamic.5.rrd=GAUGE

dynamic.6.name=pmu_ac_consumption
dynamic.6.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/axp20-supplyer.28/power_supply/ac/current_now
dynamic.6.regexp=(.*)
dynamic.6.postprocess=$this->{'dynamic'}->{'pmu_ac_voltage'} * $1 / 1000
dynamic.6.rrd=GAUGE

dynamic.7.name=pmu_cur_temp
dynamic.7.source=/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input
dynamic.7.regexp=(.*)
dynamic.7.postprocess=$1/1000
dynamic.7.rrd=GAUGE

web.status.1.content.1.name=Consumption
web.status.1.content.1.icon=pmu.png
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>"

web.statistics.1.content.1.name=PMU current/voltage
web.statistics.1.content.1.graph.1=pmu_ac_voltage
web.statistics.1.content.1.graph.2=pmu_usb_voltage
web.statistics.1.content.1.graph.3=pmu_ac_current
web.statistics.1.content.1.graph.4=pmu_usb_current
web.statistics.1.content.1.ds_graph_options.pmu_ac_voltage.label=Voltage PWR in (V)
web.statistics.1.content.1.ds_graph_options.pmu_usb_voltage.label=Voltage USB in (V)
web.statistics.1.content.1.ds_graph_options.pmu_ac_current.label=Current PWR in (mA)
web.statistics.1.content.1.ds_graph_options.pmu_usb_current.label=Current USB in (mA)
web.statistics.1.content.1.ds_graph_options.pmu_ac_voltage.yaxis=1
web.statistics.1.content.1.ds_graph_options.pmu_usb_voltage.yaxis=1
web.statistics.1.content.1.ds_graph_options.pmu_ac_current.yaxis=2
web.statistics.1.content.1.ds_graph_options.pmu_usb_current.yaxis=2
web.statistics.1.content.1.graph_options.y1axis={ position: "left", min: 4.5, max: 5.5 }
web.statistics.1.content.1.graph_options.y2axis={ position: "right" }

web.statistics.1.content.2.name=Consumption / temperature
web.statistics.1.content.2.graph.1=pmu_ac_consumption
web.statistics.1.content.2.graph.2=pmu_usb_consumption
web.statistics.1.content.2.graph.3=pmu_cur_temp
web.statistics.1.content.2.ds_graph_options.pmu_ac_consumption.label=Consumption (W)
web.statistics.1.content.2.ds_graph_options.pmu_usb_consumption.label=USB devices (W)
web.statistics.1.content.2.ds_graph_options.pmu_cur_temp.label="Current PMU temp (&#176;C)"
web.statistics.1.content.2.ds_graph_options.pmu_cur_temp.yaxis=2
web.statistics.1.content.2.graph_options.y2axis={ position: "right" }
Loading

0 comments on commit d5bfc80

Please sign in to comment.