2014-03-18 Vanessa Gil <vanessa.gil@artica.es>
* pandoradb.oracle.sql pandoradb.postgreSQL.sql pandoradb.sql extras/pandoradb_migrate_5.0_to_5.1.mysql.sql extras/pandoradb_migrate_5.0_to_5.1.oracle.sql extras/pandoradb_migrate_5.0_to_5.1.postgreSQL.sql godmode/snmpconsole/snmp_alert.php godmode/snmpconsole/snmp_view.php: Improved ACLs in SNMP Traps. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9614 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f1a6ba0543
commit
ce6628c3f7
|
@ -1,3 +1,15 @@
|
|||
2014-03-18 Vanessa Gil <vanessa.gil@artica.es>
|
||||
|
||||
* pandoradb.oracle.sql
|
||||
pandoradb.postgreSQL.sql
|
||||
pandoradb.sql
|
||||
extras/pandoradb_migrate_5.0_to_5.1.mysql.sql
|
||||
extras/pandoradb_migrate_5.0_to_5.1.oracle.sql
|
||||
extras/pandoradb_migrate_5.0_to_5.1.postgreSQL.sql
|
||||
godmode/snmpconsole/snmp_alert.php
|
||||
godmode/snmpconsole/snmp_view.php: Improved ACLs in
|
||||
SNMP Traps.
|
||||
|
||||
2014-03-18 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* godmode/agentes/configurar_agente.php,
|
||||
|
|
|
@ -57,3 +57,8 @@ CREATE TABLE IF NOT EXISTS `tmodule_relationship` (
|
|||
FOREIGN KEY (`module_b`) REFERENCES tagente_modulo(`id_agente_modulo`)
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `talert_snmp`
|
||||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE `talert_snmp` ADD COLUMN `id_group` int(10) unsigned NOT NULL default '0';
|
||||
|
|
|
@ -47,3 +47,8 @@ CREATE TABLE IF NOT EXISTS tmodule_relationship (
|
|||
CREATE SEQUENCE tmodule_relationship_s INCREMENT BY 1 START WITH 1;
|
||||
|
||||
CREATE OR REPLACE TRIGGER tmodule_relationship_inc BEFORE INSERT ON tmodule_relationship REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tmodule_relationship_s.nextval INTO :NEW.ID FROM dual; END;;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `talert_snmp`
|
||||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE talert_snmp ADD (id_group NUMBER(10, 0) default 0 NOT NULL);
|
||||
|
|
|
@ -44,3 +44,8 @@ CREATE TABLE "tmodule_relationship" (
|
|||
ON DELETE CASCADE,
|
||||
"disable_update" SMALLINT NOT NULL default 0
|
||||
);
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table "talert_snmp"
|
||||
-- ---------------------------------------------------------------------
|
||||
ALTER TABLE "talert_snmp" ADD COLUMN "id_group" INTEGER NOT NULL default 0;
|
||||
|
|
|
@ -91,6 +91,7 @@ if ($save_alert || $modify_alert) {
|
|||
$trap_type = (int) get_parameter ("trap_type", -1);
|
||||
$single_value = (string) get_parameter ("single_value");
|
||||
$position = (int) get_parameter ("position");
|
||||
$group = (int) get_parameter ("group");
|
||||
|
||||
if ($time_threshold == -1) {
|
||||
$time_threshold = $time_other;
|
||||
|
@ -129,7 +130,8 @@ if ($save_alert || $modify_alert) {
|
|||
'_snmp_f10_' => $custom_oid_data_10,
|
||||
'trap_type' => $trap_type,
|
||||
'single_value' => $single_value,
|
||||
'position' => $position);
|
||||
'position' => $position,
|
||||
'id_group' => $group);
|
||||
|
||||
$result = db_process_sql_insert('talert_snmp', $values);
|
||||
|
||||
|
@ -156,7 +158,7 @@ if ($save_alert || $modify_alert) {
|
|||
_snmp_f4_ = '%s', _snmp_f5_ = '%s', _snmp_f6_ = '%s',
|
||||
_snmp_f7_ = '%s', _snmp_f8_ = '%s', _snmp_f9_ = '%s',
|
||||
_snmp_f10_ = '%s', trap_type = %d, single_value = '%s',
|
||||
position = '%s'
|
||||
position = '%s', id_group ='%s'
|
||||
WHERE id_as = %d",
|
||||
$priority, $alert_type, $al_field1, $al_field2, $al_field3,
|
||||
$al_field4, $al_field5, $al_field6, $al_field7, $al_field8,
|
||||
|
@ -166,8 +168,8 @@ if ($save_alert || $modify_alert) {
|
|||
$custom_oid_data_3, $custom_oid_data_4, $custom_oid_data_5,
|
||||
$custom_oid_data_6, $custom_oid_data_7, $custom_oid_data_8,
|
||||
$custom_oid_data_9, $custom_oid_data_10, $trap_type, $single_value,
|
||||
$position, $id_as);
|
||||
|
||||
$position, $group, $id_as);
|
||||
|
||||
$result = db_process_sql ($sql);
|
||||
|
||||
if (!$result) {
|
||||
|
@ -220,6 +222,7 @@ if ($update_alert) {
|
|||
$trap_type = $alert["trap_type"];
|
||||
$single_value = $alert["single_value"];
|
||||
$position = $alert["position"];
|
||||
$group = $alert["id_group"];
|
||||
}
|
||||
elseif ($create_alert) {
|
||||
// Variable init
|
||||
|
@ -256,6 +259,7 @@ elseif ($create_alert) {
|
|||
$trap_type = -1;
|
||||
$single_value = '';
|
||||
$position = 0;
|
||||
$group = 0;
|
||||
}
|
||||
|
||||
// Header
|
||||
|
@ -305,6 +309,18 @@ if ($multiple_delete) {
|
|||
}
|
||||
}
|
||||
|
||||
$user_groups = users_get_groups($config['id_user'],"AR", true);
|
||||
$str_user_groups = '';
|
||||
$i = 0;
|
||||
foreach ($user_groups as $id=>$name) {
|
||||
if ($i == 0) {
|
||||
$str_user_groups .= $id;
|
||||
} else {
|
||||
$str_user_groups .= ','.$id;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Alert form
|
||||
if ($create_alert || $update_alert) {
|
||||
//if (isset ($_GET["update_alert"])) {
|
||||
|
@ -352,6 +368,11 @@ if ($create_alert || $update_alert) {
|
|||
html_print_input_text ("source_ip", $source_ip, '', 20);
|
||||
echo '</td></tr>';
|
||||
|
||||
// Group
|
||||
echo '<tr id="tr-group"><td class="datos2">'.__('Group').'</td><td class="datos2">';
|
||||
html_print_select ($user_groups, "group", $group);
|
||||
echo '</td></tr>';
|
||||
|
||||
// Trap type
|
||||
echo '<tr><td class="datos">'.__('Trap type').'</td><td class="datos">';
|
||||
echo html_print_select ($trap_types, 'trap_type', $trap_type, '', '', '', false, false, false);
|
||||
|
@ -610,8 +631,8 @@ else {
|
|||
"priority_filter=" . $priority_filter . "&" .
|
||||
"offset=" . $offset;
|
||||
}
|
||||
|
||||
$where_sql = ' 1 = 1';
|
||||
|
||||
//$where_sql = ' 1 = 1';
|
||||
if ($trap_type_filter != SNMP_TRAP_TYPE_NONE) {
|
||||
$where_sql .= ' AND `trap_type` = ' . $trap_type_filter;
|
||||
}
|
||||
|
@ -638,10 +659,9 @@ else {
|
|||
OR `description` LIKE '%" . $free_search . "%')";
|
||||
}
|
||||
|
||||
$count = db_get_value_sql('SELECT COUNT(*)
|
||||
FROM talert_snmp WHERE' . $where_sql);
|
||||
|
||||
|
||||
$count = db_get_value_sql("SELECT COUNT(*)
|
||||
FROM talert_snmp WHERE id_group IN ($str_user_groups) " . $where_sql);
|
||||
|
||||
$result = array();
|
||||
|
||||
//Overview
|
||||
|
@ -653,8 +673,9 @@ else {
|
|||
ui_pagination ($count, $url_pagination);
|
||||
|
||||
$where_sql .= ' LIMIT ' . $config['block_size'] . ' OFFSET ' . $offset;
|
||||
$result = db_get_all_rows_sql('SELECT *
|
||||
FROM talert_snmp WHERE' . $where_sql);
|
||||
$result = db_get_all_rows_sql("SELECT *
|
||||
FROM talert_snmp
|
||||
WHERE id_group IN ($str_user_groups) " . $where_sql);
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
|
|
|
@ -43,6 +43,18 @@ $offset = (int) get_parameter ('offset',0);
|
|||
$trap_type = (int) get_parameter ('trap_type', -1);
|
||||
$group_by = (int) get_parameter('group_by', 0);
|
||||
|
||||
$user_groups = users_get_groups ($config['id_user'],"AR", false);
|
||||
$str_user_groups = '';
|
||||
$i = 0;
|
||||
foreach ($user_groups as $id=>$name) {
|
||||
if ($i == 0) {
|
||||
$str_user_groups .= $id;
|
||||
} else {
|
||||
$str_user_groups .= ','.$id;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$url = "index.php?sec=estado&sec2=operation/snmpconsole/snmp_view&filter_agent=".$filter_agent."&filter_oid=".$filter_oid."&filter_severity=".$filter_severity."&filter_fired=".$filter_fired."&search_string=".$search_string."&free_search_string=".$free_search_string."&pagination=".$pagination."&offset=".$offset . "&trap_type=" . $trap_type ."&group_by=" .$group_by;
|
||||
|
||||
|
||||
|
@ -128,6 +140,11 @@ switch ($config["dbtype"]) {
|
|||
$sql = sprintf ("
|
||||
SELECT *
|
||||
FROM ttrap
|
||||
WHERE `source` IN (
|
||||
SELECT direccion FROM tagente
|
||||
WHERE id_grupo IN ($str_user_groups)
|
||||
)
|
||||
OR `source`=''
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT %d,%d",$offset,$pagination);
|
||||
break;
|
||||
|
@ -135,8 +152,13 @@ switch ($config["dbtype"]) {
|
|||
$sql = sprintf ("
|
||||
SELECT *
|
||||
FROM ttrap
|
||||
WHERE `source` IN (
|
||||
SELECT direccion FROM tagente
|
||||
WHERE id_grupo IN ($str_user_groups)
|
||||
)
|
||||
OR `source`=''
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT %d OFFSET %d", $pagination, $offset);
|
||||
LIMIT %d OFFSET %d",$pagination, $offset);
|
||||
break;
|
||||
case "oracle":
|
||||
$set = array();
|
||||
|
@ -145,13 +167,24 @@ switch ($config["dbtype"]) {
|
|||
$sql = sprintf ("
|
||||
SELECT *
|
||||
FROM ttrap
|
||||
WHERE `source` IN (
|
||||
SELECT direccion FROM tagente
|
||||
WHERE id_grupo IN ($str_user_groups)
|
||||
)
|
||||
OR `source`=''
|
||||
ORDER BY timestamp DESC");
|
||||
$sql = oracle_recode_query ($sql, $set);
|
||||
break;
|
||||
}
|
||||
|
||||
$traps = db_get_all_rows_sql ($sql);
|
||||
// All traps
|
||||
$all_traps = db_get_all_rows_sql ("SELECT DISTINCT source FROM ttrap");
|
||||
$all_traps = db_get_all_rows_sql ("SELECT DISTINCT source FROM ttrap
|
||||
WHERE `source` IN (
|
||||
SELECT direccion FROM tagente
|
||||
WHERE id_grupo IN ($str_user_groups)
|
||||
)
|
||||
OR `source`=''");
|
||||
|
||||
if (($config['dbtype'] == 'oracle') && ($traps !== false)) {
|
||||
for ($i=0; $i < count($traps); $i++) {
|
||||
|
@ -188,27 +221,41 @@ foreach ($all_traps as $trap) {
|
|||
//Make query to extract traps of DB.
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM ttrap %s
|
||||
$sql = "SELECT *
|
||||
FROM ttrap
|
||||
WHERE `source` IN (
|
||||
SELECT direccion FROM tagente
|
||||
WHERE id_grupo IN ($str_user_groups)
|
||||
)
|
||||
OR `source`='' %s
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT %d,%d";
|
||||
break;
|
||||
case "postgresql":
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM ttrap %s
|
||||
$sql = "SELECT *
|
||||
FROM ttrap
|
||||
WHERE source IN (
|
||||
SELECT direccion FROM tagente
|
||||
WHERE id_grupo IN ($str_user_groups)
|
||||
)
|
||||
OR source='' %s
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT %d OFFSET %d";
|
||||
break;
|
||||
case "oracle":
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM ttrap %s
|
||||
ORDER BY timestamp DESC";
|
||||
$sql = "SELECT *
|
||||
FROM ttrap
|
||||
WHERE source IN (
|
||||
SELECT direccion FROM tagente
|
||||
WHERE id_grupo IN ($str_user_groups)
|
||||
)
|
||||
OR source='' %s
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT %d OFFSET %d";
|
||||
break;
|
||||
}
|
||||
$whereSubquery = 'WHERE 1=1';
|
||||
//$whereSubquery = 'WHERE 1=1';
|
||||
$whereSubquery = '';
|
||||
|
||||
if ($filter_agent != '') {
|
||||
switch ($config["dbtype"]) {
|
||||
|
@ -479,6 +526,7 @@ $table->style[7] = "background: #F3F3F3; color: #111 !important;";
|
|||
// Skip offset records
|
||||
$idx = 0;
|
||||
if ($traps !== false) {
|
||||
|
||||
foreach ($traps as $trap) {
|
||||
$data = array ();
|
||||
if (empty($trap["description"])){
|
||||
|
@ -513,7 +561,7 @@ if ($traps !== false) {
|
|||
$data[1] = '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent["id_agente"].'" title="'.__('View agent details').'">';
|
||||
$data[1] .= '<strong>'.$agent["nombre"].'</strong></a>';
|
||||
}
|
||||
|
||||
|
||||
//OID
|
||||
$table->cellclass[$idx][2] = get_priority_class ($severity);
|
||||
$data[2] = '<a href="javascript: toggleVisibleExtendedInfo(' . $trap["id_trap"] . ');">' . (empty($trap["oid"]) ? __('N/A') : $trap["oid"]) .'</a>';
|
||||
|
@ -558,15 +606,24 @@ if ($traps !== false) {
|
|||
if (empty ($trap["status"]) && check_acl ($config["id_user"], 0, "IW")) {
|
||||
$data[7] .= '<a href="' . $url_snmp . '&check='.$trap["id_trap"].'">' . html_print_image("images/ok.png", true, array("border" => '0', "title" => __('Validate'))) . '</a> ';
|
||||
}
|
||||
if (check_acl ($config["id_user"], 0, "IM")) {
|
||||
$data[7] .= '<a href="' . $url_snmp . '&delete='.$trap["id_trap"].'&offset='.$offset.'" onClick="javascript:return confirm(\''.__('Are you sure?').'\')">' . html_print_image("images/cross.png", true, array("border" => "0", "title" => __('Delete'))) . '</a> ';
|
||||
if ($trap['source'] == '') {
|
||||
$is_admin = db_get_value('is_admin', 'tusuario', 'id_user',$config['id_user']);
|
||||
if ($is_admin) {
|
||||
$data[7] .= '<a href="' . $url_snmp . '&delete='.$trap["id_trap"].'&offset='.$offset.'" onClick="javascript:return confirm(\''.__('Are you sure?').'\')">' . html_print_image("images/cross.png", true, array("border" => "0", "title" => __('Delete'))) . '</a> ';
|
||||
}
|
||||
} else {
|
||||
$agent_trap_group = db_get_value('id_grupo', 'tagente', 'nombre', $trap['source']);
|
||||
if ((check_acl ($config["id_user"], $agent_trap_group, "AW"))) {
|
||||
$data[7] .= '<a href="' . $url_snmp . '&delete='.$trap["id_trap"].'&offset='.$offset.'" onClick="javascript:return confirm(\''.__('Are you sure?').'\')">' . html_print_image("images/cross.png", true, array("border" => "0", "title" => __('Delete'))) . '</a> ';
|
||||
}
|
||||
}
|
||||
|
||||
$data[7] .= '<a href="javascript: toggleVisibleExtendedInfo(' . $trap["id_trap"] . ');">' . html_print_image("images/eye.png", true, array("alt" => __('Show more'), "title" => __('Show more'))) .'</a>';
|
||||
$data[7] .= enterprise_hook ('editor_link', array ($trap));
|
||||
|
||||
|
||||
$data[8] = html_print_checkbox_extended ("snmptrapid[]", $trap["id_trap"], false, false, '', 'class="chk"', true);
|
||||
|
||||
|
||||
array_push ($table->data, $data);
|
||||
|
||||
//Hiden file for description
|
||||
|
@ -623,23 +680,26 @@ if ($traps !== false) {
|
|||
}
|
||||
$string .= '<tr><td align="left" valign="top">' . '<b>' . __('Type:') . '</td><td align="left">' . $desc_trap_type . '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
if ($group_by) {
|
||||
$sql = "SELECT * FROM ttrap $where_without_group
|
||||
$sql = "SELECT * FROM ttrap WHERE 1=1
|
||||
$where_without_group
|
||||
AND oid='".$trap['oid']."'
|
||||
AND `source`='".$trap['source']."'";
|
||||
AND source='".$trap['source']."'";
|
||||
$group_traps = db_get_all_rows_sql($sql);
|
||||
$count_group_traps = count($group_traps);
|
||||
|
||||
$sql = "SELECT `timestamp` FROM ttrap $where_without_group
|
||||
$sql = "SELECT timestamp FROM ttrap WHERE 1=1
|
||||
$where_without_group
|
||||
AND oid='".$trap['oid']."'
|
||||
AND `source`='".$trap['source']."'
|
||||
AND source='".$trap['source']."'
|
||||
ORDER BY `timestamp` DESC";
|
||||
$last_trap = db_get_value_sql($sql);
|
||||
|
||||
$sql = "SELECT `timestamp` FROM ttrap $where_without_group
|
||||
$sql = "SELECT timestamp FROM ttrap WHERE 1=1
|
||||
$where_without_group
|
||||
AND oid='".$trap['oid']."'
|
||||
AND `source`='".$trap['source']."'
|
||||
AND source='".$trap['source']."'
|
||||
ORDER BY `timestamp` ASC";
|
||||
$first_trap = db_get_value_sql($sql);
|
||||
|
||||
|
@ -655,6 +715,7 @@ if ($traps !== false) {
|
|||
<td align="left" valign="top">' . '<b>' . __('Last trap:') . '</td>
|
||||
<td align="left">' . $last_trap . '</td>
|
||||
</tr>';
|
||||
|
||||
}
|
||||
$string .= '</table>';
|
||||
|
||||
|
|
|
@ -306,7 +306,8 @@ CREATE TABLE talert_snmp (
|
|||
_snmp_f10_ CLOB default '',
|
||||
trap_type NUMBER(10, 0) DEFAULT -1 NOT NULL,
|
||||
single_value VARCHAR2(255) DEFAULT '',
|
||||
"position" NUMBER(10, 0) default 0 NOT NULL
|
||||
"position" NUMBER(10, 0) default 0 NOT NULL,
|
||||
id_group NUMBER(10, 0) default 0 NOT NULL
|
||||
);
|
||||
|
||||
CREATE SEQUENCE talert_snmp_s INCREMENT BY 1 START WITH 1;
|
||||
|
|
|
@ -289,7 +289,8 @@ CREATE TABLE "talert_snmp" (
|
|||
"_snmp_f10_" text DEFAULT '',
|
||||
"trap_type" INTEGER NOT NULL DEFAULT '-1',
|
||||
"single_value" varchar(255) DEFAULT '',
|
||||
"position" INTEGER NOT NULL default 0
|
||||
"position" INTEGER NOT NULL default 0,
|
||||
"id_group" INTEGER NOT NULL default 0
|
||||
);
|
||||
|
||||
CREATE TABLE "talert_commands" (
|
||||
|
|
|
@ -296,6 +296,7 @@ CREATE TABLE IF NOT EXISTS `talert_snmp` (
|
|||
`trap_type` int(11) NOT NULL default '-1',
|
||||
`single_value` varchar(255) default '',
|
||||
`position` int(10) unsigned NOT NULL default '0',
|
||||
`id_group` int(10) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`id_as`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
Loading…
Reference in New Issue