Added standby mode on unix agent
This commit is contained in:
parent
010207e6ad
commit
ee51114fe8
|
@ -87,6 +87,9 @@ transfer_mode tentacle
|
|||
# If set to 1 allows the agent to be configured via the web console (Only Enterprise version)
|
||||
# remote_config 1
|
||||
|
||||
# Default 0, set to 1 to avoid module executions and report to server
|
||||
# standby 1
|
||||
|
||||
# If set to 1 start Drone Agent's Proxy Mode
|
||||
# proxy_mode 1
|
||||
|
||||
|
|
|
@ -117,6 +117,9 @@ transfer_mode tentacle
|
|||
# If set to 1 allows the agent to be configured via the web console (Only Enterprise version)
|
||||
#remote_config 1
|
||||
|
||||
# Default 0, set to 1 to avoid module executions and report to server
|
||||
# standby 1
|
||||
|
||||
# If set to 1 start Drone Agent's Proxy Mode
|
||||
# proxy_mode 1
|
||||
|
||||
|
|
|
@ -130,6 +130,9 @@ transfer_mode tentacle
|
|||
# If set to 1 allows the agent to be configured via the web console (Only Enterprise version)
|
||||
remote_config 0
|
||||
|
||||
# Default 0, set to 1 to avoid module executions and report to server
|
||||
# standby 1
|
||||
|
||||
# If set to 1 start Drone Agent's Proxy Mode
|
||||
#proxy_mode 1
|
||||
|
||||
|
|
|
@ -89,6 +89,9 @@ transfer_mode tentacle
|
|||
# If set to 1 allows the agent to be configured via the web console (Only Enterprise version)
|
||||
# remote_config 1
|
||||
|
||||
# Default 0, set to 1 to avoid module executions and report to server
|
||||
# standby 1
|
||||
|
||||
# If set to 1 start Drone Agent's Proxy Mode
|
||||
# proxy_mode 1
|
||||
|
||||
|
|
|
@ -136,6 +136,9 @@ transfer_mode tentacle
|
|||
# If set to 1 allows the agent to be configured via the web console (Only Enterprise version)
|
||||
remote_config 0
|
||||
|
||||
# Default 0, set to 1 to avoid module executions and report to server
|
||||
# standby 1
|
||||
|
||||
# If set to 1 start Drone Agent's Proxy Mode
|
||||
# proxy_mode 1
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ udp_server_auth_address 0.0.0.0
|
|||
|
||||
# Group assigned for this agent (descriptive, p.e: Servers)
|
||||
#group Servers
|
||||
|
||||
# Group password (if defined).
|
||||
#group_password
|
||||
|
||||
# Group password (if defined).
|
||||
#group_password
|
||||
|
||||
# Autotime: Enforce to server to ignore timestamp coming from this
|
||||
# agent, used when agents has no timer or it's inestable. 1 to enable
|
||||
|
@ -102,6 +102,9 @@ transfer_mode tentacle
|
|||
# If set to 1 allows the agent to be configured via the web console (Only Enterprise version)
|
||||
remote_config 0
|
||||
|
||||
# Default 0, set to 1 to avoid module executions and report to server
|
||||
# standby 1
|
||||
|
||||
# Number of threads to execute modules in parallel
|
||||
#agent_threads 1
|
||||
|
||||
|
|
|
@ -98,6 +98,9 @@ transfer_mode tentacle
|
|||
# If set to 1 allows the agent to be configured via the web console (Only Enterprise version)
|
||||
#remote_config 1
|
||||
|
||||
# Default 0, set to 1 to avoid module executions and report to server
|
||||
# standby 1
|
||||
|
||||
# If set to 1 start Drone Agent's Proxy Mode
|
||||
#proxy_mode 1
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ transfer_mode tentacle
|
|||
# If set to 1 allows the agent to be configured via the web console (Only Enterprise version)
|
||||
#remote_config 1
|
||||
|
||||
# Default 0, set to 1 to avoid module executions and report to server
|
||||
# standby 1
|
||||
|
||||
# If set to 1 start Drone Agent's Proxy Mode
|
||||
#proxy_mode 1
|
||||
|
||||
|
|
|
@ -186,6 +186,7 @@ my %DefaultConf = (
|
|||
'xml_buffer' => 0,
|
||||
'custom_id' => '',
|
||||
'url_address' => '',
|
||||
'standby' => 0,
|
||||
);
|
||||
my %Conf = %DefaultConf;
|
||||
|
||||
|
@ -1333,6 +1334,41 @@ sub check_collections () {
|
|||
}
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Sleep function
|
||||
################################################################################
|
||||
sub sleep_agent {
|
||||
my ($main_agent, $iter_base_time) = @_;
|
||||
|
||||
# Sleep if main agent
|
||||
if ($main_agent != 0) {
|
||||
foreach my $broker_pid (@BrokerPid) {
|
||||
waitpid ($broker_pid, 0);
|
||||
}
|
||||
|
||||
# Cron mode
|
||||
exit (0) if ($Conf{'cron_mode'} == 1);
|
||||
|
||||
$iter_base_time += $Conf{'intensive_interval'};
|
||||
my $now = time();
|
||||
|
||||
my $interval_remain = $iter_base_time - $now;
|
||||
|
||||
if ($interval_remain >= 0) {
|
||||
sleep ($interval_remain);
|
||||
} else {
|
||||
# don't sleep if iteraion took more than "intensive_interval" seconds
|
||||
$iter_base_time = $now; # use current time as base time
|
||||
}
|
||||
}
|
||||
# Finish if broker agent
|
||||
else {
|
||||
exit (0);
|
||||
}
|
||||
|
||||
return $iter_base_time;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Return the MD5 checksum of the given string as a hex string.
|
||||
# Pseudocode from: http://en.wikipedia.org/wiki/MD5#Pseudocode
|
||||
|
@ -2959,6 +2995,12 @@ while (1) {
|
|||
}
|
||||
}
|
||||
|
||||
# Do not report to server if standby mode is enabled
|
||||
if ($Conf{'standby'} eq '1' && $Conf{'debug'} ne '1') {
|
||||
$iter_base_time = sleep_agent($main_agent, $iter_base_time);
|
||||
next;
|
||||
}
|
||||
|
||||
my $address;
|
||||
|
||||
if(defined($Conf{'address'})) {
|
||||
|
@ -3161,31 +3203,8 @@ while (1) {
|
|||
$SIG{'INT'} = \&udp_server_signal;
|
||||
}
|
||||
|
||||
# Sleep if main agent
|
||||
if ($main_agent != 0) {
|
||||
foreach my $broker_pid (@BrokerPid) {
|
||||
waitpid ($broker_pid, 0);
|
||||
}
|
||||
|
||||
# Cron mode
|
||||
last if ($Conf{'cron_mode'} == 1);
|
||||
|
||||
$iter_base_time += $Conf{'intensive_interval'};
|
||||
my $now = time();
|
||||
|
||||
my $interval_remain = $iter_base_time - $now;
|
||||
|
||||
if ($interval_remain >= 0) {
|
||||
sleep ($interval_remain);
|
||||
} else {
|
||||
# don't sleep if iteraion took more than "intensive_interval" seconds
|
||||
$iter_base_time = $now; # use current time as base time
|
||||
}
|
||||
}
|
||||
# Finish if broker agent
|
||||
else {
|
||||
exit (0);
|
||||
}
|
||||
# Sleep agent function
|
||||
$iter_base_time = sleep_agent($main_agent, $iter_base_time);
|
||||
}
|
||||
|
||||
__END__
|
||||
|
|
Loading…
Reference in New Issue