2009-01-19 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/configurar_agente.php: Removed references to old talerta and talerta_modulo tables. * godmode/agentes/alert_manager_editor.php, godmode/alerts/configure_alert.php: Removed from repository. It became a useless file since the new alert system is implemented. * godmode/agentes/manage_config.php: Style correction. Copy alerts among agents using the new tables and structures. * godmode/reporting/reporting_builder.php: Do not sort report time period, it was not human readable if it was alphanumeric sorted. * include/functions_agents.php: Fixed get_agent_alerts_simple() and commented get_agent_alerts_combined() code since it's not implemented yet. * include/functions_db.php, include/functions_reporting.php: Fixed function documentation format. Use structures, functions and tables of the new alert system. * operation/reporting/reporting_viewer.php: Style correction. * pandoradb.sql: Removed default values on mediumtext fields because it was causing a SQL warning. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1356 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
735c2a24bd
commit
02d09bd32d
|
@ -1,3 +1,31 @@
|
|||
2009-01-19 Esteban Sanchez <estebans@artica.es>
|
||||
|
||||
* godmode/agentes/configurar_agente.php: Removed references to old
|
||||
talerta and talerta_modulo tables.
|
||||
|
||||
* godmode/agentes/alert_manager_editor.php,
|
||||
godmode/alerts/configure_alert.php: Removed from repository. It became
|
||||
a useless file since the new alert system is implemented.
|
||||
|
||||
* godmode/agentes/manage_config.php: Style correction. Copy alerts
|
||||
among agents using the new tables and structures.
|
||||
|
||||
* godmode/reporting/reporting_builder.php: Do not sort report time
|
||||
period, it was not human readable if it was alphanumeric sorted.
|
||||
|
||||
* include/functions_agents.php: Fixed get_agent_alerts_simple() and
|
||||
commented get_agent_alerts_combined() code since it's not implemented
|
||||
yet.
|
||||
|
||||
* include/functions_db.php, include/functions_reporting.php: Fixed
|
||||
function documentation format. Use structures, functions and tables of
|
||||
the new alert system.
|
||||
|
||||
* operation/reporting/reporting_viewer.php: Style correction.
|
||||
|
||||
* pandoradb.sql: Removed default values on mediumtext fields because
|
||||
it was causing a SQL warning.
|
||||
|
||||
2009-01-16 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||
|
||||
* godmode/alerts/configure_alert_template.php: Some aesthetic fixes and
|
||||
|
|
|
@ -1,410 +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.
|
||||
|
||||
if (!isset ($id_agente)) {
|
||||
die ("Not Authorized");
|
||||
}
|
||||
|
||||
$add_component = get_parameter ("add_component",0);
|
||||
echo "<h3>".__('Alert association form');
|
||||
pandora_help ("alerts");
|
||||
echo "</h3>";
|
||||
|
||||
echo '<form name="agente" method="post" action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente.'">';
|
||||
|
||||
if ($form_alerttype == "combined")
|
||||
echo "<input type='hidden' name='combined' value ='1'>";
|
||||
else
|
||||
echo "<input type='hidden' name='combined' value ='0'>";
|
||||
|
||||
if (! isset($update_alert))
|
||||
$update_alert = -1;
|
||||
|
||||
if ($update_alert != 1) {
|
||||
echo '<input type="hidden" name="insert_alert" value=1>';
|
||||
} else {
|
||||
echo '<input type="hidden" name="update_alert" value=1>';
|
||||
echo '<input type="hidden" name="id_aam" value="'.$alerta_id_aam.'">';
|
||||
}
|
||||
echo '<input type="hidden" name="id_agente" value="'.$id_agente.'">';
|
||||
|
||||
echo '<table width=600 cellpadding="4" cellspacing="4" class="databox_color" border=0>';
|
||||
|
||||
// AgentModule association
|
||||
echo '<tr><td class="datos3">'.__('Assigned module');
|
||||
echo '<td class="datos3">';
|
||||
if ($form_alerttype != "combined"){
|
||||
if ($update_alert != 1) {
|
||||
echo '<select name="agente_modulo" style="width:210px;"> ';
|
||||
$sql2 = "SELECT id_agente_modulo, id_tipo_modulo, nombre FROM tagente_modulo WHERE id_agente = $id_agente ORDER BY nombre";
|
||||
$result2=mysql_query($sql2);
|
||||
while ($row2=mysql_fetch_array($result2)){
|
||||
if ($row2["id_tipo_modulo"] != -1) {
|
||||
$sql1='SELECT nombre FROM ttipo_modulo WHERE id_tipo = '.$row2["id_tipo_modulo"];
|
||||
$result=mysql_query($sql1);
|
||||
while ($row=mysql_fetch_array($result)){
|
||||
echo "<option value='".$row2["id_agente_modulo"]."'>".$row2["nombre"]." ( ".$row["nombre"]." )</option>";
|
||||
}
|
||||
} else // for -1, is a special module, keep alive monitor !!
|
||||
echo "<option value='".$row2["id_agente_modulo"]."'>".$row2["nombre"]."</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
} else {
|
||||
$agentmodule_name = get_db_sql ("SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = $alerta_id_agentemodulo");
|
||||
echo $agentmodule_name;
|
||||
}
|
||||
} else {
|
||||
echo __('N/A');
|
||||
}
|
||||
echo '<td class="datos3">';
|
||||
echo __('Priority');
|
||||
echo '<td class="datos3">';
|
||||
|
||||
if (! isset($alert_priority)) {
|
||||
$alert_priority = 3; // Warning by default
|
||||
}
|
||||
print_select (get_priorities (), "alert_priority", $alert_priority, '', '', '');
|
||||
|
||||
// Alert type
|
||||
echo '<tr><td class="datos">'. __('Alert type');
|
||||
pandora_help ("alert_type");
|
||||
echo '</td>';
|
||||
echo '<td class="datos"><select name="tipo_alerta">';
|
||||
if (isset($tipo_alerta)){
|
||||
echo "<option value='".$tipo_alerta."'>".get_alert_type ($tipo_alerta)."</option>";
|
||||
}
|
||||
$sql1 = 'SELECT id_alerta, nombre FROM talerta ORDER BY nombre';
|
||||
$result = mysql_query ($sql1);
|
||||
while ($row = mysql_fetch_array ($result)){
|
||||
echo "<option value='".$row["id_alerta"]."'>".$row["nombre"]."</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
|
||||
// Alert disable / enable
|
||||
echo "<td class='datos'>";
|
||||
echo __('Alert status');
|
||||
echo "<td class='datos'>";
|
||||
echo '<select name="disable_alert">';
|
||||
if ((isset($alerta_disable)) AND ($alerta_disable == "1")) {
|
||||
echo "<option value='1'>".__('Disabled');
|
||||
echo "<option value='0'>".__('Enabled');
|
||||
} else {
|
||||
echo "<option value='0'>".__('Enabled');
|
||||
echo "<option value='1'>".__('Disabled');
|
||||
}
|
||||
echo "</select>";
|
||||
|
||||
// Descripcion
|
||||
echo '<tr><td class="datos2">'.__('Description');
|
||||
echo '<td class="datos2" colspan=4><input type="text" name="descripcion" size="60" value ="'.$alerta_descripcion.'">';
|
||||
|
||||
// Trigger values for alert
|
||||
if ($form_alerttype != "combined"){
|
||||
echo '<tr><td class="datos">'.__('Min. Value');
|
||||
echo "<a href='#' class='tip'> <span>";echo __('Min. possible value to consider \'valid\' values, below this limit, Pandora FMS will fire the alert')."</span></a>";
|
||||
echo '<td class="datos"><input type="text" name="minimo" size="5" value="'.$alerta_dis_min.'" style="margin-right: 70px;">';
|
||||
|
||||
echo "<td class='datos'>";
|
||||
echo __('Max. Value');
|
||||
echo "<a href='#' class='tip'> <span>";
|
||||
echo __('Max. possible value to consider \'valid\' values, above this limit, Pandora FMS will fire the alert');
|
||||
echo "</span></a>";
|
||||
echo "<td class='datos'>";
|
||||
echo "<input type='text' name='maximo' size='5' value='$alerta_dis_max'>";
|
||||
|
||||
// <!-- FREE TEXT ALERT -->
|
||||
|
||||
echo '<tr><td class="datos2">'.__('Alert text')."<a href='#' class='tip'> <span>NOTE: This field is for matching text on data. Regular Expression Supported </span></a>";
|
||||
echo '<td class="datos2" colspan=4><input type="text" name="alert_text" size="60" value ="'.$alert_text.'">';
|
||||
}
|
||||
|
||||
// Time Threshold (TT)
|
||||
echo '<tr><td class="datos">'.__('Time threshold');
|
||||
echo "<a href='#' class='tip'> <span>".__('This value must be al least Module Interval * (Min.Number of Alerts + 1)')."</span></a>";
|
||||
echo '<td class="datos">';
|
||||
echo '<select name="time_threshold" style="margin-right: 60px;">';
|
||||
if ($alerta_time_threshold != ""){
|
||||
echo "<option value='".$alerta_time_threshold."'>".human_time_description($alerta_time_threshold)."</option>";
|
||||
}
|
||||
echo '
|
||||
<option value=300>5 Min.</option>
|
||||
<option value=600>10 Min.</option>
|
||||
<option value=900>15 Min.</option>
|
||||
<option value=1800>30 Min.</option>
|
||||
<option value=3600>1 Hour</option>
|
||||
<option value=7200>2 Hour</option>
|
||||
<option value=18000>5 Hour</option>
|
||||
<option value=43200>12 Hour</option>
|
||||
<option value=86400>1 Day</option>
|
||||
<option value=604800>1 Week</option>
|
||||
<option value=-1>Other value</option>
|
||||
</select>';
|
||||
|
||||
// Other TT
|
||||
echo '<td class="datos">';
|
||||
echo __('Other');
|
||||
echo '<td class="datos">';
|
||||
echo '<input type="text" name="other" size="5">';
|
||||
|
||||
// Max / Min alerts
|
||||
echo "<tr><td class='datos2'>".__('Min. number of alerts');
|
||||
echo '<td class="datos2">';
|
||||
echo '<input type="text" name="min_alerts" size="5" value="';
|
||||
if (isset($alerta_min_alerts))
|
||||
echo $alerta_min_alerts;
|
||||
else
|
||||
echo 0;
|
||||
echo '" style="margin-right: 10px;">';
|
||||
|
||||
echo '<td class="datos2">';
|
||||
echo __('Max. number of alerts');
|
||||
echo '<td class="datos2">';
|
||||
echo '<input type="text" name="max_alerts" size="5" value="';
|
||||
if (isset($alerta_max_alerts))
|
||||
echo $alerta_max_alerts;
|
||||
else
|
||||
echo 1;
|
||||
echo '" style="margin-right: 10px;">';
|
||||
|
||||
// Field1
|
||||
echo '<tr><td class="datos">'.__('Field #1 (Alias, name)');
|
||||
echo '<td class="datos" colspan=4><input type="text" name="campo_1" size="39" value="'.$alerta_campo1.'">';
|
||||
echo "<a href='#' class='tip'><span><b>Macros:</b><br>_agent_<br>";
|
||||
echo '_timestamp_<br>_data_<br></span></a>';
|
||||
|
||||
// Field2
|
||||
echo '<tr><td class="datos2">'.__('Field #2 (Single Line)');
|
||||
echo '<td class="datos2" colspan=4>';
|
||||
echo '<input type="text" name="campo_2" size="39" value="'.$alerta_campo2.'">';
|
||||
echo "<a href='#' class='tip'><span>";
|
||||
echo '<b>Macros:</b><br>_agent_<br>_timestamp_<br>_data_<br></span></a>';
|
||||
|
||||
//Field3
|
||||
echo '<tr><td class="datos">'.__('Field #3 (Full Text)');
|
||||
echo '<td class="datos" colspan=4>';
|
||||
echo '<textarea name="campo_3" style="height:85px; width: 380px" rows="4">';
|
||||
echo $alerta_campo3;
|
||||
echo '</textarea><a href="#" class="tip"><span><b>Macros:</b><br>_agent_<br>';
|
||||
echo '_timestamp_<br>_data_<br></span></a>';
|
||||
|
||||
// Time for alerting
|
||||
echo "<tr><td class='datos2'>".__('Time from');
|
||||
echo "<td class='datos2'><select name='time_from'>";
|
||||
if ($time_from != ""){
|
||||
echo "<option value='$time_from'>".substr($time_from,0,5);
|
||||
}
|
||||
|
||||
for ($a=0; $a < 48; $a++){
|
||||
echo "<option value='";
|
||||
echo render_time ($a);
|
||||
echo "'>";
|
||||
echo render_time ($a);
|
||||
}
|
||||
echo "<option value='23:59'>23:59";
|
||||
echo "</select>";
|
||||
|
||||
echo "<td class='datos2'>".__('Time to');
|
||||
echo "<td class='datos2'><select name='time_to'>";
|
||||
if ($time_from != ""){
|
||||
echo "<option value='$time_to'>".substr($time_to,0,5);
|
||||
}
|
||||
|
||||
for ($a=0; $a < 48; $a++){
|
||||
echo "<option value='";
|
||||
echo render_time ($a);
|
||||
echo "'>";
|
||||
echo render_time ($a);
|
||||
}
|
||||
echo "<option value='23:59'>23:59";
|
||||
echo "</select>";
|
||||
|
||||
// Days of week
|
||||
echo "<tr><td class='datos'>".__('Days of week');
|
||||
echo "<td class='datos' colspan=4>";
|
||||
echo __('Mon');
|
||||
print_checkbox ("alert_d1", 1, $alert_d1);
|
||||
echo " ";
|
||||
echo __('Tue');
|
||||
print_checkbox ("alert_d2", 1, $alert_d2);
|
||||
echo " ";
|
||||
echo __('Wed');
|
||||
print_checkbox ("alert_d3", 1, $alert_d3);
|
||||
echo " ";
|
||||
echo __('Thu');
|
||||
print_checkbox ("alert_d4", 1, $alert_d4);
|
||||
echo " ";
|
||||
echo __('Fri');
|
||||
print_checkbox ("alert_d5", 1, $alert_d5);
|
||||
echo " ";
|
||||
echo __('Sat');
|
||||
print_checkbox ("alert_d6", 1, $alert_d6);
|
||||
echo " ";
|
||||
echo __('Sun');
|
||||
print_checkbox ("alert_d7", 1, $alert_d7);
|
||||
|
||||
// Field2 Recovery
|
||||
echo '<tr><td class="datos2">'.__('Field #2 (Rec)');
|
||||
echo '<td class="datos2">';
|
||||
echo '<input type="text" name="campo_2_rec" size="20" value="'.$alerta_campo2_rec.'">';
|
||||
|
||||
// Alert recovery disable / enable
|
||||
echo '<td class="datos2">'. __('Alert recovery');
|
||||
pandora_help ("alert_recovery");
|
||||
echo '</td>';
|
||||
echo "<td class='datos2'>";
|
||||
echo '<select name="alert_recovery">';
|
||||
if ((isset($alert_recovery)) AND ($alert_recovery == "1")) {
|
||||
echo "<option value='1'>".__('Enabled');
|
||||
echo "<option value='0'>".__('Disabled');
|
||||
} else {
|
||||
echo "<option value='0'>".__('Disabled');
|
||||
echo "<option value='1'>".__('Enabled');
|
||||
}
|
||||
echo "</select>";
|
||||
|
||||
|
||||
//Field3 - Recovery
|
||||
echo '<tr><td class="datos">'.__('Field #3 (Rec)');
|
||||
echo '<td class="datos" colspan=4>';
|
||||
echo '<input type="text" name="campo_3_rec" size="60" value="'.$alerta_campo3_rec.'">';
|
||||
|
||||
// End block only if $creacion_agente != 1;
|
||||
|
||||
echo "</td></tr></table>";
|
||||
echo '<table width=605>';
|
||||
echo '<tr><td align="right">';
|
||||
if ($update_alert== "1"){
|
||||
echo '<input name="updbutton" type="submit" class="sub upd" value="'.__('Update').'">';
|
||||
} else {
|
||||
echo '<input name="crtbutton" type="submit" class="sub wand" value="'.__('Add').'">';
|
||||
}
|
||||
echo '</form>';
|
||||
echo '</td></tr></table>';
|
||||
|
||||
|
||||
if (($form_alerttype == "combined") AND ($update_alert != -1)){
|
||||
echo "<h3>".__('Combined alert components')."</h3>";
|
||||
echo '<table width=605 class="databox" border=0 cellpadding=4 cellspacing=4>';
|
||||
echo '<form method=POST action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.$id_agente.'&update_alert='.$alerta_id_aam.'&add_component=1&form_alerttype=combined">';
|
||||
|
||||
if ($form_alerttype == "combined")
|
||||
echo "<input type='hidden' name='combined' value ='1'>";
|
||||
else
|
||||
echo "<input type='hidden' name='combined' value ='0'>";
|
||||
|
||||
echo '<input type="hidden" name="add_alert_combined" value="1">';
|
||||
echo '<input type="hidden" name="id_agente" value="'.$id_agente.'">';
|
||||
|
||||
echo "<tr><td>";
|
||||
echo __('Source Agent/Alert');
|
||||
echo "<td>";
|
||||
echo "<select name='component_item'>";
|
||||
|
||||
// Add to combo single alerts
|
||||
$result_alert = mysql_query("SELECT tagente_modulo.id_agente_modulo, tagente.nombre, tagente_modulo.nombre, id_aam, tagente.id_grupo FROM talerta_agente_modulo, tagente_modulo, tagente WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente = tagente.id_agente");
|
||||
while ($alertrow = mysql_fetch_array($result_alert)){
|
||||
if (give_acl ($config["id_user"], $alertrow[4], "AR") == 1)
|
||||
echo "<option value='".$alertrow[3]."'>(S) ".$alertrow[1]." - ".$alertrow[2];
|
||||
}
|
||||
|
||||
// Add to combo combined alerts
|
||||
$result_alert = mysql_query("SELECT tagente.id_grupo, tagente.nombre, talerta_agente_modulo.id_aam, talerta_agente_modulo.descripcion FROM talerta_agente_modulo, tagente WHERE talerta_agente_modulo.id_agent = tagente.id_agente AND tagente.id_agente != '' AND tagente.id_agente > 0");
|
||||
|
||||
|
||||
while ($alertrow = mysql_fetch_array($result_alert)){
|
||||
if (give_acl ($config["id_user"], $alertrow[0], "AR"))
|
||||
echo "<option value='".$alertrow[2]."'>(C) ".$alertrow[1]." - ".$alertrow[3];
|
||||
}
|
||||
|
||||
echo "</select>";
|
||||
|
||||
|
||||
// there is any component already in this alert ?
|
||||
|
||||
$result = mysql_query ("SELECT COUNT(*) FROM tcompound_alert, talerta_agente_modulo WHERE tcompound_alert.id = $id_aam AND talerta_agente_modulo.id_aam = tcompound_alert.id_aam");
|
||||
$row=mysql_fetch_array($result);
|
||||
if ($row[0] > 0){
|
||||
echo "<td>";
|
||||
echo __('Operation');
|
||||
echo "<td>";
|
||||
echo "<select name='component_operation'>";
|
||||
echo "<option>OR";
|
||||
echo "<option>AND";
|
||||
echo "<option>XOR";
|
||||
echo "<option>NOR";
|
||||
echo "<option>NAND";
|
||||
echo "<option>NXOR";
|
||||
echo "</select>";
|
||||
} else {
|
||||
echo "<input type=hidden name='component_operation' value='NOP'>";
|
||||
}
|
||||
echo "<td>";
|
||||
echo '<input name="crtbutton" type="submit" class="sub wand" value="'.__('Add').'">';
|
||||
echo "</form>";
|
||||
echo "</table>";
|
||||
|
||||
echo '<table width=750 cellpadding="4" cellspacing="4" class="databox" border=0>';
|
||||
echo '<tr>';
|
||||
echo '<th>'.__('Agent');
|
||||
echo '<th>'.__('Module');
|
||||
echo "<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>";
|
||||
|
||||
$id_aam = $alerta_id_aam;
|
||||
$sql2 = "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($sql2);
|
||||
$string = "";
|
||||
$color = 1;
|
||||
|
||||
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"]);
|
||||
|
||||
echo "<tr>";
|
||||
echo "<td class='$tdcolor'>".$id_agente_name;
|
||||
echo "<td class='$tdcolor'>".$module["nombre"];
|
||||
echo show_alert_row_edit ($row2, $tdcolor, $module["id_tipo_modulo"],1);
|
||||
echo "</td><td class='$tdcolor'>";
|
||||
$id_grupo = dame_id_grupo($id_agente);
|
||||
if (give_acl ($config['id_user'], $id_grupo, "LW")) {
|
||||
echo "<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> ";
|
||||
echo "<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>";
|
||||
}
|
||||
echo "</td>";
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
?>
|
|
@ -273,22 +273,6 @@ if (isset($_GET["fix_module"])){
|
|||
}
|
||||
}
|
||||
|
||||
// Delete Alert
|
||||
// =============
|
||||
if (isset($_GET["delete_alert"])){ // if modified some parameter
|
||||
$id_borrar_modulo = get_parameter_get ("delete_alert",0);
|
||||
// get info about agent
|
||||
$sql = sprintf ("DELETE FROM talerta_agente_modulo WHERE id_aam = %d", $id_borrar_modulo);
|
||||
$result = process_sql ($sql);
|
||||
|
||||
if ($result === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem deleting the alert').'</h3>';
|
||||
} else {
|
||||
echo '<h3 class="suc">'.__('Alert successfully deleted').'</h3>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Delete Alert component (from a combined)
|
||||
// ==========================================
|
||||
if (isset($_GET["delete_alert_comp"])) { // if modified some parameter
|
||||
|
@ -304,88 +288,6 @@ if (isset($_GET["delete_alert_comp"])) { // if modified some parameter
|
|||
}
|
||||
}
|
||||
|
||||
// Create alert
|
||||
// =============
|
||||
if (isset($_POST["insert_alert"])){ // if created alert
|
||||
$combined = get_parameter ("combined",0);
|
||||
$id_agente_modulo = get_parameter ("agente_modulo",0);
|
||||
$maximo = get_parameter ("maximo",0);
|
||||
$minimo = get_parameter ("minimo",0);
|
||||
$descripcion= get_parameter ('descripcion', '');
|
||||
$campo_1 = get_parameter ('campo_1', '');
|
||||
$campo_2 = get_parameter ('campo_2', '');
|
||||
$campo_3 = get_parameter ('campo_3', '');
|
||||
$tipo_alerta = get_parameter ("tipo_alerta",3);
|
||||
$alert_text = get_parameter ("alert_text",'');
|
||||
$time_threshold = get_parameter ("time_threshold",900);
|
||||
$max_alerts = get_parameter ("max_alerts",1);
|
||||
$min_alerts = get_parameter ("min_alerts",0);
|
||||
$time_from = get_parameter ("time_from");
|
||||
$time_to= get_parameter ("time_to");
|
||||
$other = get_parameter ("other",0);
|
||||
$disable_alert = get_parameter ("disable_alert");
|
||||
$alert_d1 = get_parameter("alert_d1",0);
|
||||
$alert_d2 = get_parameter("alert_d2",0);
|
||||
$alert_d3 = get_parameter("alert_d3",0);
|
||||
$alert_d4 = get_parameter("alert_d4",0);
|
||||
$alert_d5 = get_parameter("alert_d5",0);
|
||||
$alert_d6 = get_parameter("alert_d6",0);
|
||||
$alert_d7 = get_parameter("alert_d7",0);
|
||||
$alert_recovery = get_parameter("alert_recovery", 1);
|
||||
$alert_priority = get_parameter("alert_priority", 0);
|
||||
$campo2_rec = get_parameter ("campo_2_rec","");
|
||||
$campo3_rec = get_parameter ("campo_3_rec","");
|
||||
|
||||
if ($combined == 1) {
|
||||
$alert_id_agent = $id_agente;
|
||||
} else {
|
||||
$alert_id_agent = 0;
|
||||
}
|
||||
if ($time_threshold == -1) {
|
||||
$time_threshold = $other;
|
||||
}
|
||||
|
||||
$sql = sprintf ("INSERT INTO talerta_agente_modulo
|
||||
(id_agente_modulo,
|
||||
id_alerta,
|
||||
al_campo1,
|
||||
al_campo2,
|
||||
al_campo3,
|
||||
descripcion,
|
||||
dis_max,
|
||||
dis_min,
|
||||
time_threshold,
|
||||
max_alerts,
|
||||
min_alerts,
|
||||
alert_text,
|
||||
disable,
|
||||
time_from,
|
||||
time_to,
|
||||
id_agent,
|
||||
monday,
|
||||
tuesday,
|
||||
wednesday,
|
||||
thursday,
|
||||
friday,
|
||||
saturday,
|
||||
sunday,
|
||||
recovery_notify,
|
||||
priority,
|
||||
al_f2_recovery,
|
||||
al_f3_recovery) VALUES
|
||||
(%d,%d,'%s','%s','%s','%s',%f,%f,%d,%d,%d,'%s',%d,'%s','%s',%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,'%s','%s')",
|
||||
$id_agente_modulo, $tipo_alerta, $campo_1, $campo_2, $campo_3, $descripcion, $maximo, $minimo, $time_threshold, $max_alerts, $min_alerts, $alert_text, $disable_alert,
|
||||
$time_from, $time_to, $alert_id_agent, $alert_d1, $alert_d2, $alert_d3, $alert_d4, $alert_d5, $alert_d6, $alert_d7, $alert_recovery, $alert_priority, $campo2_rec, $campo3_rec);
|
||||
$id_alerta_agente_modulo = process_sql ($sql, "insert_id");
|
||||
//False or 0 is invalid
|
||||
if (empty ($id_alerta_agente_modulo)) {
|
||||
echo '<h3 class="error">'.__('There was a problem creating alert').'</h3>';
|
||||
} else {
|
||||
echo '<h3 class="suc">'.__('Alert successfully created').'</h3>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Combined ALERT - Add component
|
||||
// ================================
|
||||
if (isset($_POST["add_alert_combined"])){ // Update an existing alert
|
||||
|
@ -402,89 +304,6 @@ if (isset($_POST["add_alert_combined"])){ // Update an existing alert
|
|||
|
||||
}
|
||||
|
||||
// Update ALERT
|
||||
// =============
|
||||
if (isset($_POST["update_alert"])) { // Update an existing alert
|
||||
$id_agente_modulo = get_parameter ("agente_modulo",0);
|
||||
$id_aam = get_parameter ("id_aam",0);
|
||||
$maximo = get_parameter ("maximo",0);
|
||||
$minimo = get_parameter ("minimo",0);
|
||||
$descripcion= get_parameter ('descripcion', '');
|
||||
$campo_1 = get_parameter ('campo_1', '');
|
||||
$campo_2 = get_parameter ('campo_2', '');
|
||||
$campo_3 = get_parameter ('campo_3', '');
|
||||
$tipo_alerta = get_parameter ("tipo_alerta",3);
|
||||
$alert_text = get_parameter ("alert_text",'');
|
||||
$time_threshold = get_parameter ("time_threshold",900);
|
||||
$max_alerts = get_parameter ("max_alerts",1);
|
||||
$min_alerts = get_parameter ("min_alerts",0);
|
||||
$time_from = get_parameter ("time_from");
|
||||
$time_to= get_parameter ("time_to");
|
||||
$other = get_parameter ("other",0);
|
||||
$disable_alert = get_parameter ("disable_alert");
|
||||
$alert_d1 = get_parameter("alert_d1",0);
|
||||
$alert_d2 = get_parameter("alert_d2",0);
|
||||
$alert_d3 = get_parameter("alert_d3",0);
|
||||
$alert_d4 = get_parameter("alert_d4",0);
|
||||
$alert_d5 = get_parameter("alert_d5",0);
|
||||
$alert_d6 = get_parameter("alert_d6",0);
|
||||
$alert_d7 = get_parameter("alert_d7",0);
|
||||
$alert_recovery = get_parameter("alert_recovery", 1);
|
||||
$alert_priority = get_parameter("alert_priority", 0);
|
||||
$campo2_rec = get_parameter ("campo_2_rec","");
|
||||
$campo3_rec = get_parameter ("campo_3_rec","");
|
||||
$alert_d1 = get_parameter("alert_d1",0);
|
||||
$alert_d2 = get_parameter("alert_d2",0);
|
||||
$alert_d3 = get_parameter("alert_d3",0);
|
||||
$alert_d4 = get_parameter("alert_d4",0);
|
||||
$alert_d5 = get_parameter("alert_d5",0);
|
||||
$alert_d6 = get_parameter("alert_d6",0);
|
||||
$alert_d7 = get_parameter("alert_d7",0);
|
||||
$alert_recovery = get_parameter("alert_recovery", 1);
|
||||
$alert_priority = get_parameter("alert_priority", 0);
|
||||
$campo2_rec = get_parameter ("campo_2_rec","");
|
||||
$campo3_rec = get_parameter ("campo_3_rec","");
|
||||
if ($time_threshold == -1) {
|
||||
$time_threshold = $other;
|
||||
}
|
||||
|
||||
$sql = sprintf ("UPDATE talerta_agente_modulo SET
|
||||
id_alerta = %d,
|
||||
max_alerts = %d,
|
||||
min_alerts = %d,
|
||||
time_threshold = '%s',
|
||||
dis_min = %f,
|
||||
dis_max = %f,
|
||||
al_campo3 = '%s',
|
||||
al_campo2 = '%s',
|
||||
al_campo1 = '%s',
|
||||
descripcion = '%s',
|
||||
alert_text = '%s',
|
||||
time_to = '%s',
|
||||
time_from = '%s',
|
||||
disable = %d,
|
||||
monday = %d,
|
||||
tuesday = %d,
|
||||
wednesday = %d,
|
||||
thursday = %d,
|
||||
friday = %d,
|
||||
saturday = %d,
|
||||
sunday = %d,
|
||||
recovery_notify = %d,
|
||||
priority = %d,
|
||||
al_f2_recovery = '%s',
|
||||
al_f3_recovery = '%s'
|
||||
WHERE id_aam = %d", $tipo_alerta, $max_alerts, $min_alerts, $time_threshold, $minimo, $maximo, $campo_3, $campo_2, $campo_1, $descripcion, $alert_text,
|
||||
$time_to, $time_from, $disable_alert, $alert_d1, $alert_d2, $alert_d3, $alert_d4, $alert_d5, $alert_d6, $alert_d7, $alert_recovery, $alert_priority,
|
||||
$campo2_rec, $campo3_rec, $id_aam);
|
||||
$result = process_sql ($sql);
|
||||
if ($result === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem updating alert').'</h3>';
|
||||
} else {
|
||||
echo '<h3 class="suc">'.__('Alert successfully updated').'</h3>';
|
||||
}
|
||||
}
|
||||
|
||||
// ================
|
||||
// Update AGENT
|
||||
// ================
|
||||
|
@ -625,54 +444,6 @@ if ((isset ($_GET["update_module"])) && (!isset ($_POST["oid"])) && (!isset ($_P
|
|||
}
|
||||
}
|
||||
|
||||
// Read ALERT data if editing alert
|
||||
// ==================================
|
||||
if (isset ($_GET["update_alert"])) {
|
||||
$id_grupo = dame_id_grupo ($id_agente);
|
||||
if (give_acl ($config["id_user"], $id_grupo, "LW") == 0){
|
||||
audit_db($config["id_user"],$REMOTE_ADDR, "ACL Violation","Trying to update an alert without admin rights");
|
||||
require ("general/noaccess.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$update_alert = 1;
|
||||
$id_aam = (int) get_parameter_get ("update_alert",0);
|
||||
$alert = get_db_row ('talerta_agente_modulo', 'id_aam', $id_aam);
|
||||
|
||||
if ($alert === false) {
|
||||
echo '<h3 class="error">'.__('There was a problem loading the alert').'</h3>';
|
||||
} else {
|
||||
$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"];
|
||||
}
|
||||
}
|
||||
|
||||
// GET DATA for MODULE UPDATE OR MODULE INSERT
|
||||
// ===========================================
|
||||
if ((isset ($_POST["update_module"])) || (isset ($_POST["insert_module"]))) {
|
||||
|
@ -889,24 +660,20 @@ if (isset ($_GET["delete_module"])){ // DELETE agent module !
|
|||
|
||||
switch ($tab) {
|
||||
case "main":
|
||||
require "agent_manager.php";
|
||||
require ("agent_manager.php");
|
||||
break;
|
||||
case "module":
|
||||
if (($form_moduletype == "") && ($moduletype == "")) {
|
||||
require "module_manager.php";
|
||||
require ("module_manager.php");
|
||||
} else {
|
||||
require "module_manager_editor.php";
|
||||
require ("module_manager_editor.php");
|
||||
}
|
||||
break;
|
||||
case "alert":
|
||||
if (($form_alerttype == "") && (!isset($_GET["update_alert"]))) {
|
||||
require "alert_manager.php";
|
||||
} else {
|
||||
require "alert_manager_editor.php";
|
||||
}
|
||||
require ("alert_manager.php");
|
||||
break;
|
||||
case "template":
|
||||
require "agent_template.php";
|
||||
require ("agent_template.php");
|
||||
break;
|
||||
default:
|
||||
if (enterprise_hook ('switch_agent_tab', array ($tab)))
|
||||
|
|
|
@ -29,12 +29,12 @@ if (! give_acl ($config['id_user'], 0, "LM")) {
|
|||
}
|
||||
|
||||
|
||||
$id_group = get_parameter ("id_group", 0);
|
||||
$origen = get_parameter ("origen", -1);
|
||||
$update_agent = get_parameter ("update_agent", -1);
|
||||
$update_group = get_parameter ("update_group", -1);
|
||||
$destino = get_parameter_post ("destino",array ());
|
||||
$origen_modulo = get_parameter_post ("origen_modulo", array ());
|
||||
$id_group = (int) get_parameter ("id_group");
|
||||
$origen = (int) get_parameter_post ("origen", -1);
|
||||
$update_agent = (int) get_parameter ("update_agent", -1);
|
||||
$update_group = (int) get_parameter ("update_group", -1);
|
||||
$destino = (array) get_parameter_post ("destino", array ());
|
||||
$origen_modulo = (array) get_parameter_post ("origen_modulo", array ());
|
||||
|
||||
// Operations
|
||||
// ---------------
|
||||
|
@ -53,31 +53,24 @@ if (isset($_POST["copy"])) {
|
|||
echo '<h3 class="error">ERROR: '.__('No modules have been selected').'</h3>';
|
||||
return;
|
||||
}
|
||||
|
||||
// If selected modules or alerts
|
||||
if (isset($_POST["modules"])) {
|
||||
$modulos = 1;
|
||||
} else {
|
||||
$modulos = 0;
|
||||
}
|
||||
|
||||
if (isset($_POST["alerts"])) {
|
||||
$alertas = 1;
|
||||
} else {
|
||||
$alertas = 0;
|
||||
}
|
||||
|
||||
if (($alertas + $modulos) == 0){
|
||||
$copy_modules = (bool) get_parameter ('modules');
|
||||
$copy_alerts = (bool) get_parameter ('alerts');
|
||||
|
||||
if (! $copy_alerts && ! $copy_modules) {
|
||||
echo '<h3 class="error">ERROR: '.__('You must check modules and/or alerts to be copied').'</h3>';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
require_once ("include/functions_alerts.php");
|
||||
|
||||
$origin_name = get_agent_name ($origen);
|
||||
|
||||
// Copy
|
||||
// ----
|
||||
$errors = 0;
|
||||
$id_new_module = 0;
|
||||
process_sql ("SET AUTOCOMMIT = 0;");
|
||||
process_sql ("START TRANSACTION;"); //Start a transaction
|
||||
process_sql ("START TRANSACTION;");
|
||||
|
||||
foreach ($origen_modulo as $id_module) {
|
||||
//For each selected module
|
||||
|
@ -85,9 +78,10 @@ if (isset($_POST["copy"])) {
|
|||
|
||||
foreach ($destino as $id_agent_dest) {
|
||||
//For each destination agent
|
||||
$destiny_name = get_agent_name ($id_agent_dest);
|
||||
|
||||
if ($modulos == 1) {
|
||||
echo '<br /><br />'.__('Copying module').'<b> ['.get_agent_name ($origen).' - '.$module["nombre"].'] -> ['.get_agent_name ($id_agent_dest).']</b>';
|
||||
if ($copy_modules) {
|
||||
echo '<br /><br />'.__('Copying module').'<b> ['.$origin_name.' - '.$module["nombre"].'] -> ['.$destiny_name.']</b>';
|
||||
$sql = sprintf ('INSERT INTO tagente_modulo
|
||||
(id_agente, id_tipo_modulo, descripcion,
|
||||
nombre, max, min, module_interval,
|
||||
|
@ -151,70 +145,64 @@ if (isset($_POST["copy"])) {
|
|||
}//If empty id_new_module
|
||||
} //If modulos
|
||||
|
||||
if ($alertas == 1) {
|
||||
if ($copy_alerts) {
|
||||
if (empty ($id_new_module)) {
|
||||
//If we didn't copy modules or if we
|
||||
//didn't create new modules we have to
|
||||
//look for the module id
|
||||
$sql = sprintf ("SELECT id_agente_modulo FROM tagente_modulo WHERE nombre = '%s' AND id_agente = %d", $module["nombre"], $id_agent_dest);
|
||||
$sql = sprintf ('SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre = "%s"
|
||||
AND id_agente = %d',
|
||||
$module['nombre'], $id_agent_dest);
|
||||
$id_new_module = get_db_sql ($sql);
|
||||
if (empty ($id_new_module)) {
|
||||
continue; //If we can't find a module belonging to this agent with the same name, skip the loop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$module_alerts = get_db_all_rows_field_filter ("talerta_agente_modulo", "id_agente_modulo", $id_module);
|
||||
if (empty ($module_alerts)) {
|
||||
$module_alerts = array ();
|
||||
if (empty ($id_new_module))
|
||||
// We can't find a module belonging to this agent
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($module_alerts as $alert) {
|
||||
echo '<br /><br />'.__('Copying alert').'<b> ['.get_agent_name ($origen).' - '.$module["nombre"].'] -> ['.get_agent_name ($id_agent_dest).']</b>';
|
||||
$alerts = get_db_all_rows_field_filter ('talert_template_modules',
|
||||
'id_agent_module', $id_module);
|
||||
if (empty ($alerts))
|
||||
// The module doesn't have alerts
|
||||
continue;
|
||||
|
||||
foreach ($alerts as $alert) {
|
||||
echo '<br />'.__('Copying alert').'<b> ['.$origin_name.' - '.$module["nombre"].'] -> ['.$destiny_name.']</b>';
|
||||
if (!empty ($alert["id_agent"])) {
|
||||
//Compound alert
|
||||
$alert["id_agent"] = $id_agent_dest;
|
||||
}
|
||||
$sql = sprintf ("INSERT INTO talerta_agente_modulo
|
||||
(id_agente_modulo, id_alerta, al_campo1, al_campo2, al_campo3, descripcion, dis_max, dis_min,
|
||||
time_threshold, max_alerts, module_type, min_alerts, alert_text, disable, time_from,
|
||||
time_to, id_agent, monday, tuesday, wednesday, thursday, friday, saturday, sunday,
|
||||
recovery_notify, priority, al_f2_recovery, al_f3_recovery)
|
||||
VALUES (
|
||||
%d,%d,'%s','%s','%s','%s',%d,%d,
|
||||
%d,%d,%d,%d,'%s',%d,'%s',
|
||||
'%s',%d,%d,%d,%d,%d,%d,%d,%d,
|
||||
%d,%d,'%s','%s')",
|
||||
$id_new_module,$alert["id_alerta"],$alert["al_campo1"],$alert["al_campo2"],$alert["al_campo3"],$alert["descripcion"],$alert["dis_max"],$alert["dis_min"],
|
||||
$alert["time_threshold"],$alert["max_alerts"],$alert["module_type"],$alert["min_alerts"],$alert["alert_text"],$alert["disable"],$alert["time_from"],
|
||||
$alert["time_to"],$alert["id_agent"],$alert["monday"],$alert["tuesday"],$alert["wednesday"],$alert["thursday"],$alert["friday"],$alert["saturday"],$alert["sunday"],
|
||||
$alert["recovery_notify"],$alert["priority"],$alert["al_f2_recovery"],$alert["al_f3_recovery"]);
|
||||
$values = array ('id_agent_module' => (int) $id_new_module,
|
||||
'id_alert_template' => (int) $alert['id_alert_template']);
|
||||
$id_alert = process_sql_insert ('talert_template_modules',
|
||||
$values);
|
||||
|
||||
$new_alert = process_sql ($sql, "insert_id");
|
||||
|
||||
if ($new_alert === false) {
|
||||
if ($id_alert === false) {
|
||||
$errors++;
|
||||
} elseif (!empty ($alert["id_agent"])) {
|
||||
$sql = sprintf ("SELECT operation FROM tcompound_alert WHERE id_aam = %d", $alert["id_aam"]);
|
||||
$result = get_db_all_row_sql ($sql);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$actions = get_alert_agent_module_actions ($alert['id']);
|
||||
if (empty ($actions))
|
||||
continue;
|
||||
foreach ($actions as $action) {
|
||||
$values = array ('id_alert_template_module' => (int) $id_alert,
|
||||
'id_alert_action' => (int) $action['id'],
|
||||
'fires_min' => (int) $action['fires_min'],
|
||||
'fires_max' => (int) $action['fires_max']);
|
||||
$result = process_sql_insert ('talert_template_module_actions',
|
||||
$values);
|
||||
if ($result === false)
|
||||
/* This alert is supposed to be part of a
|
||||
compound alert but there is no entry for
|
||||
it in the tcompound_alert table so we skip this */
|
||||
continue;
|
||||
foreach ($result as $comp_alert) {
|
||||
$sql = sprintf ("INSERT INTO tcompound_alert (id_aam, operation) VALUES (%d, '%s')",$new_alert,$comp_alert["operation"]);
|
||||
$result = process_sql ($sql);
|
||||
if ($result === false)
|
||||
$errors++;
|
||||
} //foreach compound alert
|
||||
} //if-elseif compound alert
|
||||
$errors++;
|
||||
}
|
||||
|
||||
/* TODO: Copy compound alerts */
|
||||
|
||||
} //foreach alert
|
||||
} //if alerts
|
||||
} //Foreach destino
|
||||
} //Foreach origen_modulo
|
||||
|
||||
if ($errors > 1) {
|
||||
echo '<h3 class="error">'.__('There was an error copying the module, the copy has been cancelled').'</h3>';
|
||||
process_sql ("ROLLBACK;");
|
||||
|
@ -289,8 +277,9 @@ if (isset ($_POST["delete"])) {
|
|||
|
||||
if ($alertas == 1) {
|
||||
//Alert
|
||||
temp_sql_delete ("tcompound_alert", "id_aam", "ANY(SELECT id_aam FROM talerta_agente_modulo WHERE id_agente_modulo = ".$id_module_dest.")");
|
||||
temp_sql_delete ("talerta_agente_modulo", "id_agente_modulo", $id_module_dest);
|
||||
/* TODO: Delete compound alerts */
|
||||
|
||||
temp_sql_delete ('talert_template_modules', "id_agent_module", $id_module_dest);
|
||||
}
|
||||
|
||||
if ($modulos == 1) {
|
||||
|
|
|
@ -1,104 +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;
|
||||
}
|
||||
// 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');
|
||||
}
|
||||
pandora_help ("manage_alerts");
|
||||
echo "</h2>";
|
||||
?>
|
||||
<form name="alerta" method="post" action="index.php?sec=galertas&sec2=godmode/alerts/modify_alert&id_alerta=<?php echo $id_alerta ?>">
|
||||
|
||||
<?php
|
||||
if ($creacion_alerta == 1)
|
||||
echo "<input type='hidden' name='crear_alerta' value='1'>";
|
||||
else {
|
||||
echo "<input type='hidden' name='update_alerta' value='1'>";
|
||||
echo "<input type='hidden' name='id_alerta' value='".$id_alerta."'>";
|
||||
}
|
||||
?>
|
||||
<table width="500" cellspacing="4" cellpadding="4" class="databox_color">
|
||||
<tr><td class="datos"><?php echo __('Alert name') ?></td>
|
||||
<td class="datos">
|
||||
<input type="text" name="nombre" size=30 value="<?php echo $nombre ?>"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="datos2"><?php echo __('Command') ?></td>
|
||||
<td class="datos2">
|
||||
<input type="text" name="comando" size="50" value="<?php echo $comando ?>">
|
||||
</td></tr>
|
||||
<tr><td class="datos"><?php echo __('Description') ?></td>
|
||||
<td class="datos"><textarea name="descripcion" cols="50" rows="7">
|
||||
<?php echo $descripcion ?>
|
||||
</textarea>
|
||||
</td></tr>
|
||||
</table>
|
||||
<table width=500>
|
||||
<tr><td align="right">
|
||||
<?php
|
||||
if (isset($_GET["creacion"])){
|
||||
echo "<input name='crtbutton' type='submit' class='sub wand' value='".__('Create')."'>";
|
||||
} else {
|
||||
echo "<input name='uptbutton' type='submit' class='sub upd' value='".__('Update')."'>";
|
||||
} ?>
|
||||
</form>
|
||||
|
||||
</table>
|
|
@ -400,7 +400,7 @@ if ($edit_sla_report_content) {
|
|||
$periods[360] = __('2 weeks');
|
||||
$periods[720] = __('1 month');
|
||||
$periods[4320] = __('6 months');
|
||||
$table->data[1][1] = print_select ($periods, 'period', 0, '', '--', 0, true);
|
||||
$table->data[1][1] = print_select ($periods, 'period', 0, '', '--', 0, true, false, false);
|
||||
|
||||
$table->data[2][0] = __('Source agent');
|
||||
$table->data[2][1] = print_select ($agents, 'id_agent', $id_agent, '', '--', 0, true);
|
||||
|
|
|
@ -43,13 +43,13 @@ function get_agent_alerts_simple ($id_agent, $filter = false) {
|
|||
}
|
||||
|
||||
$id_modules = array_keys (get_agent_modules ($id_agent));
|
||||
|
||||
//$modules = ();
|
||||
if (empty ($id_modules))
|
||||
return array ();
|
||||
|
||||
$sql = sprintf ("SELECT talert_template_modules.*
|
||||
FROM talert_template_modules
|
||||
WHERE id_agent_module in (%s)",
|
||||
$id_agent, implode (",", $id_modules));
|
||||
WHERE id_agent_module in (%s)%s",
|
||||
implode (",", $id_modules), $filter);
|
||||
|
||||
$alerts = get_db_all_rows_sql ($sql);
|
||||
|
||||
|
@ -66,6 +66,8 @@ function get_agent_alerts_simple ($id_agent, $filter = false) {
|
|||
* @return array An array with all combined alerts defined for an agent.
|
||||
*/
|
||||
function get_agent_alerts_combined ($id_agent, $filter = false) {
|
||||
/* TODO: Combined alerts */
|
||||
return array ();
|
||||
switch ($filter) {
|
||||
case "notfired":
|
||||
$filter = ' AND times_fired = 0 AND disable = 0';
|
||||
|
@ -79,7 +81,14 @@ function get_agent_alerts_combined ($id_agent, $filter = false) {
|
|||
default:
|
||||
$filter = '';
|
||||
}
|
||||
$sql = sprintf ("SELECT * FROM talerta_agente_modulo WHERE id_agent = %d%s", $id_agent, $filter);
|
||||
|
||||
$id_modules = array_keys (get_agent_modules ($id_agent));
|
||||
if (empty ($id_modules))
|
||||
return array ();
|
||||
|
||||
$sql = sprintf ("SELECT * FROM talert_template_modules
|
||||
WHERE id_agent_module IN (%s)%s",
|
||||
implode (',', $id_modules), $filter);
|
||||
$alerts = get_db_all_rows_sql ($sql);
|
||||
|
||||
if ($alerts === false)
|
||||
|
|
|
@ -635,22 +635,22 @@ function get_monitors_down ($monitors, $period = 0, $date = 0) {
|
|||
/**
|
||||
* Get all the times an alerts fired during a period.
|
||||
*
|
||||
* @param int $id_agent_module Agent module of the alert.
|
||||
* @param int $period Period timed to check from date
|
||||
* @param int $date Date to check (now by default)
|
||||
* @param int Alert module id.
|
||||
* @param int Period timed to check from date
|
||||
* @param int Date to check (current time by default)
|
||||
*
|
||||
* @return int The number of times an alert fired.
|
||||
*/
|
||||
function get_alert_fires_in_period ($id_agent_module, $period, $date = 0) {
|
||||
function get_alert_fires_in_period ($id_alert_module, $period, $date = 0) {
|
||||
if (!$date)
|
||||
$date = get_system_time ();
|
||||
$datelimit = $date - $period;
|
||||
$sql = sprintf ("SELECT COUNT(`id_agentmodule`) FROM `tevento` WHERE
|
||||
`event_type` = 'alert_fired'
|
||||
AND `id_agentmodule` = %d
|
||||
AND `id_alert_am` = %d
|
||||
AND `utimestamp` > %d
|
||||
AND `utimestamp` <= %d",
|
||||
$id_agent_module, $datelimit, $date);
|
||||
$id_alert_module, $datelimit, $date);
|
||||
return (int) get_db_sql ($sql);
|
||||
}
|
||||
|
||||
|
@ -666,7 +666,7 @@ function get_alert_fires_in_period ($id_agent_module, $period, $date = 0) {
|
|||
function get_group_alerts ($id_group) {
|
||||
$alerts = array ();
|
||||
$agents = get_group_agents ($id_group, false, "none");
|
||||
|
||||
require_once ('include/functions_agents.php');
|
||||
foreach ($agents as $agent_id => $agent_name) {
|
||||
$agent_alerts = get_agent_alerts ($agent_id);
|
||||
$alerts = array_merge ($alerts, $agent_alerts);
|
||||
|
@ -678,9 +678,9 @@ function get_group_alerts ($id_group) {
|
|||
/**
|
||||
* Get all the alerts fired during a period, given a list of alerts.
|
||||
*
|
||||
* @param array $alerts A list of alerts to check. See get_alerts_in_group()
|
||||
* @param int $period Period of time to check fired alerts.
|
||||
* @param int $date Beginning date to check fired alerts in UNIX format (current date by default)
|
||||
* @param array A list of alert modules to check. See get_alerts_in_group()
|
||||
* @param int Period of time to check fired alerts.
|
||||
* @param int Beginning date to check fired alerts in UNIX format (current date by default)
|
||||
*
|
||||
* @return array An array with the alert id as key and the number of times
|
||||
* the alert was fired (only included if it was fired).
|
||||
|
@ -693,11 +693,11 @@ function get_alerts_fired ($alerts, $period = 0, $date = 0) {
|
|||
$alerts_fired = array ();
|
||||
$agents = array ();
|
||||
foreach ($alerts as $alert) {
|
||||
$fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date);
|
||||
$fires = get_alert_fires_in_period ($alert['id'], $period, $date);
|
||||
if (! $fires) {
|
||||
continue;
|
||||
}
|
||||
$alerts_fired[$alert['id_aam']] = $fires;
|
||||
$alerts_fired[$alert['id']] = $fires;
|
||||
}
|
||||
return $alerts_fired;
|
||||
}
|
||||
|
@ -705,30 +705,30 @@ function get_alerts_fired ($alerts, $period = 0, $date = 0) {
|
|||
/**
|
||||
* Get the last time an alert fired during a period.
|
||||
*
|
||||
* @param int $id_agent_module Agent module of the monitor.
|
||||
* @param int $period Period timed to check from date
|
||||
* @param int $date Date to check (now by default)
|
||||
* @param int Alert agent module id.
|
||||
* @param int Period timed to check from date
|
||||
* @param int Date to check (current date by default)
|
||||
*
|
||||
* @return int The last time an alert fired.
|
||||
* @return int The last time an alert fired. It's an UNIX timestamp.
|
||||
*/
|
||||
function get_alert_last_fire_timestamp_in_period ($id_agent_module, $period, $date = 0) {
|
||||
function get_alert_last_fire_timestamp_in_period ($id_alert_module, $period, $date = 0) {
|
||||
if ($date == 0) {
|
||||
$date = get_system_time ();
|
||||
}
|
||||
$datelimit = $date - $period;
|
||||
$sql = sprintf ("SELECT MAX(`timestamp`) FROM `tevento` WHERE
|
||||
$sql = sprintf ("SELECT MAX(`utimestamp`) FROM `tevento` WHERE
|
||||
`event_type` = 'alert_fired'
|
||||
AND `id_agentmodule` = %d
|
||||
AND `id_alert_am` = %d
|
||||
AND `utimestamp` > %d
|
||||
AND `utimestamp` <= %d",
|
||||
$id_agent_module, $datelimit, $date);
|
||||
$id_alert_module, $datelimit, $date);
|
||||
return get_db_sql ($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server name.
|
||||
*
|
||||
* @param int $id_server Server id.
|
||||
* @param int Server id.
|
||||
*
|
||||
* @return string Name of the given server
|
||||
*/
|
||||
|
@ -798,7 +798,7 @@ function dame_id_grupo ($id_agent) {
|
|||
* In case an array is passed, it will have a value for every agent passed
|
||||
* incl. a total otherwise it will just return the total
|
||||
*
|
||||
* @param mixed $id_agent Agent id or array of agent id's, 0 for all
|
||||
* @param mixed Agent id or array of agent id's, 0 for all
|
||||
*
|
||||
* @return mixed The number of data in the database
|
||||
*/
|
||||
|
@ -846,7 +846,7 @@ function get_agent_modules_data_count ($id_agent = 0) {
|
|||
/**
|
||||
* Get the operating system name.
|
||||
*
|
||||
* @param int id_os Operating system id.
|
||||
* @param int Operating system id.
|
||||
*
|
||||
* @return string Name of the given operating system.
|
||||
*/
|
||||
|
@ -869,7 +869,7 @@ function update_user_contact ($id_user) {
|
|||
/**
|
||||
* Get the user email
|
||||
*
|
||||
* @param string $id_user User id.
|
||||
* @param string User id.
|
||||
*
|
||||
* @return string Get the email address of an user
|
||||
*/
|
||||
|
@ -880,7 +880,7 @@ function dame_email ($id_user) {
|
|||
/**
|
||||
* Checks if a user is administrator.
|
||||
*
|
||||
* @param string $id_user User id.
|
||||
* @param string User id.
|
||||
*
|
||||
* @return bool True is the user is admin
|
||||
*/
|
||||
|
@ -903,14 +903,16 @@ function comprueba_login () {
|
|||
/**
|
||||
* Check if an agent has alerts fired.
|
||||
*
|
||||
* @param int $id_agent Agent id.
|
||||
* @param int Agent id.
|
||||
*
|
||||
* @return bool True if the agent has fired alerts.
|
||||
*/
|
||||
function check_alert_fired ($id_agent) {
|
||||
$sql = "SELECT COUNT(*) FROM talerta_agente_modulo, tagente_modulo
|
||||
WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||
AND times_fired > 0 AND id_agente = ".$id_agent;
|
||||
$sql = sprintf ("SELECT COUNT(*)
|
||||
FROM talert_template_modules, tagente_modulo
|
||||
WHERE talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo
|
||||
AND times_fired > 0 AND id_agente = %d",
|
||||
$id_agent);
|
||||
|
||||
$value = get_db_sql ($sql);
|
||||
if ($value > 0)
|
||||
|
@ -921,7 +923,7 @@ function check_alert_fired ($id_agent) {
|
|||
/**
|
||||
* Check is a user exists in the system
|
||||
*
|
||||
* @param string $id_user User id.
|
||||
* @param string User id.
|
||||
*
|
||||
* @return bool True if the user exists.
|
||||
*/
|
||||
|
@ -937,7 +939,7 @@ function existe ($id_user) {
|
|||
*
|
||||
* If the module interval is not set, the agent interval is returned
|
||||
*
|
||||
* @param int $id_agent_module Id agent module to get the interval value.
|
||||
* @param int Id agent module to get the interval value.
|
||||
*
|
||||
* @return int Module interval or agent interval if no module interval
|
||||
*/
|
||||
|
@ -953,7 +955,7 @@ function get_module_interval ($id_agent_module) {
|
|||
/**
|
||||
* Get the interval of an agent.
|
||||
*
|
||||
* @param int $id_agent Agent id.
|
||||
* @param int Agent id.
|
||||
*
|
||||
* @return int The interval value of a given agent
|
||||
*/
|
||||
|
@ -964,7 +966,7 @@ function get_agent_interval ($id_agent) {
|
|||
/**
|
||||
* Get the flag value of an agent module.
|
||||
*
|
||||
* @param int $id_agent_module Agent module id.
|
||||
* @param int Agent module id.
|
||||
*
|
||||
* @return bool The flag value of an agent module.
|
||||
*/
|
||||
|
@ -979,8 +981,8 @@ function give_agentmodule_flag ($id_agent_module) {
|
|||
* @deprecated Use get_user_groups () in combination with print_select ()
|
||||
* instead
|
||||
*
|
||||
* @param string $id_user User id
|
||||
* @param bool $show_all Flag to show all the groups or not. True by default.
|
||||
* @param string User id
|
||||
* @param bool Flag to show all the groups or not. True by default.
|
||||
*
|
||||
* @return array An array with all the groups
|
||||
*/
|
||||
|
@ -1005,7 +1007,7 @@ function list_group ($id_user, $show_all = 1){
|
|||
*
|
||||
* @deprecated Use get_user_groups () instead
|
||||
*
|
||||
* @param int $id_user User id
|
||||
* @param int User id
|
||||
*
|
||||
* @return array A list of the groupid => groups the user has reading privileges.
|
||||
*/
|
||||
|
@ -1026,7 +1028,7 @@ function list_group2 ($id_user) {
|
|||
/**
|
||||
* Get a list of all users in an array [username] => real name
|
||||
*
|
||||
* @param string $order by (id_usuario, nombre_real or fecha_registro)
|
||||
* @param string Field to order by (id_usuario, nombre_real or fecha_registro)
|
||||
*
|
||||
* @return array An array of users
|
||||
*/
|
||||
|
@ -1055,8 +1057,9 @@ function list_users ($order = "nombre_real") {
|
|||
/**
|
||||
* Get all the groups a user has reading privileges.
|
||||
*
|
||||
* @param string $id_user User id
|
||||
* @param string $privilege The privilege to evaluate
|
||||
* @param string User id
|
||||
* @param string The privilege to evaluate
|
||||
*
|
||||
* @return array A list of the groups the user has certain privileges.
|
||||
*/
|
||||
function get_user_groups ($id_user = 0, $privilege = "AR") {
|
||||
|
@ -1086,7 +1089,7 @@ function get_user_groups ($id_user = 0, $privilege = "AR") {
|
|||
* TODO: Create print_moduletype_icon and print the full tag including hover etc.
|
||||
* @deprecated Use print_moduletype_icon instead
|
||||
*
|
||||
* @param int $id_type Module type id
|
||||
* @param int Module type id
|
||||
*
|
||||
* @return string Icon filename of the given group
|
||||
*/
|
||||
|
@ -1100,7 +1103,7 @@ function show_icon_type ($id_type) {
|
|||
*
|
||||
* @deprecated Use print_servertype_icon instead
|
||||
*
|
||||
* @param int $id Server type id
|
||||
* @param int Server type id
|
||||
*
|
||||
* @return string Fully formatted IMG HTML tag with icon
|
||||
*/
|
||||
|
@ -1129,7 +1132,7 @@ function show_server_type ($id) {
|
|||
/**
|
||||
* Get a module category name
|
||||
*
|
||||
* @param id_category Id category
|
||||
* @param int Id category
|
||||
*
|
||||
* @return Name of the given category
|
||||
*/
|
||||
|
@ -1154,7 +1157,7 @@ function give_modulecategory_name ($id_category) {
|
|||
/**
|
||||
* Get a network component group name
|
||||
*
|
||||
* @param int $id_network_component_group Id network component group.
|
||||
* @param int Id network component group.
|
||||
*
|
||||
* @return string Name of the given network component group
|
||||
*/
|
||||
|
@ -1165,7 +1168,7 @@ function give_network_component_group_name ($id_network_component_group) {
|
|||
/**
|
||||
* Get a network profile name.
|
||||
*
|
||||
* @param int $id_network_profile Id network profile
|
||||
* @param int Id network profile
|
||||
*
|
||||
* @return string Name of the given network profile.
|
||||
*/
|
||||
|
@ -1176,8 +1179,8 @@ function get_networkprofile_name ($id_network_profile) {
|
|||
/**
|
||||
* Assign an IP address to an agent.
|
||||
*
|
||||
* @param int id_agent Agent id
|
||||
* @param string ip_address IP address to assign
|
||||
* @param int Agent id
|
||||
* @param string IP address to assign
|
||||
*/
|
||||
function agent_add_address ($id_agent, $ip_address) {
|
||||
// Check if already is attached to agent
|
||||
|
@ -1207,8 +1210,8 @@ function agent_add_address ($id_agent, $ip_address) {
|
|||
/**
|
||||
* Unassign an IP address from an agent.
|
||||
*
|
||||
* @param int $id_agent Agent id
|
||||
* @param string $ip_address IP address to unassign
|
||||
* @param int Agent id
|
||||
* @param string IP address to unassign
|
||||
*/
|
||||
function agent_delete_address ($id_agent, $ip_address) {
|
||||
$sql = sprintf ("SELECT id_ag FROM taddress_agent, taddress
|
||||
|
@ -1231,7 +1234,7 @@ function agent_delete_address ($id_agent, $ip_address) {
|
|||
/**
|
||||
* Get address of an agent.
|
||||
*
|
||||
* @param int $id_agent Agent id
|
||||
* @param int Agent id
|
||||
*
|
||||
* @return string The address of the given agent
|
||||
*/
|
||||
|
@ -1242,7 +1245,7 @@ function get_agent_address ($id_agent) {
|
|||
/**
|
||||
* Get the agent that matches an IP address
|
||||
*
|
||||
* @param string $ip_address IP address to get the agents.
|
||||
* @param string IP address to get the agents.
|
||||
*
|
||||
* @return mixed The agent that has the IP address given. False if none were found.
|
||||
*/
|
||||
|
@ -1258,7 +1261,7 @@ function get_agent_with_ip ($ip_address) {
|
|||
/**
|
||||
* Get all IP addresses of an agent
|
||||
*
|
||||
* @param int $id_agent Agent id
|
||||
* @param int Agent id
|
||||
*
|
||||
* @return array Array with the IP address of the given agent or an empty array.
|
||||
*/
|
||||
|
@ -1284,7 +1287,7 @@ function get_agent_addresses ($id_agent) {
|
|||
/**
|
||||
* Get agent id from an agent module.
|
||||
*
|
||||
* @param int id_agent_module Id of the agent module.
|
||||
* @param int Id of the agent module.
|
||||
*
|
||||
* @return int The agent if of the given module.
|
||||
*/
|
||||
|
@ -1297,10 +1300,10 @@ $sql_cache = array ('saved' => 0);
|
|||
/**
|
||||
* Get the first value of the first row of a table in the database.
|
||||
*
|
||||
* @param string $field Field name to get
|
||||
* @param string $table Table to retrieve the data
|
||||
* @param string $field_search Field to filter elements
|
||||
* @param string $condition Condition the field must have
|
||||
* @param string Field name to get
|
||||
* @param string Table to retrieve the data
|
||||
* @param string Field to filter elements
|
||||
* @param string Condition the field must have
|
||||
*
|
||||
* @return mixed Value of first column of the first row. False if there were no row.
|
||||
*/
|
||||
|
@ -1326,7 +1329,7 @@ function get_db_value ($field, $table, $field_search = 1, $condition = 1) {
|
|||
/**
|
||||
* Get the first row of an SQL database query.
|
||||
*
|
||||
* @param string $sql SQL select statement to execute.
|
||||
* @param string SQL select statement to execute.
|
||||
*
|
||||
* @return mixed The first row of the result or false
|
||||
*/
|
||||
|
@ -1346,9 +1349,9 @@ function get_db_row_sql ($sql) {
|
|||
* The SQL statement executed would be something like:
|
||||
* "SELECT * FROM $table WHERE $field_search = $condition"
|
||||
*
|
||||
* @param string $table Table to get the row
|
||||
* @param string $field_search Field to filter elementes
|
||||
* @param string $condition Condition the field must have.
|
||||
* @param string Table to get the row
|
||||
* @param string Field to filter elementes
|
||||
* @param string Condition the field must have.
|
||||
*
|
||||
* @return mixed The first row of a database query or false.
|
||||
*/
|
||||
|
@ -1372,8 +1375,8 @@ function get_db_row ($table, $field_search, $condition) {
|
|||
/**
|
||||
* Get a single field in the databse from a SQL query.
|
||||
*
|
||||
* @param string $sql SQL statement to execute
|
||||
* @param mixed $field Field number or row to get, beggining by 0. Default: 0
|
||||
* @param string SQL statement to execute
|
||||
* @param mixed Field number or row to get, beggining by 0. Default: 0
|
||||
*
|
||||
* @return mixed The selected field of the first row in a select statement.
|
||||
*/
|
||||
|
@ -1388,7 +1391,7 @@ function get_db_sql ($sql, $field = 0) {
|
|||
/**
|
||||
* Get all the result rows using an SQL statement.
|
||||
*
|
||||
* @param string $sql SQL statement to execute.
|
||||
* @param string SQL statement to execute.
|
||||
*
|
||||
* @return mixed A matrix with all the values returned from the SQL statement or
|
||||
* false in case of empty result
|
||||
|
@ -1405,10 +1408,10 @@ function get_db_all_rows_sql ($sql) {
|
|||
/**
|
||||
* Error handler function when an SQL error is triggered.
|
||||
*
|
||||
* @param int $errno Level of the error raised (not used, but required by set_error_handler()).
|
||||
* @param string $errstr Contains the error message.
|
||||
* @param int Level of the error raised (not used, but required by set_error_handler()).
|
||||
* @param string Contains the error message.
|
||||
*
|
||||
* @return bool
|
||||
* @return bool True if error level is lower or equal than errno.
|
||||
*/
|
||||
function sql_error_handler ($errno, $errstr) {
|
||||
if (error_reporting () <= $errno)
|
||||
|
@ -1423,9 +1426,9 @@ function sql_error_handler ($errno, $errstr) {
|
|||
* an empty array in case of SELECT without results
|
||||
* Queries that return data will be cached so queries don't get repeated
|
||||
*
|
||||
* @param string $sql SQL statement to execute
|
||||
* @param string SQL statement to execute
|
||||
*
|
||||
* @param string $rettype (optional) What type of info to return in case of INSERT/UPDATE.
|
||||
* @param string 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
|
||||
|
@ -1478,8 +1481,8 @@ function process_sql ($sql, $rettype = "affected_rows") {
|
|||
/**
|
||||
* Get all the rows in a table of the database.
|
||||
*
|
||||
* @param string $table Database table name.
|
||||
* @param string $order_field Field to order by.
|
||||
* @param string Database table name.
|
||||
* @param string Field to order by.
|
||||
*
|
||||
* @return mixed A matrix with all the values in the table
|
||||
*/
|
||||
|
@ -1494,10 +1497,10 @@ function get_db_all_rows_in_table ($table, $order_field = "") {
|
|||
/**
|
||||
* Get all the rows in a table of the databes filtering from a field.
|
||||
*
|
||||
* @param string $table Database table name.
|
||||
* @param string $field Field of the table.
|
||||
* @param string $condition Condition the field must have to be selected.
|
||||
* @param string $order_field Field to order by.
|
||||
* @param string Database table name.
|
||||
* @param string Field of the table.
|
||||
* @param string Condition the field must have to be selected.
|
||||
* @param string Field to order by.
|
||||
*
|
||||
* @return mixed A matrix with all the values in the table that matches the condition in the field or false
|
||||
*/
|
||||
|
@ -1518,8 +1521,8 @@ function get_db_all_rows_field_filter ($table, $field, $condition, $order_field
|
|||
/**
|
||||
* Get all the rows in a table of the databes filtering from a field.
|
||||
*
|
||||
* @param string $table Database table name.
|
||||
* @param string $field Field of the table.
|
||||
* @param string Database table name.
|
||||
* @param string Field of the table.
|
||||
*
|
||||
* @return mixed A matrix with all the values in the table that matches the condition in the field
|
||||
*/
|
||||
|
@ -1583,7 +1586,7 @@ function format_array_to_update_sql ($values) {
|
|||
/**
|
||||
* Get the status of an alert assigned to an agent module.
|
||||
*
|
||||
* @param int id_agentmodule Id agent module to check.
|
||||
* @param int Id agent module to check.
|
||||
*
|
||||
* @return bool True if there were alerts fired.
|
||||
*/
|
||||
|
@ -1592,8 +1595,8 @@ function return_status_agent_module ($id_agentmodule = 0) {
|
|||
|
||||
if ($status == 100) {
|
||||
// We need to check if there are any alert on this item
|
||||
$times_fired = get_db_value ('SUM(times_fired)', 'talerta_agente_modulo',
|
||||
'id_agente_modulo', $id_agentmodule);
|
||||
$times_fired = get_db_value ('SUM(times_fired)', 'talert_template_modules',
|
||||
'id_agent_module', $id_agentmodule);
|
||||
if ($times_fired > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -1613,7 +1616,7 @@ function return_status_agent_module ($id_agentmodule = 0) {
|
|||
* layouts), and makes an AND operation to be sure that all the items
|
||||
* are OK. If any of them is down, then result is down (0)
|
||||
*
|
||||
* @param int $id_layout Id of the layout
|
||||
* @param int Id of the layout
|
||||
*
|
||||
* @return bool The status of the given layout.
|
||||
*/
|
||||
|
@ -1644,7 +1647,7 @@ function return_status_layout ($id_layout = 0) {
|
|||
/**
|
||||
* Get the current value of an agent module.
|
||||
*
|
||||
* @param int $id_agentmodule
|
||||
* @param int Agent module id.
|
||||
*
|
||||
* @return int a numerically formatted value
|
||||
*/
|
||||
|
@ -1656,7 +1659,7 @@ function return_value_agent_module ($id_agentmodule) {
|
|||
/**
|
||||
* Get the X axis coordinate of a layout item
|
||||
*
|
||||
* @param int $id_layoutdata Id of the layout to get.
|
||||
* @param int Id of the layout to get.
|
||||
*
|
||||
* @return int The X axis coordinate value.
|
||||
*/
|
||||
|
@ -1667,7 +1670,7 @@ function get_layoutdata_x ($id_layoutdata) {
|
|||
/**
|
||||
* Get the Y axis coordinate of a layout item
|
||||
*
|
||||
* @param int $id_layoutdata Id of the layout to get.
|
||||
* @param int Id of the layout to get.
|
||||
*
|
||||
* @return int The Y axis coordinate value.
|
||||
*/
|
||||
|
@ -1683,8 +1686,8 @@ function get_layoutdata_y ($id_layoutdata){
|
|||
* before the beginning of the interval. All this calculation is due
|
||||
* to the data compression algorithm.
|
||||
*
|
||||
* @param int $id_agent_module Agent module id
|
||||
* @param int $utimestamp The timestamp to look backwards from and get the data.
|
||||
* @param int Agent module id
|
||||
* @param int The timestamp to look backwards from and get the data.
|
||||
*
|
||||
* @return mixed The row of tagente_datos of the last period. False if there were no data.
|
||||
*/
|
||||
|
@ -1706,9 +1709,9 @@ function get_previous_data ($id_agent_module, $utimestamp = 0) {
|
|||
/**
|
||||
* Get the average value of an agent module in a period of time.
|
||||
*
|
||||
* @param int $id_agent_module Agent module id
|
||||
* @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
|
||||
* @param int Period of time to check (in seconds)
|
||||
* @param int Top date to check the values. Default current time.
|
||||
*
|
||||
* @return int The average module value in the interval.
|
||||
*/
|
||||
|
@ -1738,9 +1741,9 @@ function get_agentmodule_data_average ($id_agent_module, $period, $date = 0) {
|
|||
/**
|
||||
* Get the maximum value of an agent module in a period of time.
|
||||
*
|
||||
* @param int $id_agent_module Agent module id to get the maximum 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 maximum value.
|
||||
* @param int Period of time to check (in seconds)
|
||||
* @param int Top date to check the values. Default current time.
|
||||
*
|
||||
* @return float The maximum module value in the interval.
|
||||
*/
|
||||
|
@ -1793,9 +1796,9 @@ function get_agentmodule_data_min ($id_agent_module, $period, $date = 0) {
|
|||
/**
|
||||
* Get the sum of values of an agent module in a period of time.
|
||||
*
|
||||
* @param int $id_agent_module Agent module id to get the sumatory.
|
||||
* @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 sumatory.
|
||||
* @param int Period of time to check (in seconds)
|
||||
* @param int Top date to check the values. Default current time.
|
||||
*
|
||||
* @return int The sumatory of the module values in the interval.
|
||||
*/
|
||||
|
@ -1872,7 +1875,7 @@ function get_agentmodule_data_sum ($id_agent_module, $period, $date = 0) {
|
|||
/**
|
||||
* Get a translated string
|
||||
*
|
||||
* @param string $string String to translate
|
||||
* @param string String to translate
|
||||
*
|
||||
* @return string The translated string. If not defined, the same string will be returned
|
||||
*/
|
||||
|
@ -1904,16 +1907,12 @@ function check_server_status () {
|
|||
|
||||
/**
|
||||
* @deprecated Will show a small HTML table with some compound alert information
|
||||
*
|
||||
* @param int $id_combined_alert
|
||||
*
|
||||
* @return string HTML block
|
||||
*/
|
||||
function show_alert_row_mini ($id_combined_alert) {
|
||||
$color=1;
|
||||
$sql = sprintf ("SELECT talerta_agente_modulo.*,tcompound_alert.operation
|
||||
FROM talerta_agente_modulo, tcompound_alert
|
||||
WHERE tcompound_alert.id_aam = talerta_agente_modulo.id_aam
|
||||
$sql = sprintf ("SELECT talert_template_modules.*,tcompound_alert.operation
|
||||
FROM talert_template_modules, tcompound_alert
|
||||
WHERE tcompound_alert.id_aam = talert_template_modules.id
|
||||
AND tcompound_alert.id = %d", $id_combined_alert);
|
||||
$result = get_db_all_rows_sql ($sql);
|
||||
|
||||
|
@ -2026,7 +2025,8 @@ function show_alert_row_mini ($id_combined_alert) {
|
|||
* @deprecated use get_server_info instead
|
||||
* Get statistical information for a given server
|
||||
*
|
||||
* @param int Server id to get status
|
||||
* @param int Server id to get status.
|
||||
*
|
||||
* @return array Server info array
|
||||
*/
|
||||
function server_status ($id_server) {
|
||||
|
@ -2096,9 +2096,9 @@ function delete_agent ($id_agents) {
|
|||
// daily maintance process, all data for that modules are deleted
|
||||
|
||||
//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);
|
||||
/* TODO: Compound alert */
|
||||
//temp_sql_delete ("tcompound_alert", "id_aam", "ANY(SELECT id_aam FROM talerta_agente_modulo WHERE id_agent = ".$id_agent.")");
|
||||
temp_sql_delete ("talert_template_modules", "id_agent_module", $tmodbase);
|
||||
|
||||
//Events (up/down monitors)
|
||||
temp_sql_delete ("tevento", "id_agente", $id_agent);
|
||||
|
@ -2124,7 +2124,7 @@ function delete_agent ($id_agents) {
|
|||
temp_sql_delete ("tagent_access", "id_agent", $id_agent);
|
||||
|
||||
//tagente_datos_inc
|
||||
temp_sql_delete ("tagente_datos_inc", "id_agente_modulo", $tmodbase);
|
||||
temp_sql_delete ("tagente_datos_inc", "id_agente_modulo", $tmodbase);
|
||||
|
||||
//And at long last, the agent
|
||||
temp_sql_delete ("tagente", "id_agente", $id_agent);
|
||||
|
@ -2331,62 +2331,50 @@ function get_modulegroup_name ($modulegroup_id) {
|
|||
* All arrays and values should have been cleaned before passing. It's not neccessary to add quotes.
|
||||
*
|
||||
* @param string Table to insert into
|
||||
* @param mixed A single row or array of rows to insert to
|
||||
* @param mixed A single value or array of values to insert (can be a multiple amount of rows)
|
||||
*
|
||||
* @return mixed False in case of error or invalid values passed. Affected rows otherwise
|
||||
*/
|
||||
function process_sql_insert ($table, $rows, $values) {
|
||||
if (empty ($rows) || empty ($values)) { //Empty rows or values not processed
|
||||
function process_sql_insert ($table, $values) {
|
||||
//Empty rows or values not processed
|
||||
if (empty ($values))
|
||||
return false;
|
||||
}
|
||||
|
||||
$rows = (array) $rows; //Convert single strings to array
|
||||
$values = (array) $values;
|
||||
$row_count = count ($rows); //We're reusing so we put it in a variable
|
||||
$value_count = count ($values);
|
||||
|
||||
if (($value_count % $row_count) != 0) {
|
||||
//If values are not a clean multiple of rows, don't process
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$query = sprintf ("INSERT INTO `%s` ", $table);
|
||||
|
||||
foreach ($rows as $idx => $row) { //Add ` to each row name
|
||||
if ($row[0] != '`') {
|
||||
$rows[$idx] = '`'.$row.'`';
|
||||
$fields = array ();
|
||||
$values_str = '';
|
||||
$i = 1;
|
||||
$max = count ($values);
|
||||
foreach ($values as $field => $value) { //Add the correct escaping to values
|
||||
if ($field[0] != "`") {
|
||||
$field = "`".$field."`";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($values as $idx => $value) { //Add the correct escaping to values
|
||||
if ($value[0] == "'") {
|
||||
continue; //The value is already escaped
|
||||
}
|
||||
if ($value === NULL) {
|
||||
$values[$idx] = (string) "NULL";
|
||||
} elseif (is_numeric ($value)) {
|
||||
continue; //The value doesn't need esaped.
|
||||
} elseif (is_bool ($value)) {
|
||||
$values[$idx] = (int) $value; //SQL doesn't know boolean so we convert
|
||||
|
||||
array_push ($fields, $field);
|
||||
|
||||
if (is_null ($value)) {
|
||||
$values_str .= "NULL";
|
||||
} elseif (is_int ($value) || is_bool ($value)) {
|
||||
$values_str .= sprintf ("%d", $value);
|
||||
} else if (is_float ($value) || is_double ($value)) {
|
||||
$values_str .= sprintf ("%f", $value);
|
||||
} else {
|
||||
$values[$idx] = sprintf ("'%s'", $value);
|
||||
$values_str .= sprintf ("'%s'", $value);
|
||||
}
|
||||
|
||||
if ($i < $max) {
|
||||
$values_str .= ",";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$query .= "(".implode (", ", $rows).")";
|
||||
$query .= " VALUES ";
|
||||
$query .= '('.implode (', ', $fields).')';
|
||||
|
||||
for ($i = 0; $i < ($value_count / $row_count); $i++) {
|
||||
//For the times the values are multiplied
|
||||
$array = array_slice ($values, $i * $row_count, ($i+1) * $row_count);
|
||||
$query .= "(".implode (",", $array).")";
|
||||
if ($i != ($value_count / $row_count) - 1) {
|
||||
$query .= ",";
|
||||
}
|
||||
}
|
||||
$query .= ' VALUES ('.$values_str.')';
|
||||
|
||||
return process_sql ($query);
|
||||
return process_sql ($query, 'insert_id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,11 +22,11 @@ require_once ("include/functions_agents.php");
|
|||
/**
|
||||
* Get SLA of a module.
|
||||
*
|
||||
* @param int $id_agent_module Agent module to calculate SLA
|
||||
* @param int $period Period to check the SLA compliance.
|
||||
* @param int $min_value Minimum data value the module in the right interval
|
||||
* @param int $max_value Maximum data value the module in the right interval
|
||||
* @param int $date Beginning date of the report in UNIX time (current date by default).
|
||||
* @param int Agent module to calculate SLA
|
||||
* @param int Period to check the SLA compliance.
|
||||
* @param int Minimum data value the module in the right interval
|
||||
* @param int Maximum data value the module in the right interval
|
||||
* @param int Beginning date of the report in UNIX time (current date by default).
|
||||
*
|
||||
* @return int SLA percentage of the requested module.
|
||||
*/
|
||||
|
@ -198,15 +198,15 @@ function get_group_stats ($id_group) {
|
|||
} else {
|
||||
$data["monitor_ok"]++;
|
||||
}
|
||||
|
||||
$sql = sprintf ("SELECT times_fired FROM talerta_agente_modulo WHERE id_agente_modulo = %d", $row["id_agente_modulo"]);
|
||||
$fired = get_db_sql ($sql);
|
||||
|
||||
$fired = get_db_value ('times_fired', 'talert_template_modules',
|
||||
'id_agent_module', $row["id_agente_modulo"]);
|
||||
if ($fired !== false) {
|
||||
$data["monitor_alerts"]++;
|
||||
if ($fired > 0) {
|
||||
$data["monitor_alerts_fired"]++;
|
||||
$data["monitor_alerts_fire_count"] += $fired;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//This module is a data check (agent)
|
||||
|
@ -225,8 +225,8 @@ function get_group_stats ($id_group) {
|
|||
$data["data_ok"]++;
|
||||
}
|
||||
|
||||
$sql = sprintf ("SELECT times_fired FROM talerta_agente_modulo WHERE id_agente_modulo = %d", $row["id_agente_modulo"]);
|
||||
$fired = get_db_sql ($sql);
|
||||
$fired = get_db_value ('times_fired', 'talert_template_modules',
|
||||
'id_agent_module', $row["id_agente_modulo"]);
|
||||
if ($fired !== false) {
|
||||
$data["data_alerts"]++;
|
||||
if ($fired > 0) {
|
||||
|
@ -300,10 +300,10 @@ function get_group_stats ($id_group) {
|
|||
* It construct a table object with all the events happened in a group
|
||||
* during a period of time.
|
||||
*
|
||||
* @param int $id_group Group id to get the report.
|
||||
* @param int $period Period of time to get the report.
|
||||
* @param int $date Beginning date of the report
|
||||
* @param int $return Flag to return or echo the report table (echo by default).
|
||||
* @param int Group id to get the report.
|
||||
* @param int Period of time to get the report.
|
||||
* @param int Beginning date of the report
|
||||
* @param int Flag to return or echo the report table (echo by default).
|
||||
*
|
||||
* @return object A table object
|
||||
*/
|
||||
|
@ -345,7 +345,7 @@ function event_reporting ($id_group, $period, $date = 0, $return = false) {
|
|||
/**
|
||||
* Get a table report from a alerts fired array.
|
||||
*
|
||||
* @param array $alerts_fired Alerts fired array.
|
||||
* @param array Alerts fired array.
|
||||
* @see function get_alerts_fired ()
|
||||
*
|
||||
* @return object A table object with a report of the fired alerts.
|
||||
|
@ -353,15 +353,19 @@ function event_reporting ($id_group, $period, $date = 0, $return = false) {
|
|||
function get_fired_alerts_reporting_table ($alerts_fired) {
|
||||
$agents = array ();
|
||||
|
||||
require_once ('include/functions_alerts.php');
|
||||
|
||||
foreach (array_keys ($alerts_fired) as $id_alert) {
|
||||
$alert = get_db_row ('talerta_agente_modulo', 'id_aam', $id_alert);
|
||||
$alert_module = get_alert_agent_module ($id_alert);
|
||||
$template = get_alert_template ($id_alert);
|
||||
|
||||
/* Add alerts fired to $agents_fired_alerts indexed by id_agent */
|
||||
$id_agent = get_db_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', $alert['id_agente_modulo']);
|
||||
$id_agent = get_db_value ('id_agente', 'tagente_modulo',
|
||||
'id_agente_modulo', $alert_module['id_agent_module']);
|
||||
if (!isset ($agents[$id_agent])) {
|
||||
$agents[$id_agent] = array ();
|
||||
}
|
||||
array_push ($agents[$id_agent], $alert);
|
||||
array_push ($agents[$id_agent], array ($alert_module, $template));
|
||||
}
|
||||
|
||||
$table->data = array ();
|
||||
|
@ -373,14 +377,16 @@ function get_fired_alerts_reporting_table ($alerts_fired) {
|
|||
|
||||
foreach ($agents as $id_agent => $alerts) {
|
||||
$data = array ();
|
||||
foreach ($alerts as $alert) {
|
||||
foreach ($alerts as $tuple) {
|
||||
$alert_module = $tuple[0];
|
||||
$template = $tuple[1];
|
||||
if (! isset ($data[0]))
|
||||
$data[0] = get_agent_name ($id_agent);
|
||||
else
|
||||
$data[0] = '';
|
||||
$data[1] = $alert['descripcion'];
|
||||
$data[2] = $alerts_fired[$alert['id_aam']];
|
||||
$data[3] = get_alert_priority ($alert['priority']);
|
||||
$data[1] = $template['name'];
|
||||
$data[2] = $alerts_fired[$alert_module['id']];
|
||||
$data[3] = get_alert_priority ($alert_module['priority']);
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +496,7 @@ function monitor_health_reporting ($id_group, $period = 0, $date = 0, $return =
|
|||
/**
|
||||
* Get a report table with all the monitors down.
|
||||
*
|
||||
* @param array $monitors_down An array with all the monitors down
|
||||
* @param array An array with all the monitors down
|
||||
* @see function get_monitors_down()
|
||||
*
|
||||
* @return object A table object with a monitors down report.
|
||||
|
@ -537,8 +543,8 @@ function get_monitors_down_reporting_table ($monitors_down) {
|
|||
*
|
||||
* It shows the number of agents and no more things right now.
|
||||
*
|
||||
* @param $id_group Group to get the report
|
||||
* @param $return Flag to return or echo the report (by default).
|
||||
* @param int Group to get the report
|
||||
* @param bool Flag to return or echo the report (by default).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -555,9 +561,9 @@ function general_group_reporting ($id_group, $return = false) {
|
|||
/**
|
||||
* Get a report table of the fired alerts group by agents.
|
||||
*
|
||||
* @param int $id_agent Agent id to generate the report.
|
||||
* @param int $period Period of time of the report.
|
||||
* @param int $date Beginning date of the report in UNIX time (current date by default).
|
||||
* @param int Agent id to generate the report.
|
||||
* @param int Period of time of the report.
|
||||
* @param int Beginning date of the report in UNIX time (current date by default).
|
||||
*
|
||||
* @return object A table object with the alert reporting..
|
||||
*/
|
||||
|
@ -566,27 +572,52 @@ function get_agent_alerts_reporting_table ($id_agent, $period = 0, $date = 0) {
|
|||
$table->head = array ();
|
||||
$table->head[0] = __('Type');
|
||||
$table->head[1] = __('Description');
|
||||
$table->head[2] = __('Minimum');
|
||||
$table->head[3] = __('Maximum');
|
||||
$table->head[4] = __('Threshold');
|
||||
$table->head[5] = __('Last fired');
|
||||
$table->head[6] = __('Times Fired');
|
||||
$table->head[2] = __('Value');
|
||||
$table->head[3] = __('Threshold');
|
||||
$table->head[4] = __('Last fired');
|
||||
$table->head[5] = __('Times Fired');
|
||||
|
||||
$alerts = get_agent_alerts ($id_agent);
|
||||
foreach ($alerts as $alert) {
|
||||
$fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date);
|
||||
$fires = get_alert_fires_in_period ($alert['id'], $period, $date);
|
||||
if (! $fires) {
|
||||
continue;
|
||||
}
|
||||
$alert_type = get_db_row ('talerta', 'id_alerta', $alert['id_alerta']);
|
||||
|
||||
$template = get_alert_template ($alert['id_alert_template']);
|
||||
$data = array ();
|
||||
$data[0] = $alert_type['nombre'];
|
||||
$data[1] = $alert['descripcion'];
|
||||
$data[2] = $alert['dis_min'];
|
||||
$data[3] = $alert['dis_max'];
|
||||
$data[4] = $alert['time_threshold'];
|
||||
$data[5] = get_alert_last_fire_timestamp_in_period ($alert['id_agente_modulo'], $period, $date);
|
||||
$data[6] = $fires;
|
||||
$data[0] = get_alert_templates_type_name ($template['type']);
|
||||
$data[1] = $template['name'];
|
||||
|
||||
switch ($template['type']) {
|
||||
case 'regex':
|
||||
if ($template['matches_value'])
|
||||
$data[2] = '≃ "'.$template['value'].'"';
|
||||
else
|
||||
$data[2] = '≄ "'.$template['value'].'"';
|
||||
break;
|
||||
case 'equal':
|
||||
case 'not_equal':
|
||||
$data[2] = $template['value'];
|
||||
|
||||
break;
|
||||
case 'max-min':
|
||||
$data[2] = __('Min.').': '.$template['min_value']. ' ';
|
||||
$data[2] .= __('Max.').': '.$template['max_value']. ' ';
|
||||
|
||||
break;
|
||||
case 'max':
|
||||
$data[2] = $template['max_value'];
|
||||
|
||||
break;
|
||||
case 'min':
|
||||
$data[2] = $template['min_value'];
|
||||
|
||||
break;
|
||||
}
|
||||
$data[3] = $template['time_threshold'];
|
||||
$data[4] = print_timestamp (get_alert_last_fire_timestamp_in_period ($alert['id'], $period, $date), true);
|
||||
$data[5] = $fires;
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
|
@ -596,9 +627,9 @@ function get_agent_alerts_reporting_table ($id_agent, $period = 0, $date = 0) {
|
|||
/**
|
||||
* Get a report of monitors in an agent.
|
||||
*
|
||||
* @param int $id_agent Agent id to get the report
|
||||
* @param int $period Period of time of the report.
|
||||
* @param int $date Beginning date of the report in UNIX time (current date by default).
|
||||
* @param int Agent id to get the report
|
||||
* @param int Period of time of the report.
|
||||
* @param int Beginning date of the report in UNIX time (current date by default).
|
||||
*
|
||||
* @return object A table object with the report.
|
||||
*/
|
||||
|
@ -633,9 +664,9 @@ function get_agent_monitors_reporting_table ($id_agent, $period = 0, $date = 0)
|
|||
/**
|
||||
* Get a report of all the modules in an agent.
|
||||
*
|
||||
* @param int $id_agent Agent id to get the report.
|
||||
* @param int $period Period of time of the report
|
||||
* @param int $date Beginning date of the report in UNIX time (current date by default).
|
||||
* @param int Agent id to get the report.
|
||||
* @param int Period of time of the report
|
||||
* @param int Beginning date of the report in UNIX time (current date by default).
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
|
@ -661,10 +692,10 @@ function get_agent_modules_reporting_table ($id_agent, $period = 0, $date = 0) {
|
|||
/**
|
||||
* Get a detailed report of an agent
|
||||
*
|
||||
* @param int $id_agent Agent to get the report.
|
||||
* @param int $period Period of time of the desired report.
|
||||
* @param int $date Beginning date of the report in UNIX time (current date by default).
|
||||
* @param bool $return Flag to return or echo the report (by default).
|
||||
* @param int Agent to get the report.
|
||||
* @param int Period of time of the desired report.
|
||||
* @param int Beginning date of the report in UNIX time (current date by default).
|
||||
* @param bool Flag to return or echo the report (by default).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -714,10 +745,10 @@ function get_agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $retur
|
|||
/**
|
||||
* Get a detailed report of agents in a group.
|
||||
*
|
||||
* @param int $id_group Group to get the report
|
||||
* @param int $period Period
|
||||
* @param int $date Timestamp to start from
|
||||
* @param bool $return Flag to return or echo the report (by default).
|
||||
* @param int Group to get the report
|
||||
* @param int Period
|
||||
* @param int Timestamp to start from
|
||||
* @param bool Flag to return or echo the report (by default).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
// Login check
|
||||
require("include/config.php");
|
||||
require ("include/config.php");
|
||||
|
||||
check_login();
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ CREATE TABLE IF NOT EXISTS `talert_actions` (
|
|||
CREATE TABLE IF NOT EXISTS `talert_templates` (
|
||||
`id` int(10) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) default '',
|
||||
`description` mediumtext default '',
|
||||
`description` mediumtext,
|
||||
`id_alert_action` int(10) unsigned NULL,
|
||||
`field1` varchar(255) default '',
|
||||
`field2` varchar(255) default '',
|
||||
|
@ -308,7 +308,6 @@ CREATE TABLE IF NOT EXISTS `tattachment` (
|
|||
PRIMARY KEY (`id_attachment`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tconfig` (
|
||||
`id_config` int(10) unsigned NOT NULL auto_increment,
|
||||
`token` varchar(100) NOT NULL default '',
|
||||
|
@ -703,7 +702,7 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` (
|
|||
CREATE TABLE IF NOT EXISTS tplugin (
|
||||
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(200) NOT NULL,
|
||||
`description` mediumtext default "",
|
||||
`description` mediumtext,
|
||||
`max_timeout` int(4) UNSIGNED NOT NULL default 0,
|
||||
`execute`varchar(250) NOT NULL,
|
||||
`net_dst_opt` varchar(50) default '',
|
||||
|
|
Loading…
Reference in New Issue