Fixes for oracle
This commit is contained in:
parent
72ee6158fa
commit
c437797ef7
|
@ -48,7 +48,16 @@ $snmpwalk = (int) get_parameter("snmpwalk", 0);
|
|||
$create_modules = (int) get_parameter("create_modules", 0);
|
||||
|
||||
// Get the plugin
|
||||
$plugin = db_get_row_sql("SELECT * FROM tplugin WHERE execute LIKE '%/snmp_remote.pl'");
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
$plugin = db_get_row_sql("SELECT id, macros FROM tplugin WHERE execute LIKE '%/snmp_remote.pl'");
|
||||
break;
|
||||
case 'oracle':
|
||||
$plugin = db_get_row_sql("SELECT id, TO_CHAR(macros) AS macros FROM tplugin WHERE execute LIKE '%/snmp_remote.pl'");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (empty($plugin)) {
|
||||
ui_print_info_message(array('message' => __('The SNMP remote plugin doesnt seem to be installed') . '. ' . __('It is necessary to use some features') . '.<br><br>' . __('Please, install the SNMP remote plugin (The name of the plugin must be snmp_remote.pl)'), 'no_close' => true));
|
||||
|
@ -465,7 +474,10 @@ if ($create_modules) {
|
|||
$module_values['id_modulo'] = MODULE_PLUGIN;
|
||||
$module_values['id_plugin'] = $plugin['id'];
|
||||
|
||||
$macros = json_decode($plugin['macros'], true);
|
||||
// Avoid the return of a string containing the word 'null' if the macros column is not defined
|
||||
$macros = array();
|
||||
if (isset($plugin['macros']) && !empty($plugin['macros']))
|
||||
$macros = json_decode($plugin['macros'], true);
|
||||
|
||||
foreach ($macros as $k => $macro) {
|
||||
switch($macro['macro']) {
|
||||
|
@ -518,7 +530,8 @@ if ($create_modules) {
|
|||
}
|
||||
}
|
||||
|
||||
$module_values['macros'] = io_json_mb_encode($macros);
|
||||
if (!empty($macros))
|
||||
$module_values['macros'] = io_json_mb_encode($macros);
|
||||
|
||||
unset($module_values['snmp_community']); //snmp_community
|
||||
unset($module_values['ip_target']); //ip_target
|
||||
|
@ -545,7 +558,10 @@ if ($create_modules) {
|
|||
$module_values['id_modulo'] = MODULE_PLUGIN;
|
||||
$module_values['id_plugin'] = $plugin['id'];
|
||||
|
||||
$macros = json_decode($plugin['macros'], true);
|
||||
// Avoid the return of a string containing the word 'null' if the macros column is not defined
|
||||
$macros = array();
|
||||
if (isset($plugin['macros']) && !empty($plugin['macros']))
|
||||
$macros = json_decode($plugin['macros'], true);
|
||||
|
||||
foreach ($macros as $k => $macro) {
|
||||
switch($macro['macro']) {
|
||||
|
@ -591,7 +607,8 @@ if ($create_modules) {
|
|||
}
|
||||
}
|
||||
|
||||
$module_values['macros'] = io_json_mb_encode($macros);
|
||||
if (!empty($macros))
|
||||
$module_values['macros'] = io_json_mb_encode($macros);
|
||||
|
||||
unset($module_values['snmp_community']); //snmp_community
|
||||
unset($module_values['ip_target']); //ip_target
|
||||
|
@ -612,7 +629,10 @@ if ($create_modules) {
|
|||
$module_values['id_modulo'] = MODULE_PLUGIN;
|
||||
$module_values['id_plugin'] = $plugin['id'];
|
||||
|
||||
$macros = json_decode($plugin['macros'], true);
|
||||
// Avoid the return of a string containing the word 'null' if the macros column is not defined
|
||||
$macros = array();
|
||||
if (isset($plugin['macros']) && !empty($plugin['macros']))
|
||||
$macros = json_decode($plugin['macros'], true);
|
||||
|
||||
foreach ($macros as $k => $macro) {
|
||||
switch($macro['macro']) {
|
||||
|
@ -657,7 +677,8 @@ if ($create_modules) {
|
|||
}
|
||||
}
|
||||
|
||||
$module_values['macros'] = io_json_mb_encode($macros);
|
||||
if (!empty($macros))
|
||||
$module_values['macros'] = io_json_mb_encode($macros);
|
||||
|
||||
unset($module_values['snmp_community']); //snmp_community
|
||||
unset($module_values['ip_target']); //ip_target
|
||||
|
|
|
@ -1220,7 +1220,7 @@ LOCK TABLE talert_templates IN EXCLUSIVE MODE;
|
|||
EXECUTE IMMEDIATE 'ALTER TRIGGER talert_templates_inc DISABLE';
|
||||
|
||||
INSERT INTO talert_templates (id, name, description, id_alert_action, field1, field2, field3, type, value, matches_value, max_value, min_value, time_threshold, max_alerts, min_alerts, time_from, time_to, monday, tuesday, wednesday, thursday, friday, saturday, sunday, recovery_notify, field2_recovery, field3_recovery, priority, id_group, special_day, wizard_level) VALUES (1,'Critical condition','This is a generic alert template to fire on condition CRITICAL',1,'','','Hello, this is an automated email coming from Pandora FMS\r\n\r\nThis alert has been fired because a CRITICAL condition in one of your monitored items:\r\n\r\nAgent : _agent_\r\nModule: _module_\r\nModule description: _moduledescription_\r\nTimestamp _timestamp_\r\nCurrent value: _data_\r\n\r\nThanks for your time.\r\n\r\nBest regards\r\nPandora FMS\r\n','critical','',1,0.00,0.00,86400,1,0,to_date('12:00:00','hh24:mi:ss'),to_date('12:00:00','hh24:mi:ss'),1,1,1,1,1,1,1,1,'[PANDORA] Alert RECOVERED for CRITICAL status on _agent_ / _module_','Hello, this is an automated email coming from Pandora FMS\r\n\r\nThis alert has been RECOVERED from a CRITICAL condition in one of your monitored items:\r\n\r\nAgent : _agent_\r\nModule: _module_\r\nModule description: _moduledescription_\r\nTimestamp _timestamp_\r\nCurrent value: _data_\r\n\r\nThanks for your time.\r\n\r\nBest regards\r\nPandora FMS\r\n',4,0,0,'basic');
|
||||
INSERT INTO talert_templates (id, name, description, id_alert_action, field1, field2, field3, type, value, matches_value, max_value, min_value, time_threshold, max_alerts, min_alerts, time_from, time_to, monday, tuesday, wednesday, thursday, friday, saturday, sunday, recovery_notify, field2_recovery, field3_recovery, priority, id_group, special_day, wizard_level) VALUES (2,'Manual alert','This is a template used to fire manual alerts, condition defined here never will be executed. Use this template to assign to your actions/commands used to do remote management (Agent restart, execute commands on server, etc).',NULL,'','',' ','max_min','',1,0.00,1.00,86400,1,0,to_date('12:00:00','hh24:mi:ss'),to_date('12:00:00','hh24:mi:ss'),1,1,1,1,1,1,1,0,' ',' ',1,0,0,'basic');
|
||||
INSERT INTO talert_templates (id, name, description, id_alert_action, field1, field2, field3, type, value, matches_value, max_value, min_value, time_threshold, max_alerts, min_alerts, time_from, time_to, monday, tuesday, wednesday, thursday, friday, saturday, sunday, recovery_notify, field2_recovery, field3_recovery, priority, id_group, special_day, wizard_level) VALUES (2,'Manual alert','This is a template used to fire manual alerts, condition defined here never will be executed. Use this template to assign to your actions/commands used to do remote management (Agent restart, execute commands on server, etc).',NULL,'','','','max_min','',1,0.00,1.00,86400,1,0,to_date('12:00:00','hh24:mi:ss'),to_date('12:00:00','hh24:mi:ss'),1,1,1,1,1,1,1,0,'','',1,0,0,'basic');
|
||||
INSERT INTO talert_templates (id, name, description, id_alert_action, field1, field2, field3, type, value, matches_value, max_value, min_value, time_threshold, max_alerts, min_alerts, time_from, time_to, monday, tuesday, wednesday, thursday, friday, saturday, sunday, recovery_notify, field2_recovery, field3_recovery, priority, id_group, special_day, wizard_level) VALUES (3,'Warning condition','This is a generic alert template to fire on WARNING condition.',1,'','','Hello, this is an automated email coming from Pandora FMS

This alert has been fired because a WARNING condition in one of your monitored items:

Agent : _agent_
Module: _module_
Module description: _moduledescription_
Timestamp _timestamp_
Current value: _data_

Thanks for your time.

Best regards
Pandora FMS
','warning','',1,0.00,0.00,86400,1,0,to_date('12:00:00','hh24:mi:ss'),to_date('12:00:00','hh24:mi:ss'),1,1,1,1,1,1,1,1,'[PANDORA] Alert RECOVERED for WARNING status on _agent_ / _module_','Hello, this is an automated email coming from Pandora FMS

This alert has been RECOVERED from a WARNING condition in one of your monitored items:

Agent : _agent_
Module: _module_
Module description: _moduledescription_
Timestamp _timestamp_
Current value: _data_

Thanks for your time.

Best regards
Pandora FMS
',3,0,0,'basic');
|
||||
|
||||
-- Update curr val of sequence
|
||||
|
@ -1334,12 +1334,12 @@ LOCK TABLE tplugin IN EXCLUSIVE MODE;
|
|||
|
||||
EXECUTE IMMEDIATE 'ALTER TRIGGER tplugin_inc DISABLE';
|
||||
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (1,'IPMI Plugin','Plugin to get IPMI monitors from a IPMI Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{1:{macro:"_field1_",desc:Target IP,help:"",value:"","hide":""},2:{macro:"_field2_",desc:Username,help:"",value:"","hide":""},3:{macro:"_field3_",desc:Password,help:"",value:"","hide":""},"4":{"macro":"_field4_","desc":"Sensor","help":"","value":"","hide":""},"5":{"macro":"_field5_","desc":"Additional Options","help":"","value":"","hide":""}}','-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (2,'DNS Plugin','This plugin is used to check if a specific domain return a specific IP address, and to check how time (milisecs) takes the DNS to answer. Use IP address parameter to specify the IP of your domain. Use these custom parameters for the other parameters:

-d domain to check (for example pandorafms.com)
-s DNS Server to check  (for example 8.8.8.8)

Optional parameters:

-t Do a DNS time response check instead DNS resolve test

',15,'/usr/share/pandora_server/util/plugin/dns_plugin.sh',0,'{1:{macro:"_field1_",desc:Target IP,help:"",value:""},2:{macro:"_field2_",desc:Domain to check,help:For example pandorafms.com,value:""},3:{macro:"_field3_",desc:DNS Server to check,help:For example 8.8.8.8,value:""},4:{macro:"_field4_",desc:Optional parameters,help:"",value:""}}','-i _field1_ -d _field2_ -s _field3_ _field4_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (3,'UDP port check','Check a remote UDP port (by using NMAP). Use IP address and Port options.',5,'/usr/share/pandora_server/util/plugin/udp_nmap_plugin.sh',0,'{1:{macro:"_field1_",desc:Target IP,help:"",value:""},2:{macro:"_field2_",desc:Port,help:"",value:""}}','-t _field1_-p _field2_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (4,'SMTP Check','This plugin is used to send a mail to a SMTP server and check if works. 

Parameters in the plugin:

IP Address - SMTP Server IP address
User - AUTH login  
Pass - AUTH password
Port - SMTP port (optional)

Optional parameters:

-d Destination email
-f Email of the sender
-a Authentication system. Could be LOGIN, PLAIN, CRAM-MD5 or DIGEST-MD',10,'/usr/share/pandora_server/util/plugin/SMTP_check.pl',0,'{1:{macro:"_field1_",desc:Target IP,help:"",value:""},2:{macro:"_field2_",desc:Port,help:"",value:""},3:{macro:"_field3_",desc:Username,help:"",value:""},4:{macro:"_field4_",desc:Password,help:"",value:""},5:{macro:"_field5_",desc:Optional parameters,help:"",value:""}}','-h _field1_ -o _field2_ -u _field3_ -p _field4_ _field5_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (6,'MySQL Plugin','Samples:
   ./mysql_plugin.sh -u root -p none -s localhost -q Com_select
   ./mysql_plugin.sh -u root -p none -s localhost -q Com_update
   ./mysql_plugin.sh -u root -p none -s localhost -q Connections
   ./mysql_plugin.sh -u root -p anypass -s 192.168.50.24 -q Innodb_rows_read
',15,'/usr/share/pandora_server/util/plugin/mysql_plugin.sh',0,'{1:{macro:"_field1_",desc:IP address,help:IP address,value:""},2:{macro:"_field2_",desc:Username,help:Username to access to database,value:""},3:{macro:"_field3_",desc:Password,help:Password to access to database,value:""},4:{macro:"_field4_",desc:Query string,help:Query string of global status. For example 'Aborted_connects' or 'Innodb_rows_read'",value:""}}', '-s _field1_ -u _field2_ -p _field3_ -q _field4_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (8,'SNMP remote','Plugin that gets remotely, using SNMP, values such as the percentage of disk or memory used, the status of a process or the CPU load',0,'perl /usr/share/pandora_server/util/plugin/snmp_remote.pl',0,'{1:{macro:"_field1_",desc:Target IP,help:"",value:"_address_"},2:{macro:"_field2_",desc:Community,help:"",value:public},3:{macro:"_field3_",desc:Plug-in Parameters,help:Memory use (%)
-m memuse

Disk use (%)
-m diskuse -d [disk name]

Status of a process (0/1)
-m process -p [process_name] 

Average of CPUs Load (%)
-m cpuload,value:""}}', '-H _field1_ -c _field2_ _field3_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (1,'IPMI Plugin','Plugin to get IPMI monitors from a IPMI Device.',0,'/usr/share/pandora_server/util/plugin/ipmi-plugin.pl',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":"","hide":""},"2":{"macro":"_field2_","desc":"Username","help":"","value":"","hide":""},"3":{"macro":"_field3_","desc":"Password","help":"","value":"","hide":""},"4":{"macro":"_field4_","desc":"Sensor","help":"","value":"","hide":""},"5":{"macro":"_field5_","desc":"Additional Options","help":"","value":"","hide":""}}','-h _field1_ -u _field2_ -p _field3_ -s _field4_ -- _field5_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (2,'DNS Plugin','This plugin is used to check if a specific domain return a specific IP address, and to check how time (milisecs) takes the DNS to answer. Use IP address parameter to specify the IP of your domain. Use these custom parameters for the other parameters:

-d domain to check (for example pandorafms.com)
-s DNS Server to check  (for example 8.8.8.8)

Optional parameters:

-t Do a DNS time response check instead DNS resolve test

',15,'/usr/share/pandora_server/util/plugin/dns_plugin.sh',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Domain to check","help":"For example pandorafms.com","value":""},"3":{"macro":"_field3_","desc":"DNS Server to check","help":"For example 8.8.8.8","value":""},"4":{"macro":"_field4_","desc":"Optional parameters","help":"","value":""}}','-i _field1_ -d _field2_ -s _field3_ _field4_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (3,'UDP port check','Check a remote UDP port (by using NMAP). Use IP address and Port options.',5,'/usr/share/pandora_server/util/plugin/udp_nmap_plugin.sh',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Port","help":"","value":""}}','-t _field1_-p _field2_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (4,'SMTP Check','This plugin is used to send a mail to a SMTP server and check if works. 

Parameters in the plugin:

IP Address - SMTP Server IP address
User - AUTH login  
Pass - AUTH password
Port - SMTP port (optional)

Optional parameters:

-d Destination email
-f Email of the sender
-a Authentication system. Could be LOGIN, PLAIN, CRAM-MD5 or DIGEST-MD',10,'/usr/share/pandora_server/util/plugin/SMTP_check.pl',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":""},"2":{"macro":"_field2_","desc":"Port","help":"","value":""},"3":{"macro":"_field3_","desc":"Username","help":"","value":""},"4":{"macro":"_field4_","desc":"Password","help":"","value":""},"5":{"macro":"_field5_","desc":"Optional parameters","help":"","value":""}}','-h _field1_ -o _field2_ -u _field3_ -p _field4_ _field5_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (6,'MySQL Plugin','Samples:
   ./mysql_plugin.sh -u root -p none -s localhost -q Com_select
   ./mysql_plugin.sh -u root -p none -s localhost -q Com_update
   ./mysql_plugin.sh -u root -p none -s localhost -q Connections
   ./mysql_plugin.sh -u root -p anypass -s 192.168.50.24 -q Innodb_rows_read
',15,'/usr/share/pandora_server/util/plugin/mysql_plugin.sh',0,'{"1":{"macro":"_field1_","desc":"IP address","help":"IP address","value":""},"2":{"macro":"_field2_","desc":"Username","help":"Username to access to database","value":""},"3":{"macro":"_field3_","desc":"Password","help":"Password to access to database","value":""},"4":{"macro":"_field4_","desc":"Query string","help":"Query string of global status. For example 'Aborted_connects' or 'Innodb_rows_read'","value":""}}', '-s _field1_ -u _field2_ -p _field3_ -q _field4_');
|
||||
INSERT INTO tplugin (id, name, description, max_timeout, execute, plugin_type, macros, parameters) VALUES (8,'SNMP remote','Plugin that gets remotely, using SNMP, values such as the percentage of disk or memory used, the status of a process or the CPU load',0,'perl /usr/share/pandora_server/util/plugin/snmp_remote.pl',0,'{"1":{"macro":"_field1_","desc":"Target IP","help":"","value":"_address_"},"2":{"macro":"_field2_","desc":"Community","help":"","value":"public"},"3":{"macro":"_field3_","desc":"Plug-in Parameters","help":"Memory use (%)
-m memuse

Disk use (%)
-m diskuse -d [disk name]

Status of a process (0/1)
-m process -p [process_name] 

Average of CPUs Load (%)
-m cpuload","value":""}}', '-H _field1_ -c _field2_ _field3_');
|
||||
|
||||
-- Update curr val of sequence
|
||||
update_currval('tplugin', 'id');
|
||||
|
|
|
@ -3002,6 +3002,7 @@ sub pandora_exec_forced_alerts {
|
|||
FROM talert_template_modules, talert_templates
|
||||
WHERE talert_template_modules.id_alert_template = talert_templates.id
|
||||
AND force_execution = 1');
|
||||
|
||||
foreach my $alert (@alerts) {
|
||||
|
||||
# Get the agent and module associated with the alert
|
||||
|
|
Loading…
Reference in New Issue