From 82a6effcd89b253b72c3822108f895d742917fda Mon Sep 17 00:00:00 2001 From: Xavier Berger Date: Sun, 17 Aug 2014 22:00:07 +0200 Subject: [PATCH 01/24] Version 2.8 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1effb00..a4412fa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.7 +2.8 From c81d6b32a9077f5c51f8fa8208ea97cb03d5442a Mon Sep 17 00:00:00 2001 From: Xavier Berger Date: Sun, 17 Aug 2014 22:00:42 +0200 Subject: [PATCH 02/24] Add 'Badge' function for status page (similar to Label) --- rpimonitor/template/services.conf | 3 ++- rpimonitor/web/js/rpimonitor.status.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/rpimonitor/template/services.conf b/rpimonitor/template/services.conf index 6e27fe7..512339c 100644 --- a/rpimonitor/template/services.conf +++ b/rpimonitor/template/services.conf @@ -20,4 +20,5 @@ dynamic.19.regexp=tcp .*:(443).*LISTEN web.status.1.content.9.name=Servers web.status.1.content.9.icon=daemons.png -web.status.1.content.9.line.1="ssh : "+Label(data.ssh,"==22","OK","label-success")+Label(data.ssh,"!=22","KO","label-important")+" rpimonitor : "+Label(data.rpimonitor,"==8888","OK","label-success")+Label(data.rpimonitor,"!=8888","KO","label-important")+" nginx http : "+Label(data.http,"==80","OK","label-success")+Label(data.http,"!=80","KO","label-important")+" nginx https : "+Label(data.https,"==443","OK","label-success")+Label(data.https,"!=443","KO","label-important") +web.status.1.content.9.line.1="ssh : "+Label(data.ssh,"==22","OK","success")+Label(data.ssh,"!=22","KO","important")+" rpimonitor : "+Label(data.rpimonitor,"==8888","OK","success")+Label(data.rpimonitor,"!=8888","KO","important")+" nginx http : "+Label(data.http,"==80","OK","success")+Label(data.http,"!=80","KO","important")+" nginx https : "+Label(data.https,"==443","OK","success")+Label(data.https,"!=443","KO","important") +web.status.1.content.9.line.2="ssh : "+Badge(data.ssh,"==22","OK","success")+Badge(data.ssh,"!=22","KO","important")+" rpimonitor : "+Badge(data.rpimonitor,"==8888","OK","success")+Badge(data.rpimonitor,"!=8888","KO","important")+" nginx http : "+Badge(data.http,"==80","OK","success")+Badge(data.http,"!=80","KO","important")+" nginx https : "+Badge(data.https,"==443","OK","success")+Badge(data.https,"!=443","KO","important") diff --git a/rpimonitor/web/js/rpimonitor.status.js b/rpimonitor/web/js/rpimonitor.status.js index da83970..efda559 100644 --- a/rpimonitor/web/js/rpimonitor.status.js +++ b/rpimonitor/web/js/rpimonitor.status.js @@ -91,10 +91,20 @@ function ProgressBar(value, max){ function Label(data,formula, text, level){ var result=""; + if ( level.indexOf('label-') < 0 ) { level = 'label-'+level }; eval ( "if ("+data+formula+") result=\""+text+"\"" ); return result; } +function Badge(data,formula, text, level){ + var result=""; + if ( level.indexOf('badge-') < 0 ) { level = 'badge-'+level }; + if ( false ) level = 'badge-'+level; + eval ( "if ("+data+formula+") result=\""+text+"\"" ); + return result; +} + + var clocksec=0; function Clock(localtime){ clocksec=localtime[5]; From 85a51f3c243b6753e92a0bd613739fa263a8c52d Mon Sep 17 00:00:00 2001 From: Xavier Berger Date: Mon, 18 Aug 2014 10:21:16 +0200 Subject: [PATCH 03/24] Fix upstart script and make it start with default configuration --- tools/upstart/rpimonitord.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/upstart/rpimonitord.conf b/tools/upstart/rpimonitord.conf index db10796..f97437d 100644 --- a/tools/upstart/rpimonitord.conf +++ b/tools/upstart/rpimonitord.conf @@ -9,7 +9,7 @@ stop on runlevel [!2345] script cd /usr/local/rpimonitor/ - exec /usr/bin/rpimonitord -c /etc/rpimonitor/rpimonitord.conf -c /etc/rpimonitor/default.conf + exec /usr/bin/rpimonitord end script respawn From 21ef65294c0e69956e89d86d6d40f61e14ebcbe4 Mon Sep 17 00:00:00 2001 From: Xavier Berger Date: Mon, 18 Aug 2014 10:34:06 +0200 Subject: [PATCH 04/24] Simplify sysVinit script --- init/cron.d/rpimonitor | 2 +- init/default/rpimonitor | 9 --------- init/init.d/rpimonitor | 27 +-------------------------- scripts/updatePackagesStatus.sh | 11 +++++++++++ 4 files changed, 13 insertions(+), 36 deletions(-) delete mode 100644 init/default/rpimonitor create mode 100755 scripts/updatePackagesStatus.sh diff --git a/init/cron.d/rpimonitor b/init/cron.d/rpimonitor index 662632f..8c51347 100644 --- a/init/cron.d/rpimonitor +++ b/init/cron.d/rpimonitor @@ -2,6 +2,6 @@ 05 03 * * * root /usr/bin/apt-get update > /dev/null 2>&1 # run at 03:10 to update status -10 03 * * * root /etc/init.d/rpimonitor update > /dev/null 2>&1 +10 03 * * * root /usr/share/rpimonitor/scripts/updatePackagesStatus.sh > /dev/null 2>&1 diff --git a/init/default/rpimonitor b/init/default/rpimonitor deleted file mode 100644 index 441a681..0000000 --- a/init/default/rpimonitor +++ /dev/null @@ -1,9 +0,0 @@ -# DEAMON_START=0 : do not start rpimonitord at boot -# DEAMON_START=1 : rpimonitord start automatically at boot -DAEMON_START=1 - -#CONFFILE="-c /etc/rpimonitor/rpimonitord.conf -c /etc/rpimonitor/rpimonitord.conf.d/default.conf" : Define configuration file to use - -# SHOW_PACKAGE_UPDATE=0 : Do not show update packages -# SHOW_PACKAGE_UPDATE=1 : Show update packages -SHOW_PACKAGE_UPDATE=1 diff --git a/init/init.d/rpimonitor b/init/init.d/rpimonitor index dc5658e..9037b1c 100755 --- a/init/init.d/rpimonitor +++ b/init/init.d/rpimonitor @@ -15,12 +15,9 @@ DAEMON="/usr/bin/rpimonitord" PIDFILE="/var/run/rpimonitord.pid" -DEFAULTFILE="/etc/default/rpimonitor" [ -x $DAEMON ] || exit 0 -[ -r $DEFAULTFILE ] && . $DEFAULTFILE - checkroot(){ if [ "$(id -u)" != "0" ]; then echo "This script must be run as root" @@ -29,12 +26,6 @@ checkroot(){ } start() { - if [ "$DAEMON_START" = "0" ]; then - echo "RPi-Monitor deamon id disabled." - echo "Update /etc/default/rpimonitor and set DEAMON_START to 1." - return 0 - fi - touch $PIDFILE for pid in $(cat $PIDFILE); do @@ -80,19 +71,6 @@ status(){ echo } -update(){ - if [ "$SHOW_PACKAGE_UPDATE" = "0" ]; then - echo > /var/lib/rpimonitor/updatestatus.txt - return 0 - fi - - log_daemon_msg "RPi-Monitor" "Updating package status" - LANG=C - apt-get upgrade --dry-run| perl -ne '/(.*upgraded.*installed|^ \S+.*)/ and print "$1 "' 2>/dev/null > /var/lib/rpimonitor/updatestatus.txt - status=$? - log_end_msg $status -} - checkroot case "$1" in start) @@ -107,11 +85,8 @@ case "$1" in restart) restart ;; - update) - update - ;; *) - echo "Usage: $0 {start|stop|restart|status|update}" + echo "Usage: $0 {start|stop|restart|status}" ;; esac diff --git a/scripts/updatePackagesStatus.sh b/scripts/updatePackagesStatus.sh new file mode 100755 index 0000000..4d4cbe2 --- /dev/null +++ b/scripts/updatePackagesStatus.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Source function library. +. /lib/lsb/init-functions + +# Update file /var/lib/rpimonitor/updatestatus.txt +log_daemon_msg "RPi-Monitor" "Updating package status" +LANG=C +apt-get upgrade --dry-run| perl -ne '/(.*upgraded.*installed|^ \S+.*)/ and print "$1 "' 2>/dev/null > /var/lib/rpimonitor/updatestatus.txt +status=$? +log_end_msg $status From 989f42db2ef33a071a1af6ab02ecad59c9dea497 Mon Sep 17 00:00:00 2001 From: Xavier Berger Date: Mon, 18 Aug 2014 11:10:21 +0200 Subject: [PATCH 05/24] Update PACKAGING.md --- PACKAGING.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/PACKAGING.md b/PACKAGING.md index 9ab115e..5e6d368 100644 --- a/PACKAGING.md +++ b/PACKAGING.md @@ -3,6 +3,9 @@ ## Introduction This document intended to help [**RPi-Monitor**](http://rpi-experiences.blogspot.fr/)'s package maintainer to know what to install and where. +## Version +This document describe file organisation for **Version 2.8** + ## Dependencies **rpimonitord** is a perl script which require the following perl modules to work: @@ -26,9 +29,6 @@ This document intended to help [**RPi-Monitor**](http://rpi-experiences.blogspot ###Configuration -Since version 2.7: - -* /etc/default/rpimonitor : *Init script configuration file* * /etc/rpimonitor/daemon.conf : *configuration of rpimonitord daemon* * /etc/rpimonitor/data.conf : *(symlink to template/.conf) configuration of default data to be extracted and presented* * /etc/rpimonitor/\*.conf : *all other *.conf file will be parsed to look for data to be monitored* @@ -48,7 +48,6 @@ The template directory is also containing some templates that can be used as exa ###Web Interface -* /usr/share/rpimonitor * /usr/share/rpimonitor/web : *Directory containing html* * /usr/share/rpimonitor/web/js: *Directory containing javascripts* * /usr/share/rpimonitor/web/css: *Directory containing style* @@ -58,9 +57,11 @@ The template directory is also containing some templates that can be used as exa When **RPi-Monitor** is configured to not use the internal server, the json are written on the disk into the web root directory /usr/share/rpimonitor/web -###Data +###Scripts -Since version 2.7: +* /usr/share/rpimonitor/scripts/updatePackagesStatus.sh: *Script periodically executed to update /var/lib/rpimonitor/updatestatus.txt* + +###Data * /var/lib/rpimonitor/web/stat : *Directory containing \*.rrd* -* /var/lib/rpimonitor/updatestatus.txt: * Current status of packages* +* /var/lib/rpimonitor/updatestatus.txt: *Current status of packages update* From 13698bf68539d067411f917394c6fa2e6d605446 Mon Sep 17 00:00:00 2001 From: Xavier Berger Date: Mon, 25 Aug 2014 19:37:01 +0200 Subject: [PATCH 06/24] Manage cofiguration indexes unicity per file (to make configuration easier) --- rpimonitor/rpimonitord | 62 ++++++++++++----- rpimonitor/template/printer.conf | 112 +++++++++++++++--------------- rpimonitor/template/services.conf | 32 ++++----- 3 files changed, 118 insertions(+), 88 deletions(-) diff --git a/rpimonitor/rpimonitord b/rpimonitor/rpimonitord index e908833..28909b9 100755 --- a/rpimonitor/rpimonitord +++ b/rpimonitor/rpimonitord @@ -41,6 +41,10 @@ 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; } @@ -127,6 +131,7 @@ sub Load ) or die $!; if ( $this->{'show'} ) { + $Data::Dumper::Indent = 1; die Data::Dumper->Dump([$this]); } } @@ -135,6 +140,7 @@ sub LoadFile { my $this = shift; my $confFile = shift; + my $dict; $this->Debug(2,"Loading file: $confFile"); open ( FILE, $confFile) @@ -145,33 +151,57 @@ sub LoadFile my ($key, $value) = /^([^=]*)=(.*)/; # Extract key and value my @leaves=split('\.', $key); # Explode key and construct config hash my $tree=$this; + my $previous; my $current; my $next; - while (scalar(@leaves) > 0) { - $current ||= shift (@leaves); - $next = shift (@leaves); - if ( $next =~ /^\d+$/ ) { - if ($current =~ /^\d+$/) { - @{$tree}[$current-1] ||= []; - $tree=@{$tree}[$current-1]; + my $root; + while (scalar(@leaves) > 0) { # While @leaves contains data + $current ||= shift (@leaves); # If root is empty, shift the first element of @leaves to $current + $root ||= $current; + if ( $root eq 'web' ) { $root = $current } + $next = shift (@leaves); # Shift the first element of @leaves in $next + if ( $next =~ /^\d+$/ ) { # If $next is an integer -> we are in an array + if ($current =~ /^\d+$/) { # If $current is an integer -> we are in an array + @{$tree}[$current-1] ||= []; # If the branch is not an array, create an empty array + $tree=@{$tree}[$current-1]; # Define this array as $tree root } else { - $tree->{$current} ||= []; - $tree=$tree->{$current}; + $tree->{$current} ||= []; # If the branch is not an array, create an empty array + $tree=$tree->{$current}; # Define this array as $tree root } - } else { - if ($current =~ /^\d+$/) { - @{$tree}[$current-1] ||= {}; - $tree=@{$tree}[$current-1]; + } else { # If $next is not an integer -> We are in a hash + if ($current =~ /^\d+$/) { # If $current is an integer -> we are in an array + my $index = $current; + + # Manage per file indexes unicity + if ( ($root eq "static") || + ($root eq "dynamic") || + ( ( ($root eq 'status' ) || + ($root eq 'statistics' ) ) && + ($previous eq "content") ) ) + { + # If $index is not in $dict, add it with counter++ + if ( ! $dict->{$root}[$current] ) + { + $dict->{$root}[$current] = ++$this->{'counter'}->{$root}; + } + $index = $dict->{$root}[$current]; + } + + @{$tree}[$index-1] ||= {}; # If the branch is not an array, create an empty hash + $tree=@{$tree}[$index-1]; # Define this hash as $tree root } - else { - $tree->{$current} ||= {}; - $tree=$tree->{$current}; + else { # We are in a hash + $tree->{$current} ||= {}; # If the branch is not an array, create an empty hash + $tree=$tree->{$current}; # Define this hash as $tree root } } if ( ($next eq 'rrd') and $value) { push(@{$this->{'rrd'}},$tree) }; + $previous = $current; $current = $next; } + + # Add value if ($current =~ /^\d+$/) { @{$tree}[$current-1] = $value; } diff --git a/rpimonitor/template/printer.conf b/rpimonitor/template/printer.conf index cd20db6..a6e779c 100644 --- a/rpimonitor/template/printer.conf +++ b/rpimonitor/template/printer.conf @@ -1,59 +1,59 @@ # sudo apt-get install snmp -dynamic.20.name=copies -dynamic.20.source=snmpget -On -v2c -cpublic 192.168.0.14 .1.3.6.1.2.1.43.10.2.1.4.1.1 -dynamic.20.regexp=.* (\d+)$ -dynamic.20.postprocess= -dynamic.20.rrd=GAUGE - -dynamic.21.name=magenta -dynamic.21.source=wget http://192.168.0.14/general/status.html -o /dev/null -O /dev/stdout -dynamic.21.regexp=Magenta.*height="(\d+)px.*Cyan -dynamic.21.postprocess= -dynamic.21.rrd=GAUGE - -dynamic.22.name=cyan -dynamic.22.source=wget http://192.168.0.14/general/status.html -o /dev/null -O /dev/stdout -dynamic.22.regexp=Cyan.*height="(\d+)px.*Yellow -dynamic.22.postprocess= -dynamic.22.rrd=GAUGE - -dynamic.23.name=yellow -dynamic.23.source=wget http://192.168.0.14/general/status.html -o /dev/null -O /dev/stdout -dynamic.23.regexp=Yellow.*height="(\d+)px.*Black -dynamic.23.postprocess= -dynamic.23.rrd=GAUGE - -dynamic.24.name=black -dynamic.24.source=wget http://192.168.0.14/general/status.html -o /dev/null -O /dev/stdout -dynamic.24.regexp=Black.*height="(\d+)px" -dynamic.24.postprocess= -dynamic.24.rrd=GAUGE - -web.status.1.content.10.name=Printer -web.status.1.content.10.icon=printer.png -web.status.1.content.10.line.1="Number of copy: "+data.copies+"" -web.status.1.content.10.line.2="Black ("+Percent(data.black,55)+")" -web.status.1.content.10.line.3=ProgressBar(data.black,55) -web.status.1.content.10.line.4="Magenta ("+Percent(data.magenta,55)+")" -web.status.1.content.10.line.5=ProgressBar(data.magenta,55) -web.status.1.content.10.line.6="Cyan ("+Percent(data.cyan,55)+")" -web.status.1.content.10.line.7=ProgressBar(data.cyan,55) -web.status.1.content.10.line.8="Yellow ("+Percent(data.yellow,55)+")" -web.status.1.content.10.line.9=ProgressBar(data.yellow,55) - -web.statistics.1.content.10.name=Printer -web.statistics.1.content.10.graph.1=copies -web.statistics.1.content.10.graph.2=black -web.statistics.1.content.10.graph.3=magenta -web.statistics.1.content.10.graph.4=cyan -web.statistics.1.content.10.graph.5=yellow -web.statistics.1.content.10.ds_graph_options.copies.color="#00FF00" -web.statistics.1.content.10.ds_graph_options.black.color="#000000" -web.statistics.1.content.10.ds_graph_options.magenta.color="#FF0000" -web.statistics.1.content.10.ds_graph_options.cyan.color="#0000FF" -web.statistics.1.content.10.ds_graph_options.yellow.color="#FFFF00" -web.statistics.1.content.10.ds_graph_options.copies.yaxis=2 -web.statistics.1.content.10.graph_options.y2axis={ position: "right" } -web.statistics.1.content.10.graph_options.legend= { position: "se"} +dynamic.1.name=copies +dynamic.1.source=snmpget -On -v2c -cpublic 192.168.0.14 .1.3.6.1.2.1.43.1.2.1.4.1.1 +dynamic.1.regexp=.* (\d+)$ +dynamic.1.postprocess= +dynamic.1.rrd=GAUGE + +dynamic.2.name=magenta +dynamic.2.source=wget http://192.168.0.14/general/status.html -o /dev/null -O /dev/stdout +dynamic.2.regexp=Magenta.*height="(\d+)px.*Cyan +dynamic.2.postprocess= +dynamic.2.rrd=GAUGE + +dynamic.3.name=cyan +dynamic.3.source=wget http://192.168.0.14/general/status.html -o /dev/null -O /dev/stdout +dynamic.3.regexp=Cyan.*height="(\d+)px.*Yellow +dynamic.3.postprocess= +dynamic.3.rrd=GAUGE + +dynamic.4.name=yellow +dynamic.4.source=wget http://192.168.0.14/general/status.html -o /dev/null -O /dev/stdout +dynamic.4.regexp=Yellow.*height="(\d+)px.*Black +dynamic.4.postprocess= +dynamic.4.rrd=GAUGE + +dynamic.5.name=black +dynamic.5.source=wget http://192.168.0.14/general/status.html -o /dev/null -O /dev/stdout +dynamic.5.regexp=Black.*height="(\d+)px" +dynamic.5.postprocess= +dynamic.5.rrd=GAUGE + +web.status.1.content.1.name=Printer +web.status.1.content.1.icon=printer.png +web.status.1.content.1.line.1="Number of copy: "+data.copies+"" +web.status.1.content.1.line.2="Black ("+Percent(data.black,55)+")" +web.status.1.content.1.line.3=ProgressBar(data.black,55) +web.status.1.content.1.line.4="Magenta ("+Percent(data.magenta,55)+")" +web.status.1.content.1.line.5=ProgressBar(data.magenta,55) +web.status.1.content.1.line.6="Cyan ("+Percent(data.cyan,55)+")" +web.status.1.content.1.line.7=ProgressBar(data.cyan,55) +web.status.1.content.1.line.8="Yellow ("+Percent(data.yellow,55)+")" +web.status.1.content.1.line.9=ProgressBar(data.yellow,55) + +web.statistics.1.content.1.name=Printer +web.statistics.1.content.1.graph.1=copies +web.statistics.1.content.1.graph.2=black +web.statistics.1.content.1.graph.3=magenta +web.statistics.1.content.1.graph.4=cyan +web.statistics.1.content.1.graph.5=yellow +web.statistics.1.content.1.ds_graph_options.copies.color="#00FF00" +web.statistics.1.content.1.ds_graph_options.black.color="#000000" +web.statistics.1.content.1.ds_graph_options.magenta.color="#FF0000" +web.statistics.1.content.1.ds_graph_options.cyan.color="#0000FF" +web.statistics.1.content.1.ds_graph_options.yellow.color="#FFFF00" +web.statistics.1.content.1.ds_graph_options.copies.yaxis=2 +web.statistics.1.content.1.graph_options.y2axis={ position: "right" } +web.statistics.1.content.1.graph_options.legend= { position: "se"} diff --git a/rpimonitor/template/services.conf b/rpimonitor/template/services.conf index 512339c..a8e11ef 100644 --- a/rpimonitor/template/services.conf +++ b/rpimonitor/template/services.conf @@ -2,23 +2,23 @@ # External daemons information added into Raspberry Pi page # http://www.iconseeker.com/search-icon/crystal-project-application/daemons.html ######################################################################## -dynamic.16.name=ssh -dynamic.16.source=netstat -nlt -dynamic.16.regexp=tcp .*:(22).*LISTEN +dynamic.1.name=ssh +dynamic.1.source=netstat -nlt +dynamic.1.regexp=tcp .*:(22).*LISTEN -dynamic.17.name=rpimonitor -dynamic.17.source=netstat -nlt -dynamic.17.regexp=tcp .*:(8888).*LISTEN +dynamic.2.name=rpimonitor +dynamic.2.source=netstat -nlt +dynamic.2.regexp=tcp .*:(8888).*LISTEN -dynamic.18.name=http -dynamic.18.source=netstat -nlt -dynamic.18.regexp=tcp .*:(80).*LISTEN +dynamic.3.name=http +dynamic.3.source=netstat -nlt +dynamic.3.regexp=tcp .*:(80).*LISTEN -dynamic.19.name=https -dynamic.19.source=netstat -nlt -dynamic.19.regexp=tcp .*:(443).*LISTEN +dynamic.4.name=https +dynamic.4.source=netstat -nlt +dynamic.4.regexp=tcp .*:(443).*LISTEN -web.status.1.content.9.name=Servers -web.status.1.content.9.icon=daemons.png -web.status.1.content.9.line.1="ssh : "+Label(data.ssh,"==22","OK","success")+Label(data.ssh,"!=22","KO","important")+" rpimonitor : "+Label(data.rpimonitor,"==8888","OK","success")+Label(data.rpimonitor,"!=8888","KO","important")+" nginx http : "+Label(data.http,"==80","OK","success")+Label(data.http,"!=80","KO","important")+" nginx https : "+Label(data.https,"==443","OK","success")+Label(data.https,"!=443","KO","important") -web.status.1.content.9.line.2="ssh : "+Badge(data.ssh,"==22","OK","success")+Badge(data.ssh,"!=22","KO","important")+" rpimonitor : "+Badge(data.rpimonitor,"==8888","OK","success")+Badge(data.rpimonitor,"!=8888","KO","important")+" nginx http : "+Badge(data.http,"==80","OK","success")+Badge(data.http,"!=80","KO","important")+" nginx https : "+Badge(data.https,"==443","OK","success")+Badge(data.https,"!=443","KO","important") +web.status.1.content.1.name=Servers +web.status.1.content.1.icon=daemons.png +web.status.1.content.1.line.1="ssh : "+Label(data.ssh,"==22","OK","success")+Label(data.ssh,"!=22","KO","important")+" rpimonitor : "+Label(data.rpimonitor,"==8888","OK","success")+Label(data.rpimonitor,"!=8888","KO","important")+" nginx http : "+Label(data.http,"==80","OK","success")+Label(data.http,"!=80","KO","important")+" nginx https : "+Label(data.https,"==443","OK","success")+Label(data.https,"!=443","KO","important") +web.status.1.content.1.line.2="ssh : "+Badge(data.ssh,"==22","OK","success")+Badge(data.ssh,"!=22","KO","important")+" rpimonitor : "+Badge(data.rpimonitor,"==8888","OK","success")+Badge(data.rpimonitor,"!=8888","KO","important")+" nginx http : "+Badge(data.http,"==80","OK","success")+Badge(data.http,"!=80","KO","important")+" nginx https : "+Badge(data.https,"==443","OK","success")+Badge(data.https,"!=443","KO","important") From 2f311bd978217368c97eaf46bc3a21d1629f73e8 Mon Sep 17 00:00:00 2001 From: Xavier Berger Date: Mon, 25 Aug 2014 19:39:32 +0200 Subject: [PATCH 07/24] Update updatestatus.txt initial comment to match new sysVinit startup script --- rpimonitor/updatestatus.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpimonitor/updatestatus.txt b/rpimonitor/updatestatus.txt index 22d2db6..fd74d73 100644 --- a/rpimonitor/updatestatus.txt +++ b/rpimonitor/updatestatus.txt @@ -1 +1 @@ -Update needed...

    Execute sudo apt-get update && sudo service rpimonitor update +Update needed...

    Execute Execute sudo apt-get update && sudo /usr/share/rpimonitor/scripts/updatePackagesStatus.sh From 1a488ad89c4b2884db9826575ad0d0e2e87efb19 Mon Sep 17 00:00:00 2001 From: Xavier Berger Date: Mon, 25 Aug 2014 19:59:25 +0200 Subject: [PATCH 08/24] Fix oid issue in printer.conf --- rpimonitor/template/printer.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpimonitor/template/printer.conf b/rpimonitor/template/printer.conf index a6e779c..048665c 100644 --- a/rpimonitor/template/printer.conf +++ b/rpimonitor/template/printer.conf @@ -1,6 +1,6 @@ # sudo apt-get install snmp dynamic.1.name=copies -dynamic.1.source=snmpget -On -v2c -cpublic 192.168.0.14 .1.3.6.1.2.1.43.1.2.1.4.1.1 +dynamic.1.source=snmpget -On -v2c -cpublic 192.168.0.14 .1.3.6.1.2.1.43.10.2.1.4.1.1 dynamic.1.regexp=.* (\d+)$ dynamic.1.postprocess= dynamic.1.rrd=GAUGE From 212112df5ce23e3311f1d0832e169310a100c8d4 Mon Sep 17 00:00:00 2001 From: Xavier Berger Date: Mon, 25 Aug 2014 22:47:20 +0200 Subject: [PATCH 09/24] Add parameters to customise menu logo, title and page titles --- rpimonitor/rpimonitord | 15 ++++++++++++--- rpimonitor/template/raspbian.conf | 6 ++++++ rpimonitor/web/js/rpimonitor.js | 15 +++++++++------ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/rpimonitor/rpimonitord b/rpimonitor/rpimonitord index 28909b9..da51659 100755 --- a/rpimonitor/rpimonitord +++ b/rpimonitor/rpimonitord @@ -87,7 +87,7 @@ sub Load $this->{'daemon'}->{'delay'} ||= 10; $this->{'daemon'}->{'timeout'} ||= 5; $this->{'daemon'}->{'sharedmemkey'}||= 20130906; - + # Check user and group $this->{'daemon'}->{'gid'} = getgrnam($this->{'daemon'}->{'user'}) || 1000; $this->{'daemon'}->{'uid'} = getpwnam($this->{'daemon'}->{'group'}) || 1000; @@ -116,6 +116,11 @@ sub Load #print Data::Dumper->Dump([$this->{'rrdlist'}]); + # manage page common parameters + $this->{'web'}->{'page'}->{'icon'} ||= 'img/logo/png'; + $this->{'web'}->{'page'}->{'menutitle'} ||= 'RPi-Monitor'; + $this->{'web'}->{'page'}->{'pagetitle'} ||= 'RPi-Monitor'; + # manage menu foreach (@{$this->{'web'}->{'status'}}) { $_->{'name'} and push(@{$this->{'menu'}->{'status'}}, $_->{'name'}); @@ -188,8 +193,8 @@ sub LoadFile $index = $dict->{$root}[$current]; } - @{$tree}[$index-1] ||= {}; # If the branch is not an array, create an empty hash - $tree=@{$tree}[$index-1]; # Define this hash as $tree root + @{$tree}[$index-1] ||= {}; # If the branch is not an array, create an empty hash + $tree=@{$tree}[$index-1]; # Define this hash as $tree root } else { # We are in a hash $tree->{$current} ||= {}; # If the branch is not an array, create an empty hash @@ -256,6 +261,7 @@ use IO::Handle; use HTTP::Daemon; use HTTP::Status; use JSON; +use Sys::Hostname; #use Data::Dumper; sub new @@ -272,6 +278,7 @@ sub new "/statistics.json", "/menu.json", "/friends.json", + "/page.json", "/version.json", "/favicon.ico", @@ -469,6 +476,8 @@ sub Run $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'}}); + $monitor->{'static'}->{'hostname'} = hostname(); $this->{'static'} = encode_json(\%{$monitor->{'static'}}); $this->{'menu'} = encode_json(\%{$configuration->{'menu'}}); $this->{'version'} = "{\"version\":\"$configuration->{'version'}\"}"; diff --git a/rpimonitor/template/raspbian.conf b/rpimonitor/template/raspbian.conf index 194df25..3c3dffd 100644 --- a/rpimonitor/template/raspbian.conf +++ b/rpimonitor/template/raspbian.conf @@ -333,6 +333,12 @@ dynamic.15.rrd=GAUGE #web.friends.3.name=Laptop #web.friends.3.link=http://192.168.0.38/ +####################################################################### + +#web.page.icon='img/logo.png' +#web.page.menutitle='RPi-Monitor ('+data.hostname+')' +#web.page.pagetitle='RPi-Monitor ('+data.hostname+')' + ####################################################################### web.status.1.name=Raspberry Pi web.status.1.content.1.name=Version diff --git a/rpimonitor/web/js/rpimonitor.js b/rpimonitor/web/js/rpimonitor.js index 661f400..4fc3846 100644 --- a/rpimonitor/web/js/rpimonitor.js +++ b/rpimonitor/web/js/rpimonitor.js @@ -103,11 +103,11 @@ function ShowFriends(){ function AddFooter(){ $('#footer').html( - '

'+ - '

RPi-Experiences | '+ - 'GitHub | '+ - 'Raspberry Pi Foundation

'+ - '
' + '
'+ + '

RPi-Experiences | '+ + 'GitHub | '+ + 'Raspberry Pi Foundation

'+ + '
' ); } @@ -202,6 +202,9 @@ function AddDialogs(){ } function AddTopmenu(){ + page = getData('page') + data = getData('static') + document.title = eval(page.pagetitle); topmenu= '