2009-01-12 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Complete rewritten of the alert system when assigned alerts to an agent. * pandoradb.sql: New tables for alert system. These are: talert_commands, talert_actions, talert_templates, talert_template_modules, talert_template_module_actions. No migration tool is available yet. * godmode/alerts/configure_alert_template.php, godmode/alerts/configure_alert_action.php, godmode/alerts/alert_templates.php, godmode/alerts/configure_alert_command.php, godmode/alerts/alert_actions.php: Added to repository. Administration interface to new alert system. * godmode/alerts/modify_alert.php: Deleted from repository. * godmode/setup/setup.php: Added an example of the date format. Main table has now percentage width. * godmode/menu.php, operation/menu.php: Added new alert options. Removed refr value when it's not neccesary. * include/styles/pandora.css: Added width to textarea elements. Style correction and cleanup. Tables doesn't have a odd-even pattern, but the hovered row now changes its colour. New styles for alert pages. * include/functions_custom_graphs.php: Added to repository. custom graphs functions moved here. * include/functions_incidents.php, include/functions_events.php: Moved to LGPL. Style comment corrections. * include/functions_html.php: Documentation style correction. Added print_input_file() and print_label(). * include/functions_ui.php: Doc style correction. * operation/reporting/graph_viewer.php: Include new function file with custom graphs. Use generic functions. * index.php: Unset pass from POST and REQUEST arrays. * include/functions_db.php: Some documentation updated to new format. Added format_array_to_update_sql() to generate SQL sentences for updates. Style correction. * godmode/agentes/configurar_agente.php: Variables renamed to have a meaning. * extensions/update_manager/main.php: Mark an string translatable. * extensions/update_manager/lib/libupdate_manager_client.php, godmode/alerts/configure_alert.php, include/functions.php, godmode/agentes/module_manager.php, operation/agentes/networkmap.php, operation/reporting/reporting_viewer.php, godmode/agentes/manage_config.php: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1331 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
320bf931f6
commit
03ed1a9e2b
|
@ -1,3 +1,63 @@
|
|||
2009-01-12 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* godmode/agentes/alert_manager.php: Complete rewritten of the alert
|
||||
system when assigned alerts to an agent.
|
||||
|
||||
* pandoradb.sql: New tables for alert system. These are:
|
||||
talert_commands, talert_actions, talert_templates,
|
||||
talert_template_modules, talert_template_module_actions. No migration
|
||||
tool is available yet.
|
||||
|
||||
* godmode/alerts/configure_alert_template.php,
|
||||
godmode/alerts/configure_alert_action.php,
|
||||
godmode/alerts/alert_templates.php,
|
||||
godmode/alerts/configure_alert_command.php,
|
||||
godmode/alerts/alert_actions.php: Added to repository. Administration
|
||||
interface to new alert system.
|
||||
|
||||
* godmode/alerts/modify_alert.php: Deleted from repository.
|
||||
|
||||
* godmode/setup/setup.php: Added an example of the date format. Main
|
||||
table has now percentage width.
|
||||
|
||||
* godmode/menu.php, operation/menu.php: Added new alert options.
|
||||
Removed refr value when it's not neccesary.
|
||||
|
||||
* include/styles/pandora.css: Added width to textarea elements. Style
|
||||
correction and cleanup. Tables doesn't have a odd-even pattern, but
|
||||
the hovered row now changes its colour. New styles for alert pages.
|
||||
|
||||
* include/functions_custom_graphs.php: Added to repository. custom
|
||||
graphs functions moved here.
|
||||
|
||||
* include/functions_incidents.php, include/functions_events.php: Moved
|
||||
to LGPL. Style comment corrections.
|
||||
|
||||
* include/functions_html.php: Documentation style correction. Added
|
||||
print_input_file() and print_label().
|
||||
|
||||
* include/functions_ui.php: Doc style correction.
|
||||
|
||||
* operation/reporting/graph_viewer.php: Include new function file with
|
||||
custom graphs. Use generic functions.
|
||||
|
||||
* index.php: Unset pass from POST and REQUEST arrays.
|
||||
|
||||
* include/functions_db.php: Some documentation updated to new format.
|
||||
Added format_array_to_update_sql() to generate SQL sentences for
|
||||
updates. Style correction.
|
||||
|
||||
* godmode/agentes/configurar_agente.php: Variables renamed to have a
|
||||
meaning.
|
||||
|
||||
* extensions/update_manager/main.php: Mark an string translatable.
|
||||
|
||||
* extensions/update_manager/lib/libupdate_manager_client.php,
|
||||
godmode/alerts/configure_alert.php, include/functions.php,
|
||||
godmode/agentes/module_manager.php, operation/agentes/networkmap.php,
|
||||
operation/reporting/reporting_viewer.php,
|
||||
godmode/agentes/manage_config.php: Style correction.
|
||||
|
||||
2009-01-12 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* pandoradb.sql: Removed fields "timestamp" and "id_agente" (and altered
|
||||
|
|
|
@ -20,7 +20,6 @@ if ((include_once ('XML/RPC.php')) != 1)
|
|||
error_reporting ($prev_level);
|
||||
unset ($prev_level);
|
||||
|
||||
|
||||
define ('XMLRPC_DEBUG', 0);
|
||||
define ('XMLRPC_TIMEOUT', 15);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ $user_key = get_user_key ($settings);
|
|||
$update_package = (bool) get_parameter_post ('update_package');
|
||||
|
||||
if ($update_package) {
|
||||
echo '<h2>Updating...</h2>';
|
||||
echo '<h2>'.__('Updating').'...</h2>';
|
||||
flush ();
|
||||
$force = (bool) get_parameter_post ('force_update');
|
||||
|
||||
|
|
|
@ -17,175 +17,311 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Load global vars
|
||||
require_once ('include/config.php');
|
||||
require_once ('include/functions_alerts.php');
|
||||
|
||||
if (!isset ($id_agente)) {
|
||||
die ("Not Authorized");
|
||||
}
|
||||
|
||||
echo "<h2>".__('Agent configuration')." > ".__('Alerts')."</h2>";
|
||||
// ==========================
|
||||
// Create module/type combo
|
||||
// ==========================
|
||||
|
||||
echo '<table width="300" cellpadding="4" cellspacing="4" class="databox">';
|
||||
echo '<form name="modulo" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente.'">';
|
||||
echo "<tr><td class='datos'>";
|
||||
echo '<select name="form_alerttype">';
|
||||
$create_alert = (bool) get_parameter ('create_alert');
|
||||
$add_action = (bool) get_parameter ('add_action');
|
||||
|
||||
echo "<option value='simple'>".__('Create a simple alert');
|
||||
echo "<option value='combined'>".__('Create a new combined alert');
|
||||
echo "</select></td>";
|
||||
echo '<td class="datos">';
|
||||
echo '<input align="right" name="updbutton" type="submit" class="sub wand" value="'.__('Create').'">';
|
||||
echo "</form>";
|
||||
echo "</table>";
|
||||
|
||||
// ==========================
|
||||
// Simple alerts view
|
||||
// ==========================
|
||||
|
||||
$sql = 'SELECT * FROM tagente_modulo WHERE id_agente = "'.$id_agente.'"';
|
||||
$result = mysql_query ($sql);
|
||||
if ($row = mysql_num_rows( $result)) {
|
||||
|
||||
echo "<h3>".__('Simple alerts')."</h3>";
|
||||
|
||||
$color=1;
|
||||
$string='';
|
||||
while ($row=mysql_fetch_array($result)){ // All modules of this agent
|
||||
$id_tipo = $row["id_tipo_modulo"];
|
||||
$nombre_modulo = substr($row["nombre"],0,21);
|
||||
//module type modulo is $row2["nombre"];
|
||||
if ($create_alert) {
|
||||
$id_alert_template = (int) get_parameter ('template');
|
||||
$id_agent_module = (int) get_parameter ('id_agent_module');
|
||||
|
||||
$id = create_alert_agent_module ($id_agent_module, $id_alert_template);
|
||||
print_error_message ($id, __('Successfully created'),
|
||||
__('Could not be created'));
|
||||
if ($id !== false) {
|
||||
$id_alert_action = (int) get_parameter ('action');
|
||||
$fires_min = (int) get_parameter ('fires_min');
|
||||
$fires_max = (int) get_parameter ('fires_max');
|
||||
$values = array ();
|
||||
if ($fires_min != -1)
|
||||
$values['fires_min'] = $fires_min;
|
||||
if ($fires_max != -1)
|
||||
$values['fires_max'] = $fires_max;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM talerta_agente_modulo
|
||||
WHERE id_agente_modulo = '.$row["id_agente_modulo"];
|
||||
// From all the alerts give me which are from my agent
|
||||
$result3=mysql_query($sql);
|
||||
while ($row3=mysql_fetch_array($result3)){
|
||||
if ($color == 1){
|
||||
$tdcolor="datos";
|
||||
$color =0;
|
||||
} else {
|
||||
$tdcolor="datos2";
|
||||
$color =1;
|
||||
}
|
||||
$sql4='SELECT nombre FROM talerta WHERE id_alerta = '.$row3["id_alerta"];
|
||||
$result4=mysql_query($sql4);
|
||||
$row4=mysql_fetch_array($result4);
|
||||
// Alert name defined by $row4["nombre"];
|
||||
$nombre_alerta = $row4["nombre"];
|
||||
$string = $string."<tr style='color: #666;'><td class='$tdcolor'>".$nombre_modulo;
|
||||
|
||||
$string .= show_alert_row_edit ($row3, $tdcolor, $row["id_tipo_modulo"],0);
|
||||
$string = $string."</td><td class='$tdcolor'>";
|
||||
$id_grupo = dame_id_grupo($id_agente);
|
||||
if (give_acl ($config['id_user'], $id_grupo, "LW")) {
|
||||
$string = $string."<a href='index.php?sec=gagente&
|
||||
sec2=godmode/agentes/configurar_agente&tab=alert&
|
||||
id_agente=".$id_agente."&delete_alert=".$row3["id_aam"]."'>
|
||||
<img src='images/cross.png' border=0 alt='".__('Delete')."'></a> ";
|
||||
$string = $string."<a href='index.php?sec=gagente&
|
||||
sec2=godmode/agentes/configurar_agente&tab=alert&
|
||||
id_agente=".$id_agente."&update_alert=".$row3["id_aam"]."'>
|
||||
<img src='images/config.png' border=0 alt='".__('Update')."'></a>";
|
||||
}
|
||||
$string = $string."</td>";
|
||||
}
|
||||
add_alert_agent_module_action ($id, $id_alert_action, $values);
|
||||
}
|
||||
if (isset($string) & $string!='') {
|
||||
echo "<table cellpadding='4' cellspacing='4' width='750' class='databox'>
|
||||
<tr><th>".__('Name')."</th>
|
||||
<th>".__('Type')."</th>
|
||||
<th>".__('Alert')."</th>
|
||||
<th>".__('Threshold')."</th>
|
||||
<th>".__('Min.')."</th>
|
||||
<th>".__('Max.')."</th>
|
||||
<th>".__('Time')."</th>
|
||||
<th>".__('Description')."</th>
|
||||
<th>".__('info')."</th>
|
||||
<th width='50'>".__('Action')."</th></tr>";
|
||||
echo $string;
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<div class='nf'>".__('This agent doesn\'t have any alert')."</div>";
|
||||
}
|
||||
} else {
|
||||
echo "<div class='nf'>".__('This agent doesn\'t have any module')."</div>";
|
||||
}
|
||||
|
||||
// ==========================
|
||||
// Combined alerts view
|
||||
// ==========================
|
||||
if ($add_action) {
|
||||
$id_action = (int) get_parameter ('action');
|
||||
$id_alert_module = (int) get_parameter ('id_alert_module');
|
||||
$fires_min = (int) get_parameter ('fires_min');
|
||||
$fires_max = (int) get_parameter ('fires_max');
|
||||
$values = array ();
|
||||
if ($fires_min != -1)
|
||||
$values['fires_min'] = $fires_min;
|
||||
if ($fires_max != -1)
|
||||
$values['fires_max'] = $fires_max;
|
||||
|
||||
$result = add_alert_agent_module_action ($id_alert_module, $id_action, $values);
|
||||
print_error_message ($id, __('Successfully added'),
|
||||
__('Could not be added'));
|
||||
}
|
||||
|
||||
echo "<h3>".__('Combined alerts')."</h3>";
|
||||
$modules = get_agent_modules ($id_agente,
|
||||
array ('id_tipo_modulo', 'nombre', 'id_agente'));
|
||||
|
||||
$sql = 'SELECT * FROM talerta_agente_modulo WHERE id_agent = '.$id_agente;
|
||||
$result = mysql_query ($sql);
|
||||
if (mysql_num_rows($result) == 0) {
|
||||
echo "<div class='nf'>".__('This agent doesn\'t have any module')."</div>";
|
||||
} else {
|
||||
$color = 1;
|
||||
$string = "";
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
// Show data for this combined alert
|
||||
$string .= "<tr><td class='datos3'>";
|
||||
$string .= __('Combined')." #".$row["id_aam"];
|
||||
$string .= show_alert_row_edit ($row, "datos3", 0, 1);
|
||||
$string .= '<td class="datos3">'; // action
|
||||
if (give_acl($config['id_user'], $id_grupo, "LW")==1){
|
||||
$string .= "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=".$id_agente."&delete_alert=".$row["id_aam"]."'> <img src='images/cross.png' border=0 alt='".__('Delete')."'></a> ";
|
||||
$string .= "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=".$id_agente."&form_alerttype=combined&update_alert=".$row["id_aam"]."'>
|
||||
<img src='images/config.png' border=0 alt='".__('Update')."'></a>";
|
||||
}
|
||||
$id_aam = $row["id_aam"];
|
||||
$sql = "SELECT * FROM tcompound_alert, talerta_agente_modulo WHERE tcompound_alert.id = $id_aam AND talerta_agente_modulo.id_aam = tcompound_alert.id_aam";
|
||||
$result2 = mysql_query ($sql);
|
||||
while ($row2 = mysql_fetch_array($result2)) {
|
||||
// Show data for each component of this combined alert
|
||||
if ($color == 1){
|
||||
$tdcolor="datos";
|
||||
$color =0;
|
||||
} else {
|
||||
$tdcolor="datos2";
|
||||
$color =1;
|
||||
}
|
||||
$module = get_db_row ("tagente_modulo", "id_agente_modulo", $row2["id_agente_modulo"]);
|
||||
$description = $row2["descripcion"];
|
||||
$alert_mode = $row2["operation"];
|
||||
$id_agente_name = get_db_value ("nombre", "tagente", "id_agente", $module["id_agente"]);
|
||||
$string .= "<tr style='color: #666;'><td class='$tdcolor'><a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=".$module["id_agente"]."'><b>".$id_agente_name." </b>- ".substr($module["nombre"],0,15)."</A>";
|
||||
|
||||
$string .= show_alert_row_edit ($row2, $tdcolor, $module["id_tipo_modulo"],1);
|
||||
echo "<h3>".__('Modules defined')."</h3>";
|
||||
|
||||
$string .= "</td><td class='$tdcolor'>";
|
||||
$id_grupo = dame_id_grupo($id_agente);
|
||||
if (give_acl($config['id_user'], $id_grupo, "LW")==1){
|
||||
$string .= "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=".$id_agente."&delete_alert_comp=".$row2["id_aam"]."'> <img src='images/cross.png' border=0 alt='".__('Delete')."'></a> ";
|
||||
$string .= "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente=".$id_agente."&update_alert=".$row2["id_aam"]."'>
|
||||
<img src='images/config.png' border=0 alt='".__('Update')."'></a>";
|
||||
}
|
||||
$string .= "</td>";
|
||||
}
|
||||
$table->id = 'modules';
|
||||
$table->cellspacing = '0';
|
||||
$table->width = '90%';
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Module');
|
||||
$table->data = array ();
|
||||
$table->style = array ();
|
||||
$table->style[1] = 'vertical-align: top';
|
||||
|
||||
$table_alerts->class = 'listing';
|
||||
$table_alerts->width = '100%';
|
||||
$table_alerts->size = array ();
|
||||
$table_alerts->size[0] = '50%';
|
||||
$table_alerts->size[1] = '50%';
|
||||
$table_alerts->style = array ();
|
||||
$table_alerts->style[0] = 'vertical-align: top';
|
||||
$table_alerts->style[1] = 'vertical-align: top';
|
||||
|
||||
foreach ($modules as $id_agent_module => $module) {
|
||||
$data = array ();
|
||||
|
||||
$last_data = return_value_agent_module ($id_agent_module);
|
||||
if ($last_data === false)
|
||||
$last_data = '<em>'.__('N/A').'</em>';
|
||||
|
||||
$data[0] = '<span>'.$module['nombre'].'</span>';
|
||||
$data[0] .= '<div class="actions left" style="visibility: hidden;">';
|
||||
$data[0] .= '<span class="module_values" style="float: right;">';
|
||||
$data[0] .= '<em>'.__('Latest value').'</em>: ';
|
||||
$data[0] .= $last_data;
|
||||
$data[0] .= '</span>';
|
||||
$data[0] .= '</div>';
|
||||
$data[0] .= '<div class="actions right" style="visibility: hidden;">';
|
||||
$data[0] .= '<span class="add">';
|
||||
$data[0] .= '<a href="#" class="add_alert" id="module-'.$id_agent_module.'">';
|
||||
$data[0] .= __('Add alert');
|
||||
$data[0] .= '</a>';
|
||||
$data[0] .= '</span>';
|
||||
$data[0] .= '</div>';
|
||||
|
||||
|
||||
/* Alerts in module list */
|
||||
$table_alerts->id = 'alerts-'.$id_agent_module;
|
||||
$table_alerts->data = array ();
|
||||
|
||||
$alerts = get_alerts_agent_module ($id_agent_module);
|
||||
if ($alerts === false) {
|
||||
$alerts = array ();
|
||||
} else {
|
||||
$data[0] .= '<h4 class="left" style="clear: left">';
|
||||
$data[0] .= __('Alerts');
|
||||
$data[0] .= '</h4>';
|
||||
}
|
||||
|
||||
if (isset($string) & $string != "") {
|
||||
echo "<table cellpadding='4' cellspacing='4' width='750' class='databox'>
|
||||
<tr><th>".__('Name')."</th>
|
||||
<th>".__('Type')."</th>
|
||||
<th>".__('Oper')."</th>
|
||||
<th>".__('Threshold')."</th>
|
||||
<th>".__('Min.')."</th>
|
||||
<th>".__('Max.')."</th>
|
||||
<th>".__('Time')."</th>
|
||||
<th>".__('Description')."</th>
|
||||
<th>".__('info')."</th>
|
||||
<th width='50'>".__('Action')."</th></tr>";
|
||||
echo $string;
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<div class='nf'>".__('This agent doesn\'t have any alert')."</div>";
|
||||
foreach ($alerts as $alert) {
|
||||
$alert_data = array ();
|
||||
|
||||
$alert_actions = get_alert_agent_module_actions ($alert['id']);
|
||||
|
||||
$alert_data[0] = get_alert_template_name ($alert['id_alert_template']);
|
||||
$alert_data[0] .= '<span class="actions" style="visibility: hidden">';
|
||||
$alert_data[0] .= '<a href="ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template='.$alert['id_alert_template'].'"
|
||||
class="template_details">';
|
||||
$alert_data[0] .= print_image ("images/zoom.png", true,
|
||||
array ("id" => 'template-details-'.$alert['id'],
|
||||
"class" => "left img_help")
|
||||
);
|
||||
$alert_data[0] .= '</a>';
|
||||
$alert_data[0] .= '</span>';
|
||||
|
||||
$alert_data[1] = '<ul style="float: left; margin-bottom: 10px">';
|
||||
foreach ($alert_actions as $action) {
|
||||
$alert_data[1] .= '<li><div>';
|
||||
$alert_data[1] .= '<span class="left">';
|
||||
$alert_data[1] .= $action['name'].' ';
|
||||
$alert_data[1] .= '<em>(';
|
||||
if ($action['fires_min'] == $action['fires_max']) {
|
||||
if ($action['fires_min'] == 0)
|
||||
$alert_data[1] .= __('Always');
|
||||
else
|
||||
$alert_data[1] .= __('On').' '.$action['fires_min'];
|
||||
} else {
|
||||
if ($action['fires_min'] == 0)
|
||||
$alert_data[1] .= __('Until').' '.$action['fires_max'];
|
||||
else
|
||||
$alert_data[1] .= __('From').' '.$action['fires_min'].
|
||||
' '.__('to').' '.$action['fires_max'];
|
||||
}
|
||||
|
||||
$alert_data[1] .= ')</em>';
|
||||
$alert_data[1] .= '</span>';
|
||||
$alert_data[1] .= ' <span class="actions" style="visibility: hidden">';
|
||||
$alert_data[1] .= '<span class="delete">';
|
||||
$alert_data[1] .= '<a href="#">';
|
||||
$alert_data[1] .= '<img src="images/cross.png" />';
|
||||
$alert_data[1] .= '</a>';
|
||||
$alert_data[1] .= '</span>';
|
||||
$alert_data[1] .= '</span>';
|
||||
$alert_data[1] .= '</div></li>';
|
||||
}
|
||||
$alert_data[1] .= '</ul>';
|
||||
|
||||
$alert_data[1] .= '<div class="actions left" style="visibility: hidden; clear: left">';
|
||||
$alert_data[1] .= '<a class="add_action" id="add-action-'.$alert['id'].'" href="#">';
|
||||
$alert_data[1] .= __('Add action');
|
||||
$alert_data[1] .= '</a>';
|
||||
$alert_data[1] .= '</div>';
|
||||
|
||||
$table_alerts->data['alert-'.$alert['id']] = $alert_data;
|
||||
}
|
||||
}
|
||||
|
||||
$data[0] .= print_table ($table_alerts, true);
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
print_table ($table);
|
||||
|
||||
/* This hidden value is used in Javascript. It's a workaraound for IE because
|
||||
it doesn't allow input elements creation. */
|
||||
print_input_hidden ('add_action', 1);
|
||||
print_input_hidden ('id_alert_module', 0);
|
||||
|
||||
echo '<form class="add_alert_form" method="post" style="display: none"
|
||||
action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.
|
||||
$module['id_agente'].'">';
|
||||
echo '<div style="float:left">';
|
||||
print_label (__('Template'), 'template');
|
||||
$templates = get_alert_templates ();
|
||||
if (empty ($templates))
|
||||
$templates = array ();
|
||||
print_select ($templates, 'template', '', '', __('None'), 0);
|
||||
echo '</div><div style="margin-left: 270px">';
|
||||
print_label (__('Action'), 'action');
|
||||
$actions = get_alert_actions ();
|
||||
if (empty ($actions))
|
||||
$actions = array ();
|
||||
print_select ($actions, 'action', '', '', __('None'), 0);
|
||||
echo '<br />';
|
||||
echo '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' » </a></span>';
|
||||
echo '<span class="advanced_actions" style="display: none">';
|
||||
echo __('From').' ';
|
||||
print_input_text ('fires_min', -1, '', 4, 10);
|
||||
echo ' '.__('to').' ';
|
||||
print_input_text ('fires_max', -1, '', 4, 10);
|
||||
echo ' '.__('matches of the alert');
|
||||
echo '</span></div>';
|
||||
echo '<div style="float: right; margin-left: 30px;"><br />';
|
||||
print_submit_button (__('Add'), 'add', false, 'class="sub next"');
|
||||
print_input_hidden ('id_agent_module', 0);
|
||||
print_input_hidden ('create_alert', 1);
|
||||
echo '</div></form>';
|
||||
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" href="include/styles/cluetip.css" type="text/css" />
|
||||
<script type="text/javascript" src="include/javascript/jquery.cluetip.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
$("table#modules tr, table#listing tr").hover (
|
||||
function () {
|
||||
$(".actions", this).css ("visibility", "");
|
||||
},
|
||||
function () {
|
||||
$(".actions", this).css ("visibility", "hidden");
|
||||
}
|
||||
);
|
||||
|
||||
$("a.add_alert").click (function () {
|
||||
if ($("form.add_alert_form", $(this).parents ("td")).length > 0) {
|
||||
return false;
|
||||
}
|
||||
id = this.id.split ("-").pop ();
|
||||
form = $("form.add_alert_form:last").clone (true);
|
||||
$("input#hidden-id_agent_module", form).attr ("value", id);
|
||||
$(this).parents ("td").append (form);
|
||||
$(form).show ();
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".add_alert_form").submit (function () {
|
||||
if ($("#template", this).attr ("value") == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($("#action", this).attr ("value") == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
$("a.show_advanced_actions").click (function () {
|
||||
/* It can be done in two different site, so it must use two different selectors */
|
||||
actions = $(this).parents ("form").children ("span.advanced_actions");
|
||||
if (actions.length == 0)
|
||||
actions = $(this).parents ("div").children ("span.advanced_actions")
|
||||
$("#text-fires_min", actions).attr ("value", 0);
|
||||
$("#text-fires_max", actions).attr ("value", 0);
|
||||
$(actions).show ();
|
||||
$(this).remove ();
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".actions a.add_action").click (function () {
|
||||
id = this.id.split ("-").pop ();
|
||||
|
||||
/* Remove new alert form (if shown) to clean a bit the UI */
|
||||
$(this).parents ("td:last").children ("form.add_alert_form")
|
||||
.remove ();
|
||||
|
||||
/* Replace link with a combo with the actions and a form */
|
||||
a = $("a.show_advanced_actions:first").clone (true);
|
||||
advanced = $("span.advanced_actions:first").clone (true).hide ();
|
||||
select = $("select#action:first").clone ();
|
||||
button = $('<input type="image" class="sub next" value="'+"<?php echo __('Add');?>"+'"></input>');
|
||||
divbutton = $("<div></div>").css ("float", "right").html (button);
|
||||
input1 = $("input#hidden-add_action");
|
||||
input2 = $("input#hidden-id_alert_module").clone ().attr ("value", id);
|
||||
form = $('<form method="post"></form>')
|
||||
.append (select)
|
||||
.append ("<br></br>")
|
||||
.append (a)
|
||||
.append (advanced)
|
||||
.append (divbutton)
|
||||
.append (input1)
|
||||
.append (input2);
|
||||
|
||||
$(this).parents (".actions:first").replaceWith (form);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$("a.template_details").cluetip ({
|
||||
arrows: true,
|
||||
attribute: 'href',
|
||||
cluetipClass: 'default',
|
||||
fx: { open: 'fadeIn', openSpeed: 'slow' },
|
||||
}).click (function () {
|
||||
return false;
|
||||
});;
|
||||
|
||||
$("select[name=template]").change (function () {
|
||||
if (this.value == 0) {
|
||||
$(this).parents ("div:first").children ("a").remove ();
|
||||
return;
|
||||
}
|
||||
|
||||
details = $("a.template_details:first").clone (true)
|
||||
.attr ("href",
|
||||
"ajax.php?page=godmode/alerts/alert_templates&get_template_tooltip=1&id_template=" + this.value);
|
||||
$(this).after (details);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -567,8 +567,8 @@ if (isset($_GET["id_agente"])) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$row = get_db_row ('tagente', 'id_agente', $id_agente);
|
||||
if (empty ($row)) {
|
||||
$agent = get_db_row ('tagente', 'id_agente', $id_agente);
|
||||
if (empty ($agent)) {
|
||||
//Close out the page
|
||||
echo '<h3 class="error">'.__('There was a problem loading agent').'</h3>';
|
||||
echo '</table></div><div id="foot">';
|
||||
|
@ -577,21 +577,21 @@ if (isset($_GET["id_agente"])) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$intervalo = $row["intervalo"]; // Define interval in seconds
|
||||
$nombre_agente = $row["nombre"];
|
||||
$direccion_agente = $row["direccion"];
|
||||
$grupo = $row["id_grupo"];
|
||||
$ultima_act = $row["ultimo_contacto"];
|
||||
$comentarios = $row["comentarios"];
|
||||
$id_plugin_server = $row["id_plugin_server"];
|
||||
$id_network_server = $row["id_network_server"];
|
||||
$id_prediction_server = $row["id_prediction_server"];
|
||||
$id_wmi_server = $row["id_wmi_server"];
|
||||
$modo = $row["modo"];
|
||||
$id_os = $row["id_os"];
|
||||
$disabled = $row["disabled"];
|
||||
$id_parent = $row["id_parent"];
|
||||
$custom_id = $row["custom_id"];
|
||||
$intervalo = $agent["intervalo"]; // Define interval in seconds
|
||||
$nombre_agente = $agent["nombre"];
|
||||
$direccion_agente = $agent["direccion"];
|
||||
$grupo = $agent["id_grupo"];
|
||||
$ultima_act = $agent["ultimo_contacto"];
|
||||
$comentarios = $agent["comentarios"];
|
||||
$id_plugin_server = $agent["id_plugin_server"];
|
||||
$id_network_server = $agent["id_network_server"];
|
||||
$id_prediction_server = $agent["id_prediction_server"];
|
||||
$id_wmi_server = $agent["id_wmi_server"];
|
||||
$modo = $agent["modo"];
|
||||
$id_os = $agent["id_os"];
|
||||
$disabled = $agent["disabled"];
|
||||
$id_parent = $agent["id_parent"];
|
||||
$custom_id = $agent["custom_id"];
|
||||
}
|
||||
|
||||
// Read data module if editing module
|
||||
|
@ -600,28 +600,28 @@ if ((isset ($_GET["update_module"])) && (!isset ($_POST["oid"])) && (!isset ($_P
|
|||
$update_module = 1;
|
||||
$id_agente_modulo = (int) get_parameter_get ("update_module",0);
|
||||
|
||||
$row = get_db_row ('tagente_modulo', 'id_agente_modulo', $id_agente_modulo);
|
||||
$module = get_db_row ('tagente_modulo', 'id_agente_modulo', $id_agente_modulo);
|
||||
|
||||
if ($row === false) {
|
||||
if ($module === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem loading the module').'</h3>';
|
||||
} else {
|
||||
$modulo_id_agente = $row["id_agente"];
|
||||
$modulo_id_tipo_modulo = $row["id_tipo_modulo"];
|
||||
$modulo_nombre = $row["nombre"];
|
||||
$modulo_descripcion = $row["descripcion"];
|
||||
$tcp_send = $row["tcp_send"];
|
||||
$tcp_rcv = $row["tcp_rcv"];
|
||||
$ip_target = $row["ip_target"];
|
||||
$snmp_community = $row["snmp_community"];
|
||||
$snmp_oid = $row["snmp_oid"];
|
||||
$id_module_group = $row["id_module_group"];
|
||||
$module_interval = $row["module_interval"];
|
||||
$modulo_max = $row["max"];
|
||||
$modulo_id_agente = $module["id_agente"];
|
||||
$modulo_id_tipo_modulo = $module["id_tipo_modulo"];
|
||||
$modulo_nombre = $module["nombre"];
|
||||
$modulo_descripcion = $module["descripcion"];
|
||||
$tcp_send = $module["tcp_send"];
|
||||
$tcp_rcv = $module["tcp_rcv"];
|
||||
$ip_target = $module["ip_target"];
|
||||
$snmp_community = $module["snmp_community"];
|
||||
$snmp_oid = $module["snmp_oid"];
|
||||
$id_module_group = $module["id_module_group"];
|
||||
$module_interval = $module["module_interval"];
|
||||
$modulo_max = $module["max"];
|
||||
if (empty ($modulo_max))
|
||||
$modulo_max = "N/A";
|
||||
if (empty ($modulo_min))
|
||||
$modulo_min = "N/A";
|
||||
$custom_id = $row["custom_id"];
|
||||
$custom_id = $module["custom_id"];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -637,39 +637,39 @@ if (isset ($_GET["update_alert"])) {
|
|||
|
||||
$update_alert = 1;
|
||||
$id_aam = (int) get_parameter_get ("update_alert",0);
|
||||
$row = get_db_row ('talerta_agente_modulo', 'id_aam', $id_aam);
|
||||
$alert = get_db_row ('talerta_agente_modulo', 'id_aam', $id_aam);
|
||||
|
||||
if ($row === false) {
|
||||
if ($alert === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem loading the alert').'</h3>';
|
||||
} else {
|
||||
$alerta_id_aam = $row["id_aam"];
|
||||
$alerta_campo1 = $row["al_campo1"];
|
||||
$alerta_campo2 = $row["al_campo2"];
|
||||
$alerta_campo3 = $row["al_campo3"];
|
||||
$alerta_campo2_rec = $row["al_f2_recovery"];
|
||||
$alerta_campo3_rec = $row["al_f3_recovery"];
|
||||
$alerta_dis_max = $row["dis_max"];
|
||||
$alerta_dis_min = $row["dis_min"];
|
||||
$tipo_alerta = $row["id_alerta"];
|
||||
$alert_text = $row["alert_text"];
|
||||
$alerta_max_alerts = $row["max_alerts"];
|
||||
$alerta_min_alerts = $row["min_alerts"];
|
||||
$alerta_time_threshold = $row["time_threshold"];
|
||||
$alerta_descripcion = $row["descripcion"];
|
||||
$alerta_disable = $row["disable"];
|
||||
$time_from = $row["time_from"];
|
||||
$time_to = $row["time_to"];
|
||||
$alerta_id_agentemodulo = $row["id_agente_modulo"]; // Only to show, cannot be changed
|
||||
$alert_id_agent = $row["id_agent"];
|
||||
$alert_d1 = $row["monday"];
|
||||
$alert_d2 = $row["tuesday"];
|
||||
$alert_d3 = $row["wednesday"];
|
||||
$alert_d4 = $row["thursday"];
|
||||
$alert_d5 = $row["friday"];
|
||||
$alert_d6 = $row["saturday"];
|
||||
$alert_d7 = $row["sunday"];
|
||||
$alert_recovery = $row["recovery_notify"];
|
||||
$alert_priority = $row["priority"];
|
||||
$alerta_id_aam = $alert["id_aam"];
|
||||
$alerta_campo1 = $alert["al_campo1"];
|
||||
$alerta_campo2 = $alert["al_campo2"];
|
||||
$alerta_campo3 = $alert["al_campo3"];
|
||||
$alerta_campo2_rec = $alert["al_f2_recovery"];
|
||||
$alerta_campo3_rec = $alert["al_f3_recovery"];
|
||||
$alerta_dis_max = $alert["dis_max"];
|
||||
$alerta_dis_min = $alert["dis_min"];
|
||||
$tipo_alerta = $alert["id_alerta"];
|
||||
$alert_text = $alert["alert_text"];
|
||||
$alerta_max_alerts = $alert["max_alerts"];
|
||||
$alerta_min_alerts = $alert["min_alerts"];
|
||||
$alerta_time_threshold = $alert["time_threshold"];
|
||||
$alerta_descripcion = $alert["descripcion"];
|
||||
$alerta_disable = $alert["disable"];
|
||||
$time_from = $alert["time_from"];
|
||||
$time_to = $alert["time_to"];
|
||||
$alerta_id_agentemodulo = $alert["id_agente_modulo"]; // Only to show, cannot be changed
|
||||
$alert_id_agent = $alert["id_agent"];
|
||||
$alert_d1 = $alert["monday"];
|
||||
$alert_d2 = $alert["tuesday"];
|
||||
$alert_d3 = $alert["wednesday"];
|
||||
$alert_d4 = $alert["thursday"];
|
||||
$alert_d5 = $alert["friday"];
|
||||
$alert_d6 = $alert["saturday"];
|
||||
$alert_d7 = $alert["sunday"];
|
||||
$alert_recovery = $alert["recovery_notify"];
|
||||
$alert_priority = $alert["priority"];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -241,9 +241,7 @@ if (isset ($_POST["delete"])) {
|
|||
echo '<h3 class="error">ERROR: '.__('No modules have been selected').'</h3>';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// If selected modules or alerts
|
||||
if (isset($_POST["alerts"])) {
|
||||
$alertas = 1;
|
||||
|
@ -331,7 +329,7 @@ if (isset ($_POST["delete"])) {
|
|||
process_sql ("COMMIT;");
|
||||
}
|
||||
process_sql ("SET AUTOCOMMIT = 1;");
|
||||
return; //Page shouldn't continue anymore
|
||||
return; //Page shouldn't continue anymore
|
||||
} //if $_POST['delete']
|
||||
|
||||
// -----------
|
||||
|
|
|
@ -41,22 +41,22 @@ $plugin_available = get_db_value ("plugin_server", "tserver", "plugin_server", "
|
|||
$prediction_available = get_db_value ("prediction_server", "tserver", "prediction_server", "1");
|
||||
|
||||
// Development mode to use all servers
|
||||
if (1 == $develop_bypass) {
|
||||
$network_available = 1;
|
||||
$wmi_available = 1;
|
||||
$plugin_available = 1;
|
||||
$prediction_available = 1;
|
||||
if ($develop_bypass) {
|
||||
$network_available = 1;
|
||||
$wmi_available = 1;
|
||||
$plugin_available = 1;
|
||||
$prediction_available = 1;
|
||||
}
|
||||
|
||||
echo "<option value='dataserver'>".__('Create a new data server module');
|
||||
if ($network_available == 1)
|
||||
echo "<option value='networkserver'>".__('Create a new network server module');
|
||||
echo "<option value='networkserver'>".__('Create a new network server module');
|
||||
if ($plugin_available == 1)
|
||||
echo "<option value='pluginserver'>".__('Create a new plugin Server module');
|
||||
echo "<option value='pluginserver'>".__('Create a new plugin Server module');
|
||||
if ($wmi_available == 1)
|
||||
echo "<option value='wmiserver'>".__('Create a new WMI Server module');
|
||||
echo "<option value='wmiserver'>".__('Create a new WMI Server module');
|
||||
if ($prediction_available == 1)
|
||||
echo "<option value='predictionserver'>".__('Create a new prediction Server module');
|
||||
echo "<option value='predictionserver'>".__('Create a new prediction Server module');
|
||||
echo "</select></td>";
|
||||
echo '<td class="datos">';
|
||||
echo '<input align="right" name="updbutton" type="submit" class="sub wand" value="'.__('Create').'">';
|
||||
|
@ -72,93 +72,94 @@ $sql1='SELECT * FROM tagente_modulo WHERE delete_pending = 0 AND id_agente = "'.
|
|||
ORDER BY id_module_group, nombre ';
|
||||
$result=mysql_query($sql1);
|
||||
if ($row=mysql_num_rows($result)){
|
||||
echo '<table width="750" cellpadding="4" cellspacing="4" class="databox">';
|
||||
echo '<tr>';
|
||||
echo "<th>".__('Module name')."</th>";
|
||||
echo '<th>'.__('S').'</th>';
|
||||
echo '<th>'.__('Type').'</th>';
|
||||
echo "<th>".__('Interval')."</th>";
|
||||
echo "<th>".__('Description')."</th>";
|
||||
echo "<th>".__('Max/Min')."</th>";
|
||||
echo "<th width=65>".__('Action')."</th>";
|
||||
$color=1; $last_modulegroup = "0";
|
||||
while ($row = mysql_fetch_array($result)){
|
||||
if ($color == 1){
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
} else {
|
||||
$tdcolor = "datos2";
|
||||
$color = 1;
|
||||
}
|
||||
$id_tipo = $row["id_tipo_modulo"];
|
||||
$id_module = $row["id_modulo"];
|
||||
$nombre_modulo = $row["nombre"];
|
||||
$descripcion = $row["descripcion"];
|
||||
$module_max = $row["max"];
|
||||
$module_min = $row["min"];
|
||||
$module_interval2 = $row["module_interval"];
|
||||
$module_group2 = $row["id_module_group"];
|
||||
if ($module_group2 != $last_modulegroup ){
|
||||
// Render module group names (fixed code)
|
||||
$nombre_grupomodulo = dame_nombre_grupomodulo ($module_group2);
|
||||
$last_modulegroup = $module_group2;
|
||||
echo "<tr><td class='datos3' align='center' colspan='9'><b>".$nombre_grupomodulo."</b></td></tr>";
|
||||
}
|
||||
echo '<table width="750" cellpadding="4" cellspacing="4" class="databox">';
|
||||
echo '<tr>';
|
||||
echo "<th>".__('Module name')."</th>";
|
||||
echo '<th>'.__('S').'</th>';
|
||||
echo '<th>'.__('Type').'</th>';
|
||||
echo "<th>".__('Interval')."</th>";
|
||||
echo "<th>".__('Description')."</th>";
|
||||
echo "<th>".__('Max/Min')."</th>";
|
||||
echo "<th width=65>".__('Action')."</th>";
|
||||
$color=1; $last_modulegroup = "0";
|
||||
while ($row = mysql_fetch_array($result)){
|
||||
if ($color == 1){
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
} else {
|
||||
$tdcolor = "datos2";
|
||||
$color = 1;
|
||||
}
|
||||
$id_tipo = $row["id_tipo_modulo"];
|
||||
$id_module = $row["id_modulo"];
|
||||
$nombre_modulo = $row["nombre"];
|
||||
$descripcion = $row["descripcion"];
|
||||
$module_max = $row["max"];
|
||||
$module_min = $row["min"];
|
||||
$module_interval2 = $row["module_interval"];
|
||||
$module_group2 = $row["id_module_group"];
|
||||
if ($module_group2 != $last_modulegroup ){
|
||||
// Render module group names (fixed code)
|
||||
$nombre_grupomodulo = dame_nombre_grupomodulo ($module_group2);
|
||||
$last_modulegroup = $module_group2;
|
||||
echo "<tr><td class='datos3' align='center' colspan='9'><b>".$nombre_grupomodulo."</b></td></tr>";
|
||||
}
|
||||
|
||||
if ($row["disabled"] == 0)
|
||||
echo "<tr><td class='".$tdcolor."_id'>".$nombre_modulo."</td>";
|
||||
else
|
||||
echo "<tr><td class='$tdcolor'><i>$nombre_modulo</i></td>";
|
||||
|
||||
// Module type (by server type )
|
||||
echo "<td class='".$tdcolor."f9'>";
|
||||
if ($id_module > 0) {
|
||||
echo show_server_type ($id_module);
|
||||
echo ' ';
|
||||
}
|
||||
if ($row["disabled"] == 0)
|
||||
echo "<tr><td class='".$tdcolor."_id'>".$nombre_modulo."</td>";
|
||||
else
|
||||
echo "<tr><td class='$tdcolor'><i>$nombre_modulo</i></td>";
|
||||
|
||||
// Module type (by server type )
|
||||
echo "<td class='".$tdcolor."f9'>";
|
||||
if ($id_module > 0) {
|
||||
echo show_server_type ($id_module);
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
// Module type (by data type)
|
||||
echo "<td class='".$tdcolor."f9'>";
|
||||
if ($id_tipo > 0) {
|
||||
echo "<img src='images/".show_icon_type($id_tipo)."' border=0>";
|
||||
}
|
||||
echo "</td>";
|
||||
// Module type (by data type)
|
||||
echo "<td class='".$tdcolor."f9'>";
|
||||
if ($id_tipo > 0) {
|
||||
echo "<img src='images/".show_icon_type($id_tipo)."' border=0>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
// Module interval
|
||||
if ($module_interval2!=0){
|
||||
echo "<td class='$tdcolor'>".$module_interval2."</td>";
|
||||
} else {
|
||||
echo "<td class='$tdcolor'> N/A </td>";
|
||||
}
|
||||
echo "<td class='$tdcolor' title='$descripcion'>".substr($descripcion,0,30)."</td>";
|
||||
|
||||
// MAX / MIN values
|
||||
echo "<td class='$tdcolor'>";
|
||||
if ($module_max == $module_min) {
|
||||
$module_max = "N/A";
|
||||
$module_min = "N/A";
|
||||
}
|
||||
echo $module_max." / ".$module_min;
|
||||
echo "</td>";
|
||||
// Module interval
|
||||
if ($module_interval2!=0){
|
||||
echo "<td class='$tdcolor'>".$module_interval2."</td>";
|
||||
} else {
|
||||
echo "<td class='$tdcolor'> N/A </td>";
|
||||
}
|
||||
echo "<td class='$tdcolor' title='$descripcion'>".substr($descripcion,0,30)."</td>";
|
||||
|
||||
// MAX / MIN values
|
||||
echo "<td class='$tdcolor'>";
|
||||
if ($module_max == $module_min) {
|
||||
$module_max = "N/A";
|
||||
$module_min = "N/A";
|
||||
}
|
||||
echo $module_max." / ".$module_min;
|
||||
echo "</td>";
|
||||
|
||||
// Delete module
|
||||
echo "<td class='$tdcolor'>";
|
||||
echo "<a href='index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente&delete_module=".$row["id_agente_modulo"]."'".' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||
echo "<img src='images/cross.png' border=0 title='".__('Delete')."'>";
|
||||
echo "</b></a> ";
|
||||
// Update module
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente&tab=module&update_module=".$row["id_agente_modulo"]."&moduletype=$id_module#modules'>";
|
||||
echo "<img src='images/config.png' border=0 title='".__('Update')."' onLoad='type_change()'></b></a>";
|
||||
|
||||
// Make a data normalization
|
||||
if (($id_tipo == 22 ) OR ($id_tipo == 1 ) OR ($id_tipo == 4 ) OR ($id_tipo == 7 ) OR
|
||||
($id_tipo == 8 ) OR ($id_tipo == 11 ) OR ($id_tipo == 16) OR ($id_tipo == 22 )) {
|
||||
echo " ";
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente&tab=module&fix_module=".$row["id_agente_modulo"]."'".' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||
echo "<img src='images/chart_curve.png' border=0 title='Normalize'></b></a>";
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
} else
|
||||
echo "<div class='nf'>".__('No available data to show')."</div>";
|
||||
// Delete module
|
||||
echo "<td class='$tdcolor'>";
|
||||
echo "<a href='index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente&delete_module=".$row["id_agente_modulo"]."'".' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||
echo "<img src='images/cross.png' border=0 title='".__('Delete')."'>";
|
||||
echo "</b></a> ";
|
||||
// Update module
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente&tab=module&update_module=".$row["id_agente_modulo"]."&moduletype=$id_module#modules'>";
|
||||
echo "<img src='images/config.png' border=0 title='".__('Update')."' onLoad='type_change()'></b></a>";
|
||||
|
||||
// Make a data normalization
|
||||
if (($id_tipo == 22) OR ($id_tipo == 1) OR ($id_tipo == 4) OR ($id_tipo == 7) OR
|
||||
($id_tipo == 8) OR ($id_tipo == 11) OR ($id_tipo == 16) OR ($id_tipo == 22)) {
|
||||
echo " ";
|
||||
echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente&tab=module&fix_module=".$row["id_agente_modulo"]."'".' onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||
echo "<img src='images/chart_curve.png' border=0 title='Normalize'></b></a>";
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "<div class='nf'>".__('No available data to show')."</div>";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Load global vars
|
||||
require_once ("include/config.php");
|
||||
require_once ("include/functions_alerts.php");
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert actions");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (defined ('AJAX')) {
|
||||
$get_alert_action = (bool) get_parameter ('get_alert_action');
|
||||
if ($get_alert_action) {
|
||||
$id = (int) get_parameter ('id');
|
||||
$action = get_alert_action ($id);
|
||||
$action['command'] = get_alert_action_alert_command ($action['id']);
|
||||
|
||||
echo json_encode ($action);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<h1>'.__('Alert actions').'</h1>';
|
||||
|
||||
$update_action = (bool) get_parameter ('update_action');
|
||||
$create_action = (bool) get_parameter ('create_action');
|
||||
$delete_action = (bool) get_parameter ('delete_action');
|
||||
|
||||
if ($create_action) {
|
||||
$name = (string) get_parameter ('name');
|
||||
$id_alert_command = (int) get_parameter ('id_command');
|
||||
$field1 = (string) get_parameter ('field1');
|
||||
$field2 = (string) get_parameter ('field2');
|
||||
$field3 = (string) get_parameter ('field3');
|
||||
|
||||
$result = create_alert_action ($name, $id_alert_command,
|
||||
array ('field1' => $field1,
|
||||
'field2' => $field2,
|
||||
'field3' => $field3));
|
||||
|
||||
print_error_message ($result, __('Successfully created'),
|
||||
__('Could not be created'));
|
||||
}
|
||||
|
||||
if ($update_action) {
|
||||
$id = (string) get_parameter ('id');
|
||||
$name = (string) get_parameter ('name');
|
||||
$id_alert_command = (int) get_parameter ('id_command');
|
||||
$field1 = (string) get_parameter ('field1');
|
||||
$field2 = (string) get_parameter ('field2');
|
||||
$field3 = (string) get_parameter ('field3');
|
||||
|
||||
$result = update_alert_action ($id, $id_alert_command, $name,
|
||||
array ('field1' => $field1,
|
||||
'field2' => $field2,
|
||||
'field3' => $field3));
|
||||
|
||||
print_error_message ($result, __('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
}
|
||||
|
||||
if ($delete_action) {
|
||||
$id = get_parameter ('id');
|
||||
|
||||
$result = delete_alert_action ($id);
|
||||
|
||||
print_error_message ($result, __('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
}
|
||||
|
||||
$table->width = '90%';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Delete');
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->size = array ();
|
||||
$table->size[1] = '40px';
|
||||
$table->align = array ();
|
||||
$table->align[1] = 'center';
|
||||
|
||||
$actions = get_db_all_rows_in_table ('talert_actions');
|
||||
if ($actions === false)
|
||||
$actions = array ();
|
||||
|
||||
foreach ($actions as $action) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_action&id='.$action['id'].'">'.
|
||||
$action['name'].'</a>';
|
||||
$data[1] = '<a href="index.php?sec=galertas&sec2=godmode/alerts/alert_actions&delete_action=1&id='.$action['id'].'"
|
||||
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.
|
||||
'<img src="images/cross.png"></a>';
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
print_table ($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_action">';
|
||||
print_submit_button (__('Create'), 'create', false, 'class="sub next"');
|
||||
print_input_hidden ('create_alert', 1);
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
?>
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Load global vars
|
||||
require_once ("include/config.php");
|
||||
require_once ("include/functions_alerts.php");
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (defined ('AJAX')) {
|
||||
$get_alert_command = (bool) get_parameter ('get_alert_command');
|
||||
if ($get_alert_command) {
|
||||
$id = (int) get_parameter ('id');
|
||||
$command = get_alert_command ($id);
|
||||
echo json_encode ($command);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<h1>'.__('Alert commands').'</h1>';
|
||||
$update_command = (bool) get_parameter ('update_command');
|
||||
$create_command = (bool) get_parameter ('create_command');
|
||||
$delete_command = (bool) get_parameter ('delete_command');
|
||||
|
||||
if ($create_command) {
|
||||
$name = (string) get_parameter ('name');
|
||||
$command = (string) get_parameter ('command');
|
||||
$description = (string) get_parameter ('description');
|
||||
|
||||
$result = create_alert_command ($name, $command,
|
||||
array ('description' => $description));
|
||||
|
||||
print_error_message ($result, __('Successfully created'),
|
||||
__('Could not be created'));
|
||||
}
|
||||
|
||||
if ($update_command) {
|
||||
$id = (int) get_parameter ('id');
|
||||
$alert = get_alert_command ($id);
|
||||
if ($alert['internal']) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
$name = (string) get_parameter ('name');
|
||||
$command = (string) get_parameter ('command');
|
||||
$description = (string) get_parameter ('description');
|
||||
|
||||
$result = update_alert_command ($id, $name, $command,
|
||||
array ('description' => $description));
|
||||
|
||||
print_error_message ($result, __('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
}
|
||||
|
||||
if ($delete_command) {
|
||||
$id = get_parameter ('id');
|
||||
// Commands below 4 are special and cannot be deleted
|
||||
if ($id < 4) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = delete_alert_command ($id);
|
||||
|
||||
print_error_message ($result, __('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
}
|
||||
|
||||
$table->width = '90%';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[2] = __('Delete');
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->size = array ();
|
||||
$table->size[2] = '40px';
|
||||
$table->align = array ();
|
||||
$table->align[2] = 'center';
|
||||
|
||||
$commands = get_db_all_rows_in_table ('talert_commands');
|
||||
if ($commands === false)
|
||||
$commands = array ();
|
||||
|
||||
foreach ($commands as $command) {
|
||||
$data = array ();
|
||||
|
||||
if (! $command['internal'])
|
||||
$data[0] = '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_command&id='.$command['id'].'">'.
|
||||
$command['name'].'</a>';
|
||||
else
|
||||
$data[0] = $command['name'];
|
||||
|
||||
$data[1] = $command['description'];
|
||||
$data[2] = '';
|
||||
if (! $command['internal'])
|
||||
$data[2] = '<a href="index.php?sec=gagente&sec2=godmode/alerts/alert_commands&delete_command=1&id='.$command['id'].'"
|
||||
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.
|
||||
'<img src="images/cross.png"></a>';
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
print_table ($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_command">';
|
||||
print_submit_button (__('Create'), 'create', false, 'class="sub next"');
|
||||
print_input_hidden ('create_alert', 1);
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
?>
|
|
@ -0,0 +1,201 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Load global vars
|
||||
require_once ('include/config.php');
|
||||
require_once ('include/functions_alerts.php');
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if (defined ('AJAX')) {
|
||||
$get_template_tooltip = (bool) get_parameter ('get_template_tooltip');
|
||||
|
||||
if ($get_template_tooltip) {
|
||||
$id_template = (int) get_parameter ('id_template');
|
||||
$template = get_alert_template ($id_template);
|
||||
if ($template === false)
|
||||
return;
|
||||
|
||||
echo '<h3>'.$template['name'].'</h3>';
|
||||
echo '<strong>'.__('Type').':</strong> '.get_alert_templates_type_name ($template['type']).'<br />';
|
||||
|
||||
switch ($template['type']) {
|
||||
case 'regex':
|
||||
case 'equal':
|
||||
case 'not_equal':
|
||||
echo '<strong>'.__('Value').':</strong> ';
|
||||
echo '<code>'.$template['value'].'</code>';
|
||||
|
||||
break;
|
||||
case 'max':
|
||||
case 'max_min':
|
||||
echo '<strong>'.__('Max. value').':</strong> ';
|
||||
echo format_numeric ($template['max_value']);
|
||||
echo '<br />';
|
||||
|
||||
/* Break on max to not show min */
|
||||
if ($template['type'] == 'max')
|
||||
break;
|
||||
case 'min':
|
||||
echo '<strong>'.__('Min. value').':</strong> ';
|
||||
echo format_numeric ($template['min_value']);
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
if ($template['description'] != '') {
|
||||
echo '<strong>'.__('Description').':</strong><br />';
|
||||
echo $template['description'];
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
if ($template['monday'] && $template['tuesday']
|
||||
&& $template['wednesday'] && $template['thursday']
|
||||
&& $template['friday'] && $template['saturday']
|
||||
&& $template['sunday']) {
|
||||
|
||||
/* Everyday */
|
||||
echo '<strong>'.__('Everyday').'</strong><br />';
|
||||
} else {
|
||||
$days = array ('monday' => __('Monday'),
|
||||
'tuesday' => __('Tuesday'),
|
||||
'wednesday' => __('Wednesday'),
|
||||
'thursday' => __('Thursday'),
|
||||
'friday' => __('Friday'),
|
||||
'saturday' => __('Saturday'),
|
||||
'sunday' => __('Sunday'));
|
||||
|
||||
echo '<strong>'.__('Days').'</strong>: '.__('Every').' ';
|
||||
$actives = array ();
|
||||
foreach ($days as $day => $name) {
|
||||
if ($template[$day])
|
||||
array_push ($actives, $name);
|
||||
}
|
||||
|
||||
$last = array_pop ($actives);
|
||||
if (count ($actives)) {
|
||||
echo implode (', ', $actives);
|
||||
echo ' '.__('and').' ';
|
||||
}
|
||||
echo $last;
|
||||
|
||||
}
|
||||
echo '<br />';
|
||||
|
||||
if ($template['time_from'] != $template['time_to']) {
|
||||
echo '<strong>'.__('From').'</strong> ';
|
||||
echo $template['time_from'];
|
||||
echo ' <strong>'.__('to').'</strong> ';
|
||||
echo $template['time_to'];
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<h1>'.__('Alert templates').'</h1>';
|
||||
$update_template = (bool) get_parameter ('update_template');
|
||||
$delete_template = (bool) get_parameter ('delete_template');
|
||||
|
||||
if ($update_template) {
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
$recovery_notify = (bool) get_parameter ('recovery_notify');
|
||||
$field2_recovery = (bool) get_parameter ('field2_recovery');
|
||||
$field3_recovery = (bool) get_parameter ('field3_recovery');
|
||||
|
||||
$result = update_alert_template ($id,
|
||||
array ('recovery_notify' => $recovery_notify,
|
||||
'field2_recovery' => $field2_recovery,
|
||||
'field3_recovery' => $field3_recovery));
|
||||
|
||||
print_error_message ($result, __('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
}
|
||||
|
||||
if ($delete_template) {
|
||||
$id = get_parameter ('id');
|
||||
// Templates below 4 are special and cannot be deleted
|
||||
if ($id < 4) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = delete_alert_template ($id);
|
||||
|
||||
print_error_message ($result, __('Successfully deleted'),
|
||||
__('Could not be deleted'));
|
||||
}
|
||||
|
||||
$table->width = '90%';
|
||||
$table->data = array ();
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Name');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[2] = __('Type');
|
||||
$table->head[3] = __('Delete');
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->size = array ();
|
||||
$table->size[2] = '10%';
|
||||
$table->size[3] = '40px';
|
||||
$table->align = array ();
|
||||
$table->align[3] = 'center';
|
||||
|
||||
$templates = get_alert_templates (false);
|
||||
if ($templates === false)
|
||||
$templates = array ();
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&id='.$template['id'].'">'.
|
||||
$template['name'].'</a>';
|
||||
|
||||
$data[1] = $template['description'];
|
||||
$data[2] = get_alert_templates_type_name ($template['type']);
|
||||
$data[3] = '<a href="index.php?sec=gagente&sec2=godmode/alerts/alert_templates&delete_template=1&id='.$template['id'].'"
|
||||
onClick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.
|
||||
'<img src="images/cross.png"></a>';
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
||||
print_table ($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template">';
|
||||
print_submit_button (__('Create'), 'create', false, 'class="sub next"');
|
||||
print_input_hidden ('create_alert', 1);
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
?>
|
|
@ -28,40 +28,40 @@ if (! give_acl ($config['id_user'], 0, "LM")) {
|
|||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
// Var init
|
||||
$descripcion = "";
|
||||
$nombre = "";
|
||||
$comando ="";
|
||||
|
||||
if (isset($_GET["id_alerta"])){
|
||||
$id_alerta = entrada_limpia($_GET["id_alerta"]);
|
||||
$sql1='SELECT * FROM talerta WHERE id_alerta = '.$id_alerta;
|
||||
$result=mysql_query($sql1);
|
||||
if ($row=mysql_fetch_array($result)){
|
||||
$descripcion = $row["descripcion"];
|
||||
$nombre= $row["nombre"];
|
||||
$comando = $row["comando"];
|
||||
} else
|
||||
{
|
||||
echo "<h3 class='error'>".__('There was a problem loading alert')."</h3>";
|
||||
echo "</table>";
|
||||
include ("general/footer.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$creacion_alerta = 0;
|
||||
if (isset($_GET["creacion"])){
|
||||
$creacion_alerta = 1;
|
||||
// Var init
|
||||
$descripcion = "";
|
||||
$nombre = "";
|
||||
$comando ="";
|
||||
|
||||
if (isset($_GET["id_alerta"])){
|
||||
$id_alerta = entrada_limpia($_GET["id_alerta"]);
|
||||
$sql1='SELECT * FROM talerta WHERE id_alerta = '.$id_alerta;
|
||||
$result=mysql_query($sql1);
|
||||
if ($row=mysql_fetch_array($result)){
|
||||
$descripcion = $row["descripcion"];
|
||||
$nombre= $row["nombre"];
|
||||
$comando = $row["comando"];
|
||||
} else
|
||||
{
|
||||
echo "<h3 class='error'>".__('There was a problem loading alert')."</h3>";
|
||||
echo "</table>";
|
||||
include ("general/footer.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$creacion_alerta = 0;
|
||||
if (isset($_GET["creacion"])){
|
||||
$creacion_alerta = 1;
|
||||
}
|
||||
|
||||
echo "<h2>".__('Alert configuration')." > ";
|
||||
if (isset($_GET["creacion"])){
|
||||
echo __('Create alert');
|
||||
}
|
||||
if (isset($_GET["id_alerta"])){
|
||||
echo __('Modify alert');
|
||||
}
|
||||
if (isset($_GET["creacion"])){
|
||||
echo __('Create alert');
|
||||
}
|
||||
if (isset($_GET["id_alerta"])){
|
||||
echo __('Modify alert');
|
||||
}
|
||||
pandora_help ("manage_alerts");
|
||||
echo "</h2>";
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Load global vars
|
||||
require_once ('include/config.php');
|
||||
require_once ('include/functions_alerts.php');
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
$name = '';
|
||||
$id_command = '';
|
||||
$field1 = '';
|
||||
$field2 = '';
|
||||
$field3 = '';
|
||||
if ($id) {
|
||||
$action = get_alert_action ($id);
|
||||
$name = $action['name'];
|
||||
$id_command = $action['id_alert_command'];
|
||||
$field1 = $action['field1'];
|
||||
$field2 = $action['field2'];
|
||||
$field3 = $action['field3'];
|
||||
}
|
||||
|
||||
echo '<h1>'.__('Configure alert action').'</h1>';
|
||||
|
||||
$table->width = '90%';
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->size = array ();
|
||||
$table->size[0] = '20%';
|
||||
$table->data = array ();
|
||||
$table->data[0][0] = __('Name');
|
||||
$table->data[0][1] = print_input_text ('name', $name, '', 35, 255, true);
|
||||
|
||||
$table->data[1][0] = __('Command');
|
||||
$table->data[1][1] = print_select_from_sql ('SELECT id, name FROM talert_commands',
|
||||
'id_command', $id_command, '', __('None'), 0, true);
|
||||
|
||||
$table->data[2][0] = __('Field 1');
|
||||
$table->data[2][1] = print_input_text ('field1', $field1, '', 35, 255, true);
|
||||
|
||||
$table->data[3][0] = __('Field 2');
|
||||
$table->data[3][1] = print_input_text ('field2', $field2, '', 35, 255, true);
|
||||
|
||||
$table->data[4][0] = __('Field 3');
|
||||
$table->data[4][1] = print_textarea ('field3', 30, 30, $field3, '', true);
|
||||
|
||||
$table->data[6][0] = __('Command preview');
|
||||
$table->data[6][1] = print_textarea ('command_preview', 30, 30, '', 'disabled="disabled"', true);
|
||||
|
||||
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_actions">';
|
||||
print_table ($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
if ($id) {
|
||||
print_input_hidden ('id', $id);
|
||||
print_input_hidden ('update_action', 1);
|
||||
print_submit_button (__('Update'), 'create', false, 'class="sub upd"');
|
||||
} else {
|
||||
print_input_hidden ('create_action', 1);
|
||||
print_submit_button (__('Create'), 'create', false, 'class="sub next"');
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="include/javascript/pandora_alerts.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
<?php if ($id_command) : ?>
|
||||
original_command = "<?php echo get_alert_command_command ($id_command); ?>";
|
||||
render_command_preview ();
|
||||
<?php endif; ?>
|
||||
$("#id_command").change (function () {
|
||||
values = Array ();
|
||||
values.push ({name: "page",
|
||||
value: "godmode/alerts/alert_commands"});
|
||||
values.push ({name: "get_alert_command",
|
||||
value: "1"});
|
||||
values.push ({name: "id",
|
||||
value: this.value});
|
||||
jQuery.get ("ajax.php",
|
||||
values,
|
||||
function (data, status) {
|
||||
original_command = html_entity_decode (data["command"]);
|
||||
render_command_preview (original_command);
|
||||
},
|
||||
"json"
|
||||
);
|
||||
});
|
||||
|
||||
$("#text-field1").keyup (render_command_preview);
|
||||
$("#text-field2").keyup (render_command_preview);
|
||||
$("#text-field3").keyup (render_command_preview);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Load global vars
|
||||
require_once ("include/config.php");
|
||||
require_once ("include/functions_alerts.php");
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
$name = '';
|
||||
$command = '';
|
||||
$description = '';
|
||||
if ($id) {
|
||||
$alert = get_alert_command ($id);
|
||||
$name = $alert['name'];
|
||||
$command = $alert['command'];
|
||||
$description = $alert['description'];
|
||||
}
|
||||
|
||||
echo '<h1>'.__('Configure alert command').'</h1>';
|
||||
|
||||
$table->width = '90%';
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->size = array ();
|
||||
$table->size[0] = '20%';
|
||||
$table->data = array ();
|
||||
$table->data[0][0] = __('Name');
|
||||
$table->data[0][1] = print_input_text ('name', $name, '', 35, 255, true);
|
||||
$table->data[1][0] = __('Command');
|
||||
$table->data[1][1] = print_input_text ('command', $command, '', 35, 255, true);
|
||||
$table->data[2][0] = __('Description');
|
||||
$table->data[2][1] = print_textarea ('description', 30, 30, $description, '', true);
|
||||
|
||||
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_commands">';
|
||||
print_table ($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
if ($id) {
|
||||
print_input_hidden ('id', $id);
|
||||
print_input_hidden ('update_command', 1);
|
||||
print_submit_button (__('Update'), 'create', false, 'class="sub upd"');
|
||||
} else {
|
||||
print_input_hidden ('create_command', 1);
|
||||
print_submit_button (__('Create'), 'create', false, 'class="sub next"');
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
?>
|
|
@ -0,0 +1,590 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Load global vars
|
||||
require_once ('include/config.php');
|
||||
require_once ('include/functions_alerts.php');
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
function print_alert_template_steps ($step, $id) {
|
||||
echo '<div style="margin-bottom: 15px">';
|
||||
|
||||
/* Step 1 */
|
||||
if ($step == 1)
|
||||
echo '<strong>';
|
||||
if ($id) {
|
||||
echo '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&id='.$id.'">';
|
||||
echo __('Step').' 1 : '.__('Conditions');
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo __('Step').' 1 : '.__('Conditions');
|
||||
}
|
||||
if ($step == 1)
|
||||
echo '</strong>';
|
||||
|
||||
/* Step 2 */
|
||||
echo ' » ';
|
||||
|
||||
if ($step == 2)
|
||||
echo '<strong>';
|
||||
if ($id) {
|
||||
echo '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&id='.$id.'&step=2">';
|
||||
echo __('Step').' 2 : '.__('Firing');
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo __('Step').' 2 : '.__('Firing');
|
||||
}
|
||||
if ($step == 2)
|
||||
echo '</strong>';
|
||||
|
||||
/* Step 3 */
|
||||
echo ' » ';
|
||||
|
||||
if ($step == 3)
|
||||
echo '<strong>';
|
||||
if ($id) {
|
||||
echo '<a href="index.php?sec=galertas&sec2=godmode/alerts/configure_alert_template&id='.$id.'&step=3">';
|
||||
echo __('Step').' 3 : '.__('Recovery');
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo __('Step').' 3 : '.__('Recovery');
|
||||
}
|
||||
if ($step == 3)
|
||||
echo '</strong>';
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function update_template ($step) {
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
if (empty ($id))
|
||||
return false;
|
||||
|
||||
if ($step == 1) {
|
||||
$type = (string) get_parameter ('type');
|
||||
$name = (string) get_parameter ('name');
|
||||
$description = (string) get_parameter ('description');
|
||||
$type = (string) get_parameter ('type');
|
||||
$value = (string) get_parameter ('value');
|
||||
$max = (float) get_parameter ('max');
|
||||
$min = (float) get_parameter ('min');
|
||||
|
||||
$result = update_alert_template ($id,
|
||||
array ('type' => $type,
|
||||
'description' => $description,
|
||||
'value' => $value,
|
||||
'max_value' => $max,
|
||||
'min_value' => $min));
|
||||
} elseif ($step == 2) {
|
||||
$monday = (bool) get_parameter ('monday');
|
||||
$tuesday = (bool) get_parameter ('tuesday');
|
||||
$wednesday = (bool) get_parameter ('wednesday');
|
||||
$thursday = (bool) get_parameter ('thursday');
|
||||
$friday = (bool) get_parameter ('friday');
|
||||
$saturday = (bool) get_parameter ('saturday');
|
||||
$sunday = (bool) get_parameter ('sunday');
|
||||
$time_from = (string) get_parameter ('time_from');
|
||||
$time_from = date ("H:s:00", strtotime ($time_from));
|
||||
$time_to = (string) get_parameter ('time_to');
|
||||
$time_to = date ("H:s:00", strtotime ($time_to));
|
||||
$threshold = (int) get_parameter ('threshold');
|
||||
if ($threshold == -1)
|
||||
$threshold = (int) get_parameter ('other_threshold');
|
||||
$field1 = (string) get_parameter ('field1');
|
||||
$field2 = (string) get_parameter ('field2');
|
||||
$field3 = (string) get_parameter ('field3');
|
||||
$default_action = (int) get_parameter ('default_action');
|
||||
if (empty ($default_action)) {
|
||||
$default_action = NULL;
|
||||
$field1 = '';
|
||||
$field2 = '';
|
||||
$field3 = '';
|
||||
}
|
||||
|
||||
$values = array ('monday' => $monday,
|
||||
'tuesday' => $tuesday,
|
||||
'wednesday' => $wednesday,
|
||||
'thursday' => $thursday,
|
||||
'friday' => $friday,
|
||||
'saturday' => $saturday,
|
||||
'sunday' => $sunday,
|
||||
'time_from' => $time_from,
|
||||
'time_to' => $time_to,
|
||||
'time_threshold' => $threshold,
|
||||
'default_action' => $default_action,
|
||||
'field1' => $field1,
|
||||
'field2' => $field2,
|
||||
'field3' => $field3
|
||||
);
|
||||
|
||||
if ($default_action) {
|
||||
$values['id_alert_action'] = $default_action;
|
||||
$values['field1'] = $field1;
|
||||
$values['field2'] = $field2;
|
||||
$values['field3'] = $field3;
|
||||
}
|
||||
|
||||
$result = update_alert_template ($id, $values);
|
||||
} elseif ($step == 3) {
|
||||
$recovery_notify = (bool) get_parameter ('recovery_notify');
|
||||
$field2_recovery = (bool) get_parameter ('field2_recovery');
|
||||
$field3_recovery = (bool) get_parameter ('field3_recovery');
|
||||
|
||||
$result = update_alert_template ($id,
|
||||
array ('recovery_notify' => $recovery_notify,
|
||||
'field2_recovery' => $field2_recovery,
|
||||
'field3_recovery' => $field3_recovery));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$id = (int) get_parameter ('id');
|
||||
|
||||
/* We set here the number of steps */
|
||||
define ('LAST_STEP', 3);
|
||||
|
||||
$step = (int) get_parameter ('step', 1);
|
||||
|
||||
$create_template = (bool) get_parameter ('create_template');
|
||||
$update_template = (bool) get_parameter ('update_template');
|
||||
|
||||
$name = '';
|
||||
$description = '';
|
||||
$type = '';
|
||||
$value = '';
|
||||
$max = '';
|
||||
$min = '';
|
||||
$time_from = '12:00';
|
||||
$time_to = '12:00';
|
||||
$monday = true;
|
||||
$tuesday = true;
|
||||
$wednesday = true;
|
||||
$thursday = true;
|
||||
$friday = true;
|
||||
$saturday = true;
|
||||
$sunday = true;
|
||||
$default_action = 0;
|
||||
$field1 = '';
|
||||
$field2 = '';
|
||||
$field3 = '';
|
||||
$min_alerts = 0;
|
||||
$max_alerts = 1;
|
||||
$threshold = 300;
|
||||
$recovery_notify = false;
|
||||
$field2_recovery = '';
|
||||
$field3_recovery = '';
|
||||
|
||||
if ($create_template) {
|
||||
$name = (string) get_parameter ('name');
|
||||
$description = (string) get_parameter ('description');
|
||||
$type = (string) get_parameter ('type');
|
||||
$value = (string) get_parameter ('value');
|
||||
$max = (float) get_parameter ('max');
|
||||
$min = (float) get_parameter ('min');
|
||||
|
||||
$result = create_alert_template ($name, $type,
|
||||
array ('description' => $description,
|
||||
'value' => $value,
|
||||
'max' => $max,
|
||||
'min' => $min));
|
||||
|
||||
print_error_message ($result, __('Successfully created'),
|
||||
__('Could not be created'));
|
||||
/* Go to previous step in case of error */
|
||||
if ($result === false)
|
||||
$step = $step - 1;
|
||||
}
|
||||
|
||||
if ($update_template) {
|
||||
$result = update_template ($step - 1);
|
||||
|
||||
print_error_message ($result, __('Successfully updated'),
|
||||
__('Could not be updated'));
|
||||
/* Go to previous step in case of error */
|
||||
if ($result === false) {
|
||||
$step = $step - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$template = get_alert_template ($id);
|
||||
$name = $template['name'];
|
||||
$description = $template['description'];
|
||||
$type = $template['type'];
|
||||
$value = $template['value'];
|
||||
$max = $template['max_value'];
|
||||
$min = $template['min_value'];
|
||||
$time_from = $template['time_from'];
|
||||
$time_to = $template['time_to'];
|
||||
$monday = (bool) $template['monday'];
|
||||
$tuesday = (bool) $template['tuesday'];
|
||||
$wednesday = (bool) $template['wednesday'];
|
||||
$thursday = (bool) $template['thursday'];
|
||||
$friday = (bool) $template['friday'];
|
||||
$saturday = (bool) $template['saturday'];
|
||||
$sunday = (bool) $template['sunday'];
|
||||
$max_alerts = $template['max_alerts'];
|
||||
$min_alerts = $template['min_alerts'];
|
||||
$threshold = $template['time_threshold'];
|
||||
$recovery_notify = $template['recovery_notify'];
|
||||
$field2_recovery = $template['field2_recovery'];
|
||||
$field3_recovery = $template['field3_recovery'];
|
||||
$default_action = $template['id_alert_action'];
|
||||
$field1 = $template['field1'];
|
||||
$field2 = $template['field2'];
|
||||
$field3 = $template['field3'];
|
||||
}
|
||||
|
||||
echo '<h1>'.__('Configure alert template').'</h1>';
|
||||
|
||||
print_alert_template_steps ($step, $id);
|
||||
|
||||
$table->id = 'template';
|
||||
$table->width = '90%';
|
||||
$table->style = array ();
|
||||
$table->style[0] = 'font-weight: bold';
|
||||
$table->style[2] = 'font-weight: bold';
|
||||
$table->size = array ();
|
||||
$table->size[0] = '20%';
|
||||
$table->size[2] = '20%';
|
||||
|
||||
if ($step == 2) {
|
||||
/* Firing conditions and events */
|
||||
$threshold_values = get_alert_template_threshold_values ();
|
||||
if (in_array ($threshold, array_keys ($threshold_values))) {
|
||||
$table->style['other_label'] = 'display:none; font-weight: bold';
|
||||
$table->style['other_input'] = 'display:none';
|
||||
$threshold_selected = $threshold;
|
||||
} else {
|
||||
$table->style['other_label'] = 'font-weight: bold';
|
||||
$threshold_selected = -1;
|
||||
}
|
||||
|
||||
if ($default_action == 0) {
|
||||
$table->rowstyle = array ();
|
||||
$table->rowstyle['field1'] = 'display: none';
|
||||
$table->rowstyle['field2'] = 'display: none';
|
||||
$table->rowstyle['field3'] = 'display: none';
|
||||
$table->rowstyle['preview'] = 'display: none';
|
||||
}
|
||||
$table->colspan = array ();
|
||||
$table->colspan[0][1] = 3;
|
||||
$table->colspan[4][1] = 3;
|
||||
$table->colspan['field1'][1] = 3;
|
||||
$table->colspan['field2'][1] = 3;
|
||||
$table->colspan['field3'][1] = 3;
|
||||
$table->colspan['preview'][1] = 3;
|
||||
|
||||
$table->data[0][0] = __('Days of week');
|
||||
$table->data[0][1] = __('Mon');
|
||||
$table->data[0][1] .= print_checkbox ('monday', 1, $monday, true);
|
||||
$table->data[0][1] .= __('Tue');
|
||||
$table->data[0][1] .= print_checkbox ('tuesday', 1, $tuesday, true);
|
||||
$table->data[0][1] .= __('Wed');
|
||||
$table->data[0][1] .= print_checkbox ('wednesday', 1, $wednesday, true);
|
||||
$table->data[0][1] .= __('Thu');
|
||||
$table->data[0][1] .= print_checkbox ('thursday', 1, $thursday, true);
|
||||
$table->data[0][1] .= __('Fri');
|
||||
$table->data[0][1] .= print_checkbox ('friday', 1, $friday, true);
|
||||
$table->data[0][1] .= __('Sat');
|
||||
$table->data[0][1] .= print_checkbox ('saturday', 1, $saturday, true);
|
||||
$table->data[0][1] .= __('Sun');
|
||||
$table->data[0][1] .= print_checkbox ('sunday', 1, $sunday, true);
|
||||
|
||||
$table->data[1][0] = __('Time from');
|
||||
$table->data[1][1] = print_input_text ('time_from', $time_from, '', 7, 7,
|
||||
true);
|
||||
$table->data[1][2] = __('Time to');
|
||||
$table->data[1][3] = print_input_text ('time_to', $time_to, '', 7, 7,
|
||||
true);
|
||||
|
||||
$table->data['threshold'][0] = __('Time threshold');
|
||||
$table->data['threshold'][1] = print_select ($threshold_values,
|
||||
'threshold', $threshold_selected, '', '', '', true, false, false);
|
||||
$table->data['threshold']['other_label'] = __('Other value');
|
||||
$table->data['threshold']['other_input'] = print_input_text ('other_threshold',
|
||||
$threshold, '', 5, 7, true);
|
||||
$table->data['threshold']['other_input'] .= ' '.__('seconds');
|
||||
|
||||
$table->data[3][0] = __('Min. number of alerts');
|
||||
$table->data[3][1] = print_input_text ('min_alerts', $min_alerts, '',
|
||||
5, 7, true);
|
||||
$table->data[3][2] = __('Max. number of alerts');
|
||||
$table->data[3][3] = print_input_text ('max_alerts', $max_alerts, '',
|
||||
5, 7, true);
|
||||
|
||||
$table->data[4][0] = __('Default action');
|
||||
$table->data[4][1] = print_select_from_sql ('SELECT id, name FROM talert_actions ORDER BY name',
|
||||
'default_action', $default_action, '', __('None'), 0,
|
||||
true, false, false);
|
||||
|
||||
$table->data['field1'][0] = __('Field 1');
|
||||
$table->data['field1'][1] = print_input_text ('field1', $field1, '', 35, 255, true);
|
||||
|
||||
$table->data['field2'][0] = __('Field 2');
|
||||
$table->data['field2'][1] = print_input_text ('field2', $field2, '', 35, 255, true);
|
||||
|
||||
$table->data['field3'][0] = __('Field 3');
|
||||
$table->data['field3'][1] = print_textarea ('field3', 30, 30, $field3, '', true);
|
||||
|
||||
$table->data['preview'][0] = __('Command preview');
|
||||
$table->data['preview'][1] = print_textarea ('command_preview', 30, 30,
|
||||
'', 'disabled="disabled"', true);
|
||||
} else if ($step == 3) {
|
||||
/* Alert recover */
|
||||
if (! $recovery_notify) {
|
||||
$table->rowstyle = array ();
|
||||
$table->rowstyle['field2'] = 'display:none;';
|
||||
$table->rowstyle['field3'] = 'display:none';
|
||||
}
|
||||
$table->data[0][0] = __('Alert recovery');
|
||||
$values = array (false => __('Disabled'), true => __('Enabled'));
|
||||
$table->data[0][1] = print_select ($values,
|
||||
'recovery_notify', $recovery_notify, '', '', '', true, false,
|
||||
false);
|
||||
|
||||
$table->data['field2'][0] = __('Field 2');
|
||||
$table->data['field2'][1] = print_input_text ('field2_recovery',
|
||||
$field2_recovery, '', 35, 255, true);
|
||||
|
||||
$table->data['field3'][0] = __('Field 3');
|
||||
$table->data['field3'][1] = print_textarea ('field3_recovery', 30, 30,
|
||||
$field3_recovery, '', true);
|
||||
} else {
|
||||
/* Step 1 by default */
|
||||
$table->size = array ();
|
||||
$table->size[0] = '20%';
|
||||
$table->data = array ();
|
||||
$table->rowstyle = array ();
|
||||
$table->rowstyle['value'] = 'display: none';
|
||||
$table->rowstyle['max'] = 'display: none';
|
||||
$table->rowstyle['min'] = 'display: none';
|
||||
|
||||
if ($id) {
|
||||
switch ($type) {
|
||||
case "equal":
|
||||
case "not_equal":
|
||||
case "regex":
|
||||
$table->rowstyle['value'] = '';
|
||||
break;
|
||||
case "max_min":
|
||||
case "max":
|
||||
$table->rowstyle['max'] = '';
|
||||
if ($type == 'max')
|
||||
break;
|
||||
case "min":
|
||||
$table->rowstyle['min'] = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$table->data[0][0] = __('Name');
|
||||
$table->data[0][1] = print_input_text ('name', $name, '', 35, 255, true);
|
||||
|
||||
$table->data[1][0] = __('Description');
|
||||
$table->data[1][1] = print_textarea ('description', 30, 30,
|
||||
$description, '', true);
|
||||
|
||||
$table->data[2][0] = __('Condition type');
|
||||
$table->data[2][1] = print_select (get_alert_templates_types (), 'type',
|
||||
$type, '', __('Select'), 0, true, false, false);
|
||||
|
||||
$table->data['value'][0] = __('Value');
|
||||
$table->data['value'][1] = print_input_text ('value', $value, '',
|
||||
35, 255, true);
|
||||
$table->data['value'][1] .= '<span id="regex_ok">';
|
||||
$table->data['value'][1] .= print_image ('images/suc.png', true,
|
||||
array ('style' => 'display:none',
|
||||
'id' => 'regex_good',
|
||||
'title' => __('The regular expression is valid')));
|
||||
$table->data['value'][1] .= print_image ('images/err.png', true,
|
||||
array ('style' => 'display:none',
|
||||
'id' => 'regex_bad',
|
||||
'title' => __('The regular expression is not valid')));
|
||||
$table->data['value'][1] .= '</span>';
|
||||
|
||||
$table->data['max'][0] = __('Max');
|
||||
$table->data['max'][1] = print_input_text ('max', $max, '', 5, 255, true);
|
||||
|
||||
$table->data['min'][0] = __('Min');
|
||||
$table->data['min'][1] = print_input_text ('min', $min, '', 5, 255, true);
|
||||
}
|
||||
|
||||
/* If it's the last step it will redirect to template lists */
|
||||
if ($step >= LAST_STEP) {
|
||||
echo '<form method="post" action="index.php?sec=galertas&sec2=godmode/alerts/alert_templates">';
|
||||
} else {
|
||||
echo '<form method="post">';
|
||||
}
|
||||
print_table ($table);
|
||||
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
if ($id) {
|
||||
print_input_hidden ('id', $id);
|
||||
print_input_hidden ('update_template', 1);
|
||||
} else {
|
||||
print_input_hidden ('create_template', 1);
|
||||
}
|
||||
|
||||
if ($step >= LAST_STEP) {
|
||||
print_submit_button (__('Finish'), 'finish', false, 'class="sub upd"');
|
||||
} else {
|
||||
print_input_hidden ('step', $step + 1);
|
||||
print_submit_button (__('Next'), 'next', false, 'class="sub next"');
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="include/javascript/pandora_alerts.js"></script>
|
||||
<link rel="stylesheet" href="include/styles/timeentry.css" type="text/css" media="screen">
|
||||
<script src="include/javascript/jquery.ui.core.js"></script>
|
||||
<script src="include/javascript/jquery.timeentry.js"></script>
|
||||
<script src="include/languages/time_<?php echo $config['language']; ?>.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function check_regex () {
|
||||
if ($("#type").attr ('value') != 'regex') {
|
||||
$("img#regex_good, img#regex_bad").hide ();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
re = new RegExp ($("#text-value").attr ("value"));
|
||||
} catch (error) {
|
||||
$("img#regex_good").hide ();
|
||||
$("img#regex_bad").show ();
|
||||
return;
|
||||
}
|
||||
$("img#regex_bad").hide ();
|
||||
$("img#regex_good").show ();
|
||||
}
|
||||
|
||||
$(document).ready (function () {
|
||||
$("#text-time_from, #text-time_to").timeEntry ({
|
||||
spinnerImage: 'images/time-entry.png',
|
||||
spinnerSize: [20, 20, 0]
|
||||
}
|
||||
);
|
||||
|
||||
$("#type").change (function () {
|
||||
switch (this.value) {
|
||||
case "equal":
|
||||
case "not_equal":
|
||||
$("img#regex_good, img#regex_bad").hide ();
|
||||
case "regex":
|
||||
$("#template-max, #template-min").fadeOut ('normal',
|
||||
function () {
|
||||
$("#template-value").fadeIn ();
|
||||
check_regex ();
|
||||
}
|
||||
);
|
||||
break;
|
||||
case "max_min":
|
||||
$("#template-value").fadeOut ('normal',
|
||||
function () {
|
||||
$("#template-max").fadeIn ();
|
||||
$("#template-min").fadeIn ();
|
||||
}
|
||||
);
|
||||
break;
|
||||
case "max":
|
||||
$("#template-value, #template-min").fadeOut ('normal',
|
||||
function () {
|
||||
$("#template-max").fadeIn ();
|
||||
}
|
||||
);
|
||||
break;
|
||||
case "min":
|
||||
$("#template-value, #template-max").fadeOut ('normal',
|
||||
function () {
|
||||
$("#template-min").fadeIn ();
|
||||
}
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$("#template-value, #template-max, #template-min").fadeOut ();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$("#text-value").keyup (check_regex);
|
||||
$("#threshold").change (function () {
|
||||
if (this.value == -1) {
|
||||
$("#text-other_threshold").attr ("value", "");
|
||||
$("#template-threshold-other_label").fadeIn ();
|
||||
$("#template-threshold-other_input").fadeIn ();
|
||||
} else {
|
||||
$("#template-threshold-other_label").fadeOut ();
|
||||
$("#template-threshold-other_input").fadeOut ();
|
||||
}
|
||||
});
|
||||
|
||||
$("#recovery_notify").change (function () {
|
||||
if (this.value == 1) {
|
||||
$("#template-field2, #template-field3").fadeIn ();
|
||||
} else {
|
||||
$("#template-field2, #template-field3").fadeOut ();
|
||||
}
|
||||
});
|
||||
|
||||
$("#default_action").change (function () {
|
||||
if (this.value != 0) {
|
||||
values = Array ();
|
||||
values.push ({name: "page",
|
||||
value: "godmode/alerts/alert_actions"});
|
||||
values.push ({name: "get_alert_action",
|
||||
value: "1"});
|
||||
values.push ({name: "id",
|
||||
value: this.value});
|
||||
jQuery.get ("ajax.php",
|
||||
values,
|
||||
function (data) {
|
||||
$("#text-field1").attr ("value", data["field1"]);
|
||||
$("#text-field2").attr ("value", data["field2"]);
|
||||
$("#text-field3").attr ("value", data["field3"]);
|
||||
original_command = html_entity_decode (data["command"]["command"]);
|
||||
render_command_preview ();
|
||||
|
||||
$("#template-field1, #template-field2, #template-field3, #template-preview")
|
||||
.fadeIn ();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
} else {
|
||||
$("#template-field1, #template-field2, #template-field3, #template-preview").fadeOut ();
|
||||
}
|
||||
});
|
||||
|
||||
$("#text-field1").keyup (render_command_preview);
|
||||
$("#text-field2").keyup (render_command_preview);
|
||||
$("#text-field3").keyup (render_command_preview);
|
||||
})
|
||||
</script>
|
|
@ -1,116 +0,0 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
|
||||
// Load global vars
|
||||
require_once ("include/config.php");
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! give_acl ($config['id_user'], 0, "LM")) {
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation",
|
||||
"Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
if (isset($_POST["update_alerta"])){ // if modified any parameter
|
||||
$id_alerta = entrada_limpia($_POST["id_alerta"]);
|
||||
if ($id_alerta < 4){
|
||||
audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
$nombre = entrada_limpia($_POST["nombre"]);
|
||||
$comando = entrada_limpia($_POST["comando"]);
|
||||
$descripcion= entrada_limpia($_POST["descripcion"]);
|
||||
$sql_update ="UPDATE talerta SET nombre = '".$nombre."', comando = '".$comando."', descripcion = '".$descripcion."' WHERE id_alerta= '".$id_alerta."'";
|
||||
$result=mysql_query($sql_update);
|
||||
if (! $result) {
|
||||
echo "<h3 class='error'>".__('There was a problem updating alert')."</h3>";
|
||||
} else {
|
||||
echo "<h3 class='suc'>".__('Alert successfully updated')."</h3>";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST["crear_alerta"])){ // if create alert
|
||||
$nombre = entrada_limpia($_POST["nombre"]);
|
||||
$comando = entrada_limpia($_POST["comando"]);
|
||||
$descripcion= entrada_limpia($_POST["descripcion"]);
|
||||
$sql_update ="INSERT talerta (nombre, comando, descripcion) VALUES ('".$nombre."', '".$comando."', '".$descripcion."')";
|
||||
$result=mysql_query($sql_update);
|
||||
if (! $result)
|
||||
echo "<h3 class='error'>".__('There was a problem creating alert')."</h3>";
|
||||
else
|
||||
echo "<h3 class='suc'>".__('Alert successfully created')."</h3>";
|
||||
}
|
||||
|
||||
if (isset($_GET["borrar_alerta"])){ // if delete alert
|
||||
$id_alerta = entrada_limpia($_GET["borrar_alerta"]);
|
||||
if ($id_alerta < 4) {
|
||||
audit_db ($config['id_user'],$REMOTE_ADDR, "ACL Violation","Trying to access Alert Management");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
$sql_delete= "DELETE FROM talerta WHERE id_alerta = ".$id_alerta;
|
||||
$result=mysql_query($sql_delete);
|
||||
if (! $result)
|
||||
echo "<h3 class='error'>".__('There was a problem deleting alert')."</h3>";
|
||||
else
|
||||
echo "<h3 class='suc'>".__('Alert successfully deleted')."</h3>";
|
||||
|
||||
$sql_delete2 ="DELETE FROM talerta_agente_modulo WHERE id_alerta = ".$id_alerta;
|
||||
$result=mysql_query($sql_delete2);
|
||||
}
|
||||
|
||||
echo "<h2>".__('Alert configuration')." > ";
|
||||
echo __('Alerts defined in Pandora')."</h2>";
|
||||
echo "<table width='500' cellpadding='4' cellspacing='4' class='databox'>";
|
||||
echo "<th width='100px'>".__('Alert name')."</th>";
|
||||
echo "<th>".__('Description')."</th>";
|
||||
echo "<th>".__('Delete')."</th>";
|
||||
$color=1;
|
||||
$sql1='SELECT * FROM talerta';
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
if ($color == 1){
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
}
|
||||
else {
|
||||
$tdcolor = "datos2";
|
||||
$color = 1;
|
||||
}
|
||||
if ($row[0] > 4){
|
||||
echo "<tr><td class='$tdcolor'><b><a href='index.php?sec=galertas&sec2=godmode/alerts/configure_alert&id_alerta=".$row["id_alerta"]."'>".$row["nombre"]."</a></b></td>";
|
||||
echo "<td class='$tdcolor'>".$row["descripcion"]."</td>";
|
||||
echo "<td class='$tdcolor' align='center'><a href='index.php?sec=gagente&sec2=godmode/alerts/modify_alert&borrar_alerta=".$row["id_alerta"]."' onClick='if (!confirm(\' ".__('Are you sure?')."\')) return false;'><img border='0' src='images/cross.png'></a></td>";
|
||||
} else {
|
||||
echo "<tr><td class='$tdcolor'><b>".$row["nombre"]."</b></td>";
|
||||
echo "<td class='$tdcolor'>".$row["descripcion"]."</td>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</tr></table>";
|
||||
echo "<table width=500>";
|
||||
echo "<tr><td align='right'>";
|
||||
echo "<form method=post action='index.php?sec=galertas&sec2=godmode/alerts/configure_alert&creacion=1'>";
|
||||
echo "<input type='submit' class='sub next' name='crt' value='".__('Create alert')."'>";
|
||||
echo "</form>";
|
||||
echo "</td></tr></table>";
|
||||
?>
|
|
@ -25,61 +25,58 @@ if ((! give_acl ($config['id_user'], 0, "LM")) && (! give_acl ($config['id_user'
|
|||
}
|
||||
|
||||
if (give_acl ($config['id_user'], 0, "AW")) {
|
||||
|
||||
$menu["gagente"]["text"] = __('Manage agents');
|
||||
$menu["gagente"]["sec2"] = "godmode/agentes/modificar_agente";
|
||||
$menu["gagente"]["refr"] = 0;
|
||||
$menu["gagente"]["id"] = "god-agents";
|
||||
|
||||
$sub = array ();
|
||||
$sub["godmode/agentes/manage_config"]["text"] = __('Manage config');
|
||||
$sub["godmode/agentes/manage_config"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/agentes/manage_config_remote"]["text"] = __('Duplicate config');
|
||||
$sub["godmode/agentes/manage_config_remote"]["refr"] = 0;
|
||||
|
||||
if (give_acl ($config["id_user"], 0, "PM")) {
|
||||
$sub["godmode/groups/group_list"]["text"] = __('Manage groups');
|
||||
$sub["godmode/groups/group_list"]["refr"] = 0;
|
||||
}
|
||||
|
||||
$sub["godmode/agentes/planned_downtime"]["text"] = __('Scheduled downtime');
|
||||
$sub["godmode/agentes/planned_downtime"]["refr"] = 0;
|
||||
|
||||
$menu["gagente"]["sub"] = $sub;
|
||||
}
|
||||
if (give_acl ($config['id_user'], 0, "PM")) {
|
||||
$menu["gmodules"]["text"] = __('Manage modules');
|
||||
$menu["gmodules"]["sec2"] = "godmode/agentes/modificar_agente";
|
||||
$menu["gmodules"]["refr"] = 0;
|
||||
$menu["gmodules"]["id"] = "god-modules";
|
||||
|
||||
$sub = array ();
|
||||
$sub["godmode/modules/manage_nc_groups"]["text"] = __('Component groups');
|
||||
$sub["godmode/modules/manage_nc_groups"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/modules/manage_network_components"]["text"] = __('Module components');
|
||||
$sub["godmode/modules/manage_network_components"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/modules/manage_network_templates"]["text"] = __('Module templates');
|
||||
$sub["godmode/modules/manage_network_templates"]["refr"] = 0;
|
||||
|
||||
|
||||
enterprise_hook ('inventory_submenu');
|
||||
|
||||
|
||||
$menu["gmodules"]["sub"] = $sub;
|
||||
}
|
||||
|
||||
if (give_acl ($config['id_user'], 0, "LM")) {
|
||||
$menu["galertas"]["text"] = __('Manage alerts');
|
||||
$menu["galertas"]["sec2"] = "godmode/alerts/modify_alert";
|
||||
$menu["galertas"]["refr"] = 0;
|
||||
$menu["galertas"]["id"] = "god-alerts";
|
||||
|
||||
$sub = array ();
|
||||
$sub["godmode/alerts/alert_templates"]["text"] = __('Templates');
|
||||
|
||||
$sub["godmode/alerts/alert_actions"]["text"] = __('Actions');
|
||||
|
||||
$sub["godmode/alerts/alert_commands"]["text"] = __('Commands');
|
||||
|
||||
$menu["galertas"]["sub"] = $sub;
|
||||
}
|
||||
|
||||
if (give_acl ($config['id_user'], 0, "UM")) {
|
||||
$menu["gusuarios"]["text"] = __('Manage users');
|
||||
$menu["gusuarios"]["sec2"] = "godmode/users/user_list";
|
||||
$menu["gusuarios"]["refr"] = 0;
|
||||
$menu["gusuarios"]["id"] = "god-users";
|
||||
}
|
||||
|
||||
|
@ -87,13 +84,11 @@ if (give_acl ($config['id_user'], 0, "UM")) {
|
|||
if (give_acl($config['id_user'], 0, "AW")) {
|
||||
$menu["gsnmpconsole"]["text"] = __('Manage SNMP console');
|
||||
$menu["gsnmpconsole"]["sec2"] = "godmode/snmpconsole/snmp_alert";
|
||||
$menu["gsnmpconsole"]["refr"] = 0;
|
||||
$menu["gsnmpconsole"]["id"] = "god-snmpc";
|
||||
|
||||
//SNMP Console alert
|
||||
$sub = array ();
|
||||
$sub["godmode/snmpconsole/snmp_alert"]["text"] = __('Component groups');
|
||||
$sub["godmode/snmpconsole/snmp_alert"]["refr"] = 0;
|
||||
|
||||
enterprise_hook ('snmpconsole_submenu');
|
||||
|
||||
|
@ -104,45 +99,36 @@ if (give_acl($config['id_user'], 0, "AW")) {
|
|||
if (give_acl ($config['id_user'], 0, "PM")) {
|
||||
$menu["greporting"]["text"] = __('Manage reports');
|
||||
$menu["greporting"]["sec2"] = "godmode/reporting/reporting_builder";
|
||||
$menu["greporting"]["refr"] = 0;
|
||||
$menu["greporting"]["id"] = "god-reporting";
|
||||
|
||||
// Custom report builder
|
||||
$sub = array ();
|
||||
$sub["godmode/reporting/reporting_builder"]["text"] = __('Report builder');
|
||||
$sub["godmode/reporting/reporting_builder"]["refr"] = 0;
|
||||
|
||||
// Custom graph builder
|
||||
$sub["godmode/reporting/graph_builder"]["text"] = __('Graph builder');
|
||||
$sub["godmode/reporting/graph_builder"]["refr"] = 0;
|
||||
|
||||
// Custom map builder
|
||||
$sub["godmode/reporting/map_builder"]["text"] = __('Map builder');
|
||||
$sub["godmode/reporting/map_builder"]["refr"] = 0;
|
||||
|
||||
$menu["greporting"]["sub"] = $sub;
|
||||
|
||||
// Manage profiles
|
||||
$menu["gperfiles"]["text"] = __('Manage profiles');
|
||||
$menu["gperfiles"]["sec2"] = "godmode/profiles/profile_list";
|
||||
$menu["gperfiles"]["refr"] = 0;
|
||||
$menu["gperfiles"]["id"] = "god-profiles";
|
||||
|
||||
// Servers
|
||||
$menu["gservers"]["text"] = __('Manage servers');
|
||||
$menu["gservers"]["sec2"] = "godmode/servers/modificar_server";
|
||||
$menu["gservers"]["refr"] = 0;
|
||||
$menu["gservers"]["id"] = "god-servers";
|
||||
|
||||
$sub = array ();
|
||||
$sub["godmode/servers/manage_recontask"]["text"] = __('Manage recontask');
|
||||
$sub["godmode/servers/manage_recontask"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/servers/plugin"]["text"] = __('Manage plugins');
|
||||
$sub["godmode/servers/plugin"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/servers/manage_export_form"]["text"] = __('Export targets');
|
||||
$sub["godmode/servers/manage_export_form"]["refr"] = 0;
|
||||
|
||||
$menu["gservers"]["sub"] = $sub;
|
||||
|
||||
|
@ -151,21 +137,17 @@ if (give_acl ($config['id_user'], 0, "PM")) {
|
|||
// Audit
|
||||
$menu["glog"]["text"] = __('System audit log');
|
||||
$menu["glog"]["sec2"] = "godmode/admin_access_logs";
|
||||
$menu["glog"]["refr"] = 0;
|
||||
$menu["glog"]["id"] = "god-audit";
|
||||
|
||||
// Setup
|
||||
$menu["gsetup"]["text"] = __('Pandora setup');
|
||||
$menu["gsetup"]["sec2"] = "godmode/setup/setup";
|
||||
$menu["gsetup"]["refr"] = 0;
|
||||
$menu["gsetup"]["id"] = "god-setup";
|
||||
|
||||
$sub = array ();
|
||||
$sub["godmode/setup/links"]["text"] = __('Links');
|
||||
$sub["godmode/setup/links"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/setup/news"]["text"] = __('Site news');
|
||||
$sub["godmode/setup/news"]["refr"] = 0;
|
||||
|
||||
$menu["gsetup"]["sub"] = $sub;
|
||||
}
|
||||
|
@ -173,27 +155,20 @@ if (give_acl ($config['id_user'], 0, "PM")) {
|
|||
if (give_acl ($config['id_user'], 0, "DM")) {
|
||||
$menu["gdbman"]["text"] = __('DB Maintenance');
|
||||
$menu["gdbman"]["sec2"] = "godmode/db/db_main";
|
||||
$menu["gdbman"]["refr"] = 0;
|
||||
$menu["gdbman"]["id"] = "god-dbmaint";
|
||||
|
||||
$sub = array ();
|
||||
$sub["godmode/db/db_info"]["text"] = __('DB Information');
|
||||
$sub["godmode/db/db_info"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/db/db_purge"]["text"] = __('Database purge');
|
||||
$sub["godmode/db/db_purge"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/db/db_refine"]["text"] = __('Database debug');
|
||||
$sub["godmode/db/db_refine"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/db/db_audit"]["text"] = __('Database audit');
|
||||
$sub["godmode/db/db_audit"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/db/db_event"]["text"] = __('Database event');
|
||||
$sub["godmode/db/db_event"]["refr"] = 0;
|
||||
|
||||
$sub["godmode/db/db_sanity"]["text"] = __('Database sanity');
|
||||
$sub["godmode/db/db_sanity"]["refr"] = 0;
|
||||
|
||||
$menu["gdbman"]["sub"] = $sub;
|
||||
}
|
||||
|
@ -201,7 +176,6 @@ if (give_acl ($config['id_user'], 0, "DM")) {
|
|||
if (is_array ($config['extensions'])) {
|
||||
$menu["gextensions"]["text"] = __('Extensions');
|
||||
$menu["gextensions"]["sec2"] = "godmode/extensions";
|
||||
$menu["gextensions"]["refr"] = 0;
|
||||
$menu["gextensions"]["id"] = "god-extensions";
|
||||
|
||||
$sub = array ();
|
||||
|
|
|
@ -80,13 +80,14 @@ echo __('General configuration')."</h2>";
|
|||
|
||||
$file_styles = list_files('include/styles/', "pandora", 1, 0);
|
||||
|
||||
$table->width = '500px';
|
||||
$table->width = '90%';
|
||||
$table->data = array ();
|
||||
$table->data[0][0] = __('Language Code for Pandora');
|
||||
$table->data[0][1] = print_select_from_sql ('SELECT id_language, name FROM tlanguage', 'language_code', $config["language"], '', '', '', true);
|
||||
|
||||
$table->data[1][0] = __('Date format string') . pandora_help("date_format", true);
|
||||
$table->data[1][1] = print_input_text ('date_format', $config["date_format"], '', 30, 100, true);
|
||||
$table->data[1][1] = '<em>'.__('Example').'</em> '.date ($config["date_format"]);
|
||||
$table->data[1][1] .= print_input_text ('date_format', $config["date_format"], '', 30, 100, true);
|
||||
|
||||
$table->data[2][0] = __('Remote config directory');
|
||||
$table->data[2][1] = print_input_text ('remote_config', $config["remote_config"], '', 30, 100, true);
|
||||
|
@ -150,7 +151,6 @@ echo '</form>';
|
|||
?>
|
||||
|
||||
<link rel="stylesheet" href="include/styles/color-picker.css" type="text/css" />
|
||||
<script type="text/javascript" src="include/javascript/jquery.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jquery.colorpicker.js"></script>
|
||||
<script language="javascript" type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
|
|
|
@ -286,10 +286,9 @@ function pagination ($count, $url, $offset, $pagination = 0, $return = false) {
|
|||
|
||||
/* URL passed render links with some parameter
|
||||
&offset - Offset records passed to next page
|
||||
&counter - Number of items to be blocked
|
||||
Pagination needs $url to build the base URL to render links, its a base url, like
|
||||
" http://pandora/index.php?sec=godmode&sec2=godmode/admin_access_logs "
|
||||
|
||||
&counter - Number of items to be blocked
|
||||
Pagination needs $url to build the base URL to render links, its a base url, like
|
||||
" http://pandora/index.php?sec=godmode&sec2=godmode/admin_access_logs "
|
||||
*/
|
||||
$block_limit = 15; // Visualize only $block_limit blocks
|
||||
if ($count <= $pagination) {
|
||||
|
|
|
@ -0,0 +1,639 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License (LGPL)
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
function clean_alert_command_values ($values, $set_empty = true) {
|
||||
$retvalues = array ();
|
||||
|
||||
if ($set_empty) {
|
||||
$retvalues['description'] = '';
|
||||
}
|
||||
|
||||
if (empty ($values))
|
||||
return $retvalues;
|
||||
|
||||
if (isset ($values['description']))
|
||||
$retvalues['description'] = (string) $values['description'];
|
||||
|
||||
return $retvalues;
|
||||
}
|
||||
|
||||
function create_alert_command ($name, $command, $values = false) {
|
||||
if (empty ($name))
|
||||
return false;
|
||||
if (empty ($command))
|
||||
return false;
|
||||
|
||||
$values = clean_alert_command_values ($values);
|
||||
|
||||
$sql = sprintf ('INSERT talert_commands (name, command, description)
|
||||
VALUES ("%s", "%s", "%s")',
|
||||
$name, $command, $values['description']);
|
||||
return process_sql ($sql, 'insert_id');
|
||||
}
|
||||
|
||||
function update_alert_command ($id_alert_command, $name, $command, $description = '') {
|
||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||
if (empty ($id_alert_command))
|
||||
return false;
|
||||
if (empty ($name))
|
||||
return false;
|
||||
if (empty ($command))
|
||||
return false;
|
||||
|
||||
$values = clean_alert_command_values ($values);
|
||||
|
||||
$sql = sprintf ('UPDATE talert_commands SET name = "%s", command = "%s",
|
||||
description = "%s" WHERE id = %d',
|
||||
$name, $command, $values['description'], $id_alert_command);
|
||||
return process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_command ($id_alert_command) {
|
||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||
if (empty ($id_alert_command))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('DELETE FROM talert_commands WHERE id = %d',
|
||||
$id_alert_command);
|
||||
return process_sql ($sql);
|
||||
}
|
||||
|
||||
function get_alert_command ($id_alert_command) {
|
||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||
if (empty ($id_alert_command))
|
||||
return false;
|
||||
|
||||
return get_db_row ('talert_commands', 'id', $id_alert_command);
|
||||
}
|
||||
|
||||
function get_alert_command_name ($id_alert_command) {
|
||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||
if (empty ($id_alert_command))
|
||||
return false;
|
||||
|
||||
return get_db_value ('name', 'talert_commands', 'id', $id_alert_command);
|
||||
}
|
||||
|
||||
function get_alert_command_command ($id_alert_command) {
|
||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||
if (empty ($id_alert_command))
|
||||
return false;
|
||||
|
||||
return get_db_value ('command', 'talert_commands', 'id', $id_alert_command);
|
||||
}
|
||||
|
||||
function get_alert_command_description ($id_alert_command) {
|
||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||
if (empty ($id_alert_command))
|
||||
return false;
|
||||
|
||||
return get_db_value ('description', 'talert_commands', 'id', $id_alert_command);
|
||||
}
|
||||
|
||||
function clean_alert_action_values ($values, $set_empty = true) {
|
||||
$retvalues = array ();
|
||||
|
||||
if ($set_empty) {
|
||||
$retvalues['field1'] = '';
|
||||
$retvalues['field2'] = '';
|
||||
$retvalues['field3'] = '';
|
||||
}
|
||||
|
||||
if (empty ($values))
|
||||
return $retvalues;
|
||||
|
||||
if (isset ($values['field1']))
|
||||
$retvalues['field1'] = (string) $values['field1'];
|
||||
if (isset ($values['field2']))
|
||||
$retvalues['field2'] = (string) $values['field2'];
|
||||
if (isset ($values['field3']))
|
||||
$retvalues['field3'] = (string) $values['field3'];
|
||||
|
||||
return $retvalues;
|
||||
}
|
||||
|
||||
function create_alert_action ($name, $id_alert_command, $values = false) {
|
||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||
if (empty ($id_alert_command))
|
||||
return false;
|
||||
if (empty ($name))
|
||||
return false;
|
||||
|
||||
$values = clean_alert_action_values ($values);
|
||||
|
||||
$sql = sprintf ('INSERT talert_actions (name, id_alert_command, field1, field2, field3)
|
||||
VALUES ("%s", %d, "%s", "%s", "%s")',
|
||||
$name, $id_alert_command, $values['field1'], $values['field2'],
|
||||
$values['field3']);
|
||||
|
||||
return process_sql ($sql, 'insert_id');
|
||||
}
|
||||
|
||||
function update_alert_action ($id_alert_action, $id_alert_command, $name, $values = false) {
|
||||
$id_alert_action = safe_int ($id_alert_action, 1);
|
||||
if (empty ($id_alert_action))
|
||||
return false;
|
||||
$id_alert_command = safe_int ($id_alert_command, 1);
|
||||
if (empty ($id_alert_command))
|
||||
return false;
|
||||
if (empty ($name))
|
||||
return false;
|
||||
|
||||
$values = clean_alert_action_values ($values);
|
||||
|
||||
$sql = sprintf ('UPDATE talert_actions SET name = "%s",
|
||||
id_alert_command = %d, field1 = "%s",
|
||||
field2 = "%s", field3 = "%s" WHERE id = %d',
|
||||
$name, $id_alert_command, $values['field1'], $values['field2'],
|
||||
$values['field3'], $id_alert_action);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_action ($id_alert_action) {
|
||||
$id_alert_action = safe_int ($id_alert_action, 1);
|
||||
if (empty ($id_alert_action))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('DELETE FROM talert_actions WHERE id = %d',
|
||||
$id_alert_action);
|
||||
return process_sql ($sql);
|
||||
}
|
||||
|
||||
function get_alert_actions ($only_names = true) {
|
||||
$all_actions = get_db_all_rows_in_table ('talert_actions');
|
||||
|
||||
if ($all_actions === false)
|
||||
return array ();
|
||||
|
||||
if (! $only_names)
|
||||
return $all_actions;
|
||||
|
||||
$actions = array ();
|
||||
foreach ($all_actions as $action) {
|
||||
$actions[$action['id']] = $action['name'];
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
function get_alert_action ($id_alert_action) {
|
||||
$id_alert_action = safe_int ($id_alert_action, 1);
|
||||
if (empty ($id_alert_action))
|
||||
return false;
|
||||
|
||||
return get_db_row ('talert_actions', 'id', $id_alert_action);
|
||||
}
|
||||
|
||||
function get_alert_action_alert_command_id ($id_alert_action) {
|
||||
return get_db_value ('id_alert_command', 'talert_actions', 'id', $id_alert_action);
|
||||
}
|
||||
|
||||
function get_alert_action_alert_command ($id_alert_action) {
|
||||
$id_command = get_alert_action_alert_command_id ($id_alert_action);
|
||||
return get_alert_command ($id_command);
|
||||
}
|
||||
|
||||
function get_alert_action_field1 ($id_alert_action) {
|
||||
return get_db_value ('field1', 'talert_actions', 'id', $id_alert_action);
|
||||
}
|
||||
|
||||
function get_alert_action_field2 ($id_alert_action) {
|
||||
return get_db_value ('field2', 'talert_actions', 'id', $id_alert_action);
|
||||
}
|
||||
|
||||
function get_alert_action_field3 ($id_alert_action) {
|
||||
return get_db_value ('field3', 'talert_actions', 'id', $id_alert_action);
|
||||
}
|
||||
|
||||
function get_alert_action_name ($id_alert_action) {
|
||||
return get_db_value ('name', 'talert_actions', 'id', $id_alert_action);
|
||||
}
|
||||
|
||||
function get_alert_templates_types () {
|
||||
$types = array ();
|
||||
|
||||
$types['regex'] = __('Regular expression');
|
||||
$types['max_min'] = __('Max and min');
|
||||
$types['max'] = __('Max');
|
||||
$types['min'] = __('Min');
|
||||
$types['equal'] = __('Equal to');
|
||||
$types['not_equal'] = __('Not equal to');
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
function get_alert_templates_type_name ($type) {
|
||||
$types = get_alert_templates_types ();
|
||||
if (! isset ($type[$type]))
|
||||
return __('Unknown');
|
||||
return $types[$type];
|
||||
}
|
||||
|
||||
function clean_alert_template_values ($values, $set_empty = true) {
|
||||
$retvalues = array ();
|
||||
|
||||
if ($set_empty) {
|
||||
$retvalues['type'] = 'equal';
|
||||
$retvalues['description'] = '';
|
||||
$retvalues['id_alert_action'] = NULL;
|
||||
$retvalues['field1'] = '';
|
||||
$retvalues['field2'] = '';
|
||||
$retvalues['field3'] = '';
|
||||
$retvalues['value'] = '';
|
||||
$retvalues['max_value'] = 0;
|
||||
$retvalues['min_value'] = 0;
|
||||
$retvalues['time_threshold'] = 0;
|
||||
$retvalues['max_alerts'] = 0;
|
||||
$retvalues['min_alerts'] = 0;
|
||||
$retvalues['monday'] = 0;
|
||||
$retvalues['tuesday'] = 0;
|
||||
$retvalues['wednesday'] = 0;
|
||||
$retvalues['thursday'] = 0;
|
||||
$retvalues['friday'] = 0;
|
||||
$retvalues['saturday'] = 0;
|
||||
$retvalues['sunday'] = 0;
|
||||
$retvalues['time_from'] = '00:00';
|
||||
$retvalues['time_to'] = '00:00';
|
||||
$retvalues['time_threshold'] = '300';
|
||||
$retvalues['recovery_notify'] = '';
|
||||
$retvalues['field2_recovery'] = '';
|
||||
$retvalues['field2_recovery'] = '';
|
||||
}
|
||||
|
||||
if (empty ($values))
|
||||
return $retvalues;
|
||||
|
||||
if (isset ($values['type']))
|
||||
$retvalues['type'] = (string) $values['type'];
|
||||
if (isset ($values['description']))
|
||||
$retvalues['description'] = (string) $values['description'];
|
||||
if (isset ($values['id_alert_action']))
|
||||
$retvalues['id_alert_action'] = (int) $values['id_alert_action'];
|
||||
if (isset ($values['field1']))
|
||||
$retvalues['field1'] = (string) $values['field1'];
|
||||
if (isset ($values['field2']))
|
||||
$retvalues['field2'] = (string) $values['field2'];
|
||||
if (isset ($values['field3']))
|
||||
$retvalues['field3'] = (string) $values['field3'];
|
||||
if (isset ($values['value']))
|
||||
$retvalues['value'] = (string) $values['value'];
|
||||
if (isset ($values['max_value']))
|
||||
$retvalues['max_value'] = (float) $values['max_value'];
|
||||
if (isset ($values['min_value']))
|
||||
$retvalues['min_value'] = (float) $values['min_value'];
|
||||
if (isset ($values['time_threshold']))
|
||||
$retvalues['time_threshold'] = (int) $values['time_threshold'];
|
||||
if (isset ($values['max_alerts']))
|
||||
$retvalues['max_alerts'] = (int) $values['max_alerts'];
|
||||
if (isset ($values['min_alerts']))
|
||||
$retvalues['min_alerts'] = (int) $values['min_alerts'];
|
||||
if (isset ($values['monday']))
|
||||
$retvalues['monday'] = (bool) $values['monday'];
|
||||
if (isset ($values['tuesday']))
|
||||
$retvalues['tuesday'] = (bool) $values['tuesday'];
|
||||
if (isset ($values['wednesday']))
|
||||
$retvalues['wednesday'] = (bool) $values['wednesday'];
|
||||
if (isset ($values['thursday']))
|
||||
$retvalues['thursday'] = (bool) $values['thursday'];
|
||||
if (isset ($values['friday']))
|
||||
$retvalues['friday'] = (bool) $values['friday'];
|
||||
if (isset ($values['saturday']))
|
||||
$retvalues['saturday'] = (bool) $values['saturday'];
|
||||
if (isset ($values['sunday']))
|
||||
$retvalues['sunday'] = (bool) $values['sunday'];
|
||||
if (isset ($values['time_from']))
|
||||
$retvalues['time_from'] = (string) $values['time_from'];
|
||||
if (isset ($values['time_to']))
|
||||
$retvalues['time_to'] = (string) $values['time_to'];
|
||||
if (isset ($values['time_threshold']))
|
||||
$retvalues['time_threshold'] = (int) $values['time_threshold'];
|
||||
if (isset ($values['recovery_notify']))
|
||||
$retvalues['recovery_notify'] = (bool) $values['recovery_notify'];
|
||||
if (isset ($values['field2_recovery']))
|
||||
$retvalues['field2_recovery'] = (string) $values['field2_recovery'];
|
||||
if (isset ($values['field3_recovery']))
|
||||
$retvalues['field3_recovery'] = (string) $values['field3_recovery'];
|
||||
|
||||
return $retvalues;
|
||||
}
|
||||
|
||||
function create_alert_template ($name, $type, $values = false) {
|
||||
if (empty ($name))
|
||||
return false;
|
||||
if (empty ($type))
|
||||
return false;
|
||||
|
||||
$values = clean_alert_template_values ($values);
|
||||
|
||||
switch ($type) {
|
||||
/* TODO: Check values based on type, return false if failure */
|
||||
}
|
||||
|
||||
$sql = sprintf ('INSERT talert_templates (name, type, description,
|
||||
field1, field2, field3, value, max_value, min_value,
|
||||
time_threshold, max_alerts, min_alerts)
|
||||
VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", %.2f,
|
||||
%.2f, %d, %d, %d)',
|
||||
$name, $type, $values['description'], $values['field1'],
|
||||
$values['field2'], $values['field3'], $values['value'],
|
||||
$values['max_value'], $values['min_value'],
|
||||
$values['time_threshold'], $values['max_alerts'],
|
||||
$values['min_alerts']);
|
||||
|
||||
return process_sql ($sql, 'insert_id');
|
||||
}
|
||||
|
||||
function update_alert_template ($id_alert_template, $values = false) {
|
||||
$id_alert_template = safe_int ($id_alert_template, 1);
|
||||
if (empty ($id_alert_template))
|
||||
return false;
|
||||
|
||||
$values = clean_alert_template_values ($values, false);
|
||||
|
||||
$sql = sprintf ('UPDATE talert_templates
|
||||
SET %s
|
||||
WHERE id = %d',
|
||||
format_array_to_update_sql ($values), $id_alert_template);
|
||||
echo $sql;
|
||||
return process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function delete_alert_template ($id_alert_template) {
|
||||
$id_alert_template = safe_int ($id_alert_template, 1);
|
||||
if (empty ($id_alert_template))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('DELETE FROM talert_templates WHERE id = %d',
|
||||
$id_alert_template);
|
||||
return process_sql ($sql);
|
||||
}
|
||||
|
||||
function get_alert_templates ($only_names = true) {
|
||||
$all_templates = get_db_all_rows_in_table ('talert_templates');
|
||||
|
||||
if ($all_templates === false)
|
||||
return array ();
|
||||
|
||||
if (! $only_names)
|
||||
return $all_templates;
|
||||
|
||||
$templates = array ();
|
||||
foreach ($all_templates as $template) {
|
||||
$templates[$template['id']] = $template['name'];
|
||||
}
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
function get_alert_template ($id_alert_template) {
|
||||
$id_alert_template = safe_int ($id_alert_template, 1);
|
||||
if (empty ($id_alert_template))
|
||||
return false;
|
||||
|
||||
return get_db_row ('talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_field1 ($id_alert_template) {
|
||||
return get_db_value ('field1', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_field2 ($id_alert_template) {
|
||||
return get_db_value ('field2', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_field3 ($id_alert_template) {
|
||||
return get_db_value ('field3', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_name ($id_alert_template) {
|
||||
return get_db_value ('name', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_description ($id_alert_template) {
|
||||
return get_db_value ('description', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_type ($id_alert_template) {
|
||||
return get_db_value ('type', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_type_name ($id_alert_template) {
|
||||
$type = get_alert_template_type ($id_alert_template);
|
||||
return get_alert_templates_type_name ($type);
|
||||
}
|
||||
|
||||
function get_alert_template_value ($id_alert_template) {
|
||||
return get_db_value ('value', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_max_value ($id_alert_template) {
|
||||
return get_db_value ('max_value', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_min_value ($id_alert_template) {
|
||||
return get_db_value ('min_value', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_alert_text ($id_alert_template) {
|
||||
return get_db_value ('alert_text', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_time_from ($id_alert_template) {
|
||||
return get_db_value ('time_from', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_time_to ($id_alert_template) {
|
||||
return get_db_value ('time_from', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_weekdays ($id_alert_template) {
|
||||
$alert = get_alert_template ($id_alert_template);
|
||||
if ($alert === false)
|
||||
return false;
|
||||
$retval = array ();
|
||||
$days = array ('monday', 'tuesday', 'wednesday', 'thursday', 'friday',
|
||||
'saturday', 'sunday');
|
||||
foreach ($days as $day)
|
||||
$retval[$day] = (bool) $alert[$day];
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function get_alert_template_recovery_notify ($id_alert_template) {
|
||||
return get_db_value ('recovery_notify', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_field2_recovery ($id_alert_template) {
|
||||
return get_db_value ('field2_recovery', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_field3_recovery ($id_alert_template) {
|
||||
return get_db_value ('field3_recovery', 'talert_templates', 'id', $id_alert_template);
|
||||
}
|
||||
|
||||
function get_alert_template_threshold_values () {
|
||||
$times = array ();
|
||||
|
||||
$times['300'] = '5 '.__('minutes');
|
||||
$times['600'] = '10 '.__('minutes');
|
||||
$times['900'] = '15 '.__('minutes');
|
||||
$times['1800'] = '30 '.__('minutes');
|
||||
$times['3600'] = '1 '.__('hour');
|
||||
$times['7200'] = '2 '.__('hours');
|
||||
$times['18000'] = '5 '.__('hours');
|
||||
$times['43200'] = '12 '.__('hours');
|
||||
$times['86400'] = '1 '.__('day');
|
||||
$times['604800'] = '1 '.__('week');
|
||||
$times['-1'] = __('Other value');
|
||||
|
||||
return $times;
|
||||
}
|
||||
|
||||
function clean_alert_agent_module_values ($values, $set_empty = true) {
|
||||
$retvalues = array ();
|
||||
|
||||
if ($set_empty) {
|
||||
$retvalues['internal_counter'] = 0;
|
||||
$retvalues['last_fired'] = 0;
|
||||
$retvalues['times_fired'] = 0;
|
||||
$retvalues['disabled'] = 0;
|
||||
$retvalues['priority'] = 0;
|
||||
$retvalues['force_execution'] = 0;
|
||||
}
|
||||
|
||||
if (empty ($values))
|
||||
return $retvalues;
|
||||
|
||||
if (isset ($values['internal_counter']))
|
||||
$retvalues['internal_counter'] = (int) $values['internal_counter'];
|
||||
if (isset ($values['last_fired']))
|
||||
$retvalues['last_fired'] = (int) $values['last_fired'];
|
||||
if (isset ($values['times_fired']))
|
||||
$retvalues['times_fired'] = (int) $values['times_fired'];
|
||||
if (isset ($values['disabled']))
|
||||
$retvalues['disabled'] = (int) $values['disabled'];
|
||||
if (isset ($values['priority']))
|
||||
$retvalues['priority'] = (int) $values['priority'];
|
||||
if (isset ($values['force_execution']))
|
||||
$retvalues['force_execution'] = (int) $values['force_execution'];
|
||||
|
||||
return $retvalues;
|
||||
}
|
||||
|
||||
function create_alert_agent_module ($id_agent_module, $id_alert_template, $values = false) {
|
||||
if (empty ($id_agent_module))
|
||||
return false;
|
||||
if (empty ($id_alert_template))
|
||||
return false;
|
||||
|
||||
$values = clean_alert_agent_module_values ($values);
|
||||
|
||||
$sql = sprintf ('INSERT talert_template_modules (id_agent_module,
|
||||
id_alert_template, internal_counter, last_fired, times_fired,
|
||||
disabled, priority, force_execution)
|
||||
VALUES (%d, %d, %d, %d, %d, %d, %d, %d)',
|
||||
$id_agent_module, $id_alert_template,
|
||||
$values['internal_counter'], $values['last_fired'],
|
||||
$values['times_fired'], $values['disabled'], $values['priority'],
|
||||
$values['force_execution']);
|
||||
|
||||
return process_sql ($sql, 'insert_id');
|
||||
}
|
||||
|
||||
function update_alert_agent_module ($id_alert_agent_module, $values = false) {
|
||||
if (empty ($id_agent_module))
|
||||
return false;
|
||||
|
||||
$values = clean_alert_agent_module_values ($values, false);
|
||||
if ($empty ($values))
|
||||
return true;
|
||||
|
||||
$sql = sprintf ('UPDATE talert_template_modules
|
||||
SET %s
|
||||
WHERE id = %d',
|
||||
format_array_to_update_sql ($values), $id_alert_agent_module);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function get_alert_agent_module ($id_alert_agent_module) {
|
||||
$id_alert_agent_module = safe_int ($id_alert_agent_module, 1);
|
||||
if (empty ($id_alert_agent_module))
|
||||
return false;
|
||||
|
||||
return get_db_row ('talert_template_modules', 'id', $id_alert_agent_module);
|
||||
}
|
||||
|
||||
function get_alerts_agent_module ($id_agent_module) {
|
||||
$sql = sprintf ('SELECT * FROM talert_template_modules
|
||||
WHERE id_agent_module = %d
|
||||
AND disabled = 0', $id_agent_module);
|
||||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
function add_alert_agent_module_action ($id_alert_agent_module, $id_alert_action, $options = false) {
|
||||
if (empty ($id_alert_agent_module))
|
||||
return false;
|
||||
if (empty ($id_alert_action))
|
||||
return false;
|
||||
|
||||
$fires_max = 0;
|
||||
$fires_min = 0;
|
||||
if ($options) {
|
||||
$max = 0;
|
||||
$min = 0;
|
||||
if (isset ($options['fires_max']))
|
||||
$max = (int) $options['fires_max'];
|
||||
if (isset ($options['fires_min']))
|
||||
$min = (int) $options['fires_min'];
|
||||
|
||||
$fires_max = max ($max, $min);
|
||||
$fires_min = min ($max, $min);
|
||||
}
|
||||
|
||||
$sql = sprintf ('INSERT INTO talert_template_module_actions
|
||||
VALUES (%d, %d, %d, %d)',
|
||||
$id_alert_agent_module, $id_alert_action, $fires_min, $fires_max);
|
||||
|
||||
return process_sql ($sql) !== false;
|
||||
}
|
||||
|
||||
function get_alert_agent_module_actions ($id_alert_agent_module) {
|
||||
if (empty ($id_alert_agent_module))
|
||||
return false;
|
||||
|
||||
$sql = sprintf ('SELECT id_alert_action id, fires_min, fires_max
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_template_module = %d',
|
||||
$id_alert_agent_module);
|
||||
$actions = get_db_all_rows_sql ($sql);
|
||||
if ($actions === false)
|
||||
return array ();
|
||||
|
||||
$retval = array ();
|
||||
foreach ($actions as $element) {
|
||||
$action = get_alert_action ($element['id']);
|
||||
$action['fires_min'] = $element['fires_min'];
|
||||
$action['fires_max'] = $element['fires_max'];
|
||||
array_push ($retval, $action);
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// ============================================
|
||||
// Copyright (c) 2008 Artica Soluciones Tecnologicas, http://www.artica.es
|
||||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License (LGPL)
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
/**
|
||||
* Get all the custom graphs a user can see.
|
||||
*
|
||||
* @param $id_user User id to check.
|
||||
* @param $only_names Wheter to return only graphs names in an associative array
|
||||
* or all the values.
|
||||
*
|
||||
* @return Custom graphs of a an user. Empty array if none.
|
||||
*/
|
||||
function get_user_custom_graphs ($id_user = 0, $only_names = false) {
|
||||
global $config;
|
||||
|
||||
if (!$id_user) {
|
||||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$all_graphs = get_db_all_rows_in_table ('tgraph', 'name');
|
||||
if ($all_graphs === false)
|
||||
return array ();
|
||||
|
||||
$graphs = array ();
|
||||
foreach ($all_graphs as $graph) {
|
||||
if ($graph["id_user"] != $id_user && $graph['private'])
|
||||
continue;
|
||||
|
||||
if ($only_names) {
|
||||
$graphs[$graph['id_graph']] = $graph['name'];
|
||||
} else {
|
||||
array_push ($graphs, $graph);
|
||||
}
|
||||
}
|
||||
|
||||
return $graphs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a custom graph image.
|
||||
*
|
||||
* @param $id_graph Graph id to print.
|
||||
* @param $height Height of the returning image.
|
||||
* @param $width Width of the returning image.
|
||||
* @param $period Period of time to get data in seconds.
|
||||
* @param $stacked Wheter the graph is stacked or not.
|
||||
* @param $return Whether to return an output string or echo now (optional, echo by default).
|
||||
*/
|
||||
function print_custom_graph ($id_graph, $height, $width, $period, $stacked, $return = false) {
|
||||
global $config;
|
||||
|
||||
$sources = get_db_all_rows_field_filter ('tgraph_source', 'id_graph', $id_graph);
|
||||
$modules = array ();
|
||||
$weights = array ();
|
||||
foreach ($sources as $source) {
|
||||
$sql = sprintf ("SELECT id_grupo
|
||||
FROM tagente, tagente_modulo
|
||||
WHERE tagente_modulo.id_agente_modulo = %d
|
||||
AND tagente.id_agente = tagente_modulo.id_agente",
|
||||
$source['id_agent_module']);
|
||||
$id_group = get_db_sql ($sql);
|
||||
if (! give_acl ($config["id_user"], $id_group, 'AR'))
|
||||
continue;
|
||||
array_push ($modules, $source['id_agent_module']);
|
||||
array_push ($weights, $source['weight']);
|
||||
}
|
||||
$modules = implode (',', $modules);
|
||||
$weights = implode (',', $weights);
|
||||
|
||||
$output = '<img src="reporting/fgraph.php?tipo=combined&height='.$height.'&width='.$width.'&id='.$modules.'&period='.$period.'&weight_l='.$weights.'&stacked='.$stacked.'">';
|
||||
|
||||
if ($return)
|
||||
return $output;
|
||||
echo $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the possible periods in a custom graph.
|
||||
*
|
||||
* @return The possible periods in a custom graph in an associative array.
|
||||
*/
|
||||
function get_custom_graph_periods () {
|
||||
$periods = array ();
|
||||
|
||||
$periods[1] = __('1 hour');
|
||||
$periods[2] = '2 '.__('hours');
|
||||
$periods[3] = '3 '.__('hours');
|
||||
$periods[6] = '6 '.__('hours');
|
||||
$periods[12] = '12 '.__('hours');
|
||||
$periods[24] = __('1 day');
|
||||
$periods[48] = __('2 days');
|
||||
$periods[360] = __('1 week');
|
||||
$periods[720] = __('1 month');
|
||||
$periods[4320] = __('6 months');
|
||||
|
||||
return $periods;
|
||||
}
|
||||
|
||||
?>
|
|
@ -246,10 +246,12 @@ function get_group_agents ($id_group = 0, $disabled = false, $case = "lower") {
|
|||
/**
|
||||
* Get all the modules in an agent. If an empty list is passed it will select all
|
||||
*
|
||||
* @param mixed $id_agent Agent id. If empty it selects all, array or int can be passed too
|
||||
* @param mixed $details Array, comma delimited list or singular value of rows to select. If nothing is specified, nombre will be selected
|
||||
* @param mixed Agent id to get modules. It can also be an array of agent id's.
|
||||
* @param mixed Array, comma delimited list or singular value of rows to
|
||||
* select. If nothing is specified, nombre will be selected.
|
||||
*
|
||||
* @return array An array with all modules in the agent. If multiple rows are selected, they will be in an array
|
||||
* @return array An array with all modules in the agent.
|
||||
* If multiple rows are selected, they will be in an array
|
||||
*/
|
||||
function get_agent_modules ($id_agent, $details = false) {
|
||||
$id_agent = safe_int ($id_agent, 1);
|
||||
|
@ -266,8 +268,13 @@ function get_agent_modules ($id_agent, $details = false) {
|
|||
$details = safe_input ($details);
|
||||
}
|
||||
|
||||
$sql = "SELECT id_agente_modulo,".implode (",", (array) $details)." FROM tagente_modulo".$filter." ORDER BY nombre";
|
||||
$result = get_db_all_rows_sql ($sql); //cast as array, that way a false will be converted into an array
|
||||
$sql = sprintf ('SELECT id_agente_modulo,%s
|
||||
FROM tagente_modulo
|
||||
%s
|
||||
ORDER BY nombre',
|
||||
implode (",", (array) $details),
|
||||
$filter);
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
|
||||
if (empty ($result)) {
|
||||
return array ();
|
||||
|
@ -276,9 +283,10 @@ function get_agent_modules ($id_agent, $details = false) {
|
|||
$modules = array ();
|
||||
foreach ($result as $row) {
|
||||
if (is_array ($details)) {
|
||||
$modules[$row["id_agente_modulo"]] = $row; //Just stack the information in array by ID
|
||||
//Just stack the information in array by ID
|
||||
$modules[$row['id_agente_modulo']] = $row;
|
||||
} else {
|
||||
$modules[$row["id_agente_modulo"]] = $row[$details];
|
||||
$modules[$row['id_agente_modulo']] = $row[$details];
|
||||
}
|
||||
}
|
||||
return $modules;
|
||||
|
@ -287,26 +295,33 @@ function get_agent_modules ($id_agent, $details = false) {
|
|||
/**
|
||||
* Get all the simple alerts of an agent.
|
||||
*
|
||||
* @param int $id_agent Agent id
|
||||
* @param string $filter Filter on "fired", "notfired" or "disabled"
|
||||
* @param int Agent id
|
||||
* @param string Filter on "fired", "notfired" or "disabled". Any other value
|
||||
* will not do any filter.
|
||||
*
|
||||
* @return array An array with all simple alerts defined for an agent.
|
||||
* @return array All simple alerts defined for an agent. Empty array if no
|
||||
* alerts found.
|
||||
*/
|
||||
function get_agent_alerts_simple ($id_agent, $filter = false) {
|
||||
switch ($filter) {
|
||||
case "notfired":
|
||||
$filter = ' AND times_fired = 0 AND disable = 0';
|
||||
break;
|
||||
case "fired":
|
||||
$filter = ' AND times_fired > 0 AND disable = 0';
|
||||
break;
|
||||
case "disabled":
|
||||
$filter = ' AND disable = 1';
|
||||
break;
|
||||
default:
|
||||
$filter = '';
|
||||
case "notfired":
|
||||
$filter = ' AND times_fired = 0 AND disable = 0';
|
||||
break;
|
||||
case "fired":
|
||||
$filter = ' AND times_fired > 0 AND disable = 0';
|
||||
break;
|
||||
case "disabled":
|
||||
$filter = ' AND disable = 1';
|
||||
break;
|
||||
default:
|
||||
$filter = '';
|
||||
}
|
||||
$sql = sprintf ("SELECT talerta_agente_modulo.* FROM talerta_agente_modulo, tagente_modulo WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente = %d%s", $id_agent, $filter);
|
||||
|
||||
$sql = sprintf ("SELECT talerta_agente_modulo.*
|
||||
FROM talerta_agente_modulo, tagente_modulo
|
||||
WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND tagente_modulo.id_agente = %d %s",
|
||||
$id_agent, $filter);
|
||||
$alerts = get_db_all_rows_sql ($sql);
|
||||
|
||||
if ($alerts === false)
|
||||
|
@ -363,7 +378,7 @@ function get_agent_alerts ($id_agent, $filter = false) {
|
|||
* A user can view a report by two ways:
|
||||
* - The user created the report (id_user field in treport)
|
||||
* - The report is not private and the user has reading privileges on
|
||||
* the group associated to the report
|
||||
* the group associated to the report
|
||||
*
|
||||
* @param string $id_user User id
|
||||
*
|
||||
|
@ -516,7 +531,8 @@ function get_agentmodule_agent ($id_agentmodule) {
|
|||
* @return string The name of the given agent module.
|
||||
*/
|
||||
function get_agentmodule_agent_name ($id_agentmodule) {
|
||||
return (string) get_agent_name (get_agentmodule_agent ($id_agentmodule)); //since this is a helper function we don't need to do casting
|
||||
// Since this is a helper function we don't need to do casting
|
||||
return (string) get_agent_name (get_agentmodule_agent ($id_agentmodule));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1132,7 +1148,7 @@ function show_icon_type ($id_type) {
|
|||
*
|
||||
* @return string Fully formatted IMG HTML tag with icon
|
||||
*/
|
||||
function show_server_type ($id){
|
||||
function show_server_type ($id) {
|
||||
global $config;
|
||||
switch ($id) {
|
||||
case 1:
|
||||
|
@ -1391,7 +1407,7 @@ function get_db_row ($table, $field_search, $condition) {
|
|||
}
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
|
||||
if($result === false)
|
||||
if ($result === false)
|
||||
return false;
|
||||
|
||||
return $result[0];
|
||||
|
@ -1454,9 +1470,9 @@ function sql_error_handler ($errno, $errstr) {
|
|||
* @param string $sql SQL statement to execute
|
||||
*
|
||||
* @param string $rettype (optional) What type of info to return in case of INSERT/UPDATE.
|
||||
* 'affected_rows' will return mysql_affected_rows (default value)
|
||||
* 'insert_id' will return the ID of an autoincrement value
|
||||
* 'info' will return the full (debug) information of a query
|
||||
* 'affected_rows' will return mysql_affected_rows (default value)
|
||||
* 'insert_id' will return the ID of an autoincrement value
|
||||
* 'info' will return the full (debug) information of a query
|
||||
*
|
||||
* @return mixed An array with the rows, columns and values in a multidimensional array or false in error
|
||||
*/
|
||||
|
@ -1530,7 +1546,7 @@ function get_db_all_rows_in_table ($table, $order_field = "") {
|
|||
* @return mixed A matrix with all the values in the table that matches the condition in the field or false
|
||||
*/
|
||||
function get_db_all_rows_field_filter ($table, $field, $condition, $order_field = "") {
|
||||
if (is_int ($condition)) {
|
||||
if (is_int ($condition) || is_bool ($condition)) {
|
||||
$sql = sprintf ("SELECT * FROM `%s` WHERE `%s` = %d", $table, $field, $condition);
|
||||
} else if (is_float ($condition) || is_double ($condition)) {
|
||||
$sql = sprintf ("SELECT * FROM `%s` WHERE `%s` = %f", $table, $field, $condition);
|
||||
|
@ -1563,6 +1579,53 @@ function get_db_all_fields_in_table ($table, $field = '', $condition = '', $orde
|
|||
return get_db_all_rows_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an array of values into a SQL string.
|
||||
*
|
||||
* This function is useful to generate an UPDATE SQL sentence from a list of
|
||||
* values. Example code:
|
||||
*
|
||||
* <code>
|
||||
* <?php
|
||||
* $values = array ();
|
||||
* $values['name'] = "Name";
|
||||
* $values['description'] = "Long description";
|
||||
* $sql = 'UPDATE table SET '.format_array_to_update_sql ($values).' WHERE id=1';
|
||||
* echo $sql;
|
||||
* ?>
|
||||
* </code>
|
||||
* Will return:
|
||||
* <code>
|
||||
* UPDATE table SET `name` = "Name", `description` = "Long description" WHERE id=1
|
||||
* </code>
|
||||
*
|
||||
* @param array Values to be formatted in an array indexed by the field name.
|
||||
*
|
||||
* @return string Values joined into an SQL string that can fits into an UPDATE
|
||||
* sentence.
|
||||
*/
|
||||
function format_array_to_update_sql ($values) {
|
||||
$fields = array ();
|
||||
|
||||
foreach ($values as $field => $value) {
|
||||
if (! is_string ($field))
|
||||
continue;
|
||||
|
||||
if ($value === NULL) {
|
||||
$sql = sprintf ("`%s` = NULL", $field);
|
||||
} elseif (is_int ($value) || is_bool ($value)) {
|
||||
$sql = sprintf ("`%s` = %d", $field, $value);
|
||||
} else if (is_float ($value) || is_double ($value)) {
|
||||
$sql = sprintf ("`%s` = %f", $field, $value);
|
||||
} else {
|
||||
$sql = sprintf ("`%s` = '%s'", $field, $value);
|
||||
}
|
||||
array_push ($fields, $sql);
|
||||
}
|
||||
|
||||
return implode (", ", $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status of an alert assigned to an agent module.
|
||||
*
|
||||
|
@ -1644,7 +1707,7 @@ function return_value_agent_module ($id_agentmodule) {
|
|||
* @return int The X axis coordinate value.
|
||||
*/
|
||||
function get_layoutdata_x ($id_layoutdata) {
|
||||
return (float) get_db_value ('pos_x', 'tlayout_data', 'id', $id_layoutdata);
|
||||
return (float) get_db_value ('pos_x', 'tlayout_data', 'id', (int) $id_layoutdata);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1655,7 +1718,7 @@ function get_layoutdata_x ($id_layoutdata) {
|
|||
* @return int The Y axis coordinate value.
|
||||
*/
|
||||
function get_layoutdata_y ($id_layoutdata){
|
||||
return (float) get_db_value ('pos_y', 'tlayout_data', 'id', $id_layoutdata);
|
||||
return (float) get_db_value ('pos_y', 'tlayout_data', 'id', (int) $id_layoutdata);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1671,7 +1734,10 @@ function get_layoutdata_y ($id_layoutdata){
|
|||
*
|
||||
* @return mixed The row of tagente_datos of the last period. False if there were no data.
|
||||
*/
|
||||
function get_previous_data ($id_agent_module, $utimestamp) {
|
||||
function get_previous_data ($id_agent_module, $utimestamp = 0) {
|
||||
if (empty ($utimestamp))
|
||||
$utimestamp = time ();
|
||||
|
||||
$interval = get_module_interval ($id_agent_module);
|
||||
$sql = sprintf ('SELECT * FROM tagente_datos
|
||||
WHERE id_agente_modulo = %d
|
||||
|
@ -1722,7 +1788,7 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) {
|
|||
* @param int $period Period of time to check (in seconds)
|
||||
* @param int $date Top date to check the values. Default current time.
|
||||
*
|
||||
* @return int The maximum module value in the interval.
|
||||
* @return float The maximum module value in the interval.
|
||||
*/
|
||||
function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
|
||||
if (! $date)
|
||||
|
@ -1737,20 +1803,20 @@ function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
|
|||
|
||||
/* Get also the previous report before the selected interval. */
|
||||
$previous_data = get_previous_data ($id_agent_module, $datelimit);
|
||||
if ($previous_data)
|
||||
if ($previous_data !== false)
|
||||
return max ($previous_data['datos'], $max);
|
||||
|
||||
return max ($previous_data, $max);
|
||||
return max ((float) $previous_data, $max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum value of an agent module in a period of time.
|
||||
*
|
||||
* @param int $id_agent_module Agent module id to get the minimum value.
|
||||
* @param int $period Period of time to check (in seconds)
|
||||
* @param int $date Top date to check the values. Default current time.
|
||||
* @param int Agent module id to get the minimum value.
|
||||
* @param int Period of time to check (in seconds)
|
||||
* @param int Top date to check the values in Unix time. Default current time.
|
||||
*
|
||||
* @return int The minimum module value of the module
|
||||
* @return float The minimum module value of the module
|
||||
*/
|
||||
function get_agentmodule_data_min ($id_agent_module, $period, $date = 0) {
|
||||
if (! $date)
|
||||
|
@ -1848,6 +1914,7 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
|
|||
|
||||
return (float) $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a translated string
|
||||
*
|
||||
|
@ -2005,25 +2072,23 @@ function show_alert_row_mini ($id_combined_alert) {
|
|||
* @deprecated use get_server_info instead
|
||||
* Get statistical information for a given server
|
||||
*
|
||||
* @param int $id_server
|
||||
*
|
||||
* @return array Serverinfo array
|
||||
*/
|
||||
* @param int Server id to get status
|
||||
* @return array Server info array
|
||||
*/
|
||||
function server_status ($id_server) {
|
||||
$serverinfo = get_server_info ($id_server);
|
||||
return $serverinfo[$id_server];
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will delete the agent from the database in a transaction
|
||||
* You can pass a variable or an array of ID's to be removed (int)
|
||||
* Delete an agent from the database.
|
||||
*
|
||||
* @param mixed $id_agents An array or variable with integeres of ID's to be erased
|
||||
* @param mixed An array of agents ids or a single integer id to be erased
|
||||
*
|
||||
* @return bool false in case of a problem, true in case of successful
|
||||
*/
|
||||
* @return bool False if error, true if success.
|
||||
*/
|
||||
function delete_agent ($id_agents) {
|
||||
//Init vars
|
||||
//Init vars
|
||||
$errors = 0;
|
||||
|
||||
//Subfunciton for less typing
|
||||
|
@ -2075,12 +2140,12 @@ function delete_agent ($id_agents) {
|
|||
// because it's a huge ammount of time. tagente_module has a special
|
||||
// field to mark for delete each module of agent deleted and in
|
||||
// daily maintance process, all data for that modules are deleted
|
||||
|
||||
//Alert
|
||||
|
||||
//Alert
|
||||
temp_sql_delete ("tcompound_alert", "id_aam", "ANY(SELECT id_aam FROM talerta_agente_modulo WHERE id_agent = ".$id_agent.")");
|
||||
temp_sql_delete ("talerta_agente_modulo", "id_agente_modulo", $tmodbase);
|
||||
temp_sql_delete ("talerta_agente_modulo", "id_agent", $id_agent);
|
||||
|
||||
|
||||
//Events (up/down monitors)
|
||||
temp_sql_delete ("tevento", "id_agente", $id_agent);
|
||||
|
||||
|
@ -2088,7 +2153,7 @@ function delete_agent ($id_agents) {
|
|||
temp_sql_delete ("tgraph_source", "id_agent_module", $tmodbase);
|
||||
temp_sql_delete ("tlayout_data", "id_agente_modulo", $tmodbase);
|
||||
temp_sql_delete ("treport_content", "id_agent_module", $tmodbase);
|
||||
|
||||
|
||||
//Planned Downtime
|
||||
temp_sql_delete ("tplanned_downtime_agents", "id_agent", $id_agent);
|
||||
|
||||
|
@ -2132,9 +2197,9 @@ function delete_agent ($id_agents) {
|
|||
/**
|
||||
* This function will get all the server information in an array or a specific server
|
||||
*
|
||||
* @param mixed $id_server An optional integer or array of integers to select specific servers
|
||||
* @param mixed An optional integer or array of integers to select specific servers
|
||||
*
|
||||
* @return bool false in case the server doesn't exist or an array with info
|
||||
* @return mixed False in case the server doesn't exist or an array with info.
|
||||
*/
|
||||
function get_server_info ($id_server = -1) {
|
||||
if (is_array ($id_server)) {
|
||||
|
@ -2173,30 +2238,30 @@ function get_server_info ($id_server = -1) {
|
|||
}
|
||||
|
||||
$server["modules"] = get_db_sql ("SELECT COUNT(*) FROM tagente_estado, tagente_modulo
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_estado.running_by = ".$server["id_server"]);
|
||||
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_estado.running_by = ".$server["id_server"]);
|
||||
|
||||
$server["module_lag"] = get_db_sql ("SELECT COUNT(*) FROM tagente_estado, tagente_modulo, tagente
|
||||
WHERE tagente_estado.last_execution_try > 0
|
||||
AND tagente_estado.running_by = ".$server["id_server"]."
|
||||
AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente.disabled = 0
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
|
||||
WHERE tagente_estado.last_execution_try > 0
|
||||
AND tagente_estado.running_by = ".$server["id_server"]."
|
||||
AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente.disabled = 0
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
|
||||
|
||||
// Lag over 1200 seconds is not lag, is module without contacting data in several time.or with a
|
||||
// 1200 sec is 20 min
|
||||
$server["lag"] = get_db_sql ("SELECT MAX(tagente_estado.last_execution_try - tagente_estado.current_interval)
|
||||
FROM tagente_estado, tagente_modulo, tagente
|
||||
WHERE tagente_estado.last_execution_try > 0
|
||||
AND tagente_estado.running_by = ".$server["id_server"]."
|
||||
AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente.disabled = 0
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
|
||||
FROM tagente_estado, tagente_modulo, tagente
|
||||
WHERE tagente_estado.last_execution_try > 0
|
||||
AND tagente_estado.running_by = ".$server["id_server"]."
|
||||
AND tagente_modulo.id_agente = tagente.id_agente
|
||||
AND tagente.disabled = 0
|
||||
AND tagente_modulo.disabled = 0
|
||||
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND (UNIX_TIMESTAMP() - tagente_estado.last_execution_try - tagente_estado.current_interval < 1200)");
|
||||
|
||||
if (empty ($server["lag"])) {
|
||||
$server["lag"] = 0;
|
||||
|
@ -2211,15 +2276,16 @@ function get_server_info ($id_server = -1) {
|
|||
}
|
||||
|
||||
/**
|
||||
* This function will return the number of all agent modules in the database
|
||||
* Get the number of all agent modules in the database
|
||||
*
|
||||
* @param mixed $id_agent array of or just integers with agent(s). Leave empty to select everything
|
||||
* @param mixed Array of integers with agent(s) id or a single agent id. Default
|
||||
* value will select all.
|
||||
*
|
||||
* @return int The number of agent modules
|
||||
*
|
||||
*/
|
||||
*/
|
||||
function get_agent_modules_count ($id_agent = 0) {
|
||||
$id_agent = safe_int ($id_agent, 1); //Make sure we're all int's and filter out bad stuff
|
||||
//Make sure we're all int's and filter out bad stuff
|
||||
$id_agent = safe_int ($id_agent, 1);
|
||||
|
||||
if (empty ($id_agent)) {
|
||||
//If the array proved empty or the agent is less than 1 (eg. -1)
|
||||
|
@ -2234,7 +2300,7 @@ function get_agent_modules_count ($id_agent = 0) {
|
|||
/**
|
||||
* This function gets the agent group for a given agent module
|
||||
*
|
||||
* @param int $id_module: The agent module id
|
||||
* @param int The agent module id
|
||||
*
|
||||
* @return int The group id
|
||||
*/
|
||||
|
@ -2246,7 +2312,7 @@ function get_agentmodule_group ($id_module) {
|
|||
/**
|
||||
* This function gets the group for a given agent
|
||||
*
|
||||
* @param int $id_agent: The agent id
|
||||
* @param int The agent id
|
||||
*
|
||||
* @return int The group id
|
||||
*/
|
||||
|
@ -2257,7 +2323,7 @@ function get_agent_group ($id_agent) {
|
|||
/**
|
||||
* This function gets the group name for a given group id
|
||||
*
|
||||
* @param int $id_group: The group id
|
||||
* @param int The group id
|
||||
*
|
||||
* @return string The group name
|
||||
*/
|
||||
|
@ -2265,12 +2331,14 @@ function get_group_name ($id_group) {
|
|||
return (string) get_db_value ('nombre', 'tgrupo', 'id_grupo', (int) $id_group);
|
||||
}
|
||||
/**
|
||||
* Validates an alert id or an array of alert id's
|
||||
*
|
||||
* Validates an alert id or an array of alert id's
|
||||
*
|
||||
* @param mixed $alert_id Array of or a single id
|
||||
* @param mixed Array of alerts ids or single id
|
||||
*
|
||||
* @return bool True if it was successful, false if it doesn't
|
||||
*/
|
||||
* @return bool True if it was successful, false otherwise.
|
||||
*/
|
||||
function process_alerts_validate ($id_alert) {
|
||||
global $config;
|
||||
require_once ("include/functions_events.php");
|
||||
|
@ -2312,7 +2380,9 @@ function process_alerts_validate ($id_alert) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets all module groups. (General, Networking, System). Module groups are merely for sorting frontend
|
||||
* Gets all module groups. (General, Networking, System).
|
||||
*
|
||||
* Module groups are merely for sorting frontend
|
||||
*
|
||||
* @return array All module groups
|
||||
*/
|
||||
|
@ -2334,7 +2404,7 @@ function get_modulegroups () {
|
|||
/**
|
||||
* Gets a modulegroup name based on the id
|
||||
*
|
||||
* @param int $modulegroup_id The id of the modulegroup
|
||||
* @param int The id of the modulegroup
|
||||
*
|
||||
* @return string The modulegroup name
|
||||
*/
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// modify it under the terms of the GNU Lesser General Public License (LGPL)
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
|
@ -26,7 +27,8 @@
|
|||
function delete_event ($id_event) {
|
||||
global $config;
|
||||
|
||||
$id_event = (array) safe_int ($id_event, 1); //Cleans up the selection for all unwanted values also casts any single values as an array
|
||||
//Cleans up the selection for all unwanted values also casts any single values as an array
|
||||
$id_event = (array) safe_int ($id_event, 1);
|
||||
|
||||
process_sql ("SET AUTOCOMMIT = 0;");
|
||||
process_sql ("START TRANSACTION;");
|
||||
|
@ -71,7 +73,8 @@ function delete_event ($id_event) {
|
|||
function process_event_validate ($id_event) {
|
||||
global $config;
|
||||
|
||||
$id_event = (array) safe_int ($id_event, 1); //Cleans up the selection for all unwanted values also casts any single values as an array
|
||||
//Cleans up the selection for all unwanted values also casts any single values as an array
|
||||
$id_event = (array) safe_int ($id_event, 1);
|
||||
|
||||
process_sql ("SET AUTOCOMMIT = 0;");
|
||||
process_sql ("START TRANSACTION;");
|
||||
|
@ -145,11 +148,11 @@ function get_event_description ($id_event) {
|
|||
*/
|
||||
function create_event ($event, $id_group, $id_agent, $status = 0, $id_user = "", $event_type = "unknown", $priority = 0, $id_agent_module = 0, $id_aam = 0) {
|
||||
$sql = sprintf ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp,
|
||||
estado, utimestamp, id_usuario, event_type, criticity,
|
||||
id_agentmodule, id_alert_am)
|
||||
VALUES (%d, %d, "%s", NOW(), %d, NOW(), "%s", "%s", %d, %d, %d)',
|
||||
$id_agent, $id_group, $event, $status, $id_user, $event_type,
|
||||
$priority, $id_agent_module, $id_aam);
|
||||
estado, utimestamp, id_usuario, event_type, criticity,
|
||||
id_agentmodule, id_alert_am)
|
||||
VALUES (%d, %d, "%s", NOW(), %d, NOW(), "%s", "%s", %d, %d, %d)',
|
||||
$id_agent, $id_group, $event, $status, $id_user, $event_type,
|
||||
$priority, $id_agent_module, $id_aam);
|
||||
|
||||
return (int) process_sql ($sql, "insert_id");
|
||||
}
|
||||
|
@ -286,4 +289,4 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return =
|
|||
return $return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -23,16 +23,16 @@
|
|||
*
|
||||
* Based on choose_from_menu() from Moodle
|
||||
*
|
||||
* @param array $fields Array with dropdown values. Example: $fields["value"] = "label"
|
||||
* @param string $name Select form name
|
||||
* @param variant $selected Current selected value. Can be a single value or an
|
||||
* @param array Array with dropdown values. Example: $fields["value"] = "label"
|
||||
* @param string Select form name
|
||||
* @param variant Current selected value. Can be a single value or an
|
||||
* array of selected values (in combination with multiple)
|
||||
* @param string $script Javascript onChange code.
|
||||
* @param string $nothing Label when nothing is selected.
|
||||
* @param variant $nothing_value Value when nothing is selected
|
||||
* @param bool $return Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param bool $multiple Set the input to allow multiple selections (optional, single selection by default).
|
||||
* @param bool $sort Whether to sort the options or not (optional, unsorted by default).
|
||||
* @param string Javascript onChange code.
|
||||
* @param string Label when nothing is selected.
|
||||
* @param variant Value when nothing is selected
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param bool Set the input to allow multiple selections (optional, single selection by default).
|
||||
* @param bool Whether to sort the options or not (optional, unsorted by default).
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
@ -60,7 +60,8 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
|
|||
if ($nothing_value == $selected) {
|
||||
$output .= " selected";
|
||||
}
|
||||
$output .= '>'.$nothing."</option>"; //You should pass a translated string already
|
||||
//You should pass a translated string already
|
||||
$output .= '>'.$nothing."</option>";
|
||||
}
|
||||
|
||||
if (!empty ($fields)) {
|
||||
|
@ -343,7 +344,7 @@ function print_textarea ($name, $rows, $columns, $value = '', $attributes = '',
|
|||
/**
|
||||
* Print a nicely formatted table. Code taken from moodle.
|
||||
*
|
||||
* @param object $table is an object with several properties:
|
||||
* @param object Object with several properties:
|
||||
* $table->head - An array of heading names.
|
||||
* $table->align - An array of column alignments
|
||||
* $table->valign - An array of column alignments
|
||||
|
@ -365,7 +366,7 @@ function print_textarea ($name, $rows, $columns, $value = '', $attributes = '',
|
|||
* $table->title - Title of the table is a single string that will be on top of the table in the head spanning the whole table
|
||||
* $table->titlestyle - Title style
|
||||
* $table->titleclass - Title class
|
||||
* @param bool $return whether to return an output string or echo now
|
||||
* @param bool Whether to return an output string or echo now
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
@ -544,14 +545,14 @@ function print_table (&$table, $return = false) {
|
|||
/**
|
||||
* Render a radio button input. Extended version, use print_radio_button() to simplify.
|
||||
*
|
||||
* @param string $name Input name.
|
||||
* @param string $value Input value.
|
||||
* @param string $checked Set the button to be marked (optional, unmarked by default).
|
||||
* @param bool $disabled Disable the button (optional, button enabled by default).
|
||||
* @param string $script Script to execute when onClick event is triggered (optional).
|
||||
* @param string $attributes Optional HTML attributes. It's a free string which will be
|
||||
* @param string Input name.
|
||||
* @param string Input value.
|
||||
* @param string Set the button to be marked (optional, unmarked by default).
|
||||
* @param bool Disable the button (optional, button enabled by default).
|
||||
* @param string Script to execute when onClick event is triggered (optional).
|
||||
* @param string Optional HTML attributes. It's a free string which will be
|
||||
inserted into the HTML tag, use it carefully (optional).
|
||||
* @param bool $return Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
@ -589,11 +590,11 @@ function print_radio_button_extended ($name, $value, $label, $checkedvalue, $dis
|
|||
/**
|
||||
* Render a radio button input.
|
||||
*
|
||||
* @param string $name Input name.
|
||||
* @param string $value Input value.
|
||||
* @param string $label Label to add after the radio button (optional).
|
||||
* @param string $checkedvalue Checked and selected value, the button will be selected if it matches $value (optional).
|
||||
* @param bool $return Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param string Input name.
|
||||
* @param string Input value.
|
||||
* @param string Label to add after the radio button (optional).
|
||||
* @param string Checked and selected value, the button will be selected if it matches $value (optional).
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
@ -609,14 +610,14 @@ function print_radio_button ($name, $value, $label = '', $checkedvalue = '', $re
|
|||
/**
|
||||
* Render a checkbox button input. Extended version, use print_checkbox() to simplify.
|
||||
*
|
||||
* @param string $name Input name.
|
||||
* @param string $value Input value.
|
||||
* @param string $checked Set the button to be marked (optional, unmarked by default).
|
||||
* @param bool $disabled Disable the button (optional, button enabled by default).
|
||||
* @param string $script Script to execute when onClick event is triggered (optional).
|
||||
* @param string $attributes Optional HTML attributes. It's a free string which will be
|
||||
* @param string Input name.
|
||||
* @param string Input value.
|
||||
* @param string Set the button to be marked (optional, unmarked by default).
|
||||
* @param bool Disable the button (optional, button enabled by default).
|
||||
* @param string Script to execute when onClick event is triggered (optional).
|
||||
* @param string Optional HTML attributes. It's a free string which will be
|
||||
inserted into the HTML tag, use it carefully (optional).
|
||||
* @param bool $return Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
@ -642,10 +643,10 @@ function print_checkbox_extended ($name, $value, $checked, $disabled, $script, $
|
|||
/**
|
||||
* Render a checkbox button input.
|
||||
*
|
||||
* @param string $name Input name.
|
||||
* @param string $value Input value.
|
||||
* @param string $checked Set the button to be marked (optional, unmarked by default).
|
||||
* @param bool $return Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param string Input name.
|
||||
* @param string Input value.
|
||||
* @param string Set the button to be marked (optional, unmarked by default).
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
@ -660,8 +661,8 @@ function print_checkbox ($name, $value, $checked = false, $return = false) {
|
|||
/**
|
||||
* Prints only a tip button which shows a text when the user puts the mouse over it.
|
||||
*
|
||||
* @param string $text Complete text to show in the tip
|
||||
* @param bool $return whether to return an output string or echo now
|
||||
* @param string Complete text to show in the tip
|
||||
* @param bool whether to return an output string or echo now
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
@ -716,4 +717,72 @@ function print_image ($src, $return = false, $options = false) {
|
|||
return $output;
|
||||
echo $output;
|
||||
}
|
||||
?>
|
||||
|
||||
/**
|
||||
* Render an input text element. Extended version, use print_input_text() to simplify.
|
||||
*
|
||||
* @param string Input name.
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param array An array with optional HTML parameters.
|
||||
* Key size: HTML size attribute.
|
||||
* Key disabled: Whether to disable the input or not.
|
||||
* Key class: HTML class
|
||||
*/
|
||||
function print_input_file ($name, $return = false, $options = false) {
|
||||
$output = '';
|
||||
|
||||
$output .= '<input type="file" value="" name="'.$name.'" id="file-'.$name.'" ';
|
||||
|
||||
if ($options) {
|
||||
if (isset ($options['size']))
|
||||
$output .= 'size="'.$options['size'].'"';
|
||||
|
||||
if (isset ($options['disabled']))
|
||||
$output .= 'disabled="disabled"';
|
||||
|
||||
if (isset ($options['class']))
|
||||
$output .= 'class="'.$options['class'].'"';
|
||||
}
|
||||
|
||||
$output .= ' />';
|
||||
|
||||
if ($return)
|
||||
return $output;
|
||||
echo $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a label for a input elemennt.
|
||||
*
|
||||
* @param string Label text.
|
||||
* @param string Input id to refer.
|
||||
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||
* @param array An array with optional HTML parameters.
|
||||
* Key html: Extra HTML to add after the label.
|
||||
* Key class: HTML class
|
||||
*/
|
||||
function print_label ($text, $id, $return = false, $options = false) {
|
||||
$output = '';
|
||||
|
||||
$output .= '<label id="label-'.$id.'" ';
|
||||
|
||||
if ($options) {
|
||||
if (isset ($options['class']))
|
||||
$output .= 'class="'.$options['class'].'" ';
|
||||
}
|
||||
|
||||
$output .= 'for="'.$id.'" >';
|
||||
$output .= $text;
|
||||
$output .= '</label>';
|
||||
|
||||
if ($options) {
|
||||
if (isset ($options['html']))
|
||||
$output .= $options['html'];
|
||||
}
|
||||
|
||||
if ($return)
|
||||
return $output;
|
||||
|
||||
echo $output;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
// Please see http://pandora.sourceforge.net for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// modify it under the terms of the GNU Lesser General Public License (LGPL)
|
||||
// as published by the Free Software Foundation for version 2.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
|
@ -41,24 +42,24 @@ function get_incidents_priorities () {
|
|||
*/
|
||||
function print_incidents_priority_img ($id_priority, $return = false) {
|
||||
switch ($id_priority) {
|
||||
case 0:
|
||||
$img = '<img src="images/dot_green.png" /><img src="images/dot_green.png" /><img src="images/dot_yellow.png" />';
|
||||
break;
|
||||
case 1:
|
||||
$img = '<img src="images/dot_green.png" /><img src="images/dot_yellow.png" /><img src="images/dot_yellow.png" />';
|
||||
break;
|
||||
case 2:
|
||||
$img = '<img src="images/dot_yellow.png" /><img src="images/dot_yellow.png" /><img src="images/dot_red.png" />';
|
||||
break;
|
||||
case 3:
|
||||
$img = '<img src="images/dot_yellow.png" /><img src="images/dot_red.png" /><img src="images/dot_red.png" />';
|
||||
break;
|
||||
case 4:
|
||||
$img = '<img src="images/dot_red.png" /><img src="images/dot_red.png" /><img src="images/dot_red.png" />';
|
||||
break;
|
||||
case 10:
|
||||
$img = '<img src="images/dot_green.png" /><img src="images/dot_green.png" /><img src="images/dot_green.png" />';
|
||||
break;
|
||||
case 0:
|
||||
$img = '<img src="images/dot_green.png" /><img src="images/dot_green.png" /><img src="images/dot_yellow.png" />';
|
||||
break;
|
||||
case 1:
|
||||
$img = '<img src="images/dot_green.png" /><img src="images/dot_yellow.png" /><img src="images/dot_yellow.png" />';
|
||||
break;
|
||||
case 2:
|
||||
$img = '<img src="images/dot_yellow.png" /><img src="images/dot_yellow.png" /><img src="images/dot_red.png" />';
|
||||
break;
|
||||
case 3:
|
||||
$img = '<img src="images/dot_yellow.png" /><img src="images/dot_red.png" /><img src="images/dot_red.png" />';
|
||||
break;
|
||||
case 4:
|
||||
$img = '<img src="images/dot_red.png" /><img src="images/dot_red.png" /><img src="images/dot_red.png" />';
|
||||
break;
|
||||
case 10:
|
||||
$img = '<img src="images/dot_green.png" /><img src="images/dot_green.png" /><img src="images/dot_green.png" />';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($return === false) {
|
||||
|
@ -442,4 +443,4 @@ $result = get_db_sql ($sql);
|
|||
if (!empty ($result)) {
|
||||
upgrade_inc13to21 ();
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -59,9 +59,9 @@ function print_error_message ($result, $good = '', $bad = '', $attributes = '',
|
|||
* @param int $unixtime: Any type of timestamp really, but we prefer unixtime
|
||||
* @param bool $return whether to output the string or return it
|
||||
* @param array $option: An array with different options for this function
|
||||
* Key html_attr: which html attributes to add (defaults to none)
|
||||
* Key tag: Which html tag to use (defaults to span)
|
||||
* Key prominent: Overrides user preference and display "comparation" or "timestamp"
|
||||
* Key html_attr: which html attributes to add (defaults to none)
|
||||
* Key tag: Which html tag to use (defaults to span)
|
||||
* Key prominent: Overrides user preference and display "comparation" or "timestamp"
|
||||
*
|
||||
* @return string HTML code if return parameter is true.
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/*
|
||||
// Pandora FMS - the Flexible Monitoring System
|
||||
// =============================================
|
||||
|
||||
// Copyright (c) 2004-2008 Sancho Lerena, slerena@gmail.comnt
|
||||
// Copyright (c) 2004-2008 Raul Mateos Martin, raulofpandora@gmail.com
|
||||
// Copyright (c) 2005-2008 Artica Soluciones Tecnologicas, info@artica.es
|
||||
|
@ -17,7 +16,6 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
@import url(menu.css);
|
||||
@import url(tip.css);
|
||||
* {
|
||||
|
@ -33,6 +31,7 @@ input, textarea {
|
|||
textarea {
|
||||
padding: 5px;
|
||||
height: 100px;
|
||||
width: 100%;
|
||||
}
|
||||
textarea.conf_editor {
|
||||
padding: 5px;
|
||||
|
@ -96,13 +95,11 @@ a.white_bold {
|
|||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a.white_grey_bold {
|
||||
color: #999;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a.white {
|
||||
color: #eee;
|
||||
text-decoration: none;
|
||||
|
@ -187,7 +184,7 @@ div#main {
|
|||
padding-bottom: 20px;
|
||||
margin-bottom: 25px;
|
||||
background-color: #fefefe;
|
||||
background-image: url(../../images/backgrounds/background4.jpg);
|
||||
background-image: url(../../images/backgrounds/background4.jpg);
|
||||
margin-top: 0px;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
|
@ -222,8 +219,8 @@ div#foot {
|
|||
}
|
||||
label {
|
||||
display: block;
|
||||
float: left;
|
||||
padding-top: 4px;
|
||||
font-weight: bold;
|
||||
}
|
||||
th > label {
|
||||
padding-top: 7px;
|
||||
|
@ -253,35 +250,35 @@ input.sub {
|
|||
border-right-color: #708090;
|
||||
-moz-border-radius: 5%;
|
||||
font-size: 8pt;
|
||||
background-color: #e5e5e5;
|
||||
}
|
||||
input.next, input.upd, input.ok, input.wand, input.delete, input.search, input.copy {
|
||||
padding-right: 21px;
|
||||
}
|
||||
input.next {
|
||||
padding-right: 21px;
|
||||
background: #e5e5e5 url(../../images/go.png) no-repeat right 2px;
|
||||
}
|
||||
input.upd {
|
||||
padding-right: 21px;
|
||||
background: #e5e5e5 url(../../images/upd.png) no-repeat right 3px;
|
||||
}
|
||||
input.wand {
|
||||
padding-right: 21px;
|
||||
background: #e5e5e5 url(../../images/wand.png) no-repeat right 3px;
|
||||
}
|
||||
input.delete {
|
||||
padding-right: 21px;
|
||||
background: #e5e5e5 url(../../images/cross.png) no-repeat right 3px;
|
||||
}
|
||||
input.search {
|
||||
padding-right: 21px;
|
||||
background: #e5e5e5 url(../../images/zoom.png) no-repeat right 3px;
|
||||
}
|
||||
input.copy {
|
||||
padding-right: 21px;
|
||||
background: #e5e5e5 url(../../images/copy.png) no-repeat right 3px;
|
||||
}
|
||||
input.ok {
|
||||
padding-right: 21px;
|
||||
background: #e5e5e5 url(../../images/ok.png) no-repeat right 3px;
|
||||
}
|
||||
input.ok {
|
||||
background: #e5e5e5 url(../../images/add.png) no-repeat right 3px;
|
||||
}
|
||||
table, img {
|
||||
border: 0px;
|
||||
}
|
||||
|
@ -289,10 +286,13 @@ th {
|
|||
color: #fff;
|
||||
background-color: #786;
|
||||
}
|
||||
td.datos, td.datost, td.datosb , td.datos_id, td.datosf9 {
|
||||
tr.datos, tr.datost, tr.datosb , tr.datos_id, tr.datosf9,
|
||||
tr.datos2, tr.datos2t, tr.datos2b, tr.datos2_id , tr.datos2f9, {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
td.datos2, td.datos2t, td.datos2b, td.datos2_id , td.datos2f9 {
|
||||
tr.datos:hover, tr.datost:hover, tr.datosb:hover, tr.datos_id:hover,
|
||||
tr.datosf9:hover, tr.datos2:hover, tr.datos2t:hover,
|
||||
tr.datos2b:hover, tr.datos2_id:hover, tr.datos2f9:hover {
|
||||
background-color: #efefef;
|
||||
}
|
||||
td.datos3 {
|
||||
|
@ -433,22 +433,22 @@ div.title_line {
|
|||
width: 762px;
|
||||
}
|
||||
#menu_tab_frame {
|
||||
background: #D84437;
|
||||
width: 805px;
|
||||
min-height: 22px;
|
||||
padding-left: 0px;
|
||||
margin-left: -25px;
|
||||
float:left;
|
||||
border-bottom: 1px solid #778866;
|
||||
background: #D84437;
|
||||
width: 805px;
|
||||
min-height: 22px;
|
||||
padding-left: 0px;
|
||||
margin-left: -25px;
|
||||
float:left;
|
||||
border-bottom: 1px solid #778866;
|
||||
}
|
||||
#menu_tab_frame_view {
|
||||
background: #66AA44;
|
||||
width: 805px;
|
||||
min-height: 22px;
|
||||
padding-left: 0px;
|
||||
margin-left: -25px;
|
||||
float:left;
|
||||
border-bottom: 1px solid #778866;
|
||||
background: #66AA44;
|
||||
width: 805px;
|
||||
min-height: 22px;
|
||||
padding-left: 0px;
|
||||
margin-left: -25px;
|
||||
float:left;
|
||||
border-bottom: 1px solid #778866;
|
||||
}
|
||||
#menu_tab .mn, #menu_tab ul, #menu_tab .mn ul {
|
||||
padding: 0px;
|
||||
|
@ -468,12 +468,12 @@ div.title_line {
|
|||
line-height: 18px;
|
||||
}
|
||||
#menu_tab li.nomn_high a {
|
||||
background: #799E48;
|
||||
color: #fff;
|
||||
padding: 2px 10px 2px 10px;
|
||||
border-left: 2px solid #778866;
|
||||
font-weight: bold;
|
||||
line-height: 18px;
|
||||
background: #799E48;
|
||||
color: #fff;
|
||||
padding: 2px 10px 2px 10px;
|
||||
border-left: 2px solid #778866;
|
||||
font-weight: bold;
|
||||
line-height: 18px;
|
||||
}
|
||||
#menu_tab .mn li a {
|
||||
display: block;
|
||||
|
@ -481,7 +481,7 @@ div.title_line {
|
|||
}
|
||||
#menu_tab li.nomn:hover a, #menu_tab li:hover ul a:hover {
|
||||
background: #799E48;
|
||||
color: #fff;
|
||||
color: #fff;
|
||||
}
|
||||
#menu_tab li:hover a {
|
||||
background: #b2b08a url("../images/arrow.png") no-repeat right 3px;
|
||||
|
@ -540,16 +540,16 @@ span.master {
|
|||
background: url(../../images/master.png) no-repeat;
|
||||
}
|
||||
span.wmi {
|
||||
background: url(../../images/wmi.png) no-repeat;
|
||||
background: url(../../images/wmi.png) no-repeat;
|
||||
}
|
||||
span.prediction {
|
||||
background: url(../../images/chart_bar.png) no-repeat;
|
||||
background: url(../../images/chart_bar.png) no-repeat;
|
||||
}
|
||||
span.plugin {
|
||||
background: url(../../images/plugin.png) no-repeat;
|
||||
background: url(../../images/plugin.png) no-repeat;
|
||||
}
|
||||
span.export {
|
||||
background: url(../../images/database_refresh.png) no-repeat;
|
||||
background: url(../../images/database_refresh.png) no-repeat;
|
||||
}
|
||||
span.snmp {
|
||||
background: url(../../images/snmp.png) no-repeat;
|
||||
|
@ -566,11 +566,9 @@ span.rmess {
|
|||
span.nrmess {
|
||||
background: url(../../images/email.png) no-repeat;
|
||||
}
|
||||
|
||||
/* This kind of span do not have any sense, should be replaced on PHP code
|
||||
by a real img in code. They are not useful because insert too much margin around
|
||||
(for example, not valid to use in the table of server view */
|
||||
|
||||
span.users, span.agents, span.data, span.alerts, span.time, span.net,
|
||||
span.master, span.snmp, span.binary, span.recon, span.wmi, span.prediction,
|
||||
span.plugin, span.plugin, span.export {
|
||||
|
@ -613,7 +611,6 @@ span.rmess, span.nrmess {
|
|||
padding-top: 6px;
|
||||
padding-left: 12em;
|
||||
}
|
||||
|
||||
span#logo_text1 {
|
||||
font: bolder 3em Arial, Sans-serif;
|
||||
letter-spacing: -2px;
|
||||
|
@ -630,41 +627,32 @@ span#logo_text2 {
|
|||
.bt0 {
|
||||
border-top: 0px;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#table-add-item select, #table-add-sla select {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
/* classes for event priorities. Sits now in functions.php */
|
||||
.datos_green, .datos_greenf9 {
|
||||
background-color: #BBFFA4;
|
||||
}
|
||||
|
||||
.datos_red, .datos_redf9 {
|
||||
background-color: #FFC0B5;
|
||||
}
|
||||
|
||||
.datos_yellow, .datos_yellowf9 {
|
||||
background-color: #F4FFBF;
|
||||
}
|
||||
|
||||
.datos_blue, .datos_bluef9 {
|
||||
background-color: #CDE2EA;
|
||||
}
|
||||
|
||||
.datos_grey, .datos_greyf9 {
|
||||
background-color: #E4E4E4;
|
||||
}
|
||||
|
||||
td.datos_greyf9, td.datos_bluef9, td.datos_greenf9, td.datos_redf9, td.datos_yellowf9 {
|
||||
padding: 5px 5px 5px 5px;
|
||||
}
|
||||
/* end of classes for event priorities */
|
||||
|
||||
div#main_pure {
|
||||
background-color: #fefefe;
|
||||
text-align: left;
|
||||
|
@ -673,44 +661,35 @@ div#main_pure {
|
|||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
#table-agent-configuration radio {
|
||||
margin-right: 40px;
|
||||
}
|
||||
|
||||
.ui-draggable {
|
||||
cursor:move;
|
||||
}
|
||||
|
||||
#layout_trash_drop {
|
||||
float: right;
|
||||
width: 300px;
|
||||
height: 180px;
|
||||
background: #fff url("../../images/trash.png") no-repeat bottom left;
|
||||
}
|
||||
|
||||
#layout_trash_drop div {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#layout_editor_drop {
|
||||
float: left;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.agent_reporting {
|
||||
margin: 5px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.report_table, .agent_reporting {
|
||||
border: #CCC outset 3px;
|
||||
}
|
||||
|
||||
.img_help {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
#loading {
|
||||
position:fixed;
|
||||
width: 200px;
|
||||
|
@ -720,15 +699,47 @@ div#main_pure {
|
|||
background-color: #999999;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* big_data is used in tactical and logon_ok */
|
||||
a.big_data {
|
||||
text-decoration: none; font: bold 2em Arial, Sans-serif;
|
||||
}
|
||||
|
||||
.notify {
|
||||
background-color: #f7ffa5;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
.listing {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.listing td {
|
||||
border-bottom: 1px solid #CCCCCC;
|
||||
border-top: 1px solid #CCCCCC;
|
||||
}
|
||||
.left {
|
||||
float: left;
|
||||
text-align: left;
|
||||
}
|
||||
.right {
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
.top {
|
||||
vertical-align: top
|
||||
margin-top: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
span.actions {
|
||||
margin-left: 30px;
|
||||
}
|
||||
code {
|
||||
font-family: courier;
|
||||
}
|
||||
select#template, select#action {
|
||||
width: 250px;
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ if (! isset ($_SESSION['id_usuario']) && isset ($_GET["login"])) {
|
|||
logon_db ($nick, $REMOTE_ADDR);
|
||||
$_SESSION['id_usuario'] = $nick;
|
||||
$config['id_user'] = $nick;
|
||||
unset ($_GET['pass'], $pass);
|
||||
unset ($_GET['pass'], $pass, $_POST['pass'], $_REQUEST['pass']);
|
||||
} else {
|
||||
// User not known
|
||||
$login_failed = true;
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
|
||||
// Load global vars
|
||||
require("include/config.php");
|
||||
|
||||
|
@ -369,7 +367,6 @@ if ($result !== false) {
|
|||
|
||||
<link rel="stylesheet" href="include/styles/cluetip.css" type="text/css" />
|
||||
<script type="text/javascript" src="include/javascript/jquery.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jquery.js"></script>
|
||||
<script type="text/javascript" src="include/javascript/jquery.cluetip.js"></script>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
|
|
@ -39,7 +39,6 @@ if (give_acl ($config['id_user'], 0, "AR")) {
|
|||
$sub["operation/agentes/estado_grupo"]["refr"] = 60;
|
||||
|
||||
$sub["operation/agentes/networkmap"]["text"] = __('Network Map');
|
||||
$sub["operation/agentes/networkmap"]["refr"] = 0;
|
||||
|
||||
$sub["operation/agentes/estado_agente"]["text"] = __('Agent detail');
|
||||
$sub["operation/agentes/estado_agente"]["refr"] = 60;
|
||||
|
@ -88,7 +87,7 @@ if (give_acl ($config['id_user'], 0, "AR")) {
|
|||
$menu["estado_server"]["id"] = "oper-servers";
|
||||
//End of server view
|
||||
}
|
||||
|
||||
|
||||
enterprise_hook ('inventory_menu');
|
||||
|
||||
//Incidents
|
||||
|
@ -100,10 +99,8 @@ if (give_acl ($config['id_user'], 0, "IR") == 1) {
|
|||
|
||||
$sub = array ();
|
||||
$sub["operation/incidents/incident_search"]["text"] = __('Search incidents');
|
||||
$sub["operation/incidents/incident_search"]["refr"] = 0;
|
||||
|
||||
$sub["operation/incidents/incident_statistics"]["text"] = __('Statistics');
|
||||
$sub["operation/incidents/incident_statistics"]["refr"] = 0;
|
||||
|
||||
$menu["incidencias"]["sub"] = $sub;
|
||||
}
|
||||
|
@ -118,40 +115,33 @@ if (give_acl ($config['id_user'], 0, "AR")) {
|
|||
|
||||
$sub = array ();
|
||||
$sub["operation/events/event_statistics"]["text"] = __('Statistics');
|
||||
$sub["operation/events/event_statistics"]["refr"] = 0;
|
||||
|
||||
//RSS
|
||||
$sub["operation/events/events_rss.php"]["text"] = __('RSS');
|
||||
$sub["operation/events/events_rss.php"]["refr"] = 0;
|
||||
$sub["operation/events/events_rss.php"]["type"] = "direct";
|
||||
|
||||
//CSV
|
||||
$sub["operation/events/export_csv.php"]["text"] = __('CSV File');
|
||||
$sub["operation/events/export_csv.php"]["refr"] = 0;
|
||||
$sub["operation/events/export_csv.php"]["type"] = "direct";
|
||||
|
||||
//Marquee
|
||||
$sub["operation/events/events_marquee.php"]["text"] = __('Marquee');
|
||||
$sub["operation/events/events_marquee.php"]["refr"] = 0;
|
||||
$sub["operation/events/events_marquee.php"]["type"] = "direct";
|
||||
|
||||
$menu["eventos"]["sub"] = $sub;
|
||||
|
||||
// Users
|
||||
$menu["usuarios"]["text"] = __('View users');
|
||||
$menu["usuarios"]["refr"] = 0;
|
||||
$menu["usuarios"]["sec2"] = "operation/users/user";
|
||||
$menu["usuarios"]["id"] = "oper-users";
|
||||
|
||||
$sub = array ();
|
||||
$sub["operation/users/user_edit"]["text"] = __('Edit my user');
|
||||
$sub["operation/users/user_edit"]["refr"] = 0;
|
||||
$sub["operation/users/user_edit"]["options"]["name"] = "ver";
|
||||
$sub["operation/users/user_edit"]["options"]["value"] = $config["id_user"];
|
||||
|
||||
if (give_acl ($config["id_user"], 0, "UM")) {
|
||||
$sub["operation/users/user_statistics"]["text"] = __('Statistics');
|
||||
$sub["operation/users/user_statistics"]["refr"] = 0;
|
||||
}
|
||||
|
||||
$menu["usuarios"]["sub"] = $sub;
|
||||
|
@ -171,7 +161,6 @@ if (give_acl ($config['id_user'], 0, "AR")) {
|
|||
|
||||
$sub = array ();
|
||||
$sub["operation/messages/message"]["text"] = __('Messages to groups');
|
||||
$sub["operation/messages/message"]["refr"] = 0;
|
||||
$sub["operation/messages/message"]["options"]["name"] = "nuevo_g";
|
||||
$sub["operation/messages/message"]["options"]["value"] = 1;
|
||||
|
||||
|
@ -179,23 +168,19 @@ if (give_acl ($config['id_user'], 0, "AR")) {
|
|||
|
||||
// Reporting
|
||||
$menu["reporting"]["text"] = __('Reporting');
|
||||
$menu["reporting"]["refr"] = 0;
|
||||
$menu["reporting"]["sec2"] = "operation/reporting/custom_reporting";
|
||||
$menu["reporting"]["id"] = "oper-reporting";
|
||||
|
||||
$sub = array ();
|
||||
$sub["operation/reporting/custom_reporting"]["text"] = __('Custom reporting');
|
||||
$sub["operation/reporting/custom_reporting"]["refr"] = 0;
|
||||
|
||||
$sub["operation/reporting/graph_viewer"]["text"] = __('Custom graphs');
|
||||
$sub["operation/reporting/graph_viewer"]["refr"] = 0;
|
||||
|
||||
$menu["reporting"]["sub"] = $sub;
|
||||
|
||||
// Extensions menu additions
|
||||
if (is_array ($config['extensions'])) {
|
||||
$menu["extensions"]["text"] = __('Extensions');
|
||||
$menu["extensions"]["refr"] = 0;
|
||||
$menu["extensions"]["sec2"] = "operation/extensions";
|
||||
$menu["extensions"]["id"] = "oper-extensions";
|
||||
|
||||
|
@ -212,4 +197,4 @@ if (give_acl ($config['id_user'], 0, "AR")) {
|
|||
$menu["extensions"]["sub"] = $sub;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
check_login ();
|
||||
|
||||
require_once ('include/functions_custom_graphs.php');
|
||||
|
||||
$delete_graph = (bool) get_parameter ('delete_graph');
|
||||
$view_graph = (bool) get_parameter ('view_graph');
|
||||
$id = (int) get_parameter ('id');
|
||||
|
@ -82,7 +84,6 @@ if ($view_graph) {
|
|||
if ($stacked == -1)
|
||||
$stacked = $graph["stacked"];
|
||||
|
||||
|
||||
$name = $graph["name"];
|
||||
if (($graph["private"]==1) && ($graph["id_user"] != $id_user)){
|
||||
audit_db($config['id_user'],$REMOTE_ADDR, "ACL Violation","Trying to access to a custom graph not allowed");
|
||||
|
@ -90,29 +91,11 @@ if ($view_graph) {
|
|||
exit;
|
||||
}
|
||||
|
||||
$sql2="SELECT * FROM tgraph_source WHERE id_graph = $id";
|
||||
$res2=mysql_query($sql2);
|
||||
while ($graph_source = mysql_fetch_array($res2)) {
|
||||
$weight = $graph_source["weight"];
|
||||
$id_agent_module = $graph_source["id_agent_module"];
|
||||
$id_grupo = get_db_sql ("SELECT id_grupo FROM tagente, tagente_modulo WHERE tagente_modulo.id_agente_modulo = $id_agent_module AND tagente.id_agente = tagente_modulo.id_agente");
|
||||
if (give_acl($config["id_user"], $id_grupo, "AR")==1){
|
||||
if (!isset($modules)){
|
||||
$modules = $id_agent_module;
|
||||
$weights = $weight;
|
||||
} else {
|
||||
$modules = $modules.",".$id_agent_module;
|
||||
$weights = $weights.",".$weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "<h2>".__('Reporting')." > ";
|
||||
echo __('Combined image render')."</h2>";
|
||||
echo "<table class='databox_frame' cellpadding=0 cellspacing=0>";
|
||||
echo "<tr><td>";
|
||||
echo "<img
|
||||
src='reporting/fgraph.php?tipo=combined&height=$height&width=$width&id=$modules&period=$period&weight_l=$weights&stacked=$stacked'
|
||||
border=1 alt=''>";
|
||||
print_custom_graph ($id, $height, $width, $period, $stacked);
|
||||
echo "</td></tr></table>";
|
||||
$period_label = human_time_description ($period);
|
||||
echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=$id'>";
|
||||
|
@ -120,18 +103,9 @@ border=1 alt=''>";
|
|||
echo "<tr><td class='datos'>";
|
||||
echo "<b>".__('Period')."</b>";
|
||||
echo "<td class='datos'>";
|
||||
$periods = array ();
|
||||
$periods[1] = __('1 hour');
|
||||
$periods[2] = '2 '.__('hours');
|
||||
$periods[3] = '3 '.__('hours');
|
||||
$periods[6] = '6 '.__('hours');
|
||||
$periods[12] = '12 '.__('hours');
|
||||
$periods[24] = __('1 day');
|
||||
$periods[48] = __('2 days');
|
||||
$periods[360] = __('1 week');
|
||||
$periods[720] = __('1 month');
|
||||
$periods[4320] = __('6 months');
|
||||
print_select ($periods, 'period', intval ($period / 3600), '', '', 0);
|
||||
|
||||
print_select (get_custom_graph_periods (), 'period', intval ($period / 3600),
|
||||
'', '', 0, false, false, false);
|
||||
|
||||
echo "<td class='datos'>";
|
||||
$stackeds = array ();
|
||||
|
@ -158,43 +132,35 @@ border=1 alt=''>";
|
|||
echo "<h2>" . __('Reporting') . " > ";
|
||||
echo __('Custom graph viewer') . "</h2>";
|
||||
|
||||
$color=1;
|
||||
$sql="SELECT * FROM tgraph ORDER by name";
|
||||
$res=mysql_query($sql);
|
||||
if (mysql_num_rows($res)) {
|
||||
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_frame'>";
|
||||
echo "<tr>
|
||||
<th>".__('Graph name')."</th>
|
||||
<th>".__('Description')."</th>
|
||||
<th>".__('View')."</th>";
|
||||
$graphs = get_user_custom_graphs ();
|
||||
if (! empty ($graphs)) {
|
||||
$table->width = '500px';
|
||||
$tale->class = 'databox_frame';
|
||||
$table->align = array ();
|
||||
$table->align[2] = 'center';
|
||||
$table->head = array ();
|
||||
$table->head[0] = __('Graph name');
|
||||
$table->head[1] = __('Description');
|
||||
if (give_acl ($config['id_user'], 0, "AW"))
|
||||
echo "<th>".__('Delete')."</th>";
|
||||
echo "</tr>";
|
||||
|
||||
while ($graph = mysql_fetch_array($res)){
|
||||
if (($graph["private"] == 0) || ($graph["id_user"] == $id_user)) {
|
||||
// Calculate table line color
|
||||
if ($color == 1){
|
||||
$tdcolor = "datos";
|
||||
$color = 0;
|
||||
}
|
||||
else {
|
||||
$tdcolor = "datos2";
|
||||
$color = 1;
|
||||
}
|
||||
echo "<tr>";
|
||||
echo "<td valign='top' class='$tdcolor'>".$graph["name"]."</td>";
|
||||
echo "<td class='$tdcolor'>".$graph["description"]."</td>";
|
||||
$id = $graph["id_graph"];
|
||||
echo "<td valign='middle' class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id=$id'><img src='images/images.png'></a>";
|
||||
|
||||
if (give_acl ($config['id_user'], 0, "AW")) {
|
||||
echo "<td class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&delete_graph=1&id=$id' ".'onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">';
|
||||
echo "<img src='images/cross.png'></a></td>";
|
||||
}
|
||||
$table->head[2] = __('Delete');
|
||||
$table->data = array ();
|
||||
|
||||
foreach ($graphs as $graph) {
|
||||
$data = array ();
|
||||
|
||||
$data[0] = '<a href="index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=1&id='.
|
||||
$graph['id_graph'].'">'.$graph['name'].'</a>';
|
||||
$data[1] = $graph["description"];
|
||||
|
||||
if (give_acl ($config['id_user'], 0, "AW")) {
|
||||
$data[2] = '<a href="index.php?sec=reporting&sec2=operation/reporting/graph_viewer&delete_graph=1&id='
|
||||
.$graph['id_graph'].'" onClick="if (!confirm(\''.__('Are you sure?').'\'))
|
||||
return false;"><img src="images/cross.png" /></a>';
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
echo "</table>";
|
||||
print_table ($table);
|
||||
} else {
|
||||
echo "<div class='nf'>".__('There are no defined reportings')."</div>";
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
// Login check
|
||||
require("include/config.php");
|
||||
|
||||
|
|
|
@ -200,13 +200,96 @@ CREATE TABLE IF NOT EXISTS `talert_snmp` (
|
|||
PRIMARY KEY (`id_as`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_commands` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(100) NOT NULL default '',
|
||||
`command` varchar(500) default '',
|
||||
`description` varchar(255) default '',
|
||||
`internal` tinyint(1) default 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_actions` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) default '',
|
||||
`id_alert_command` int(10) unsigned NOT NULL,
|
||||
`field1` varchar(255) NOT NULL default '',
|
||||
`field2` varchar(255) default '',
|
||||
`field3` varchar(255) default '',
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`)
|
||||
ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_templates` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) default '',
|
||||
`description` mediumtext default '',
|
||||
`id_alert_action` int(10) unsigned NULL,
|
||||
`field1` varchar(255) default '',
|
||||
`field2` varchar(255) default '',
|
||||
`field3` mediumtext NOT NULL,
|
||||
`type` ENUM ('regex', 'max_min', 'max', 'min', 'equal', 'not_equal'),
|
||||
`value` varchar(255) default '',
|
||||
`max_value` double(18,2) default NULL,
|
||||
`min_value` double(18,2) default NULL,
|
||||
`time_threshold` int(10) NOT NULL default '0',
|
||||
`max_alerts` int(4) unsigned NOT NULL default '1',
|
||||
`module_type` int(10) unsigned NOT NULL default '0',
|
||||
`min_alerts` int(4) unsigned NOT NULL default '0',
|
||||
`alert_text` varchar(255) default '',
|
||||
`time_from` time default '00:00:00',
|
||||
`time_to` time default '00:00:00',
|
||||
`monday` tinyint(1) default '1',
|
||||
`tuesday` tinyint(1) default '1',
|
||||
`wednesday` tinyint(1) default '1',
|
||||
`thursday` tinyint(1) default '1',
|
||||
`friday` tinyint(1) default '1',
|
||||
`saturday` tinyint(1) default '1',
|
||||
`sunday` tinyint(1) default '1',
|
||||
`recovery_notify` tinyint(1) default '0',
|
||||
`field2_recovery` varchar(255) NOT NULL default '',
|
||||
`field3_recovery` mediumtext NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
|
||||
ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_template_modules` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_agent_module` int(10) unsigned NOT NULL,
|
||||
`id_alert_template` int(10) unsigned NOT NULL,
|
||||
`internal_counter` int(4) default '0',
|
||||
`last_fired` bigint(20) NOT NULL default '0',
|
||||
`times_fired` int(3) NOT NULL default '0',
|
||||
`disabled` tinyint(1) default '0',
|
||||
`priority` tinyint(4) default '0',
|
||||
`force_execution` tinyint(1) default '0',
|
||||
PRIMARY KEY (`id`),
|
||||
FOREIGN KEY (`id_agent_module`) REFERENCES tagente_modulo(`id_agente_modulo`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_alert_template`) REFERENCES talert_templates(`id`)
|
||||
ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
UNIQUE (`id_agent_module`, `id_alert_template`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talert_template_module_actions` (
|
||||
`id_alert_template_module` int(10) unsigned NOT NULL,
|
||||
`id_alert_action` int(10) unsigned NOT NULL,
|
||||
`fires_min` int(3) unsigned default 0,
|
||||
`fires_max` int(3) unsigned default 0,
|
||||
FOREIGN KEY (`id_alert_template_module`) REFERENCES talert_template_modules(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`)
|
||||
ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `talerta` (
|
||||
`id_alerta` int(10) unsigned NOT NULL auto_increment,
|
||||
`nombre` varchar(100) NOT NULL default '',
|
||||
`comando` varchar(500) default '',
|
||||
`descripcion` varchar(255) default '',
|
||||
PRIMARY KEY (`id_alerta`)
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_alert_module` int(10) unsigned NOT NULL,
|
||||
`id_alert_template` int(10) unsigned NOT NULL,
|
||||
`id_alert_action` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tcompound_alert` (
|
||||
|
@ -251,8 +334,8 @@ CREATE TABLE `talerta_agente_modulo` (
|
|||
`al_f3_recovery` mediumtext NOT NULL,
|
||||
`flag` tinyint(1) unsigned default '0',
|
||||
PRIMARY KEY (`id_aam`),
|
||||
KEY `id_agente_modulo` (`id_agente_modulo`),
|
||||
KEY `disable` (`disable`)
|
||||
KEY `id_agente_modulo` (`id_agente_modulo`),
|
||||
KEY `disable` (`disable`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue