From: Will Budic Date: Fri, 31 Jan 2020 00:56:21 +0000 (+1100) Subject: System log on stats run. New onBodyLoadGeneric. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=282e38e368cdb167566f49c713579320fb101835;p=LifeLog.git System log on stats run. New onBodyLoadGeneric. --- diff --git a/htdocs/cgi-bin/stats.cgi b/htdocs/cgi-bin/stats.cgi index 937894b..914587f 100755 --- a/htdocs/cgi-bin/stats.cgi +++ b/htdocs/cgi-bin/stats.cgi @@ -8,14 +8,14 @@ use warnings; use Try::Tiny; use Switch; - + use CGI; use CGI::Session '-ip_match'; use DBI; use DateTime; use DateTime::Format::SQLite; use Number::Bytes::Human qw(format_bytes); -use IPC::Run qw( run ); +use IPC::Run qw( run ); #SETTINGS HERE! @@ -79,9 +79,15 @@ $ENV{'HOME'} = "~/"; print $cgi->header(-expires=>"+6os", -charset=>"UTF-8"); print $cgi->start_html(-title => "Log Data Stats", -BGCOLOR=>"$BGCOL", - -script=>{-type => 'text/javascript', -src => 'wsrc/main.js'}, - -style =>{-type => 'text/css', -src => "wsrc/$TH_CSS"} - ); + -script=> [{-type => 'text/javascript', -src => 'wsrc/main.js'}, + {-type => 'text/javascript', -src => 'wsrc/jquery.js' }, + { -type => 'text/javascript', -src => 'wsrc/jquery-ui.js' }], + -style => [{-type => 'text/css', -src => "wsrc/$TH_CSS"}, + { -type => 'text/css', -src => 'wsrc/jquery-ui.css' }, + { -type => 'text/css', -src => 'wsrc/jquery-ui.theme.css' }], + + -onload => "onBodyLoadGeneric()" + ); my $tbl = ''; @@ -112,15 +118,17 @@ run \@cmd, '>&', \$HS; #instead of -> system("inxi",'-b', '-c0'); my $hardware_status = $HS;#`inxi -b -c0; uptime -p`; +my $syslog = "".substr $HS, index($HS, 'Host:'), index($HS, 'Console:'); + $syslog .= "\n".substr $HS, rindex($HS, 'Info:'); + $HS = "
".`df -h -l -x tmpfs`."
"; + $syslog .= $HS; $hardware_status =~ s/\n//g; $hardware_status =~ s/Memory:/Memory:/g; $hardware_status =~ s/Init:/<\/b>Initial:/g; $hardware_status =~ s/up\s/Server is up: /g; -$hardware_status .= ''; +$hardware_status .= "$HS"; my $prc = 'ps -eo size,pid,user,command --sort -size | awk \'{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }\''; - - my $processes = `$prc | sort -u -r -`; my $dbSize = (uc format_bytes($stat[7], bs => 1000)); #Strip kernel 0 processes reported @@ -131,7 +139,7 @@ my $year =$today->year(); my $IPPublic = `curl -s https://www.ifconfig.me`; my $IPPrivate = `hostname -I`; $IPPrivate =~ s/\s/
/g; - + $tbl .=qq(
@@ -139,13 +147,13 @@ $tbl .=qq( - +
* Personal Log Data Statistics *
LifeLog App. Version:$RELEASE_VER
Number of Records:$log_rc
No. of Records This Year:$log_this_year_rc
LifeLog App. Version:$RELEASE_VER
# Sum of Expenses For Year $year$expense
# Sum of Income For Year $year$income
Gross For Year $year$gross
$database$dbSize
$database$dbSize
Public IP$IPPublic
Private IP$IPPrivate
); -print qq(