mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
2010-05-19 Sancho Lerena <slerena@artica.es>
* lib/PandoraFMS/DataServer.pm: XML data files coming from a disabled agent are now discarded. * util/pandora_manage.pl: Added CLI mode to disable/enable agents from a given group. This will help admins to implement recurrent downtime periods. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2751 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f87f26acc0
commit
3e3f4d6783
@ -1,3 +1,11 @@
|
|||||||
|
2010-05-19 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/DataServer.pm: XML data files coming from a disabled
|
||||||
|
agent are now discarded.
|
||||||
|
|
||||||
|
* util/pandora_manage.pl: Added CLI mode to disable/enable agents from
|
||||||
|
a given group. This will help admins to implement recurrent downtime periods.
|
||||||
|
|
||||||
2010-05-18 Sancho Lerena <slerena@artica.es>
|
2010-05-18 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
* pandora_server_upgrade: Fixed a check on pandora_db.pl script in cron.
|
* pandora_server_upgrade: Fixed a check on pandora_db.pl script in cron.
|
||||||
|
@ -276,6 +276,14 @@ sub process_xml_data ($$$$$) {
|
|||||||
}
|
}
|
||||||
$AgentSem->up ();
|
$AgentSem->up ();
|
||||||
|
|
||||||
|
# Check if agent is disabled and return if it's disabled. Disabled agents doesnt process data
|
||||||
|
# in order to avoid not only events, also possible invalid data coming from agents.
|
||||||
|
|
||||||
|
my $agent_disabled = get_db_value ($dbh, 'SELECT disabled FROM tagente WHERE id_agente = ?', $agent_id);
|
||||||
|
if (defined ($agent_disabled) && $agent_disabled == 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($valid_position_data == 1 && $pa_config->{'activate_gis'} != 0) {
|
if ($valid_position_data == 1 && $pa_config->{'activate_gis'} != 0) {
|
||||||
if (!defined($parent_agent_name)){
|
if (!defined($parent_agent_name)){
|
||||||
$parent_agent_name = "";
|
$parent_agent_name = "";
|
||||||
|
@ -18,7 +18,7 @@ use PandoraFMS::DB;
|
|||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
# version: define current version
|
# version: define current version
|
||||||
my $version = "3.1 PS100321";
|
my $version = "3.1 PS100519";
|
||||||
|
|
||||||
# Pandora server configuration
|
# Pandora server configuration
|
||||||
my %conf;
|
my %conf;
|
||||||
@ -97,6 +97,32 @@ sub pandora_disable_eacl ($$$) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Disable a entire group
|
||||||
|
###############################################################################
|
||||||
|
sub pandora_disable_group ($$$$) {
|
||||||
|
my ($conf, $dbh, $mode, $group) = @_;
|
||||||
|
|
||||||
|
|
||||||
|
if ($mode == 0){ # Disable
|
||||||
|
print "[INFO] Disabling group $group\n\n";
|
||||||
|
if ($group == 1){
|
||||||
|
db_do ($dbh, "UPDATE tagente SET disabled = 1");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
db_do ($dbh, "UPDATE tagente SET disabled = 1 WHERE id_grupo = $group");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print "[INFO] Enabling group $group\n\n";
|
||||||
|
if ($group == 1){
|
||||||
|
db_do ($dbh, "UPDATE tagente SET disabled = 0");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
db_do ($dbh, "UPDATE tagente SET disabled = 0 WHERE id_grupo = $group");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Read external configuration file.
|
# Read external configuration file.
|
||||||
@ -147,12 +173,14 @@ sub pandora_init ($) {
|
|||||||
# Print a help screen and exit.
|
# Print a help screen and exit.
|
||||||
##############################################################################
|
##############################################################################
|
||||||
sub help_screen{
|
sub help_screen{
|
||||||
print "Usage: $0 <path to pandora_server.conf> [options] \n";
|
print "Usage: $0 <path to pandora_server.conf> [options] \n\n";
|
||||||
print "Available options:\n\n";
|
print "Available options:\n\n";
|
||||||
print "\t--disable_alerts Disable alerts in all groups.\n";
|
print "\t--disable_alerts Disable alerts in all groups.\n";
|
||||||
print "\t--enable_alerts Enable alerts in all groups\n";
|
print "\t--enable_alerts Enable alerts in all groups\n";
|
||||||
print "\t--disable_eacl Disable enterprise ACL system\n";
|
print "\t--disable_eacl Disable enterprise ACL system\n";
|
||||||
print "\t--enable_eacl Enable enterprise ACL system\n";
|
print "\t--enable_eacl Enable enterprise ACL system\n";
|
||||||
|
print "\t--disable_group <id> Disable agents from an entire group (Use group 1 for all)\n";
|
||||||
|
print "\t--enable_group <id> Enable agents from an entire group (1 for all) \n";
|
||||||
print "\n";
|
print "\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -163,8 +191,20 @@ sub help_screen{
|
|||||||
sub pandora_manage_main ($$$) {
|
sub pandora_manage_main ($$$) {
|
||||||
my ($conf, $dbh, $history_dbh) = @_;
|
my ($conf, $dbh, $history_dbh) = @_;
|
||||||
|
|
||||||
# If there are not valid parameters
|
my @args = @ARGV;
|
||||||
foreach my $param (@ARGV) {
|
my $param;
|
||||||
|
my $ltotal=$#args;
|
||||||
|
my $ax;
|
||||||
|
|
||||||
|
# Has read setup file ok ?
|
||||||
|
if ( $ltotal == 0 ) {
|
||||||
|
print "[ERROR] No valid arguments";
|
||||||
|
help_screen();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($ax=0;$ax<=$ltotal;$ax++){
|
||||||
|
$param = $args[$ax];
|
||||||
|
|
||||||
# help!
|
# help!
|
||||||
help_screen () if ($param =~ m/--*h\w*\z/i );
|
help_screen () if ($param =~ m/--*h\w*\z/i );
|
||||||
@ -181,6 +221,12 @@ sub pandora_manage_main ($$$) {
|
|||||||
elsif ($param =~ m/--enable_eacl\z/i) {
|
elsif ($param =~ m/--enable_eacl\z/i) {
|
||||||
pandora_disable_eacl ($conf, $dbh, 1);
|
pandora_disable_eacl ($conf, $dbh, 1);
|
||||||
}
|
}
|
||||||
|
elsif ($param =~ m/--disable_group/i) {
|
||||||
|
pandora_disable_group ($conf, $dbh, 0, $args[$ax+1]);
|
||||||
|
}
|
||||||
|
elsif ($param =~ m/--enable_group/i) {
|
||||||
|
pandora_disable_group ($conf, $dbh, 1, $args[$ax+1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "[W] Nothing to do. Exiting !\n\n";
|
print "[W] Nothing to do. Exiting !\n\n";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user