Fix a problem with high CPU consumption (up to 30%) by bsnmpd on a loaded system.
Instead of constantly calling the mibII_idle function when the server is not busy call the function only once every 10 seconds to avoid bsnmpd constantly doing gettimeofday syscalls. Make the idle polling interval confugurable via begemotIfDataPoll. Reported and tested by: misho (at) aitbg (dot) com Oked by: harti MFC after: 1 week
This commit is contained in:
parent
2208eadf43
commit
bd96183d5e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=200063
@ -39,7 +39,7 @@ IMPORTS
|
|||||||
FROM BEGEMOT-IP-MIB;
|
FROM BEGEMOT-IP-MIB;
|
||||||
|
|
||||||
begemotMib2 MODULE-IDENTITY
|
begemotMib2 MODULE-IDENTITY
|
||||||
LAST-UPDATED "200602130000Z"
|
LAST-UPDATED "200908030000Z"
|
||||||
ORGANIZATION "German Aerospace Center"
|
ORGANIZATION "German Aerospace Center"
|
||||||
CONTACT-INFO
|
CONTACT-INFO
|
||||||
" Hartmut Brandt
|
" Hartmut Brandt
|
||||||
@ -54,6 +54,12 @@ begemotMib2 MODULE-IDENTITY
|
|||||||
E-mail: harti@freebsd.org"
|
E-mail: harti@freebsd.org"
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
"The MIB for private mib2 stuff."
|
"The MIB for private mib2 stuff."
|
||||||
|
REVISION "200908030000Z"
|
||||||
|
DESCRIPTION
|
||||||
|
"Second edition adds begemotIfDataPoll object."
|
||||||
|
REVISION "200602130000Z"
|
||||||
|
DESCRIPTION
|
||||||
|
"Initial revision."
|
||||||
::= { begemotIp 1 }
|
::= { begemotIp 1 }
|
||||||
|
|
||||||
begemotIfMaxspeed OBJECT-TYPE
|
begemotIfMaxspeed OBJECT-TYPE
|
||||||
@ -87,4 +93,14 @@ begemotIfForcePoll OBJECT-TYPE
|
|||||||
bit rate in its MIB."
|
bit rate in its MIB."
|
||||||
::= { begemotMib2 3 }
|
::= { begemotMib2 3 }
|
||||||
|
|
||||||
|
begemotIfDataPoll OBJECT-TYPE
|
||||||
|
SYNTAX TimeTicks
|
||||||
|
UNITS "deciseconds"
|
||||||
|
MAX-ACCESS read-write
|
||||||
|
STATUS current
|
||||||
|
DESCRIPTION
|
||||||
|
"The rate at which the mib2 module will poll interface data."
|
||||||
|
DEFVAL { 100 }
|
||||||
|
::= { begemotMib2 4 }
|
||||||
|
|
||||||
END
|
END
|
||||||
|
@ -117,6 +117,15 @@ u_int mibif_hc_update_interval;
|
|||||||
/* HC update timer handle */
|
/* HC update timer handle */
|
||||||
static void *hc_update_timer;
|
static void *hc_update_timer;
|
||||||
|
|
||||||
|
/* Idle poll timer */
|
||||||
|
static void *mibII_poll_timer;
|
||||||
|
|
||||||
|
/* interfaces' data poll interval */
|
||||||
|
u_int mibII_poll_ticks;
|
||||||
|
|
||||||
|
/* Idle poll hook */
|
||||||
|
static void mibII_idle(void *arg __unused);
|
||||||
|
|
||||||
/*****************************/
|
/*****************************/
|
||||||
|
|
||||||
static const struct asn_oid oid_ifMIB = OIDX_ifMIB;
|
static const struct asn_oid oid_ifMIB = OIDX_ifMIB;
|
||||||
@ -410,6 +419,20 @@ mibif_reset_hc_timer(void)
|
|||||||
mibif_hc_update_interval = ticks;
|
mibif_hc_update_interval = ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restart the idle poll timer.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mibif_restart_mibII_poll_timer(void)
|
||||||
|
{
|
||||||
|
if (mibII_poll_timer != NULL)
|
||||||
|
timer_stop(mibII_poll_timer);
|
||||||
|
|
||||||
|
if ((mibII_poll_timer = timer_start_repeat(mibII_poll_ticks * 10,
|
||||||
|
mibII_poll_ticks * 10, mibII_idle, NULL, module)) == NULL)
|
||||||
|
syslog(LOG_ERR, "timer_start(%u): %m", mibII_poll_ticks);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch new MIB data.
|
* Fetch new MIB data.
|
||||||
*/
|
*/
|
||||||
@ -1553,7 +1576,7 @@ get_cloners(void)
|
|||||||
* Idle function
|
* Idle function
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
mibII_idle(void)
|
mibII_idle(void *arg __unused)
|
||||||
{
|
{
|
||||||
struct mibifa *ifa;
|
struct mibifa *ifa;
|
||||||
|
|
||||||
@ -1608,6 +1631,10 @@ mibII_start(void)
|
|||||||
ipForward_reg = or_register(&oid_ipForward,
|
ipForward_reg = or_register(&oid_ipForward,
|
||||||
"The MIB module for the display of CIDR multipath IP Routes.",
|
"The MIB module for the display of CIDR multipath IP Routes.",
|
||||||
module);
|
module);
|
||||||
|
|
||||||
|
mibII_poll_timer = NULL;
|
||||||
|
mibII_poll_ticks = MIBII_POLL_TICKS;
|
||||||
|
mibif_restart_mibII_poll_timer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1651,6 +1678,11 @@ mibII_init(struct lmodule *mod, int argc __unused, char *argv[] __unused)
|
|||||||
static int
|
static int
|
||||||
mibII_fini(void)
|
mibII_fini(void)
|
||||||
{
|
{
|
||||||
|
if (mibII_poll_timer != NULL ) {
|
||||||
|
timer_stop(mibII_poll_timer);
|
||||||
|
mibII_poll_timer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (route_fd != NULL)
|
if (route_fd != NULL)
|
||||||
fd_deselect(route_fd);
|
fd_deselect(route_fd);
|
||||||
if (route != -1)
|
if (route != -1)
|
||||||
@ -1690,7 +1722,7 @@ const struct snmp_module config = {
|
|||||||
"This module implements the interface and ip groups.",
|
"This module implements the interface and ip groups.",
|
||||||
mibII_init,
|
mibII_init,
|
||||||
mibII_fini,
|
mibII_fini,
|
||||||
mibII_idle, /* idle */
|
NULL, /* idle */
|
||||||
NULL, /* dump */
|
NULL, /* dump */
|
||||||
NULL, /* config */
|
NULL, /* config */
|
||||||
mibII_start,
|
mibII_start,
|
||||||
|
@ -211,6 +211,14 @@ extern u_int mibif_hc_update_interval;
|
|||||||
/* re-compute update interval */
|
/* re-compute update interval */
|
||||||
void mibif_reset_hc_timer(void);
|
void mibif_reset_hc_timer(void);
|
||||||
|
|
||||||
|
/* interfaces' data poll interval */
|
||||||
|
extern u_int mibII_poll_ticks;
|
||||||
|
|
||||||
|
/* restart the data poll timer */
|
||||||
|
void mibif_restart_mibII_poll_timer(void);
|
||||||
|
|
||||||
|
#define MIBII_POLL_TICKS 100
|
||||||
|
|
||||||
/* get interfaces and interface addresses. */
|
/* get interfaces and interface addresses. */
|
||||||
void mib_fetch_interfaces(void);
|
void mib_fetch_interfaces(void);
|
||||||
|
|
||||||
|
@ -59,6 +59,11 @@ op_begemot_mibII(struct snmp_context *ctx __unused, struct snmp_value *value,
|
|||||||
ctx->scratch->int1 = mibif_force_hc_update_interval;
|
ctx->scratch->int1 = mibif_force_hc_update_interval;
|
||||||
mibif_force_hc_update_interval = value->v.uint32;
|
mibif_force_hc_update_interval = value->v.uint32;
|
||||||
return (SNMP_ERR_NOERROR);
|
return (SNMP_ERR_NOERROR);
|
||||||
|
|
||||||
|
case LEAF_begemotIfDataPoll:
|
||||||
|
ctx->scratch->int1 = mibII_poll_ticks;
|
||||||
|
mibII_poll_ticks = value->v.uint32;
|
||||||
|
return (SNMP_ERR_NOERROR);
|
||||||
}
|
}
|
||||||
abort();
|
abort();
|
||||||
|
|
||||||
@ -68,6 +73,10 @@ op_begemot_mibII(struct snmp_context *ctx __unused, struct snmp_value *value,
|
|||||||
case LEAF_begemotIfForcePoll:
|
case LEAF_begemotIfForcePoll:
|
||||||
mibif_force_hc_update_interval = ctx->scratch->int1;
|
mibif_force_hc_update_interval = ctx->scratch->int1;
|
||||||
return (SNMP_ERR_NOERROR);
|
return (SNMP_ERR_NOERROR);
|
||||||
|
|
||||||
|
case LEAF_begemotIfDataPoll:
|
||||||
|
mibII_poll_ticks = ctx->scratch->int1;
|
||||||
|
return (SNMP_ERR_NOERROR);
|
||||||
}
|
}
|
||||||
abort();
|
abort();
|
||||||
|
|
||||||
@ -78,6 +87,10 @@ op_begemot_mibII(struct snmp_context *ctx __unused, struct snmp_value *value,
|
|||||||
mibif_force_hc_update_interval = ctx->scratch->int1;
|
mibif_force_hc_update_interval = ctx->scratch->int1;
|
||||||
mibif_reset_hc_timer();
|
mibif_reset_hc_timer();
|
||||||
return (SNMP_ERR_NOERROR);
|
return (SNMP_ERR_NOERROR);
|
||||||
|
|
||||||
|
case LEAF_begemotIfDataPoll:
|
||||||
|
mibif_restart_mibII_poll_timer();
|
||||||
|
return (SNMP_ERR_NOERROR);
|
||||||
}
|
}
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -98,6 +111,10 @@ op_begemot_mibII(struct snmp_context *ctx __unused, struct snmp_value *value,
|
|||||||
case LEAF_begemotIfForcePoll:
|
case LEAF_begemotIfForcePoll:
|
||||||
value->v.uint32 = mibif_force_hc_update_interval;
|
value->v.uint32 = mibif_force_hc_update_interval;
|
||||||
return (SNMP_ERR_NOERROR);
|
return (SNMP_ERR_NOERROR);
|
||||||
|
|
||||||
|
case LEAF_begemotIfDataPoll:
|
||||||
|
value->v.uint32 = mibII_poll_ticks;
|
||||||
|
return (SNMP_ERR_NOERROR);
|
||||||
}
|
}
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -240,6 +240,7 @@
|
|||||||
(1 begemotIfMaxspeed COUNTER64 op_begemot_mibII GET)
|
(1 begemotIfMaxspeed COUNTER64 op_begemot_mibII GET)
|
||||||
(2 begemotIfPoll TIMETICKS op_begemot_mibII GET)
|
(2 begemotIfPoll TIMETICKS op_begemot_mibII GET)
|
||||||
(3 begemotIfForcePoll TIMETICKS op_begemot_mibII GET SET)
|
(3 begemotIfForcePoll TIMETICKS op_begemot_mibII GET SET)
|
||||||
|
(4 begemotIfDataPoll TIMETICKS op_begemot_mibII GET SET)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user