mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Fixed empty agent_name in pandora_agent
This commit is contained in:
parent
7b3e71f79a
commit
4f91a8f12b
@ -832,20 +832,24 @@ sub read_config (;$) {
|
|||||||
config_update('agent_name', $Conf{'agent_name'});
|
config_update('agent_name', $Conf{'agent_name'});
|
||||||
} elsif ($Conf{'agent_name_cmd'} ne '') {
|
} elsif ($Conf{'agent_name_cmd'} ne '') {
|
||||||
my $result = `$Conf{'agent_name_cmd'}`;
|
my $result = `$Conf{'agent_name_cmd'}`;
|
||||||
|
if($result ne '') {
|
||||||
|
# Use only the first line.
|
||||||
|
my ($temp_agent_name, $remain) = split(/\n/, $result);
|
||||||
|
chomp ($temp_agent_name);
|
||||||
|
|
||||||
# Use only the first line.
|
# Remove white spaces of the first and last.
|
||||||
my ($temp_agent_name, $remain) = split(/\n/, $result);
|
$temp_agent_name =~ s/^ *(.*?) *$/$1/;
|
||||||
chomp ($temp_agent_name);
|
|
||||||
|
|
||||||
# Remove white spaces of the first and last.
|
$Conf{'agent_name'} = $temp_agent_name if ($temp_agent_name ne '');
|
||||||
$temp_agent_name =~ s/^ *(.*?) *$/$1/;
|
}
|
||||||
|
|
||||||
$Conf{'agent_name'} = $temp_agent_name if ($temp_agent_name ne '');
|
|
||||||
} else {
|
|
||||||
$Conf{'agent_name'} = hostname();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Fall back to the hostname if agent_name is still empty.
|
||||||
|
if ($Conf{'agent_name'} eq '') {
|
||||||
|
$Conf{'agent_name'} = hostname();
|
||||||
|
}
|
||||||
|
|
||||||
# Update the agent MD5 since agent_name may have changed
|
# Update the agent MD5 since agent_name may have changed
|
||||||
$AgentMD5 = md5 ($Conf{'agent_name'});
|
$AgentMD5 = md5 ($Conf{'agent_name'});
|
||||||
$RemoteConfFile = "$AgentMD5.conf";
|
$RemoteConfFile = "$AgentMD5.conf";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user