2014-05-26 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_networkmap.php: added the generate networkmap
	from the ip mask.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10008 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2014-05-26 14:55:19 +00:00
parent 2dc9ec6e2e
commit 0caf3566b3
2 changed files with 30 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2014-05-26 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_networkmap.php: added the generate networkmap
from the ip mask.
2014-05-26 Vanessa Gil <vanessa.gil@artica.es>
* godmode/agentes/configurar_agente.php: Comment module

View File

@ -233,7 +233,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
$simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0,
$zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0,
$id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
$relative = false, $text_filter = '', $l2_network = false) {
$relative = false, $text_filter = '', $l2_network = false, $ip_mask = null) {
global $config;
@ -268,6 +268,12 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
else if ($group == -666) {
$agents = false;
}
else if (!empty($ip_mask)) {
$agents = networkmap_get_new_nodes_from_ip_mask($ip_mask,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
normal_count, warning_count, critical_count,
unknown_count, total_count, notinit_count'));
}
else {
$agents = agents_get_agents ($filter,
array ('id_grupo, nombre, id_os, id_parent, id_agente,
@ -275,6 +281,8 @@ function networkmap_generate_dot ($pandora_name, $group = 0,
unknown_count, total_count, notinit_count'));
}
if ($agents === false)
//return false;
$agents = array();
@ -1531,7 +1539,9 @@ function networkmap_cidr_match($ip, $cidr_mask) {
//copy from open source code
// https://gist.github.com/linickx/1309388
list ($subnet, $bits) = split('/', $cidr_mask);
$chunks = explode("/", $cidr_mask);
$subnet = $chunks[0];
$bits = $chunks[1];
$ip = ip2long($ip);
$subnet = ip2long($subnet);
@ -1541,7 +1551,7 @@ function networkmap_cidr_match($ip, $cidr_mask) {
return ($ip & $mask) == $subnet;
}
function networkmap_get_new_nodes_from_ip_mask($ip_mask) {
function networkmap_get_new_nodes_from_ip_mask($ip_mask, $fields = array()) {
$list_ip_masks = explode(",", $ip_mask);
$list_address = db_get_all_rows_in_table('taddress');
@ -1552,8 +1562,18 @@ function networkmap_get_new_nodes_from_ip_mask($ip_mask) {
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']));
if (empty($fields)) {
$agents[] = db_get_value_filter('id_agent',
'taddress_agent', array('id_a' => $address['id_a']));
}
else {
$id_agent = db_get_value_filter('id_agent',
'taddress_agent', array('id_a' => $address['id_a']));
$agents[] = db_get_row('tagente', 'id_agente',
$id_agent, $fields);
}
}
}
}