Minor fixes
This commit is contained in:
parent
183daaa744
commit
4e73d8045a
|
@ -445,32 +445,36 @@ class Agent extends Entity
|
|||
continue;
|
||||
}
|
||||
|
||||
$name_filters = [
|
||||
'ifOperStatus' => ['nombre' => $interface.'_ifOperStatus'],
|
||||
'ifInOctets' => ['nombre' => $interface.'_ifInOctets'],
|
||||
'ifOutOctets' => ['nombre' => $interface.'_ifOutOctets'],
|
||||
'ifHCInOctets' => ['nombre' => $interface.'_ifHCInOctets'],
|
||||
'ifHCOutOctets' => ['nombre' => $interface.'_ifHCOutOctets'],
|
||||
];
|
||||
|
||||
$ifOperStatus = $this->searchModules(
|
||||
$name_filters['ifOperStatus']
|
||||
);
|
||||
$ifInOctets = $this->searchModules(
|
||||
$name_filters['ifInOctets']
|
||||
);
|
||||
$ifOutOctets = $this->searchModules(
|
||||
$name_filters['ifOutOctets']
|
||||
);
|
||||
$ifHCInOctets = $this->searchModules(
|
||||
$name_filters['ifHCInOctets']
|
||||
);
|
||||
$ifHCOutOctets = $this->searchModules(
|
||||
$name_filters['ifHCOutOctets']
|
||||
);
|
||||
|
||||
$interfaces[$interface] = [
|
||||
'ifOperStatus' => array_shift(
|
||||
$this->searchModules(
|
||||
['nombre' => $interface.'_ifOperStatus']
|
||||
)
|
||||
),
|
||||
'ifInOctets' => array_shift(
|
||||
$this->searchModules(
|
||||
['nombre' => $interface.'_ifInOctets']
|
||||
)
|
||||
),
|
||||
'ifOutOctets' => array_shift(
|
||||
$this->searchModules(
|
||||
['nombre' => $interface.'_ifOutOctets']
|
||||
)
|
||||
),
|
||||
'ifHCInOctets' => array_shift(
|
||||
$this->searchModules(
|
||||
['nombre' => $interface.'_ifHCInOctets']
|
||||
)
|
||||
),
|
||||
'ifHCOutOctets' => array_shift(
|
||||
$this->searchModules(
|
||||
['nombre' => $interface.'_ifHCOutOctets']
|
||||
)
|
||||
),
|
||||
'ifOperStatus' => array_shift($ifOperStatus),
|
||||
'ifInOctets' => array_shift($ifInOctets),
|
||||
'ifOutOctets' => array_shift($ifOutOctets),
|
||||
'ifHCInOctets' => array_shift($ifHCInOctets),
|
||||
'ifHCOutOctets' => array_shift($ifHCOutOctets),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -478,6 +482,47 @@ class Agent extends Entity
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves status, in and out modules from given interface name.
|
||||
*
|
||||
* @param string $interface Interface name.
|
||||
*
|
||||
* @return array|null With status, in and out modules. Null if no iface.
|
||||
*/
|
||||
public function getInterfaceMetrics(string $interface):?array
|
||||
{
|
||||
$modules = $this->getInterfaces([$interface]);
|
||||
if (empty($modules) === true) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$modules = $modules[$interface];
|
||||
|
||||
$in = null;
|
||||
$out = null;
|
||||
$status = $modules['ifOperStatus'];
|
||||
|
||||
if (empty($modules['ifHCInOctets']) === false) {
|
||||
$in = $modules['ifHCInOctets'];
|
||||
} else if (empty($modules['ifInOctets']) === false) {
|
||||
$in = $modules['ifInOctets'];
|
||||
}
|
||||
|
||||
if (empty($modules['ifHCOutOctets']) === false) {
|
||||
$out = $modules['ifHCOutOctets'];
|
||||
} else if (empty($modules['ifOutOctets']) === false) {
|
||||
$out = $modules['ifOutOctets'];
|
||||
}
|
||||
|
||||
return [
|
||||
'in' => $in,
|
||||
'out' => $out,
|
||||
'status' => $status,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Search for modules into this agent.
|
||||
*
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
namespace Models\VisualConsole;
|
||||
use Models\VisualConsole\Container as VisualConsole;
|
||||
|
||||
define('__DEBUG', 1);
|
||||
define('__DEBUG', 0);
|
||||
|
||||
global $config;
|
||||
require_once $config['homedir'].'/include/class/HTML.class.php';
|
||||
|
@ -621,46 +621,147 @@ class View extends \HTML
|
|||
public function networkLinkPopup()
|
||||
{
|
||||
global $config;
|
||||
include_once $config['homedir'].'/include/functions_graph.php';
|
||||
$item_idFrom = get_parameter('from');
|
||||
$item_idTo = get_parameter('to');
|
||||
|
||||
$itemFrom = db_get_row_filter(
|
||||
'tlayout_data',
|
||||
['id' => $item_idFrom]
|
||||
);
|
||||
try {
|
||||
include_once $config['homedir'].'/include/functions_graph.php';
|
||||
$item_idFrom = get_parameter('from');
|
||||
$item_idTo = get_parameter('to');
|
||||
|
||||
$itemTo = db_get_row_filter(
|
||||
'tlayout_data',
|
||||
['id' => $item_idTo]
|
||||
);
|
||||
$itemFrom = db_get_row_filter(
|
||||
'tlayout_data',
|
||||
['id' => $item_idFrom]
|
||||
);
|
||||
|
||||
$from = new \PandoraFMS\Module((int) $itemFrom['id_agente_modulo']);
|
||||
$to = new \PandoraFMS\Module((int) $itemTo['id_agente_modulo']);
|
||||
$itemTo = db_get_row_filter(
|
||||
'tlayout_data',
|
||||
['id' => $item_idTo]
|
||||
);
|
||||
|
||||
echo 'From '.$from->nombre().' con valor '.$from->lastValue();
|
||||
ini_set('display_errors', 1);
|
||||
// Interface chart base configuration.
|
||||
$params = [
|
||||
'period' => SECONDS_6HOURS,
|
||||
'width' => '90%',
|
||||
'height' => 150,
|
||||
'date' => time(),
|
||||
'homeurl' => $config['homeurl'],
|
||||
];
|
||||
|
||||
echo \grafico_modulo_sparse(
|
||||
[
|
||||
'agent_module_id' => $from->id_agente_modulo(),
|
||||
'period' => SECONDS_1DAY,
|
||||
'height' => 150,
|
||||
'menu' => false,
|
||||
]
|
||||
);
|
||||
if ($config['type_interface_charts'] == 'line') {
|
||||
$stacked = CUSTOM_GRAPH_LINE;
|
||||
} else {
|
||||
$stacked = CUSTOM_GRAPH_AREA;
|
||||
}
|
||||
|
||||
echo 'To '.$to->nombre().' con valor '.$to->lastValue();
|
||||
$params_combined = [
|
||||
'weight_list' => [],
|
||||
'projection' => false,
|
||||
'from_interface' => true,
|
||||
'return' => 0,
|
||||
'stacked' => $stacked,
|
||||
];
|
||||
|
||||
echo \grafico_modulo_sparse(
|
||||
[
|
||||
'agent_module_id' => $to->id_agente_modulo(),
|
||||
'period' => SECONDS_1DAY,
|
||||
'height' => 150,
|
||||
'menu' => false,
|
||||
]
|
||||
);
|
||||
if ((bool) is_metaconsole() === true) {
|
||||
$params['id_server'] = $server_id;
|
||||
}
|
||||
|
||||
// Interface FROM.
|
||||
$from = new \PandoraFMS\Module((int) $itemFrom['id_agente_modulo']);
|
||||
if ((bool) $from->isInterfaceModule() === true) {
|
||||
$interface_name = $from->getInterfaceName();
|
||||
if ($interface_name !== null) {
|
||||
$data = $from->agent()->getInterfaceMetrics(
|
||||
$interface_name
|
||||
);
|
||||
|
||||
echo '<div class="margin-top-10 interface-status from w90p flex-row-vcenter">';
|
||||
ui_print_module_status($data['status']->lastStatus());
|
||||
echo '<span style="margin-left: 1em;">';
|
||||
echo __('Interface %s status', $interface_name);
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
|
||||
$interface_traffic_modules = [
|
||||
__('In') => $data['in']->id_agente_modulo(),
|
||||
__('Out') => $data['out']->id_agente_modulo(),
|
||||
];
|
||||
|
||||
$params['unit_name'] = array_fill(
|
||||
0,
|
||||
count($interface_traffic_modules),
|
||||
$config['interface_unit']
|
||||
);
|
||||
|
||||
$params_combined['labels'] = array_keys(
|
||||
$interface_traffic_modules
|
||||
);
|
||||
|
||||
$params_combined['modules_series'] = array_values(
|
||||
$interface_traffic_modules
|
||||
);
|
||||
|
||||
// Graph.
|
||||
echo '<div id="stat-win-interface-graph from">';
|
||||
|
||||
\graphic_combined_module(
|
||||
array_values($interface_traffic_modules),
|
||||
$params,
|
||||
$params_combined
|
||||
);
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Interface TO.
|
||||
$to = new \PandoraFMS\Module((int) $itemTo['id_agente_modulo']);
|
||||
if ((bool) $to->isInterfaceModule() === true) {
|
||||
$interface_name = $to->getInterfaceName();
|
||||
if ($interface_name !== null) {
|
||||
$data = $to->agent()->getInterfaceMetrics(
|
||||
$interface_name
|
||||
);
|
||||
|
||||
echo '<div class="interface-status from w90p flex-row-vcenter">';
|
||||
ui_print_module_status($data['status']->lastStatus());
|
||||
echo '<span style="margin-left: 1em;">';
|
||||
echo __('Interface %s status', $interface_name);
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
|
||||
$interface_traffic_modules = [
|
||||
__('In') => $data['in']->id_agente_modulo(),
|
||||
__('Out') => $data['out']->id_agente_modulo(),
|
||||
];
|
||||
|
||||
$params['unit_name'] = array_fill(
|
||||
0,
|
||||
count($interface_traffic_modules),
|
||||
$config['interface_unit']
|
||||
);
|
||||
|
||||
$params_combined['labels'] = array_keys(
|
||||
$interface_traffic_modules
|
||||
);
|
||||
|
||||
$params_combined['modules_series'] = array_values(
|
||||
$interface_traffic_modules
|
||||
);
|
||||
|
||||
// Graph.
|
||||
echo '<div id="stat-win-interface-graph to">';
|
||||
|
||||
\graphic_combined_module(
|
||||
array_values($interface_traffic_modules),
|
||||
$params,
|
||||
$params_combined
|
||||
);
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
echo __('Failed to generate charts: %s', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -753,6 +753,9 @@ p.center {
|
|||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
.centered {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.margin-top-10 {
|
||||
margin-top: 10px;
|
||||
|
|
Loading…
Reference in New Issue