2007-02-27 20:03:56 +01:00
< ? php
2008-04-03 17:43:34 +02:00
// Pandora FMS - the Free Monitoring System
2007-03-12 18:58:52 +01:00
// ========================================
2008-04-03 17:43:34 +02:00
// Copyright (c) 2008 Artica Soluciones Tecnológicas, http://www.artica.es
// Please see http://pandora.sourceforge.net for full contribution list
2007-03-07 13:37:23 +01:00
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
2008-04-03 17:43:34 +02:00
// as published by the Free Software Foundation for version 2.
2007-03-07 13:37:23 +01:00
// 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.
2007-02-27 20:03:56 +01:00
// ====================================================================================
// VIEW ALERTS
2007-05-24 22:03:05 +02:00
// ====================================================================================
2007-02-27 20:03:56 +01:00
2008-04-01 15:53:11 +02:00
// Load global vars
require ( " include/config.php " );
check_login ();
if ( give_acl ( $config [ " id_user " ], 0 , " AW " ) != 1 ) {
audit_db ( $config [ " id_user " ], $REMOTE_ADDR , " ACL Violation " , " Trying to access agent manager " );
require ( $config [ " homedir " ] . " /general/noaccess.php " );
exit ;
};
2008-04-03 17:43:34 +02:00
echo " <h2> " . $lang_label [ " agent_conf " ] . " > " . $lang_label [ " alerts " ] . " </h2> " ;
2008-04-01 15:53:11 +02:00
// ==========================
// 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">' ;
echo " <option value='simple'> " . lang_string ( " Create a simple alert " );
echo " <option value='combined'> " . lang_string ( " Create a new combined alert " );
echo " </select></td> " ;
echo '<td class="datos">' ;
echo '<input align="right" name="updbutton" type="submit" class="sub wand" value="' . $lang_label [ " create " ] . '">' ;
echo " </form> " ;
echo " </table> " ;
2008-04-03 17:43:34 +02:00
// ==========================
// Simple alerts view
// ==========================
2007-05-28 21:15:44 +02:00
2007-02-27 20:03:56 +01:00
$sql1 = 'SELECT * FROM tagente_modulo WHERE id_agente = "' . $id_agente . '"' ;
$result = mysql_query ( $sql1 );
if ( $row = mysql_num_rows ( $result )){
2008-04-03 17:43:34 +02:00
echo " <h3> " . lang_string ( " Simple alerts " ) . " </h3> " ;
2007-02-27 20:03:56 +01:00
$color = 1 ;
$string = '' ;
while ( $row = mysql_fetch_array ( $result )){ // All modules of this agent
$id_tipo = $row [ " id_tipo_modulo " ];
2007-06-12 13:57:03 +02:00
$nombre_modulo = substr ( $row [ " nombre " ], 0 , 21 );
2007-02-27 20:03:56 +01:00
//module type modulo is $row2["nombre"];
2007-04-19 20:50:07 +02:00
$sql3 = ' SELECT *
FROM talerta_agente_modulo
WHERE id_agente_modulo = ' . $row [ " id_agente_modulo " ];
// From all the alerts give me which are from my agent
2007-02-27 20:03:56 +01:00
$result3 = mysql_query ( $sql3 );
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 " ];
2007-06-17 12:34:39 +02:00
$string = $string . " <tr style='color: #666;'><td class=' $tdcolor '> " . $nombre_modulo ;
2007-06-12 13:57:03 +02:00
2008-04-03 17:43:34 +02:00
$string .= show_alert_row_edit ( $row3 , $tdcolor , $row [ " id_tipo_modulo " ], 0 );
2007-06-27 19:45:42 +02:00
$string = $string . " </td><td class=' $tdcolor '> " ;
2007-02-27 20:03:56 +01:00
$id_grupo = dame_id_grupo ( $id_agente );
if ( give_acl ( $id_user , $id_grupo , " LW " ) == 1 ){
$string = $string . " <a href='index.php?sec=gagente&
2007-04-18 11:58:26 +02:00
sec2 = godmode / agentes / configurar_agente & tab = alert &
2007-02-27 20:03:56 +01:00
id_agente = " . $id_agente . " & delete_alert = " . $row3["id_aam"] . " ' >
2007-04-02 Raul Mateos <raulofpandora@gmail.com>
* images/ok.gif: Deleted
* images/cross.png, go.png, ok.png, upd.png: Added new images
* include/styles/pandora.css, tip.css, op.css: Updated. Deleted some
old styles, not all.
* include/languages/language_en.php, language_es_es.php: Added text
for no recon task.
* godmode/*.php, operation/*.php, help/*.php: Changed some icons,
updated several buttons with new icons.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@410 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2007-04-02 19:17:27 +02:00
< img src = 'images/cross.png' border = 0 alt = '".$lang_label["delete"]."' ></ a > & nbsp ; " ;
2007-02-27 20:03:56 +01:00
$string = $string . " <a href='index.php?sec=gagente&
2007-04-18 11:58:26 +02:00
sec2 = godmode / agentes / configurar_agente & tab = alert &
2008-04-03 17:43:34 +02:00
id_agente = " . $id_agente . " & update_alert = " . $row3["id_aam"] . " ' >
2007-06-27 19:45:42 +02:00
< img src = 'images/config.png' border = 0 alt = '".$lang_label["update"]."' ></ a > " ;
2007-02-27 20:03:56 +01:00
}
$string = $string . " </td> " ;
}
}
if ( isset ( $string ) & $string != '' ) {
2007-06-21 17:48:47 +02:00
echo " <table cellpadding='4' cellspacing='4' width='750' class='databox'>
2007-06-12 13:57:03 +02:00
< tr >< th > " . $lang_label["name"] . " </ th >
< th > " . $lang_label["type"] . " </ th >
2007-02-27 20:03:56 +01:00
< th > " . $lang_label["alert"] . " </ th >
2007-05-24 22:03:05 +02:00
< th > " . $lang_label["threshold"] . " </ th >
2007-06-12 13:57:03 +02:00
< th > " . $lang_label["min."] . " </ th >
< th > " . $lang_label["max."] . " </ th >
2007-06-21 17:48:47 +02:00
< th > " . $lang_label["time"] . " </ th >
2007-02-27 20:03:56 +01:00
< th > " . $lang_label["description"] . " </ th >
2008-04-03 17:43:34 +02:00
< th > " .lang_string ( " info " ). " </ th >
2007-02-27 20:03:56 +01:00
< th width = '50' > " . $lang_label["action"] . " </ th ></ tr > " ;
echo $string ;
2007-05-24 22:03:05 +02:00
echo " </table> " ;
2007-02-27 20:03:56 +01:00
} else {
echo " <div class='nf'> " . $lang_label [ " no_alerts " ] . " </div> " ;
}
} else {
echo " <div class='nf'> " . $lang_label [ " no_modules " ] . " </div> " ;
}
2008-04-03 17:43:34 +02:00
// ==========================
// Combined alerts view
// ==========================
2007-06-21 17:48:47 +02:00
2008-04-01 15:53:11 +02:00
echo " <h3> " . lang_string ( " combined alerts " ) . " </h3> " ;
2007-02-27 20:03:56 +01:00
2008-04-01 15:53:11 +02:00
$sql1 = 'SELECT * FROM talerta_agente_modulo WHERE id_agent = ' . $id_agente ;
$result = mysql_query ( $sql1 );
2008-04-10 16:00:50 +02:00
if ( mysql_num_rows ( $result ) == 0 ){
echo " <div class='nf'> " . $lang_label [ " no_modules " ] . " </div> " ;
} else {
$color = 1 ;
$string = " " ;
while ( $row = mysql_fetch_array ( $result )){
// Show data for this combined alert
$string .= " <tr><td class='datos3'> " ;
$string .= lang_string ( " Combined " ) . " # " . $row [ " id_aam " ];
$string .= show_alert_row_edit ( $row , " datos3 " , 0 , 1 );
$string .= '<td class="datos3">' ; // action
if ( give_acl ( $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=' " . $lang_label [ " 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 = '".$lang_label["update"]."' ></ a > " ;
}
$id_aam = $row [ " 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 );
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 ;
2008-04-03 17:43:34 +02:00
}
2008-04-10 16:00:50 +02:00
$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 );
$string .= " </td><td class=' $tdcolor '> " ;
$id_grupo = dame_id_grupo ( $id_agente );
if ( give_acl ( $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=' " . $lang_label [ " 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 = '".$lang_label["update"]."' ></ a > " ;
2008-04-01 15:53:11 +02:00
}
2008-04-10 16:00:50 +02:00
$string .= " </td> " ;
2008-04-01 15:53:11 +02:00
}
2008-04-10 16:00:50 +02:00
}
if ( isset ( $string ) & $string != " " ) {
echo " <table cellpadding='4' cellspacing='4' width='750' class='databox'>
< tr >< th > " . $lang_label["name"] . " </ th >
< th > " . $lang_label["type"] . " </ th >
< th > " .lang_string ( " Oper " ). " </ th >
< th > " . $lang_label["threshold"] . " </ th >
< th > " . $lang_label["min."] . " </ th >
< th > " . $lang_label["max."] . " </ th >
< th > " . $lang_label["time"] . " </ th >
< th > " . $lang_label["description"] . " </ th >
< th > " .lang_string ( " info " ). " </ th >
< th width = '50' > " . $lang_label["action"] . " </ th ></ tr > " ;
echo $string ;
echo " </table> " ;
2008-04-01 15:53:11 +02:00
} else {
2008-04-10 16:00:50 +02:00
echo " <div class='nf'> " . $lang_label [ " no_alerts " ] . " </div> " ;
2008-04-01 15:53:11 +02:00
}
2008-04-10 16:00:50 +02:00
}
2007-02-27 20:03:56 +01:00
2007-06-17 12:34:39 +02:00
?>