From bc87b827004c5d296ea678645036635a93dda7e4 Mon Sep 17 00:00:00 2001 From: esanchezm Date: Mon, 12 Jan 2009 15:17:19 +0000 Subject: [PATCH] 2009-01-12 Esteban Sanchez * include/javascript/pandora_alerts.js: Added to repository. Javascript functions for alerts. * pandoradb_data.sql: Added missing field in a talert_commands row. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1333 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 +++++++ .../include/javascript/pandora_alerts.js | 21 +++++++++++++++++++ pandora_console/pandoradb_data.sql | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 pandora_console/include/javascript/pandora_alerts.js diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 26a1130a9f..7155c30321 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2009-01-12 Esteban Sanchez + + * include/javascript/pandora_alerts.js: Added to repository. + Javascript functions for alerts. + + * pandoradb_data.sql: Added missing field in a talert_commands row. + 2009-01-12 Esteban Sanchez * include/functions_alerts.php: Removed debug output. Show no SQL diff --git a/pandora_console/include/javascript/pandora_alerts.js b/pandora_console/include/javascript/pandora_alerts.js new file mode 100644 index 0000000000..7bf104273b --- /dev/null +++ b/pandora_console/include/javascript/pandora_alerts.js @@ -0,0 +1,21 @@ +var original_command = ""; + +function parse_alert_command (command) { + value = $("#text-field1").attr ("value"); + re = /_FIELD1_/gi; + command = command.replace (re, "\""+value+"\""); + + value = $("#text-field2").attr ("value"); + re = /_FIELD2_/gi; + command = command.replace (re, "\""+value+"\""); + + value = $("#text-field3").attr ("value"); + re = /_FIELD3_/gi; + command = command.replace (re, "\""+value+"\""); + + return command; +} + +function render_command_preview () { + $("#textarea_command_preview").text (parse_alert_command (original_command)); +} diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index cf9a6ca052..366e18f538 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -35,7 +35,7 @@ INSERT INTO `talert_commands` VALUES (5,'Pandora FMS Alertlog','echo _timestamp_ INSERT INTO `talert_commands` VALUES (6,'SNMP Trap','/usr/bin/snmptrap -v 1 -c trap_public 192.168.0.4 1.1.1.1.1.1.1.1 _agent_ _field1_','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); INSERT INTO `talert_commands` VALUES (7,'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); INSERT INTO `talert_commands` VALUES (8,'Sound Alert','/usr/bin/play /usr/share/sounds/alarm.wav','', 0); -INSERT INTO `talert_commands` VALUES (9,'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'); +INSERT INTO `talert_commands` VALUES (9,'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); --