mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
fheminfo: uptime patches from betateilchen
git-svn-id: https://svn.fhem.de/fhem/trunk@5369 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1b4580a222
commit
535080db49
@ -79,6 +79,8 @@ CommandFheminfo($$)
|
||||
my $sendStatistics = AttrVal("global","sendStatistics",undef);
|
||||
my $moddir = $attr{global}{modpath}."/FHEM";
|
||||
my $uidFile = $moddir."/FhemUtils/uniqueID";
|
||||
my $upTime;
|
||||
$upTime = fhemUptime();
|
||||
|
||||
if(defined($uniqueID) && $uniqueID eq $uidFile) {
|
||||
my $fh;
|
||||
@ -170,6 +172,7 @@ CommandFheminfo($$)
|
||||
$str .= sprintf(" Arch%*s: %s\n",5," ",$arch);
|
||||
$str .= sprintf(" Perl%*s: %s\n",5," ",$perl);
|
||||
$str .= sprintf(" uniqueID%*s: %s\n",0," ",$uniqueID);
|
||||
$str .= sprintf(" upTime%*s: %s\n",3," ",$upTime);
|
||||
$str .= "\n";
|
||||
|
||||
my $contModules;
|
||||
@ -366,6 +369,27 @@ sub checkModule($) {
|
||||
}
|
||||
}
|
||||
|
||||
sub fhemUptime {
|
||||
my $diff = time - $fhem_started;
|
||||
my ($d,$h,$m,$ret);
|
||||
|
||||
($d,$diff) = _myDiv($diff,86400);
|
||||
($h,$diff) = _myDiv($diff,3600);
|
||||
($m,$diff) = _myDiv($diff,60);
|
||||
|
||||
$ret = "";
|
||||
$ret .= "$d days, " if($d > 1);
|
||||
$ret .= "1 day, " if($d == 1);
|
||||
$ret .= sprintf("%02s:%02s:%02s", $h, $m, $diff);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
sub _myDiv($$) {
|
||||
my ($p1,$p2) = @_;
|
||||
return (int($p1/$p2), $p1 % $p2);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
62
fhem/fhem.pl
62
fhem/fhem.pl
@ -191,51 +191,50 @@ sub cfgDB_svnId;
|
||||
# VOLATILE- Set if the definition should be saved to the "statefile"
|
||||
# NOTIFYDEV - if set, the notifyFn will only be called for this device
|
||||
|
||||
use vars qw(%modules); # List of loaded modules (device/log/etc)
|
||||
use vars qw(%defs); # FHEM device/button definitions
|
||||
use vars qw(%attr); # Attributes
|
||||
use vars qw(%interfaces); # see createInterfaceDefinitions below
|
||||
use vars qw(%selectlist); # devices which want a "select"
|
||||
use vars qw(%readyfnlist); # devices which want a "readyfn"
|
||||
use vars qw($readytimeout); # Polling interval. UNIX: device search only
|
||||
$readytimeout = ($^O eq "MSWin32") ? 0.1 : 5.0;
|
||||
|
||||
use vars qw(%value); # Current values, see commandref.html
|
||||
use vars qw(%oldvalue); # Old values, see commandref.html
|
||||
use vars qw($devcount); # Maximum device number, used for storing
|
||||
use vars qw($fhem_started); # used for uptime calculation
|
||||
use vars qw($init_done); #
|
||||
use vars qw($internal_data); # FileLog/DbLog -> SVG data transport
|
||||
use vars qw(%cmds); # Global command name hash.
|
||||
use vars qw(%data); # Hash for user data
|
||||
use vars qw($devcount); # Maximum device number, used for storing
|
||||
use vars qw(%defaultattr); # Default attributes, used by FHEM2FHEM
|
||||
use vars qw(%inform); # Used by telnet_ActivateInform
|
||||
use vars qw(%intAt); # Internal at timer hash, global for benchmark
|
||||
use vars qw($nextat); # Time when next timer will be triggered.
|
||||
use vars qw(%ntfyHash); # hash of devices needed to be notified.
|
||||
|
||||
use vars qw($readytimeout); # Polling interval. UNIX: device search only
|
||||
use vars qw($reread_active);
|
||||
use vars qw($winService); # the Windows Service object
|
||||
use vars qw(%attr); # Attributes
|
||||
use vars qw(%cmds); # Global command name hash.
|
||||
use vars qw(%data); # Hash for user data
|
||||
use vars qw(%defaultattr); # Default attributes, used by FHEM2FHEM
|
||||
use vars qw(%defs); # FHEM device/button definitions
|
||||
use vars qw(%inform); # Used by telnet_ActivateInform
|
||||
use vars qw(%intAt); # Internal at timer hash, global for benchmark
|
||||
use vars qw(%interfaces); # see createInterfaceDefinitions below
|
||||
use vars qw(%modules); # List of loaded modules (device/log/etc)
|
||||
use vars qw(%ntfyHash); # hash of devices needed to be notified.
|
||||
use vars qw(%oldvalue); # Old values, see commandref.html
|
||||
use vars qw(%readyfnlist); # devices which want a "readyfn"
|
||||
use vars qw(%selectlist); # devices which want a "select"
|
||||
use vars qw(%value); # Current values, see commandref.html
|
||||
|
||||
my $AttrList = "verbose:0,1,2,3,4,5 room group comment alias ".
|
||||
"eventMap userReadings";
|
||||
|
||||
my %comments; # Comments from the include files
|
||||
my $currlogfile; # logfile, without wildcards
|
||||
my $currcfgfile=""; # current config/include file
|
||||
my $logopened = 0; # logfile opened or using stdout
|
||||
my $rcvdquit; # Used for quit handling in init files
|
||||
my $sig_term = 0; # if set to 1, terminate (saving the state)
|
||||
my $intAtCnt=0;
|
||||
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
||||
my $duplidx=0; # helper for the above pool
|
||||
my $readingsUpdateDelayTrigger; # needed internally
|
||||
my $currlogfile; # logfile, without wildcards
|
||||
my $cvsid = '$Id$';
|
||||
my $duplidx=0; # helper for the above pool
|
||||
my $evalSpecials; # Used by EvalSpecials->AnalyzeCommand parameter passing
|
||||
my $intAtCnt=0;
|
||||
my $logopened = 0; # logfile opened or using stdout
|
||||
my $namedef = "where <name> is a single device name, a list separated by komma (,) or a regexp. See the devspec section in the commandref.html for details.\n";
|
||||
my $rcvdquit; # Used for quit handling in init files
|
||||
my $readingsUpdateDelayTrigger; # needed internally
|
||||
my $sig_term = 0; # if set to 1, terminate (saving the state)
|
||||
my $wbName = ".WRITEBUFFER"; # Buffuer-name for delayed writing via select
|
||||
my %comments; # Comments from the include files
|
||||
my %duplicate; # Pool of received msg for multi-fhz/cul setups
|
||||
my @cmdList; # Remaining commands in a chain. Used by sleep
|
||||
my $evalSpecials; # Used by EvalSpecials->AnalyzeCommand parameter passing
|
||||
my $wbName = ".WRITEBUFFER";
|
||||
|
||||
$init_done = 0;
|
||||
$readytimeout = ($^O eq "MSWin32") ? 0.1 : 5.0;
|
||||
|
||||
|
||||
$modules{Global}{ORDER} = -1;
|
||||
$modules{Global}{LOADED} = 1;
|
||||
@ -480,6 +479,7 @@ foreach my $d (keys %defs) {
|
||||
}
|
||||
}
|
||||
DoTrigger("global", "INITIALIZED", 1);
|
||||
$fhem_started = time;
|
||||
|
||||
$attr{global}{motd} .= "Running with root privileges."
|
||||
if($^O !~ m/Win/ && $<==0 && $attr{global}{motd} =~ m/^$sc_text/);
|
||||
|
Loading…
x
Reference in New Issue
Block a user