Closed flying-bigbird closed 1 year ago
Describe the bug A clear and concise description of what the bug is. error Undefined offset in mactrack_function.php
$i = 0; foreach($ifIndexes as $ifIndex) { $ifInterfaces[$ifIndex]['ifIndex'] = $ifIndex; $ifInterfaces[$ifIndex]['ifName'] = (isset($ifNames[$ifIndex]) ? $ifNames[$ifIndex] : ''); $ifInterfaces[$ifIndex]['ifType'] = (isset($ifTypes[$ifIndex]) ? $ifTypes[$ifIndex] : ''); if ($getLinkPorts) { $ifInterfaces[$ifIndex]['linkPort'] = (isset($link_ports[$ifIndex]) ? $link_ports[$ifIndex] : ''); $linkPort = (isset($link_ports[$ifIndex]) ? $link_ports[$ifIndex] : ''); } else { $linkPort = 0; } if (($getAlias) && (cacti_sizeof($ifAliases))) { $ifInterfaces[$ifIndex]['ifAlias'] = (isset($ifAliases[$ifIndex]) ? $ifAliases[$ifIndex] : ''); $ifAlias = (isset($ifAliases[$ifIndex]) ? $ifAliases[$ifIndex] : ''); } else { $ifAlias = ''; } /* update the last up/down status */ if (!isset($db_interface[$ifIndex]['ifOperStatus'])) { if ($ifOperStatus[$ifIndex] == 1) { $last_up_time = date('Y-m-d H:i:s'); $stateChanges = 0; $last_down_time = 0; } else { $stateChanges = 0; $last_up_time = 0; $last_down_time = date('Y-m-d H:i:s'); } } else { $last_up_time = $db_interface[$ifIndex]['last_up_time']; $last_down_time = $db_interface[$ifIndex]['last_down_time']; $stateChanges = $db_interface[$ifIndex]['stateChanges']; if ($db_interface[$ifIndex]['ifOperStatus'] == 0) { /* interface previously not up */ if ($ifOperStatus[$ifIndex] == 1) { /* the interface just went up, mark the time */ $last_up_time = date('Y-m-d H:i:s'); $stateChanges += 1; /* if the interface has never been marked down before, make it the current time */ if ($db_interface[$ifIndex]['last_down_time'] == '0000-00-00 00:00:00') { $last_down_time = $last_up_time; } } else { /* if the interface has never been down, make the current time */ $last_down_time = date('Y-m-d H:i:s'); /* if the interface stayed down, set the last up time if not set before */ if ($db_interface[$ifIndex]['last_up_time'] == '0000-00-00 00:00:00') { $last_up_time = date('Y-m-d H:i:s'); } } } else { if ($ifOperStatus[$ifIndex] == 0) { /* the interface just went down, mark the time */ $last_down_time = date('Y-m-d H:i:s'); $stateChanges += 1; /* if the interface has never been up before, mark it the current time */ if ($db_interface[$ifIndex]['last_up_time'] == '0000-00-00 00:00:00') { $last_up_time = date('Y-m-d H:i:s'); } } else { $last_up_time = date('Y-m-d H:i:s'); if ($db_interface[$ifIndex]['last_down_time'] == '0000-00-00 00:00:00') { $last_down_time = date('Y-m-d H:i:s'); } } } } /* do the in octets */ $int_ifInOctets = get_link_int_value('ifInOctets', $ifIndex, $ifInOctets, $db_interface, $divisor, 'traffic'); /* do the out octets */ $int_ifOutOctets = get_link_int_value('ifOutOctets', $ifIndex, $ifOutOctets, $db_interface, $divisor, 'traffic'); if ($device['snmp_version'] > 1) { /* do the in octets */ $int_ifHCInOctets = get_link_int_value('ifHCInOctets', $ifIndex, $ifHCInOctets, $db_interface, $divisor, 'traffic', '64'); /* do the out octets */ $int_ifHCOutOctets = get_link_int_value('ifHCOutOctets', $ifIndex, $ifHCOutOctets, $db_interface, $divisor, 'traffic', '64'); } /* accomodate values in high speed octets for interfaces that don't support 64 bit */ if (isset($ifInOctets[$ifIndex])) { if (!isset($ifHCInOctets[$ifIndex])) { $ifHCInOctets[$ifIndex] = $ifInOctets[$ifIndex]; $int_ifHCInOctets = $int_ifInOctets; } } if (isset($ifOutOctets[$ifIndex])) { if (!isset($ifHCOutOctets[$ifIndex])) { $ifHCOutOctets[$ifIndex] = $ifOutOctets[$ifIndex]; $int_ifHCOutOctets = $int_ifOutOctets; } } $int_ifInMulticastPkts = get_link_int_value('ifInMulticastPkts', $ifIndex, $ifInMulticastPkts, $db_interface, $divisor, 'traffic'); $int_ifOutMulticastPkts = get_link_int_value('ifOutMulticastPkts', $ifIndex, $ifOutMulticastPkts, $db_interface, $divisor, 'traffic'); $int_ifInBroadcastPkts = get_link_int_value('ifInBroadcastPkts', $ifIndex, $ifInBroadcastPkts, $db_interface, $divisor, 'traffic'); $int_ifOutBroadcastPkts = get_link_int_value('ifOutBroadcastPkts', $ifIndex, $ifOutBroadcastPkts, $db_interface, $divisor, 'traffic'); $int_ifInUcastPkts = get_link_int_value('ifInUcastPkts', $ifIndex, $ifInUcastPkts, $db_interface, $divisor, 'traffic'); $int_ifOutUcastPkts = get_link_int_value('ifOutUcastPkts', $ifIndex, $ifOutUcastPkts, $db_interface, $divisor, 'traffic'); /* see if in error's have been increasing */ $int_ifInErrors = get_link_int_value('ifInErrors', $ifIndex, $ifInErrors, $db_interface, $divisor, 'errors'); /* see if out error's have been increasing */ $int_ifOutErrors = get_link_int_value('ifOutErrors', $ifIndex, $ifOutErrors, $db_interface, $divisor, 'errors'); if ($int_ifInErrors > 0 || $int_ifOutErrors > 0) { $int_errors_present = true; } else { $int_errors_present = false; } /* see if in discards's have been increasing */ $int_ifInDiscards = get_link_int_value('ifInDiscards', $ifIndex, $ifInDiscards, $db_interface, $divisor, 'errors'); /* see if out discards's have been increasing */ $int_ifOutDiscards = get_link_int_value('ifOutDiscards', $ifIndex, $ifOutDiscards, $db_interface, $divisor, 'errors'); if ($int_ifInDiscards > 0 || $int_ifOutDiscards > 0) { $int_discards_present = true; } else { $int_discards_present = false; } /* see if in discards's have been increasing */ $int_ifInUnknownProtos = get_link_int_value('ifInUnknownProtos', $ifIndex, $ifInUnknownProtos, $db_interface, $divisor, 'errors'); /* format the update packet */ if ($i == 0) { $insert_vals .= ' '; } else { $insert_vals .= ','; } $mac_address = isset($ifPhysAddress[$ifIndex]) ? xform_mac_address($ifPhysAddress[$ifIndex]):''; $insert_vals .= "('" . @$device['site_id'] . "', '" . @$device['device_id'] . "', '" . @$device['snmp_sysUptime'] . "', '" . @$ifIndex . "', '" . @$ifTypes[$ifIndex] . "', " . @db_qstr(@$ifNames[$ifIndex]) . ", " . @db_qstr($ifAlias) . ", '" . @$linkPort . "', '" . @$vlan_id . "', " . @db_qstr(@$vlan_name) . ", '" . @$vlan_trunk . "', '" . @$ifSpeed[$ifIndex] . "', '" . (isset($ifHighSpeed[$ifIndex]) ? $ifHighSpeed[$ifIndex] : '') . "', '" . (isset($ifDuplex[$ifIndex]) ? $ifDuplex[$ifIndex] : '') . "', " . @db_qstr(@$ifDescr[$ifIndex]) . ", '" . (isset($ifMtu[$ifIndex]) ? $ifMtu[$ifIndex] : '') . "', '" . $mac_address . "', '" . (isset($ifAdminStatus[$ifIndex]) ? $ifAdminStatus[$ifIndex] : '') . "', '" . (isset($ifOperStatus[$ifIndex]) ? $ifOperStatus[$ifIndex] : '') . "', '" . (isset($ifLastChange[$ifIndex]) ? $ifLastChange[$ifIndex] : '') . "', '" . (isset($ifInOctets[$ifIndex]) ? $ifInOctets[$ifIndex] : '') . "', '" . (isset($ifOutOctets[$ifIndex]) ? $ifOutOctets[$ifIndex] : '') . "', '" . (isset($ifHCInOctets[$ifIndex]) ? $ifHCInOctets[$ifIndex] : '') . "', '" . (isset($ifHCOutOctets[$ifIndex]) ? $ifHCOutOctets[$ifIndex] : '') . "', '" . (isset($ifInUcastPkts[$ifIndex]) ? $ifInUcastPkts[$ifIndex] : '') . "', '" . (isset($ifOutUcastPkts[$ifIndex]) ? $ifOutUcastPkts[$ifIndex] : '') . "', '" . (isset($ifInDiscards[$ifIndex]) ? $ifInDiscards[$ifIndex] : '') . "', '" . (isset($ifInErrors[$ifIndex]) ? $ifInErrors[$ifIndex] : '') . "', '" . (isset($ifInUnknownProtos[$ifIndex]) ? $ifInUnknownProtos[$ifIndex] : '') . "', '" . (isset($ifOutDiscards[$ifIndex]) ? $ifOutDiscards[$ifIndex] : '') . "', '" . (isset($ifOutErrors[$ifIndex]) ? $ifOutErrors[$ifIndex] : '') . "', '" . (isset($ifInMulticastPkts[$ifIndex]) ? $ifInMulticastPkts[$ifIndex] : '') . "', '" . (isset($ifOutMulticastPkts[$ifIndex]) ? $ifOutMulticastPkts[$ifIndex] : '') . "', '" . (isset($ifInBroadcastPkts[$ifIndex]) ? $ifInBroadcastPkts[$ifIndex] : '') . "', '" . (isset($ifOutBroadcastPkts[$ifIndex]) ? $ifOutBroadcastPkts[$ifIndex] : '') . "', '" . @$int_ifInOctets . "', '" . @$int_ifOutOctets . "', '" . @$int_ifHCInOctets . "', '" . @$int_ifHCOutOctets . "', '" . @$int_ifInMulticastPkts . "', '" . @$int_ifOutMulticastPkts . "', '" . @$int_ifInBroadcastPkts . "', '" . @$int_ifOutBroadcastPkts . "', '" . @$int_ifInUcastPkts . "', '" . @$int_ifOutUcastPkts . "', '" . @$int_ifInDiscards . "', '" . @$int_ifInErrors . "', '" . @$int_ifInUnknownProtos . "', '" . @$int_ifOutDiscards . "', '" . @$int_ifOutErrors . "', '" . @$int_discards_present . "', '" . $int_errors_present . "', '" . $last_down_time . "', '" . $last_up_time . "', '" . $stateChanges . "', '" . "1')"; $i++; }
Screenshots If applicable, add screenshots to help explain your problem.
Plugin (please complete the following information):
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context I find the problem is array i out of range ,How to fix it!
I have fix it。 if (@$ifOperStatus[$ifIndex] == 1) { if (@$ifOperStatus[$ifIndex] == 0) {
Try again. There is something much larger afoot. Just not sure what it is.
Describe the bug A clear and concise description of what the bug is. error Undefined offset in mactrack_function.php
Screenshots If applicable, add screenshots to help explain your problem.
Plugin (please complete the following information):
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context I find the problem is array i out of range ,How to fix it!
I have fix it。 if (@$ifOperStatus[$ifIndex] == 1) { if (@$ifOperStatus[$ifIndex] == 0) {