mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Improved to be able to define agent name using external command.
This commit is contained in:
parent
fc42032a50
commit
6b8c399f7d
@ -126,6 +126,7 @@ my %DefaultConf = (
|
|||||||
'interval' => 300,
|
'interval' => 300,
|
||||||
'debug' => 0,
|
'debug' => 0,
|
||||||
'agent_name' => hostname (),
|
'agent_name' => hostname (),
|
||||||
|
'agent_name_cmd' => '',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'group' => '',
|
'group' => '',
|
||||||
'encoding' => 'UTF-8',
|
'encoding' => 'UTF-8',
|
||||||
@ -732,6 +733,20 @@ sub read_config (;$) {
|
|||||||
# Module, plugin and collection definitions
|
# Module, plugin and collection definitions
|
||||||
parse_conf_modules(\@file);
|
parse_conf_modules(\@file);
|
||||||
|
|
||||||
|
# If agent_name_cmd is defined, agent_name is set by command result.
|
||||||
|
if ($Conf{'agent_name_cmd'} ne '') {
|
||||||
|
my $result = `$Conf{'agent_name_cmd'}`;
|
||||||
|
|
||||||
|
# Use only the first line.
|
||||||
|
my ($temp_agent_name, $remain) = split(/\n/, $result);
|
||||||
|
chomp ($temp_agent_name);
|
||||||
|
|
||||||
|
# Remove white spaces of the first and last.
|
||||||
|
$temp_agent_name =~ s/^ *(.*?) *$/$1/;
|
||||||
|
|
||||||
|
$Conf{'agent_name'} = $temp_agent_name if ($temp_agent_name ne '');
|
||||||
|
}
|
||||||
|
|
||||||
# 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