Fixed the snmp wizard for uptime and added unit octets. TICKET: #1742
(cherry picked from commit 584d00f321
)
This commit is contained in:
parent
f19f971273
commit
ab12b4456a
|
@ -75,8 +75,8 @@ $static_snmp_descriptions = array(
|
||||||
'ssRawContexts' => 'Number of context switches',
|
'ssRawContexts' => 'Number of context switches',
|
||||||
'ssCpuRawUser' => 'user CPU time',
|
'ssCpuRawUser' => 'user CPU time',
|
||||||
'ssCpuRawSystem' => 'system CPU time',
|
'ssCpuRawSystem' => 'system CPU time',
|
||||||
'ssCpuRawIdle' => 'idle CPU time'
|
'ssCpuRawIdle' => 'idle CPU time',
|
||||||
);
|
'sysUpTime' => 'system Up time');
|
||||||
|
|
||||||
$static_snmp_oids = array(
|
$static_snmp_oids = array(
|
||||||
'Load-1' => '.1.3.6.1.4.1.2021.10.1.5.1',
|
'Load-1' => '.1.3.6.1.4.1.2021.10.1.5.1',
|
||||||
|
@ -98,8 +98,11 @@ $static_snmp_oids = array(
|
||||||
'ssRawContexts' => '.1.3.6.1.4.1.2021.11.60.0',
|
'ssRawContexts' => '.1.3.6.1.4.1.2021.11.60.0',
|
||||||
'ssCpuRawUser' => '.1.3.6.1.4.1.2021.11.50.0',
|
'ssCpuRawUser' => '.1.3.6.1.4.1.2021.11.50.0',
|
||||||
'ssCpuRawSystem' => '.1.3.6.1.4.1.2021.11.52.0',
|
'ssCpuRawSystem' => '.1.3.6.1.4.1.2021.11.52.0',
|
||||||
'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0'
|
'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0',
|
||||||
);
|
'sysUpTime' => '1.3.6.1.2.1.1.3.0');
|
||||||
|
|
||||||
|
$static_snmp_post_process = array(
|
||||||
|
'sysUpTime' => "0.00000011574074");
|
||||||
|
|
||||||
// Using plugin
|
// Using plugin
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
|
@ -450,6 +453,10 @@ if ($create_modules) {
|
||||||
|
|
||||||
$module_values['descripcion'] = $static_snmp_descriptions[$snmpdata_name];
|
$module_values['descripcion'] = $static_snmp_descriptions[$snmpdata_name];
|
||||||
$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp');
|
$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp');
|
||||||
|
if (isset($static_snmp_post_process[$snmpdata_name])) {
|
||||||
|
$module_values['post_process'] =
|
||||||
|
$static_snmp_post_process[$snmpdata_name];
|
||||||
|
}
|
||||||
|
|
||||||
//Average use of CPUs is a plugin module
|
//Average use of CPUs is a plugin module
|
||||||
switch ($snmpdata_name) {
|
switch ($snmpdata_name) {
|
||||||
|
@ -460,7 +467,7 @@ if ($create_modules) {
|
||||||
|
|
||||||
$macros = json_decode($plugin['macros'], true);
|
$macros = json_decode($plugin['macros'], true);
|
||||||
|
|
||||||
foreach($macros as $k => $macro) {
|
foreach ($macros as $k => $macro) {
|
||||||
switch($macro['macro']) {
|
switch($macro['macro']) {
|
||||||
case '_field1_':
|
case '_field1_':
|
||||||
// Field 1 is the IP Address
|
// Field 1 is the IP Address
|
||||||
|
@ -656,7 +663,8 @@ if ($create_modules) {
|
||||||
unset($module_values['ip_target']); //ip_target
|
unset($module_values['ip_target']); //ip_target
|
||||||
unset($module_values['tcp_send']); //snmp_version
|
unset($module_values['tcp_send']); //snmp_version
|
||||||
|
|
||||||
$result = modules_create_agent_module($id_agent, io_safe_input($disk), $module_values);
|
$result = modules_create_agent_module($id_agent,
|
||||||
|
io_safe_input($disk), $module_values);
|
||||||
|
|
||||||
$results[$result][] = $disk;
|
$results[$result][] = $disk;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,53 +157,57 @@ if ($create_modules) {
|
||||||
$ifPhysAddress = $interfaces[$id]['ifPhysAddress']['value'];
|
$ifPhysAddress = $interfaces[$id]['ifPhysAddress']['value'];
|
||||||
}
|
}
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
$oid_array = explode('.',$module);
|
$oid_array = explode('.', $module);
|
||||||
$oid_array[count($oid_array)-1] = $id;
|
$oid_array[count($oid_array) - 1] = $id;
|
||||||
$oid = implode('.',$oid_array);
|
$oid = implode('.', $oid_array);
|
||||||
|
|
||||||
// Get the name
|
// Get the name
|
||||||
$name_array = explode('::',$oid_array[0]);
|
$name_array = explode('::', $oid_array[0]);
|
||||||
$name = $name_array[1] . "_" . $ifname;
|
$name = $name_array[1] . "_" . $ifname;
|
||||||
|
|
||||||
// Clean the name
|
// Clean the name
|
||||||
$name = str_replace ( "\"" , "" , $name);
|
$name = str_replace ( "\"" , "" , $name);
|
||||||
|
|
||||||
// Proc moduletypes
|
// Proc moduletypes
|
||||||
if (preg_match ( "/Status/", $name_array[1]))
|
if (preg_match ("/Status/", $name_array[1]))
|
||||||
$module_type = 18;
|
$module_type = 18;
|
||||||
|
|
||||||
elseif (preg_match ( "/Present/", $name_array[1]))
|
elseif (preg_match ("/Present/", $name_array[1]))
|
||||||
$module_type = 18;
|
$module_type = 18;
|
||||||
|
|
||||||
elseif (preg_match ( "/PromiscuousMode/", $name_array[1]))
|
elseif (preg_match("/PromiscuousMode/", $name_array[1]))
|
||||||
$module_type = 18;
|
$module_type = 18;
|
||||||
|
|
||||||
// String moduletypes
|
// String moduletypes
|
||||||
elseif (preg_match ( "/Alias/", $name_array[1]))
|
elseif (preg_match("/Alias/", $name_array[1]))
|
||||||
$module_type = 17;
|
$module_type = 17;
|
||||||
|
|
||||||
elseif (preg_match ( "/Address/", $name_array[1]))
|
elseif (preg_match("/Address/", $name_array[1]))
|
||||||
$module_type = 17;
|
$module_type = 17;
|
||||||
|
|
||||||
elseif (preg_match ( "/Name/", $name_array[1]))
|
elseif (preg_match("/Name/", $name_array[1]))
|
||||||
$module_type = 17;
|
$module_type = 17;
|
||||||
|
|
||||||
elseif (preg_match ( "/Specific/", $name_array[1]))
|
elseif (preg_match("/Specific/", $name_array[1]))
|
||||||
$module_type = 17;
|
$module_type = 17;
|
||||||
|
|
||||||
elseif (preg_match ( "/Descr/", $name_array[1]))
|
elseif (preg_match("/Descr/", $name_array[1]))
|
||||||
$module_type = 17;
|
$module_type = 17;
|
||||||
|
|
||||||
// Specific counters (ends in s)
|
// Specific counters (ends in s)
|
||||||
elseif (preg_match ( "/s$/", $name_array[1]))
|
elseif (preg_match("/s$/", $name_array[1]))
|
||||||
$module_type = 16;
|
$module_type = 16;
|
||||||
|
|
||||||
// Otherwise, numeric
|
// Otherwise, numeric
|
||||||
else
|
else
|
||||||
$module_type = 15;
|
$module_type = 15;
|
||||||
|
|
||||||
|
if (preg_match("/Octets/", $name_array[1])) {
|
||||||
|
$values['unit'] = "Bytes";
|
||||||
|
}
|
||||||
|
|
||||||
$values['id_tipo_modulo'] = $module_type;
|
$values['id_tipo_modulo'] = $module_type;
|
||||||
|
|
||||||
if (!empty($ifPhysAddress))
|
if (!empty($ifPhysAddress))
|
||||||
$values['descripcion'] = io_safe_input("(".$ip_target." - ".$ifPhysAddress." - ".$name.") " . $interfaces[$id]['ifDescr']['value']);
|
$values['descripcion'] = io_safe_input("(".$ip_target." - ".$ifPhysAddress." - ".$name.") " . $interfaces[$id]['ifDescr']['value']);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue