mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
Added type to SNMP browser module creation
This commit is contained in:
parent
57df59448e
commit
b40b98fc54
@ -13,6 +13,7 @@
|
|||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
require_once $config['homedir'].'/include/functions_config.php';
|
require_once $config['homedir'].'/include/functions_config.php';
|
||||||
require_once $config['homedir'].'/include/functions_snmp_browser.php';
|
require_once $config['homedir'].'/include/functions_snmp_browser.php';
|
||||||
|
require_once $config['homedir'].'/include/functions_snmp.php';
|
||||||
require_once $config['homedir'].'/include/functions_network_components.php';
|
require_once $config['homedir'].'/include/functions_network_components.php';
|
||||||
|
|
||||||
|
|
||||||
|
@ -455,3 +455,61 @@ function print_snmp_tags_active_filters($filter_resume=[])
|
|||||||
ui_print_tags_view($title, $tags_set);
|
ui_print_tags_view($title, $tags_set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retunr module type for snmp data type
|
||||||
|
*
|
||||||
|
* @param [type] $snmp_data_type
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function snmp_module_get_type(string $snmp_data_type)
|
||||||
|
{
|
||||||
|
if (preg_match('/INTEGER/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
} else if (preg_match('/Integer32/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
} else if (preg_match('/octect string/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
} else if (preg_match('/bits/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
} else if (preg_match('/object identifier/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp_string';
|
||||||
|
} else if (preg_match('/IpAddress/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp_string';
|
||||||
|
} else if (preg_match('/Counter/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp_inc';
|
||||||
|
} else if (preg_match('/Counter32/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp_inc';
|
||||||
|
} else if (preg_match('/Gauge/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
} else if (preg_match('/Gauge32/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
} else if (preg_match('/Gauge64/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
} else if (preg_match('/Unsigned32/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp_inc';
|
||||||
|
} else if (preg_match('/TimeTicks/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
} else if (preg_match('/Opaque/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp_string';
|
||||||
|
} else if (preg_match('/Counter64/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp_inc';
|
||||||
|
} else if (preg_match('/UInteger32/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
} else if (preg_match('/BIT STRING/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp_string';
|
||||||
|
} else if (preg_match('/STRING/i', $snmp_data_type)) {
|
||||||
|
$type = 'remote_snmp_string';
|
||||||
|
} else {
|
||||||
|
$type = 'remote_snmp_string';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$type) {
|
||||||
|
$type = 'remote_snmp';
|
||||||
|
}
|
||||||
|
|
||||||
|
$type_id = modules_get_type_id($type);
|
||||||
|
|
||||||
|
return $type_id;
|
||||||
|
}
|
||||||
|
@ -945,6 +945,12 @@ function snmp_browser_create_modules_snmp(string $module_target, array $snmp_val
|
|||||||
$description = io_safe_input(preg_replace('/\s+/', ' ', $oid['description']));
|
$description = io_safe_input(preg_replace('/\s+/', ' ', $oid['description']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($oid['type'])) {
|
||||||
|
$module_type = snmp_module_get_type($oid['type']);
|
||||||
|
} else {
|
||||||
|
$module_type = 17;
|
||||||
|
}
|
||||||
|
|
||||||
if ($module_target == 'network_component') {
|
if ($module_target == 'network_component') {
|
||||||
$name_check = db_get_value(
|
$name_check = db_get_value(
|
||||||
'name',
|
'name',
|
||||||
@ -956,7 +962,7 @@ function snmp_browser_create_modules_snmp(string $module_target, array $snmp_val
|
|||||||
if (!$name_check) {
|
if (!$name_check) {
|
||||||
$id = network_components_create_network_component(
|
$id = network_components_create_network_component(
|
||||||
$oid['oid'],
|
$oid['oid'],
|
||||||
17,
|
$module_type,
|
||||||
1,
|
1,
|
||||||
[
|
[
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
@ -1009,12 +1015,13 @@ function snmp_browser_create_modules_snmp(string $module_target, array $snmp_val
|
|||||||
'min_ff_event_critical' => 0,
|
'min_ff_event_critical' => 0,
|
||||||
'ff_type' => 0,
|
'ff_type' => 0,
|
||||||
'each_ff' => 0,
|
'each_ff' => 0,
|
||||||
|
'history_data' => 1,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if ($module_target == 'agent') {
|
} else if ($module_target == 'agent') {
|
||||||
$values = [
|
$values = [
|
||||||
'id_tipo_modulo' => 17,
|
'id_tipo_modulo' => $module_type,
|
||||||
'descripcion' => $description,
|
'descripcion' => $description,
|
||||||
'module_interval' => 300,
|
'module_interval' => 300,
|
||||||
'max' => 0,
|
'max' => 0,
|
||||||
@ -1065,6 +1072,7 @@ function snmp_browser_create_modules_snmp(string $module_target, array $snmp_val
|
|||||||
'ff_type' => 0,
|
'ff_type' => 0,
|
||||||
'each_ff' => 0,
|
'each_ff' => 0,
|
||||||
'ip_target' => $target_ip,
|
'ip_target' => $target_ip,
|
||||||
|
'history_data' => 1,
|
||||||
];
|
];
|
||||||
foreach ($id_target as $agent) {
|
foreach ($id_target as $agent) {
|
||||||
$ids[] = modules_create_agent_module($agent, $oid['oid'], $values);
|
$ids[] = modules_create_agent_module($agent, $oid['oid'], $values);
|
||||||
@ -1073,7 +1081,7 @@ function snmp_browser_create_modules_snmp(string $module_target, array $snmp_val
|
|||||||
// Policies only in enterprise version.
|
// Policies only in enterprise version.
|
||||||
if (enterprise_installed()) {
|
if (enterprise_installed()) {
|
||||||
$values = [
|
$values = [
|
||||||
'id_tipo_modulo' => 17,
|
'id_tipo_modulo' => $module_type,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'module_interval' => 300,
|
'module_interval' => 300,
|
||||||
'max' => 0,
|
'max' => 0,
|
||||||
@ -1123,6 +1131,7 @@ function snmp_browser_create_modules_snmp(string $module_target, array $snmp_val
|
|||||||
'each_ff' => 0,
|
'each_ff' => 0,
|
||||||
'ip_target' => $target_ip,
|
'ip_target' => $target_ip,
|
||||||
'configuration_data' => '',
|
'configuration_data' => '',
|
||||||
|
'history_data' => 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
enterprise_include_once('include/functions_policies.php');
|
enterprise_include_once('include/functions_policies.php');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user