mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
2011-11-14 Sergio Martin <sergio.martin@artica.es>
* util/pandora_manage.pl: Moved to functions each command bit of code git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5132 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
80294df5f4
commit
d7109d601d
@ -1,3 +1,7 @@
|
||||
2011-11-14 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* util/pandora_manage.pl: Moved to functions each command bit of code
|
||||
|
||||
2011-11-04 Koichiro Kikuchi <koichiro@rworks.jp>
|
||||
|
||||
* lib/PandoraFMS/Core.pm: Avoid warning message intrduced by last
|
||||
|
@ -58,6 +58,8 @@ my $dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, '3306', $conf{'
|
||||
my $history_dbh = ($conf{'_history_db_enabled'} eq '1') ? db_connect ('mysql', $conf{'_history_db_name'},
|
||||
$conf{'_history_db_host'}, '3306', $conf{'_history_db_user'}, $conf{'_history_db_pass'}) : undef;
|
||||
|
||||
my $conf = \%conf;
|
||||
|
||||
# Main
|
||||
pandora_manage_main(\%conf, $dbh, $history_dbh);
|
||||
|
||||
@ -72,54 +74,6 @@ exit;
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# Disable alert system globally
|
||||
###############################################################################
|
||||
sub pandora_disable_alerts ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
|
||||
# This works by disabling alerts in each defined group
|
||||
# If you have previously a group with alert disabled, and you disable
|
||||
# alerts globally, when enabled it again, it will enabled also !
|
||||
|
||||
db_do ($dbh, "UPDATE tgrupo SET disabled = 1");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Enable alert system globally
|
||||
###############################################################################
|
||||
sub pandora_enable_alerts ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
|
||||
db_do ($dbh, "UPDATE tgrupo SET disabled = 0");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Disable enterprise ACL
|
||||
###############################################################################
|
||||
sub pandora_disable_eacl ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
|
||||
db_do ($dbh, "UPDATE tconfig SET `value` ='0' WHERE `token` = 'acl_enterprise'");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Enable enterprise ACL
|
||||
###############################################################################
|
||||
sub pandora_enable_eacl ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
|
||||
db_do ($dbh, "UPDATE tconfig SET `value` ='1' WHERE `token` = 'acl_enterprise'");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Disable a entire group
|
||||
###############################################################################
|
||||
@ -456,50 +410,16 @@ sub help_screen{
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
# MAIN
|
||||
# CLI FUNCTIONS
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
sub pandora_manage_main ($$$) {
|
||||
my ($conf, $dbh, $history_dbh) = @_;
|
||||
##############################################################################
|
||||
# Disable group
|
||||
# Related option: --disable_group
|
||||
##############################################################################
|
||||
|
||||
my @args = @ARGV;
|
||||
my $ltotal=$#args;
|
||||
my $ax;
|
||||
|
||||
# Has read setup file ok ?
|
||||
if ( $ltotal == 0 ) {
|
||||
print "[ERROR] No valid arguments\n\n";
|
||||
help_screen();
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$param = $args[1];
|
||||
|
||||
# help!
|
||||
if ($param =~ m/--*h\w*\z/i ) {
|
||||
$param = '';
|
||||
help_screen () ;
|
||||
exit;
|
||||
}
|
||||
elsif ($param eq '--disable_alerts') {
|
||||
print "[INFO] Disabling all alerts \n\n";
|
||||
pandora_disable_alerts ($conf, $dbh);
|
||||
}
|
||||
elsif ($param eq '--enable_alerts') {
|
||||
print "[INFO] Enabling all alerts \n\n";
|
||||
pandora_enable_alerts ($conf, $dbh);
|
||||
}
|
||||
elsif ($param eq '--disable_eacl') {
|
||||
print "[INFO] Disabling Enterprise ACL system (system wide)\n\n";
|
||||
pandora_disable_eacl ($conf, $dbh);
|
||||
}
|
||||
elsif ($param eq '--enable_eacl') {
|
||||
print "[INFO] Enabling Enterprise ACL system (system wide)\n\n";
|
||||
pandora_enable_eacl ($conf, $dbh);
|
||||
}
|
||||
elsif ($param eq '--disable_group') {
|
||||
param_check($ltotal, 1);
|
||||
sub cli_disable_group() {
|
||||
my $group_name = @ARGV[2];
|
||||
my $id_group;
|
||||
|
||||
@ -508,15 +428,20 @@ sub pandora_manage_main ($$$) {
|
||||
$id_group = 0;
|
||||
}
|
||||
else {
|
||||
$id_group = get_group_id($dbh, $args[2]);
|
||||
$id_group = get_group_id($dbh, $group_name);
|
||||
exist_check($id_group,'group',$group_name);
|
||||
print "[INFO] Disabling group '$group_name'\n\n";
|
||||
}
|
||||
|
||||
pandora_disable_group ($conf, $dbh, $id_group);
|
||||
}
|
||||
elsif ($param eq '--enable_group') {
|
||||
param_check($ltotal, 1);
|
||||
|
||||
##############################################################################
|
||||
# Enable group
|
||||
# Related option: --enable_group
|
||||
##############################################################################
|
||||
|
||||
sub cli_enable_group() {
|
||||
my $group_name = @ARGV[2];
|
||||
my $id_group;
|
||||
|
||||
@ -525,15 +450,20 @@ sub pandora_manage_main ($$$) {
|
||||
print "[INFO] Enabling all groups\n\n";
|
||||
}
|
||||
else {
|
||||
$id_group = get_group_id($dbh, $args[2]);
|
||||
$id_group = get_group_id($dbh, $group_name);
|
||||
exist_check($id_group,'group',$group_name);
|
||||
print "[INFO] Enabling group '$group_name'\n\n";
|
||||
}
|
||||
|
||||
pandora_enable_group ($conf, $dbh, $id_group);
|
||||
}
|
||||
elsif ($param eq '--create_agent') {
|
||||
param_check($ltotal, 7, 3);
|
||||
|
||||
##############################################################################
|
||||
# Create an agent.
|
||||
# Related option: --created_agent
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_agent() {
|
||||
my ($agent_name,$os_name,$group_name,$server_name,$address,$description,$interval) = @ARGV[2..8];
|
||||
|
||||
print "[INFO] Creating agent '$agent_name'\n\n";
|
||||
@ -548,8 +478,13 @@ sub pandora_manage_main ($$$) {
|
||||
exist_check($id_group,'operating system',$group_name);
|
||||
pandora_create_agent ($conf, $server_name, $agent_name, $address, $id_group, 0, $os_id, $description, $interval, $dbh);
|
||||
}
|
||||
elsif ($param eq '--delete_agent') {
|
||||
param_check($ltotal, 1);
|
||||
|
||||
##############################################################################
|
||||
# Delete an agent.
|
||||
# Related option: --delete_agent
|
||||
##############################################################################
|
||||
|
||||
sub cli_delete_agent() {
|
||||
my $agent_name = @ARGV[2];
|
||||
|
||||
$agent_name = decode_entities($agent_name);
|
||||
@ -560,9 +495,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_delete_agent($dbh,$id_agent,$conf);
|
||||
}
|
||||
elsif ($param eq '--create_data_module') {
|
||||
param_check($ltotal, 15, 12);
|
||||
|
||||
##############################################################################
|
||||
# Create data module.
|
||||
# Related option: --create_data_module
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_data_module() {
|
||||
my ($module_name, $module_type, $agent_name, $description, $module_group,
|
||||
$min,$max,$post_process, $interval, $warning_min, $warning_max, $critical_min,
|
||||
$critical_max, $history_data, $definition_file) = @ARGV[2..16];
|
||||
@ -655,9 +594,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
|
||||
}
|
||||
elsif ($param eq '--create_network_module') {
|
||||
param_check($ltotal, 17, 13);
|
||||
|
||||
##############################################################################
|
||||
# Create network module.
|
||||
# Related option: --create_network_module
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_network_module() {
|
||||
my ($module_name, $module_type, $agent_name, $module_address, $module_port, $description,
|
||||
$module_group, $min, $max, $post_process, $interval, $warning_min, $warning_max, $critical_min,
|
||||
$critical_max, $history_data, $ff_threshold) = @ARGV[2..18];
|
||||
@ -724,9 +667,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
|
||||
}
|
||||
elsif ($param eq '--create_snmp_module') {
|
||||
param_check($ltotal, 26, 20);
|
||||
|
||||
##############################################################################
|
||||
# Create snmp module.
|
||||
# Related option: --create_snmp_module
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_snmp_module() {
|
||||
my ($module_name, $module_type, $agent_name, $module_address, $module_port, $version, $community,
|
||||
$oid, $description, $module_group, $min, $max, $post_process, $interval, $warning_min,
|
||||
$warning_max, $critical_min, $critical_max, $history_data, $snmp3_priv_method, $snmp3_priv_pass,
|
||||
@ -796,9 +743,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
|
||||
}
|
||||
elsif ($param eq '--create_plugin_module') {
|
||||
param_check($ltotal, 21, 12);
|
||||
|
||||
##############################################################################
|
||||
# Create plugin module.
|
||||
# Related option: --create_plugin_module
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_plugin_module() {
|
||||
my ($module_name, $module_type, $agent_name, $module_address, $module_port, $plugin_name,
|
||||
$user, $password, $parameters, $description, $module_group, $min, $max, $post_process,
|
||||
$interval, $warning_min, $warning_max, $critical_min, $critical_max, $history_data,
|
||||
@ -862,8 +813,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_create_module_from_hash ($conf, \%parameters, $dbh);
|
||||
}
|
||||
elsif ($param eq '--delete_module') {
|
||||
param_check($ltotal, 2);
|
||||
|
||||
##############################################################################
|
||||
# Create delete module.
|
||||
# Related option: --delete_module
|
||||
##############################################################################
|
||||
|
||||
sub cli_delete_module() {
|
||||
my ($module_name,$agent_name) = @ARGV[2..3];
|
||||
|
||||
print "[INFO] Deleting module '$module_name' from agent '$agent_name' \n\n";
|
||||
@ -875,9 +831,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_delete_module($dbh,$id_module,$conf);
|
||||
}
|
||||
elsif ($param eq '--delete_not_policy_modules') {
|
||||
param_check($ltotal, 0);
|
||||
|
||||
##############################################################################
|
||||
# Create delete not policy modules.
|
||||
# Related option: --delete_not_policy_modules
|
||||
##############################################################################
|
||||
|
||||
sub cli_delete_not_policy_modules() {
|
||||
my $incomingdir;
|
||||
|
||||
$incomingdir = $conf->{incomingdir}.'/conf/';
|
||||
@ -904,8 +864,13 @@ sub pandora_manage_main ($$$) {
|
||||
pandora_delete_module ($dbh, $module->{'id_agente_modulo'});
|
||||
}
|
||||
}
|
||||
elsif ($param eq '--create_template_module') {
|
||||
param_check($ltotal, 3);
|
||||
|
||||
##############################################################################
|
||||
# Create template module.
|
||||
# Related option: --create_template_module
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_template_module() {
|
||||
my ($template_name,$module_name,$agent_name) = @ARGV[2..4];
|
||||
|
||||
print "[INFO] Adding template '$template_name' to module '$module_name' from agent '$agent_name' \n\n";
|
||||
@ -919,8 +884,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_create_template_module ($conf, $module_id, $template_id, $dbh);
|
||||
}
|
||||
elsif ($param eq '--delete_template_module') {
|
||||
param_check($ltotal, 3);
|
||||
|
||||
##############################################################################
|
||||
# Delete template module.
|
||||
# Related option: --delete_template_module
|
||||
##############################################################################
|
||||
|
||||
sub cli_delete_template_module() {
|
||||
my ($template_name,$module_name,$agent_name) = @ARGV[2..4];
|
||||
|
||||
print "[INFO] Delete template '$template_name' from module '$module_name' from agent '$agent_name' \n\n";
|
||||
@ -937,8 +907,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_delete_template_module ($dbh, $template_module_id);
|
||||
}
|
||||
elsif ($param eq '--create_template_action') {
|
||||
param_check($ltotal, 6, 2);
|
||||
|
||||
##############################################################################
|
||||
# Create template action.
|
||||
# Related option: --create_template_action
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_template_action() {
|
||||
my ($action_name,$template_name,$module_name,$agent_name,$fires_min,$fires_max) = @ARGV[2..7];
|
||||
|
||||
print "[INFO] Adding action '$action_name' to template '$template_name' in module '$module_name' from agent '$agent_name' with $fires_min min. fires and $fires_max max. fires\n\n";
|
||||
@ -966,8 +941,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_create_template_module_action ($conf, \%parameters, $dbh);
|
||||
}
|
||||
elsif ($param eq '--delete_template_action') {
|
||||
param_check($ltotal, 4);
|
||||
|
||||
##############################################################################
|
||||
# Delete template action.
|
||||
# Related option: --delete_template_action
|
||||
##############################################################################
|
||||
|
||||
sub cli_delete_template_action() {
|
||||
my ($action_name,$template_name,$module_name,$agent_name) = @ARGV[2..5];
|
||||
|
||||
print "[INFO] Deleting action '$action_name' from template '$template_name' in module '$module_name' from agent '$agent_name')\n\n";
|
||||
@ -985,8 +965,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_delete_template_module_action ($dbh, $template_module_id, $action_id);
|
||||
}
|
||||
elsif ($param eq '--data_module') {
|
||||
param_check($ltotal, 5, 1);
|
||||
|
||||
##############################################################################
|
||||
# Insert data to module.
|
||||
# Related option: --data_module
|
||||
##############################################################################
|
||||
|
||||
sub cli_data_module() {
|
||||
my ($server_name,$agent_name,$module_name,$module_type,$datetime) = @ARGV[2..6];
|
||||
my $utimestamp;
|
||||
|
||||
@ -1026,8 +1011,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
print "[INFO] Inserting data to module '$module_name'\n\n";
|
||||
}
|
||||
elsif ($param eq '--create_user') {
|
||||
param_check($ltotal, 4, 1);
|
||||
|
||||
##############################################################################
|
||||
# Create a user.
|
||||
# Related option: --create_user
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_user() {
|
||||
my ($user_name,$password,$is_admin,$comments) = @ARGV[2..5];
|
||||
|
||||
$comments = (defined ($comments) ? safe_input($comments) : '' );
|
||||
@ -1036,8 +1026,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_create_user ($dbh, $user_name, md5($password), $is_admin, $comments);
|
||||
}
|
||||
elsif ($param eq '--delete_user') {
|
||||
param_check($ltotal, 1);
|
||||
|
||||
##############################################################################
|
||||
# Delete a user.
|
||||
# Related option: --delete_user
|
||||
##############################################################################
|
||||
|
||||
sub cli_delete_user() {
|
||||
my $user_name = @ARGV[2];
|
||||
|
||||
print "[INFO] Deleting user '$user_name' \n\n";
|
||||
@ -1045,8 +1040,13 @@ sub pandora_manage_main ($$$) {
|
||||
my $result = pandora_delete_user($dbh,$user_name);
|
||||
exist_check($result,'user',$user_name);
|
||||
}
|
||||
elsif ($param eq '--create_profile') {
|
||||
param_check($ltotal, 3);
|
||||
|
||||
##############################################################################
|
||||
# Create profile.
|
||||
# Related option: --create_profile
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_profile() {
|
||||
my ($user_name,$profile_name,$group_name) = @ARGV[2..4];
|
||||
|
||||
my $id_profile = get_profile_id($dbh,$profile_name);
|
||||
@ -1066,8 +1066,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_create_user_profile ($dbh, $user_name, $id_profile, $id_group);
|
||||
}
|
||||
elsif ($param eq '--delete_profile') {
|
||||
param_check($ltotal, 3);
|
||||
|
||||
##############################################################################
|
||||
# Delete profile.
|
||||
# Related option: --delete_profile
|
||||
##############################################################################
|
||||
|
||||
sub cli_delete_profile() {
|
||||
my ($user_name,$profile_name,$group_name) = @ARGV[2..4];
|
||||
|
||||
my $id_profile = get_profile_id($dbh,$profile_name);
|
||||
@ -1087,8 +1092,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
pandora_delete_user_profile ($dbh, $user_name, $id_profile, $id_group);
|
||||
}
|
||||
elsif ($param eq '--create_event') {
|
||||
param_check($ltotal, 8, 3);
|
||||
|
||||
##############################################################################
|
||||
# Create event.
|
||||
# Related option: --create_event
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_event() {
|
||||
my ($event,$event_type,$agent_name,$module_name,$group_name,$event_status,$severity,$template_name) = @ARGV[2..9];
|
||||
|
||||
$event_status = 0 unless defined($event_status);
|
||||
@ -1141,13 +1151,17 @@ sub pandora_manage_main ($$$) {
|
||||
pandora_event ($conf, $event, $id_group, $id_agent, $severity,
|
||||
$id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh);
|
||||
}
|
||||
elsif ($param eq '--validate_event') {
|
||||
param_check($ltotal, 7, 6);
|
||||
|
||||
##############################################################################
|
||||
# Validate event.
|
||||
# Related option: --validate_event
|
||||
##############################################################################
|
||||
|
||||
sub cli_validate_event() {
|
||||
my ($agent_name, $module_name, $datetime_min, $datetime_max, $user_name, $criticity, $template_name) = @ARGV[2..8];
|
||||
my $id_agent = '';
|
||||
my $id_agentmodule = '';
|
||||
|
||||
|
||||
if(defined($agent_name) && $agent_name ne '') {
|
||||
$id_agent = get_agent_id($dbh,$agent_name);
|
||||
exist_check($id_agent,'agent',$agent_name);
|
||||
@ -1188,8 +1202,13 @@ sub pandora_manage_main ($$$) {
|
||||
pandora_validate_event_filter ($conf, $id_agentmodule, $id_agent, $datetime_min, $datetime_max, $user_name, $id_alert_agent_module, $criticity, $dbh);
|
||||
print "[INFO] Validating event for agent '$agent_name'\n\n";
|
||||
}
|
||||
elsif ($param eq '--create_incident') {
|
||||
param_check($ltotal, 7, 1);
|
||||
|
||||
##############################################################################
|
||||
# Create incident.
|
||||
# Related option: --create_incident
|
||||
##############################################################################
|
||||
|
||||
sub cli_create_incident() {
|
||||
my ($title, $description, $origin, $status, $priority, $group_name, $owner) = @ARGV[2..8];
|
||||
|
||||
my $id_group = get_group_id($dbh,$group_name);
|
||||
@ -1198,8 +1217,14 @@ sub pandora_manage_main ($$$) {
|
||||
pandora_create_incident ($conf, $dbh, $title, $description, $priority, $status, $origin, $id_group, $owner);
|
||||
print "[INFO] Creating incident '$title'\n\n";
|
||||
}
|
||||
elsif ($param eq '--delete_data') {
|
||||
param_check($ltotal, 3, 1);
|
||||
|
||||
##############################################################################
|
||||
# Delete data.
|
||||
# Related option: --delete_data
|
||||
##############################################################################
|
||||
|
||||
sub cli_delete_data($) {
|
||||
my $ltotal = shift;
|
||||
my ($opt, $name, $name2) = @ARGV[2..4];
|
||||
|
||||
if($opt eq '-m' || $opt eq '--m') {
|
||||
@ -1239,8 +1264,13 @@ sub pandora_manage_main ($$$) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
elsif ($param eq '--apply_policy') {
|
||||
param_check($ltotal, 1);
|
||||
|
||||
##############################################################################
|
||||
# Add policy to apply queue.
|
||||
# Related option: --apply policy
|
||||
##############################################################################
|
||||
|
||||
sub cli_apply_policy() {
|
||||
my $policy_name = @ARGV[2];
|
||||
|
||||
my $configuration_data = "";
|
||||
@ -1257,8 +1287,13 @@ sub pandora_manage_main ($$$) {
|
||||
|
||||
print "[INFO] Added operation 'apply' to policy '$policy_name'\n\n";
|
||||
}
|
||||
elsif ($param eq '--disable_policy_alerts') {
|
||||
param_check($ltotal, 1);
|
||||
|
||||
##############################################################################
|
||||
# Disable policy alerts.
|
||||
# Related option: --disable_policy_alerts
|
||||
##############################################################################
|
||||
|
||||
sub cli_disable_policy_alerts() {
|
||||
my $policy_name = @ARGV[2];
|
||||
|
||||
my $configuration_data = "";
|
||||
@ -1269,6 +1304,211 @@ sub pandora_manage_main ($$$) {
|
||||
# Flag as disabled the policy alerts
|
||||
my $array_pointer_ag = enterprise_hook('pandora_disable_policy_alerts',[$dbh, $policy_id]);
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Disable alert system globally
|
||||
# Related option: --disable_alerts
|
||||
###############################################################################
|
||||
sub cli_disable_alerts ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
|
||||
print "[INFO] Disabling all alerts \n\n";
|
||||
|
||||
# This works by disabling alerts in each defined group
|
||||
# If you have previously a group with alert disabled, and you disable
|
||||
# alerts globally, when enabled it again, it will enabled also !
|
||||
|
||||
db_do ($dbh, "UPDATE tgrupo SET disabled = 1");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Enable alert system globally
|
||||
# Related option: --enable_alerts
|
||||
###############################################################################
|
||||
sub cli_enable_alerts ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
|
||||
print "[INFO] Enabling all alerts \n\n";
|
||||
|
||||
db_do ($dbh, "UPDATE tgrupo SET disabled = 0");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Disable enterprise ACL
|
||||
# Related option: --disable_eacl
|
||||
###############################################################################
|
||||
sub cli_disable_eacl ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
|
||||
print "[INFO] Disabling Enterprise ACL system (system wide)\n\n";
|
||||
|
||||
db_do ($dbh, "UPDATE tconfig SET `value` ='0' WHERE `token` = 'acl_enterprise'");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Enable enterprise ACL
|
||||
# Related option: --enable_eacl
|
||||
###############################################################################
|
||||
sub cli_enable_eacl ($$) {
|
||||
my ($conf, $dbh) = @_;
|
||||
|
||||
print "[INFO] Enabling Enterprise ACL system (system wide)\n\n";
|
||||
|
||||
db_do ($dbh, "UPDATE tconfig SET `value` ='1' WHERE `token` = 'acl_enterprise'");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
# MAIN
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
sub pandora_manage_main ($$$) {
|
||||
my ($conf, $dbh, $history_dbh) = @_;
|
||||
|
||||
my @args = @ARGV;
|
||||
my $ltotal=$#args;
|
||||
my $ax;
|
||||
|
||||
# Has read setup file ok ?
|
||||
if ( $ltotal == 0 ) {
|
||||
print "[ERROR] No valid arguments\n\n";
|
||||
help_screen();
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$param = $args[1];
|
||||
|
||||
# help!
|
||||
if ($param =~ m/--*h\w*\z/i ) {
|
||||
$param = '';
|
||||
help_screen () ;
|
||||
exit;
|
||||
}
|
||||
elsif ($param eq '--disable_alerts') {
|
||||
param_check($ltotal, 0);
|
||||
cli_disable_alerts ($conf, $dbh);
|
||||
}
|
||||
elsif ($param eq '--enable_alerts') {
|
||||
param_check($ltotal, 0);
|
||||
cli_enable_alerts ($conf, $dbh);
|
||||
}
|
||||
elsif ($param eq '--disable_eacl') {
|
||||
param_check($ltotal, 0);
|
||||
cli_disable_eacl ($conf, $dbh);
|
||||
}
|
||||
elsif ($param eq '--enable_eacl') {
|
||||
param_check($ltotal, 0);
|
||||
pandora_enable_eacl ($conf, $dbh);
|
||||
}
|
||||
elsif ($param eq '--disable_group') {
|
||||
param_check($ltotal, 1);
|
||||
cli_disable_group();
|
||||
}
|
||||
elsif ($param eq '--enable_group') {
|
||||
param_check($ltotal, 1);
|
||||
cli_enable_group();
|
||||
}
|
||||
elsif ($param eq '--create_agent') {
|
||||
param_check($ltotal, 7, 3);
|
||||
cli_create_agent();
|
||||
}
|
||||
elsif ($param eq '--delete_agent') {
|
||||
param_check($ltotal, 1);
|
||||
cli_delete_agent();
|
||||
}
|
||||
elsif ($param eq '--create_data_module') {
|
||||
param_check($ltotal, 15, 12);
|
||||
cli_create_data_module();
|
||||
}
|
||||
elsif ($param eq '--create_network_module') {
|
||||
param_check($ltotal, 17, 13);
|
||||
cli_create_network_module();
|
||||
}
|
||||
elsif ($param eq '--create_snmp_module') {
|
||||
param_check($ltotal, 26, 20);
|
||||
cli_create_snmp_module();
|
||||
}
|
||||
elsif ($param eq '--create_plugin_module') {
|
||||
param_check($ltotal, 21, 12);
|
||||
cli_create_plugin_module();
|
||||
}
|
||||
elsif ($param eq '--delete_module') {
|
||||
param_check($ltotal, 2);
|
||||
cli_delete_module();
|
||||
}
|
||||
elsif ($param eq '--delete_not_policy_modules') {
|
||||
param_check($ltotal, 0);
|
||||
cli_delete_not_policy_modules();
|
||||
}
|
||||
elsif ($param eq '--create_template_module') {
|
||||
param_check($ltotal, 3);
|
||||
cli_create_template_module();
|
||||
}
|
||||
elsif ($param eq '--delete_template_module') {
|
||||
param_check($ltotal, 3);
|
||||
cli_delete_template_module();
|
||||
}
|
||||
elsif ($param eq '--create_template_action') {
|
||||
param_check($ltotal, 6, 2);
|
||||
cli_create_template_action();
|
||||
}
|
||||
elsif ($param eq '--delete_template_action') {
|
||||
param_check($ltotal, 4);
|
||||
cli_delete_template_action();
|
||||
}
|
||||
elsif ($param eq '--data_module') {
|
||||
param_check($ltotal, 5, 1);
|
||||
cli_data_module();
|
||||
}
|
||||
elsif ($param eq '--create_user') {
|
||||
param_check($ltotal, 4, 1);
|
||||
cli_create_user();
|
||||
}
|
||||
elsif ($param eq '--delete_user') {
|
||||
param_check($ltotal, 1);
|
||||
cli_delete_user();
|
||||
}
|
||||
elsif ($param eq '--create_profile') {
|
||||
param_check($ltotal, 3);
|
||||
cli_create_profile();
|
||||
}
|
||||
elsif ($param eq '--delete_profile') {
|
||||
param_check($ltotal, 3);
|
||||
cli_delete_profile();
|
||||
}
|
||||
elsif ($param eq '--create_event') {
|
||||
param_check($ltotal, 8, 3);
|
||||
cli_create_event();
|
||||
}
|
||||
elsif ($param eq '--validate_event') {
|
||||
param_check($ltotal, 7, 6);
|
||||
cli_validate_event();
|
||||
}
|
||||
elsif ($param eq '--create_incident') {
|
||||
param_check($ltotal, 7, 1);
|
||||
cli_create_incident();
|
||||
}
|
||||
elsif ($param eq '--delete_data') {
|
||||
param_check($ltotal, 3, 1);
|
||||
cli_delete_data($ltotal);
|
||||
}
|
||||
elsif ($param eq '--apply_policy') {
|
||||
param_check($ltotal, 1);
|
||||
cli_apply_policy();
|
||||
}
|
||||
elsif ($param eq '--disable_policy_alerts') {
|
||||
param_check($ltotal, 1);
|
||||
cli_disable_policy_alerts();
|
||||
}
|
||||
else {
|
||||
print "[ERROR] Invalid option '$param'.\n\n";
|
||||
$param = '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user