2012-04-17 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php, extensions/net_tools.php: cleaned source code style. * include/functions_networkmap.php: into the functions "networkmap_generate_dot" and "networkmap_create_agent_node" added new parameter $relative for set the url of icons as relative. It is used in networmap enterprise. * include/functions_ui.php: fixed into the function "ui_print_message" lost the javascript code when the first messages are without close button. And into the function "ui_print_os_icon" added new parameter $relative for set the url of icons as relative. It is used in networmap enterprise. Merged from the branch "pandora_4.0". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6000 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
e90e66f7e5
commit
641e7cffcb
|
@ -1,3 +1,21 @@
|
|||
2012-04-17 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_html.php, extensions/net_tools.php: cleaned
|
||||
source code style.
|
||||
|
||||
* include/functions_networkmap.php: into the functions
|
||||
"networkmap_generate_dot" and "networkmap_create_agent_node"
|
||||
added new parameter $relative for set the url of icons as relative.
|
||||
It is used in networmap enterprise.
|
||||
|
||||
* include/functions_ui.php: fixed into the function
|
||||
"ui_print_message" lost the javascript code when the first messages
|
||||
are without close button. And into the function "ui_print_os_icon"
|
||||
added new parameter $relative for set the url of icons as relative.
|
||||
It is used in networmap enterprise.
|
||||
|
||||
Merged from the branch "pandora_4.0".
|
||||
|
||||
2012-04-17 Vanessa Gil <vanessa.gil@artica.es>
|
||||
|
||||
* godmode/reporting/reporting_builder.item_editor.php: Fixed
|
||||
|
|
|
@ -25,47 +25,45 @@ function main_net_tools () {
|
|||
echo "<h3 class=error>The agent hasn't got IP</h3>";
|
||||
return;
|
||||
}
|
||||
echo "<div>";
|
||||
echo "<form name='actionbox' method='post'>";
|
||||
echo "<table class=databox width=650>";
|
||||
echo "<tr><td>";
|
||||
echo __("Operation");
|
||||
echo "<td>";
|
||||
echo "<select name='operation'>";
|
||||
echo "<option value=1>".__("Traceroute");
|
||||
echo "<option value=2>".__("Ping host & Latency");
|
||||
echo "<option value=3>".__("SNMP Interface status");
|
||||
echo "<option value=4>".__("Basic TCP Port Scan");
|
||||
echo "<option value=5>".__("DiG/Whois Lookup");
|
||||
echo "</select>";
|
||||
echo "<td>";
|
||||
echo __("SNMP Community");
|
||||
echo "<td>";
|
||||
echo "<input name=community type=text value='public'>";
|
||||
echo "<td>";
|
||||
echo "<input name=submit type=submit class='sub next' value='".__('Execute')."'>";
|
||||
echo "</tr></table>";
|
||||
echo "</form>";
|
||||
|
||||
|
||||
$operation = get_parameter ("operation",0);
|
||||
$community = get_parameter ("community","public");
|
||||
|
||||
switch($operation){
|
||||
|
||||
case 1:
|
||||
if (!file_exists('/usr/sbin/traceroute')) {
|
||||
ui_print_error_message(__('Traceroute executable does not exist.'));
|
||||
}
|
||||
else {
|
||||
echo "<h3>".__("Traceroute to "). $ip. "</h3>";
|
||||
echo "<pre>";
|
||||
echo system ("/usr/sbin/traceroute $ip");
|
||||
echo "</pre>";
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
echo "<div>";
|
||||
echo "<form name='actionbox' method='post'>";
|
||||
echo "<table class=databox width=650>";
|
||||
echo "<tr><td>";
|
||||
echo __("Operation");
|
||||
echo "<td>";
|
||||
echo "<select name='operation'>";
|
||||
echo "<option value=1>".__("Traceroute");
|
||||
echo "<option value=2>".__("Ping host & Latency");
|
||||
echo "<option value=3>".__("SNMP Interface status");
|
||||
echo "<option value=4>".__("Basic TCP Port Scan");
|
||||
echo "<option value=5>".__("DiG/Whois Lookup");
|
||||
echo "</select>";
|
||||
echo "<td>";
|
||||
echo __("SNMP Community");
|
||||
echo "<td>";
|
||||
echo "<input name=community type=text value='public'>";
|
||||
echo "<td>";
|
||||
echo "<input name=submit type=submit class='sub next' value='".__('Execute')."'>";
|
||||
echo "</tr></table>";
|
||||
echo "</form>";
|
||||
|
||||
|
||||
$operation = get_parameter ("operation",0);
|
||||
$community = get_parameter ("community","public");
|
||||
|
||||
switch($operation) {
|
||||
case 1:
|
||||
if (!file_exists('/usr/sbin/traceroute')) {
|
||||
ui_print_error_message(__('Traceroute executable does not exist.'));
|
||||
}
|
||||
else {
|
||||
echo "<h3>".__("Traceroute to "). $ip. "</h3>";
|
||||
echo "<pre>";
|
||||
echo system ("/usr/sbin/traceroute $ip");
|
||||
echo "</pre>";
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
ob_start();
|
||||
system('whereis ping');
|
||||
$output = ob_get_clean();
|
||||
|
|
|
@ -1194,14 +1194,14 @@ function html_print_checkbox ($name, $value, $checked = false, $return = false,
|
|||
*/
|
||||
function html_print_image ($src, $return = false, $options = false, $return_src = false, $relative = false) {
|
||||
global $config;
|
||||
|
||||
|
||||
/* Checks if user's skin is available */
|
||||
$isFunctionSkins = enterprise_include_once ('include/functions_skins.php');
|
||||
|
||||
|
||||
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
|
||||
$skin_path = enterprise_hook('skins_get_image_path',array($src));
|
||||
if ($skin_path)
|
||||
$src = $skin_path;
|
||||
$src = $skin_path;
|
||||
}
|
||||
|
||||
if (!$relative) {
|
||||
|
|
|
@ -44,10 +44,12 @@ function networkmap_is_descendant ($node, $ascendant, $parents) {
|
|||
// Generate a dot graph definition for graphviz
|
||||
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) {
|
||||
$regen = 1, $pure = 0, $id_networkmap = 0, $show_snmp_modules = 0, $cut_names = true,
|
||||
$relative = false) {
|
||||
|
||||
$parents = array();
|
||||
$orphans = array();
|
||||
|
||||
|
||||
$filter = array ();
|
||||
$filter['disabled'] = 0;
|
||||
if ($group >= 1) {
|
||||
|
@ -84,7 +86,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_
|
|||
}
|
||||
|
||||
$node_count = 1;
|
||||
|
||||
|
||||
foreach ($agents as $agent) {
|
||||
// Save node parent information to define edges later
|
||||
if ($agent['id_parent'] != "0") {
|
||||
|
@ -95,9 +97,9 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_
|
|||
}
|
||||
|
||||
$agent['id_node'] = $node_count;
|
||||
|
||||
|
||||
$agent['type'] = 'agent';
|
||||
|
||||
|
||||
// Add node
|
||||
$nodes[$node_count] = $agent;
|
||||
|
||||
|
@ -108,15 +110,15 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_
|
|||
foreach ($modules as $key => $module) {
|
||||
$node_count ++;
|
||||
$agent_module = modules_get_agentmodule($key);
|
||||
|
||||
|
||||
$alerts_module = db_get_sql('SELECT count(*) as num
|
||||
FROM talert_template_modules WHERE id_agent_module = '.$key);
|
||||
|
||||
|
||||
// Save node parent information to define edges later
|
||||
$parents[$node_count] = $agent_module['parent'] = $agent['id_node'];
|
||||
|
||||
|
||||
$agent_module['id_node'] = $node_count;
|
||||
|
||||
|
||||
$agent_module['type'] = 'module';
|
||||
// Add node
|
||||
$nodes[$node_count] = $agent_module;
|
||||
|
@ -133,10 +135,10 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_
|
|||
unset ($nodes[$node_id]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
switch($node['type']){
|
||||
case 'agent':
|
||||
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names)."\n\t\t";
|
||||
$graph .= networkmap_create_agent_node ($node , $simple, $font_size, $cut_names, $relative)."\n\t\t";
|
||||
break;
|
||||
case 'module':
|
||||
$graph .= networkmap_create_module_node ($node , $simple, $font_size)."\n\t\t";
|
||||
|
@ -158,7 +160,7 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_
|
|||
if (count ($orphans) || empty ($nodes)) {
|
||||
$graph .= networkmap_create_pandora_node ($pandora_name, $font_size, $simple);
|
||||
}
|
||||
|
||||
|
||||
// Define edges for orphan nodes
|
||||
foreach (array_keys($orphans) as $node) {
|
||||
$graph .= networkmap_create_edge ('0', $node, $layout, $nooverlap, $pure, $zoom, $ranksep, $simple, $regen, $font_size, $group, 'operation/agentes/networkmap', 'topology', $id_networkmap);
|
||||
|
@ -173,10 +175,10 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $simple = 0, $font_
|
|||
// Generate a dot graph definition for graphviz with groups
|
||||
function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0, $font_size = 12, $layout = 'radial', $nooverlap = 0, $zoom = 1, $ranksep = 2.5, $center = 0, $regen = 1, $pure = 0, $modwithalerts = 0, $module_group = 0, $hidepolicymodules = 0, $depth = 'all', $id_networkmap = 0) {
|
||||
global $config;
|
||||
|
||||
|
||||
$parents = array();
|
||||
$orphans = array();
|
||||
|
||||
|
||||
$filter = array ();
|
||||
$filter['disabled'] = 0;
|
||||
|
||||
|
@ -212,13 +214,13 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, $simple = 0,
|
|||
$node_count ++;
|
||||
$group2['type'] = 'group';
|
||||
$group2['id_node'] = $node_count;
|
||||
|
||||
|
||||
// Add node
|
||||
$nodes_groups[$group2['id_grupo']] = $group2;
|
||||
}
|
||||
|
||||
$node_count = 0;
|
||||
|
||||
|
||||
foreach ($nodes_groups as $node_group) {
|
||||
|
||||
$node_count++;
|
||||
|
@ -408,11 +410,11 @@ function networkmap_create_group_node ($group, $simple = 0, $font_size = 10) {
|
|||
}
|
||||
|
||||
// Returns a node definition
|
||||
function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cut_names = true) {
|
||||
function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cut_names = true, $relative = false) {
|
||||
global $config;
|
||||
|
||||
$status = agents_get_status($agent['id_agente']);
|
||||
|
||||
|
||||
// Set node status
|
||||
switch($status) {
|
||||
case 0:
|
||||
|
@ -431,18 +433,26 @@ function networkmap_create_agent_node ($agent, $simple = 0, $font_size = 10, $cu
|
|||
$status_color = '#BBBBBB'; // Unknown monitor
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Short name
|
||||
$name = io_safe_output($agent["nombre"]);
|
||||
if ((strlen ($name) > 16) && ($cut_names)) {
|
||||
$name = substr ($name, 0, 16) . '...';
|
||||
}
|
||||
|
||||
|
||||
if ($simple == 0){
|
||||
// Set node icon
|
||||
$img_node = ui_print_os_icon ($agent['id_os'], false, true, true, true, true);
|
||||
$img_node = ui_print_os_icon ($agent['id_os'], false, true, true, true, true, $relative);
|
||||
$img_node = str_replace($config['homeurl'] . '/', '', $img_node);
|
||||
|
||||
$node = $agent['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD>' . html_print_image($img_node, true, false, false, true) . '</TD></TR>
|
||||
if ($relative) {
|
||||
$img_node = html_print_image($img_node, true, false, false, true);
|
||||
}
|
||||
else {
|
||||
$img_node = html_print_image($img_node, true, false, false, false);
|
||||
}
|
||||
|
||||
$node = $agent['id_node'].' [ color="'.$status_color.'", fontsize='.$font_size.', style="filled", fixedsize=true, width=0.40, height=0.40, label=<<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD>' . $img_node . '</TD></TR>
|
||||
<TR><TD>'.$name.'</TD></TR></TABLE>>,
|
||||
shape="doublecircle", URL="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$agent['id_agente'].'",
|
||||
tooltip="ajax.php?page=operation/agentes/ver_agente&get_agent_status_tooltip=1&id_agent='.$agent['id_agente'].'"];';
|
||||
|
|
|
@ -220,7 +220,7 @@ function ui_print_message ($message, $class = '', $attributes = '', $return = fa
|
|||
</tr>
|
||||
</table>';
|
||||
|
||||
if ($first_execution) {
|
||||
if (($first_execution) && (!$no_close_bool)) {
|
||||
$first_execution = false;
|
||||
|
||||
$output .= '
|
||||
|
@ -501,7 +501,7 @@ function ui_print_group_icon_path ($id_group, $return = false, $path = "images/g
|
|||
*
|
||||
* @return string HTML with icon of the OS
|
||||
*/
|
||||
function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = true, $networkmap = false, $only_src = false) {
|
||||
function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin = true, $networkmap = false, $only_src = false, $relative = false) {
|
||||
$subfolter = 'os_icons';
|
||||
if ($networkmap) {
|
||||
$subfolter = 'networkmap';
|
||||
|
@ -511,7 +511,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin =
|
|||
$os_name = get_os_name ($id_os);
|
||||
if (empty ($icon)) {
|
||||
if ($only_src) {
|
||||
$output = html_print_image("images/".$subfolter."/unknown.png", false, false, true);
|
||||
$output = html_print_image("images/".$subfolter."/unknown.png", false, false, true, $relative);
|
||||
}
|
||||
else {
|
||||
return "-";
|
||||
|
@ -520,10 +520,10 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin =
|
|||
|
||||
if ($apply_skin) {
|
||||
if ($only_src) {
|
||||
$output = html_print_image("images/".$subfolter."/".$icon, true, false, true);
|
||||
$output = html_print_image("images/".$subfolter."/".$icon, true, false, true, $relative);
|
||||
}
|
||||
else {
|
||||
$output = html_print_image("images/".$subfolter."/".$icon, true, array("alt" => $os_name, "title" => $os_name));
|
||||
$output = html_print_image("images/".$subfolter."/".$icon, true, array("alt" => $os_name, "title" => $os_name), false, $relative);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue