693759: RHEL 6 SS8: Log files fill up quickly when running hp-snmp-agents Backported from RHEL6 diff -ur net-snmp-5.3.2.2/agent/mibgroup/if-mib/data_access/interface.c old/agent/mibgroup/if-mib/data_access/interface.c --- net-snmp-5.3.2.2/agent/mibgroup/if-mib/data_access/interface.c 2011-04-05 15:31:28.339539850 +0200 +++ old/agent/mibgroup/if-mib/data_access/interface.c 2011-04-05 15:30:53.620813424 +0200 @@ -518,38 +518,70 @@ memcpy(prev_vals->old_stats, &prev_vals->stats, sizeof(new_vals->stats)); } - netsnmp_c64_check32_and_update(&prev_vals->stats.ibytes, + if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.ibytes, &new_vals->stats.ibytes, &prev_vals->old_stats->ibytes, - &need_wrap_check); - netsnmp_c64_check32_and_update(&prev_vals->stats.iucast, + &need_wrap_check)) + NETSNMP_LOGONCE((LOG_ERR, + "Error expanding ifHCInOctets to 64bits\n")); + + if (new_vals->ns_flags & NETSNMP_INTERFACE_FLAGS_CALCULATE_UCAST) { + if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.iall, + &new_vals->stats.iall, + &prev_vals->old_stats->iall, + &need_wrap_check)) + NETSNMP_LOGONCE((LOG_ERR, + "Error expanding packet count to 64bits\n")); + } else { + if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.iucast, &new_vals->stats.iucast, &prev_vals->old_stats->iucast, - &need_wrap_check); - netsnmp_c64_check32_and_update(&prev_vals->stats.imcast, + &need_wrap_check)) + NETSNMP_LOGONCE((LOG_ERR, + "Error expanding ifHCInUcastPkts to 64bits\n")); + } + + if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.imcast, &new_vals->stats.imcast, &prev_vals->old_stats->imcast, - &need_wrap_check); - netsnmp_c64_check32_and_update(&prev_vals->stats.ibcast, + &need_wrap_check)) + NETSNMP_LOGONCE((LOG_ERR, + "Error expanding ifHCInMulticastPkts to 64bits\n")); + + if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.ibcast, &new_vals->stats.ibcast, &prev_vals->old_stats->ibcast, - &need_wrap_check); - netsnmp_c64_check32_and_update(&prev_vals->stats.obytes, + &need_wrap_check)) + NETSNMP_LOGONCE((LOG_ERR, + "Error expanding ifHCInBroadcastPkts to 64bits\n")); + + if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.obytes, &new_vals->stats.obytes, &prev_vals->old_stats->obytes, - &need_wrap_check); - netsnmp_c64_check32_and_update(&prev_vals->stats.oucast, + &need_wrap_check)) + NETSNMP_LOGONCE((LOG_ERR, + "Error expanding ifHCOutOctets to 64bits\n")); + + if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.oucast, &new_vals->stats.oucast, &prev_vals->old_stats->oucast, - &need_wrap_check); - netsnmp_c64_check32_and_update(&prev_vals->stats.omcast, + &need_wrap_check)) + NETSNMP_LOGONCE((LOG_ERR, + "Error expanding ifHCOutUcastPkts to 64bits\n")); + + if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.omcast, &new_vals->stats.omcast, &prev_vals->old_stats->omcast, - &need_wrap_check); - netsnmp_c64_check32_and_update(&prev_vals->stats.obcast, + &need_wrap_check)) + NETSNMP_LOGONCE((LOG_ERR, + "Error expanding ifHCOutMulticastPkts to 64bits\n")); + + if (0 != netsnmp_c64_check32_and_update(&prev_vals->stats.obcast, &new_vals->stats.obcast, &prev_vals->old_stats->obcast, - &need_wrap_check); + &need_wrap_check)) + NETSNMP_LOGONCE((LOG_ERR, + "Error expanding ifHCOutBroadcastPkts to 64bits\n")); /* * Copy 32 bit counters @@ -582,6 +614,23 @@ } /** + * Calculate stats + * + * @retval 0 : success + * @retval -1 : error + */ +int +netsnmp_access_interface_entry_calculate_stats(netsnmp_interface_entry *entry) +{ + DEBUGMSGTL(("access:interface", "calculate_stats\n")); + if (entry->ns_flags & NETSNMP_INTERFACE_FLAGS_CALCULATE_UCAST) { + u64Subtract(&entry->stats.iall, &entry->stats.imcast, + &entry->stats.iucast); + } + return 0; +} + +/** * copy interface entry data (after checking for counter wraps) * * @retval -2 : malloc failed @@ -603,6 +652,7 @@ * update stats */ netsnmp_access_interface_entry_update_stats(lhs, rhs); + netsnmp_access_interface_entry_calculate_stats(lhs); /* * update data diff -ur net-snmp-5.3.2.2/agent/mibgroup/if-mib/data_access/interface_linux.c old/agent/mibgroup/if-mib/data_access/interface_linux.c --- net-snmp-5.3.2.2/agent/mibgroup/if-mib/data_access/interface_linux.c 2011-04-05 15:31:28.620529542 +0200 +++ old/agent/mibgroup/if-mib/data_access/interface_linux.c 2011-04-05 15:30:35.129491676 +0200 @@ -420,16 +420,15 @@ * subtract out multicast packets from rec_pkt before * we store it as unicast counter. */ - rec_pkt -= rec_mcast; - + entry->ns_flags |= NETSNMP_INTERFACE_FLAGS_CALCULATE_UCAST; entry->stats.ibytes.low = rec_oct & 0xffffffff; - entry->stats.iucast.low = rec_pkt & 0xffffffff; + entry->stats.iall.low = rec_pkt & 0xffffffff; entry->stats.imcast.low = rec_mcast & 0xffffffff; entry->stats.obytes.low = snd_oct & 0xffffffff; entry->stats.oucast.low = snd_pkt & 0xffffffff; #ifdef SCNuMAX /* XXX - should be flag for 64-bit variables */ entry->stats.ibytes.high = rec_oct >> 32; - entry->stats.iucast.high = rec_pkt >> 32; + entry->stats.iall.high = rec_pkt >> 32; entry->stats.imcast.high = rec_mcast >> 32; entry->stats.obytes.high = snd_oct >> 32; entry->stats.oucast.high = snd_pkt >> 32; diff -ur net-snmp-5.3.2.2/config.log old/config.log diff -ur net-snmp-5.3.2.2/include/net-snmp/data_access/interface.h old/include/net-snmp/data_access/interface.h --- net-snmp-5.3.2.2/include/net-snmp/data_access/interface.h 2011-04-05 15:31:28.620529542 +0200 +++ old/include/net-snmp/data_access/interface.h 2011-04-05 15:30:59.381602113 +0200 @@ -34,6 +34,20 @@ #define NETSNMP_INTERFACE_FLAGS_HAS_V6_REACHABLE 0x00040000 #define NETSNMP_INTERFACE_FLAGS_HAS_V6_IFID 0x00080000 #define NETSNMP_INTERFACE_FLAGS_HAS_V6_FORWARDING 0x00100000 +/* Some platforms, e.g.Linux, do not provide standalone counter + * for incoming unicast packets - they provide counter of all packets + * + separate counter for the multicast ones. + * That means the counter of all packets must watched and checked + * for overflows to reconstruct its 64-bit value (i.e. as usual + * for counter of unicast packets), and after its expansion to 64-bits, + * nr.of multicast packets must be substracted to get nr. of unicast + * packets. + * This flag marks stats of such platforms. Nr. of all incoming packets, + * provided by the platform, must be stored in + * netsnmp_interface_stats.iall and netsnmp_interface_stats.iucast will + * be automatically calculated later. + */ +#define NETSNMP_INTERFACE_FLAGS_CALCULATE_UCAST 0x00200000 /************************************************************* * constants for enums for the MIB node @@ -89,6 +103,11 @@ */ /** input */ struct counter64 ibytes; + /* + * nr. of all packets (to calculate iucast, when underlying platform does + * not provide it) + */ + struct counter64 iall; struct counter64 iucast; struct counter64 imcast; struct counter64 ibcast;