2014-05-23 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_modules.php, include/functions_networkmap.php: added the filters for the CIDR network masks. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9994 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
667d73f8a5
commit
64c3affbb9
|
@ -1,3 +1,9 @@
|
|||
2014-05-23 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_modules.php,
|
||||
include/functions_networkmap.php: added the filters for the
|
||||
CIDR network masks.
|
||||
|
||||
2014-05-23 Vanessa Gil <vanessa.gil@artica.es>
|
||||
|
||||
* godmode/agentes/module_manager.php: Added optional
|
||||
|
|
|
@ -81,7 +81,8 @@ function modules_is_disable_type_event($id_agent_module = false, $type_event = f
|
|||
}
|
||||
|
||||
$disabled_types_event = json_decode(
|
||||
db_get_value('disabled_types_event', 'tagente_modulo', 'id_agente_modulo', $id_agent_module), true);
|
||||
db_get_value('disabled_types_event', 'tagente_modulo', 'id_agente_modulo', $id_agent_module),
|
||||
true);
|
||||
|
||||
if (isset($disabled_types_event[$type_event])) {
|
||||
if ($disabled_types_event[$type_event]) {
|
||||
|
@ -978,7 +979,9 @@ function modules_get_interfaces($id_agent, $fields_param = false) {
|
|||
$modules = array();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
if ($module['id_tipo_modulo'] == 18 || $module['id_tipo_modulo'] == 6) {
|
||||
//18 = remote_snmp_proc
|
||||
//6 = remote_icmp_proc
|
||||
if ($module['id_tipo_modulo'] == 18) {
|
||||
|
||||
if ($fields_param !== false) {
|
||||
if (is_array($fields_param)) {
|
||||
|
@ -1849,7 +1852,6 @@ function modules_get_module_macros_json ($macro_names, $macro_values) {
|
|||
* @return mixed Array with relations between modules. False if there were no data.
|
||||
*/
|
||||
function modules_get_relations ($params = array()) {
|
||||
|
||||
$id_agent = 0;
|
||||
if (isset($params['id_agent'])) {
|
||||
$id_agent = $params['id_agent'];
|
||||
|
@ -1873,8 +1875,12 @@ function modules_get_relations ($params = array()) {
|
|||
$modules_type = $params['modules_type'];
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT tmr.id, tmr.module_a, tmr.module_b, tmr.disable_update
|
||||
FROM tmodule_relationship AS tmr, tagente_modulo AS tam, tagente AS ta, ttipo_modulo AS ttm
|
||||
$sql = "SELECT DISTINCT tmr.id, tmr.module_a, tmr.module_b,
|
||||
tmr.disable_update
|
||||
FROM tmodule_relationship AS tmr,
|
||||
tagente_modulo AS tam,
|
||||
tagente AS ta,
|
||||
ttipo_modulo AS ttm
|
||||
WHERE ";
|
||||
|
||||
$agent_filter = "";
|
||||
|
@ -1889,11 +1895,13 @@ function modules_get_relations ($params = array()) {
|
|||
}
|
||||
$disabled_update_filter = "";
|
||||
if ($disabled_update >= 0) {
|
||||
$disabled_update_filter = sprintf("AND tmr.disable_update = %d", $disabled_update);
|
||||
$disabled_update_filter = sprintf(
|
||||
"AND tmr.disable_update = %d", $disabled_update);
|
||||
}
|
||||
$modules_type_filter = "";
|
||||
if ($modules_type != "") {
|
||||
$modules_type_filter = sprintf("AND (tam.id_tipo_modulo = ttm.id_tipo AND ttm.nombre = '%s')", $modules_type);
|
||||
$modules_type_filter = sprintf(
|
||||
"AND (tam.id_tipo_modulo = ttm.id_tipo AND ttm.nombre = '%s')", $modules_type);
|
||||
}
|
||||
|
||||
$sql .= "( (tmr.module_a = tam.id_agente_modulo
|
||||
|
|
|
@ -1527,6 +1527,40 @@ function networkmap_get_filter_types () {
|
|||
return $networkmap_types;
|
||||
}
|
||||
|
||||
function networkmap_cidr_match($ip, $cidr_mask) {
|
||||
//copy from open source code
|
||||
// https://gist.github.com/linickx/1309388
|
||||
|
||||
list ($subnet, $bits) = split('/', $cidr_mask);
|
||||
|
||||
$ip = ip2long($ip);
|
||||
$subnet = ip2long($subnet);
|
||||
$mask = -1 << (32 - $bits);
|
||||
$subnet &= $mask; # nb: in case the supplied subnet wasn't correctly aligned
|
||||
|
||||
return ($ip & $mask) == $subnet;
|
||||
}
|
||||
|
||||
function networkmap_get_new_nodes_from_ip_mask($ip_mask) {
|
||||
$list_ip_masks = explode(",", $ip_mask);
|
||||
|
||||
$list_address = db_get_all_rows_in_table('taddress');
|
||||
if (empty($address))
|
||||
$address = array();
|
||||
|
||||
$agents = array();
|
||||
foreach ($list_address as $address) {
|
||||
foreach ($list_ip_masks as $ip_mask) {
|
||||
if (networkmap_cidr_match($address['ip'], $ip_mask)) {
|
||||
$agents[] = db_get_value_filter('id_agent',
|
||||
'taddress_agent', array('id_a' => $address['id_a']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $agents;
|
||||
}
|
||||
|
||||
?>
|
||||
<script language="javascript" type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
|
|
Loading…
Reference in New Issue