mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-28 17:12:32 +00:00
PRESENCE/collectord: fix perl warning (Forum: #84243)
git-svn-id: https://svn.fhem.de/fhem/trunk@16171 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3abd49a0c1
commit
a2609b315c
@ -72,12 +72,10 @@ my %handle;
|
|||||||
my %socket_to_handle;
|
my %socket_to_handle;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$SIG{__DIE__} = sub {
|
$SIG{__DIE__} = sub {
|
||||||
my ($msg) = @_;
|
my ($msg) = @_;
|
||||||
|
|
||||||
Log 1, "PERL ERROR: $msg";
|
Log 1, "PERL ERROR: $msg";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -85,7 +83,6 @@ $SIG{__WARN__} = sub {
|
|||||||
my ($msg) = @_;
|
my ($msg) = @_;
|
||||||
|
|
||||||
Log 1, "PERL WARN: $msg";
|
Log 1, "PERL WARN: $msg";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -145,16 +142,12 @@ if(not $opt_c)
|
|||||||
print STDERR "no config file provided\n\n";
|
print STDERR "no config file provided\n\n";
|
||||||
print_usage();
|
print_usage();
|
||||||
exit 1;
|
exit 1;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(not -e "$opt_c" or not -r "$opt_c")
|
if(not -e "$opt_c" or not -r "$opt_c")
|
||||||
{
|
{
|
||||||
|
|
||||||
print STDERR "config-file $opt_c could not be loaded\n";
|
print STDERR "config-file $opt_c could not be loaded\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log 0, "started with PID $$";
|
Log 0, "started with PID $$";
|
||||||
@ -186,8 +179,6 @@ Log 1, "created socket on ".$server->sockhost()." with port ".$server->sockport(
|
|||||||
my $listener = IO::Select->new();
|
my $listener = IO::Select->new();
|
||||||
$listener->add($server);
|
$listener->add($server);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
my @new_handles;
|
my @new_handles;
|
||||||
my %child_handles;
|
my %child_handles;
|
||||||
my %child_config;
|
my %child_config;
|
||||||
@ -228,7 +219,6 @@ while(1)
|
|||||||
Log 2, "cleaning up status values (UUID: $uuid)";
|
Log 2, "cleaning up status values (UUID: $uuid)";
|
||||||
delete $state{$uuid};
|
delete $state{$uuid};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# process all status messages from all threads via status queue
|
# process all status messages from all threads via status queue
|
||||||
@ -274,21 +264,17 @@ while(1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#print Dumper(\%state);
|
#print Dumper(\%state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# If a thread has something reported via Log Queue, print it out if verbose is activated
|
# If a thread has something reported via Log Queue, print it out if verbose is activated
|
||||||
while($log_queue->pending)
|
while($log_queue->pending)
|
||||||
{
|
{
|
||||||
Log 2, $log_queue->dequeue;
|
Log 2, $log_queue->dequeue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# If a INET socket has anything to report
|
# If a INET socket has anything to report
|
||||||
if(@new_handles = $listener->can_read(1))
|
if(@new_handles = $listener->can_read(1))
|
||||||
{
|
{
|
||||||
@ -503,7 +489,6 @@ sub daemonize
|
|||||||
# the thread subroutine which performs a request for a specific room
|
# the thread subroutine which performs a request for a specific room
|
||||||
sub doQuery($$$)
|
sub doQuery($$$)
|
||||||
{
|
{
|
||||||
|
|
||||||
my ($do_config, $do_room, $do_address, $do_uuid) = @_;
|
my ($do_config, $do_room, $do_address, $do_uuid) = @_;
|
||||||
my $return;
|
my $return;
|
||||||
my $socket;
|
my $socket;
|
||||||
@ -642,7 +627,6 @@ sub doQuery($$$)
|
|||||||
# if the socket has a message available
|
# if the socket has a message available
|
||||||
if(@client_handle = $selector->can_read(1))
|
if(@client_handle = $selector->can_read(1))
|
||||||
{
|
{
|
||||||
|
|
||||||
# get all socket handles which has a message available
|
# get all socket handles which has a message available
|
||||||
foreach my $local_client (@client_handle)
|
foreach my $local_client (@client_handle)
|
||||||
{
|
{
|
||||||
@ -715,11 +699,8 @@ sub doQuery($$$)
|
|||||||
$log_queue->enqueue(threads->tid()."|exiting thread");
|
$log_queue->enqueue(threads->tid()."|exiting thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub readConfig
|
sub readConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
my ($ini) = @_;
|
my ($ini) = @_;
|
||||||
|
|
||||||
my $section;
|
my $section;
|
||||||
@ -733,26 +714,30 @@ sub readConfig
|
|||||||
%config = ();
|
%config = ();
|
||||||
|
|
||||||
open (INI, "$ini") or (print STDERR timestamp()."Can't open $ini: $!\n" and exit(1));
|
open (INI, "$ini") or (print STDERR timestamp()."Can't open $ini: $!\n" and exit(1));
|
||||||
while (<INI>) {
|
|
||||||
chomp;
|
|
||||||
if (/^\s*?\[([^\]\n\r]+?)\]/) {
|
|
||||||
$section = $1;
|
|
||||||
|
|
||||||
|
while (<INI>)
|
||||||
|
{
|
||||||
|
chomp;
|
||||||
|
|
||||||
|
if (/^\s*?\[([^\]\n\r]+?)\]/)
|
||||||
|
{
|
||||||
|
$section = $1;
|
||||||
}
|
}
|
||||||
if (/^\s*(\w+?)=(.+?)\s*(#.*)?$/ and defined($section)) {
|
|
||||||
|
if (/^\s*(\w+?)=(.+?)\s*(#.*)?$/ and defined($section))
|
||||||
|
{
|
||||||
$keyword = $1;
|
$keyword = $1;
|
||||||
$value = $2 ;
|
$value = $2 ;
|
||||||
# put them into hash
|
# put them into hash
|
||||||
$config{$section}{$keyword} = $value;
|
$config{$section}{$keyword} = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close (INI);
|
|
||||||
|
|
||||||
|
close (INI);
|
||||||
|
|
||||||
# validating config
|
# validating config
|
||||||
foreach my $room (keys %config)
|
foreach my $room (keys %config)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(not exists($config{$room}{address}))
|
if(not exists($config{$room}{address}))
|
||||||
{
|
{
|
||||||
Log 0, "room $room has no value for address configured";
|
Log 0, "room $room has no value for address configured";
|
||||||
@ -765,7 +750,6 @@ sub readConfig
|
|||||||
Log 0, "no valid address for room $room found: ".$config{$room}{address};
|
Log 0, "no valid address for room $room found: ".$config{$room}{address};
|
||||||
$errorcount++;
|
$errorcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(not exists($config{$room}{port}))
|
if(not exists($config{$room}{port}))
|
||||||
@ -832,10 +816,8 @@ sub readConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub aggregateRooms
|
sub aggregateRooms
|
||||||
{
|
{
|
||||||
|
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
my $previous = "absence";
|
my $previous = "absence";
|
||||||
@ -867,7 +849,6 @@ sub aggregateRooms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# if multiple rooms are present, try selection by highest RSSI
|
# if multiple rooms are present, try selection by highest RSSI
|
||||||
if(@rooms > 0)
|
if(@rooms > 0)
|
||||||
{
|
{
|
||||||
@ -923,12 +904,11 @@ sub aggregateRooms
|
|||||||
|
|
||||||
if(@rooms > 0)
|
if(@rooms > 0)
|
||||||
{
|
{
|
||||||
my $rssi_data = join(";", map("rssi_".$_."='".$rssi_results{$_}."'", map {s/\s+/_/rg } keys %rssi_results));
|
return "present".
|
||||||
my $ret = "present".
|
|
||||||
(defined($hroom) ? ";room='".$hroom."'" : "").
|
|
||||||
";rooms='".join(",",sort @rooms)."'".
|
";rooms='".join(",",sort @rooms)."'".
|
||||||
(defined($hroom) ? ";".$hash->{$hroom}{data} : (defined($hash->{$rooms[0]}{data}) ? ";".$hash->{$rooms[0]}{data} : "")).
|
(defined($hroom) ? ";room='".$hroom."'" : "").
|
||||||
(defined($rssi_data) ? ";".$rssi_data : "");
|
(%rssi_results ? ";".join(";", map { "rssi_".($_ =~ s/\s+/_/gr)."='".$rssi_results{$_}."'" } keys %rssi_results) : "").
|
||||||
|
(defined($hroom) ? ";".$hash->{$hroom}{data} : (defined($hash->{$rooms[0]}{data}) ? ";".$hash->{$rooms[0]}{data} : ""));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user