From: Will Budic Date: Mon, 4 Nov 2019 04:47:10 +0000 (+1100) Subject: Activated researche, in local user perlbrew instead system wide installed perl, on... X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=2c54764df818469b39ac184e1b5a19286e3598b7;p=LifeLog.git Activated researche, in local user perlbrew instead system wide installed perl, on linux system. --- diff --git a/htdocs/cgi-bin/stats.cgi b/htdocs/cgi-bin/stats.cgi index 39f4ed9..7e20179 100755 --- a/htdocs/cgi-bin/stats.cgi +++ b/htdocs/cgi-bin/stats.cgi @@ -1,9 +1,11 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # Programed by: Will Budic # Open Source License -> https://choosealicense.com/licenses/isc/ # use strict; use warnings; +no warnings 'uninitialized'; + use Try::Tiny; use Switch; @@ -13,6 +15,7 @@ use DBI; use DateTime; use DateTime::Format::SQLite; use Number::Bytes::Human qw(format_bytes); +#use File::HomeDir; #SETTINGS HERE! my $REC_LIMIT = 25; @@ -62,6 +65,9 @@ my $BGCOL = '#c8fff8'; $BGCOL = 'green'; } +$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'}, @@ -69,6 +75,8 @@ print $cgi->start_html(-title => "Log Data Stats", -BGCOLOR=>"$BGCOL", ); + + my $tbl = ''; my $log_rc = selectSQL('select count(rowid) from LOG;'); @@ -87,7 +95,7 @@ $stm2 = 'SELECT sum(AMOUNT) from LOG where date>=date("now","start of year") AND my $expense = big_money(sprintf("%.2f",selectSQL($stm1))); my $income = big_money(sprintf("%.2f",selectSQL($stm2))); my $gross = big_money($income - $expense); -my $hardware_status =`inxi -b -c0;uptime -p`; +my $hardware_status = `inxi -b -c0;uptime -p`; $hardware_status =~ s/\n//g; $hardware_status =~ s/Memory:/Memory:/g; $hardware_status =~ s/Init:/<\/b>Initial:/g; @@ -97,9 +105,13 @@ my $prc = 'ps -eo size,pid,user,command --sort -size | awk \'{ hr=$1/1024 ; prin my $processes = `$prc | sort -u -r -`; +my $dbSize = (uc format_bytes($stat[7], bs => 1000)); #Strip kernel 0 processes reported $processes =~ s/\s*0.00.*//gd; my $year =$today->year(); + +my $IPPublic = `curl ifconfig.me`; +my $IPPrivate = `hostname -I`; $IPPrivate =~ s/\s/
/g; $tbl .=qq(
@@ -108,9 +120,12 @@ $tbl .=qq( - + + +
* Personal Log Data Statistics *
LifeLog App. Version:$RELEASE_VER
Number of Records:$log_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).(uc format_bytes($stat[7], bs => 1000)).q(
$database$dbSize
Public IP$IPPublic
Private IP$IPPrivate
); + print qq(