Fixed problems with data from database when db is oracle

This commit is contained in:
m-lopez-f 2015-10-19 08:32:37 +02:00
parent dcc22b984e
commit 1f99733ac8
2 changed files with 12 additions and 5 deletions

View File

@ -65,19 +65,26 @@ if (is_ajax ()) {
// Descriptions are stored in json // Descriptions are stored in json
$fields_descriptions = empty($command['fields_descriptions']) ? $fields_descriptions = empty($command['fields_descriptions']) ?
'' : json_decode(io_safe_output($command['fields_descriptions']), true); '' : json_decode(io_safe_output($command['fields_descriptions']), true);
html_debug($fields_descriptions,true);
// Fields values are stored in json // Fields values are stored in json
$fields_values = empty($command['fields_values']) ? $fields_values = empty($command['fields_values']) ?
'' : io_safe_output(json_decode($command['fields_values'], true)); '' : io_safe_output(json_decode($command['fields_values'], true));
break; break;
case "oracle": case "oracle":
// Descriptions are stored in json // Descriptions are stored in json
$description_field = str_replace("\\\"","\"",$command['fields_descriptions']);
$description_field = str_replace("\\","",$description_field);
$fields_descriptions = empty($command['fields_descriptions']) ? $fields_descriptions = empty($command['fields_descriptions']) ?
'' : json_decode(io_safe_output(str_replace("\\","",$command['fields_descriptions'])), true); '' : json_decode(io_safe_output($description_field), true);
html_debug($fields_descriptions,true);
// Fields values are stored in json // Fields values are stored in json
$values_fields = str_replace("\\\"","\"",$command['fields_values']);
$values_fields = str_replace("\\","",$values_fields);
$fields_values = empty($command['fields_values']) ? $fields_values = empty($command['fields_values']) ?
'' : io_safe_output(json_decode(str_replace("\\","",$command['fields_values']), true)); '' : io_safe_output(json_decode($values_fields, true));
break; break;
} }

View File

@ -34,7 +34,7 @@ INSERT INTO talert_commands (id, name, command, description, internal, fields_de
INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (2,'Internal Audit','Internal type','This alert save alert in Pandora internal audit system. Fields are static and only _field1_ is used.',1,'[\"Description\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (2,'Internal Audit','Internal type','This alert save alert in Pandora internal audit system. Fields are static and only _field1_ is used.',1,'[\"Description\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (3,'Pandora FMS Event','Internal type','This alert create an special event into Pandora FMS event manager.',1,'[\"Event text\",\"Event type\",\"Source\",\"Agent name or _agent_\",\"Event criticity\",\"ID extra\",\"Tags separated by commas\",\"Comments\",\"\",\"\"]','[\"\",\"alert_ceased,Alert ceased;alert_fired,Alert fired;alert_manual_validation,Alert manual validation;alert_recovered,Alert recovered;configuration_change,Configuration change ;error,Error;critical,Monitor Critical;normal,Monitor Normal;going_unknown,Monitor\",\"\",\"\",\"4,Critical;1,Informational;0,Maintenance;6,Major;5,Minor;2,Normal;3,Warning\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (3,'Pandora FMS Event','Internal type','This alert create an special event into Pandora FMS event manager.',1,'[\"Event text\",\"Event type\",\"Source\",\"Agent name or _agent_\",\"Event criticity\",\"ID extra\",\"Tags separated by commas\",\"Comments\",\"\",\"\"]','[\"\",\"alert_ceased,Alert ceased;alert_fired,Alert fired;alert_manual_validation,Alert manual validation;alert_recovered,Alert recovered;configuration_change,Configuration change ;error,Error;critical,Monitor Critical;normal,Monitor Normal;going_unknown,Monitor\",\"\",\"\",\"4,Critical;1,Informational;0,Maintenance;6,Major;5,Minor;2,Normal;3,Warning\",\"\",\"\",\"\",\"\",\"\"]');
INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (4,'Pandora FMS Alertlog','echo _timestamp_ pandora _agent_ _data_ _field1_ _field2_ >> /var/log/pandora/pandora_alert.log','This is a default alert to write alerts in a standard ASCII  plaintext log file in /var/log/pandora/pandora_alert.log
',0,'[\"Log Info 1\",\"Log Info 2\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (4,'Pandora FMS Alertlog','echo _timestamp_ pandora _agent_ _data_ _field1_ _field2_ >> /var/log/pandora/pandora_alert.log','This is a default alert to write alerts in a standard ASCII  plaintext log file in /var/log/pandora/pandora_alert.log
',0,'[\"Log Info 1\",\"Log Info 2\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (5,'SNMP Trap','/usr/bin/snmptrap -v 1 -c _field1_ _field2_ _field3_ _field4_','Send a SNMPTRAP to 192.168.0.4. Please review config and adapt to your needs, this is only a sample, not functional itself.',0,'[\"Community\",\Destination address\",\"OID\",\"Source address\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (5,'SNMP Trap','/usr/bin/snmptrap -v 1 -c _field1_ _field2_ _field3_ _field4_','Send a SNMPTRAP to 192.168.0.4. Please review config and adapt to your needs, this is only a sample, not functional itself.',0,'[\"Community\",\"Destination address\",\"OID\",\"Source address\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (6,'Syslog','logger -p daemon.alert Pandora Alert _agent_ _data_ _field1_ _field2_','Uses field1 and field2 to generate Syslog alert in facility daemon with "alert" level.',0,'[\"Log Info 1\",\"Log Info 2\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (6,'Syslog','logger -p daemon.alert Pandora Alert _agent_ _data_ _field1_ _field2_','Uses field1 and field2 to generate Syslog alert in facility daemon with "alert" level.',0,'[\"Log Info 1\",\"Log Info 2\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');
INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (7,'Sound Alert','/usr/bin/play /usr/share/sounds/alarm.wav','',0,NULL,NULL); INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (7,'Sound Alert','/usr/bin/play /usr/share/sounds/alarm.wav','',0,NULL,NULL);
INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (8,'Jabber Alert','echo _field3_ | sendxmpp -r _field1_ --chatroom _field2_','Send jabber alert to chat room in a predefined server (configure first .sendxmpprc file). Uses field3 as text message, field1 as useralias for source message, and field2 for chatroom name',0,'[\"User alias\",\"Chatroom name\",\Message\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]'); INSERT INTO talert_commands (id, name, command, description, internal, fields_descriptions, fields_values) VALUES (8,'Jabber Alert','echo _field3_ | sendxmpp -r _field1_ --chatroom _field2_','Send jabber alert to chat room in a predefined server (configure first .sendxmpprc file). Uses field3 as text message, field1 as useralias for source message, and field2 for chatroom name',0,'[\"User alias\",\"Chatroom name\",\Message\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]','[\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]');