"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/zabbix_server/poller/checks_snmp.c" between
zabbix-5.4.2.tar.gz and zabbix-5.4.3.tar.gz

About: ZABBIX is an enterprise-class distributed monitoring solution for servers and applications.

checks_snmp.c  (zabbix-5.4.2):checks_snmp.c  (zabbix-5.4.3)
skipping to change at line 105 skipping to change at line 105
zbx_snmpidx_main_key_t; zbx_snmpidx_main_key_t;
typedef struct typedef struct
{ {
char *value; char *value;
char *index; char *index;
} }
zbx_snmpidx_mapping_t; zbx_snmpidx_mapping_t;
static zbx_hashset_t snmpidx; /* Dynamic Index Cache */ static zbx_hashset_t snmpidx; /* Dynamic Index Cache */
static char zbx_snmp_init_done;
static zbx_hash_t __snmpidx_main_key_hash(const void *data) static zbx_hash_t __snmpidx_main_key_hash(const void *data)
{ {
const zbx_snmpidx_main_key_t *main_key = (const zbx_snmpidx_main_key_t *)data; const zbx_snmpidx_main_key_t *main_key = (const zbx_snmpidx_main_key_t *)data;
zbx_hash_t hash; zbx_hash_t hash;
hash = ZBX_DEFAULT_STRING_HASH_FUNC(main_key->addr); hash = ZBX_DEFAULT_STRING_HASH_FUNC(main_key->addr);
hash = ZBX_DEFAULT_STRING_HASH_ALGO(&main_key->port, sizeof(main_key->por t), hash); hash = ZBX_DEFAULT_STRING_HASH_ALGO(&main_key->port, sizeof(main_key->por t), hash);
hash = ZBX_DEFAULT_STRING_HASH_ALGO(main_key->oid, strlen(main_key->oid), hash); hash = ZBX_DEFAULT_STRING_HASH_ALGO(main_key->oid, strlen(main_key->oid), hash);
skipping to change at line 2109 skipping to change at line 2110
int get_value_snmp(const DC_ITEM *item, AGENT_RESULT *result, unsigned char p oller_type) int get_value_snmp(const DC_ITEM *item, AGENT_RESULT *result, unsigned char p oller_type)
{ {
int errcode = SUCCEED; int errcode = SUCCEED;
get_values_snmp(item, result, &errcode, 1, poller_type); get_values_snmp(item, result, &errcode, 1, poller_type);
return errcode; return errcode;
} }
static void zbx_init_snmp(void)
{
sigset_t mask, orig_mask;
if (1 == zbx_snmp_init_done)
return;
sigemptyset(&mask);
sigaddset(&mask, SIGTERM);
sigaddset(&mask, SIGUSR2);
sigaddset(&mask, SIGHUP);
sigaddset(&mask, SIGQUIT);
sigprocmask(SIG_BLOCK, &mask, &orig_mask);
init_snmp(progname);
zbx_snmp_init_done = 1;
sigprocmask(SIG_SETMASK, &orig_mask, NULL);
}
void get_values_snmp(const DC_ITEM *items, AGENT_RESULT *results, int *errcode s, int num, unsigned char poller_type) void get_values_snmp(const DC_ITEM *items, AGENT_RESULT *results, int *errcode s, int num, unsigned char poller_type)
{ {
struct snmp_session *ss; struct snmp_session *ss;
char error[MAX_STRING_LEN]; char error[MAX_STRING_LEN];
int i, j, err = SUCCEED, max_succeed = 0, min_fail = MAX_SNMP_ITEMS + 1, int i, j, err = SUCCEED, max_succeed = 0, min_fail = MAX_SNMP_ITEMS + 1,
bulk = SNMP_BULK_ENABLED; bulk = SNMP_BULK_ENABLED;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() host:'%s' addr:'%s' num:%d", zabbix_log(LOG_LEVEL_DEBUG, "In %s() host:'%s' addr:'%s' num:%d",
__func__, items[0].host.host, items[0].interface.addr, nu m); __func__, items[0].host.host, items[0].interface.addr, nu m);
zbx_init_snmp(); /* avoid high CPU usage by only initializing SNMP
once used */
for (j = 0; j < num; j++) /* locate first supported item to use as a reference */ for (j = 0; j < num; j++) /* locate first supported item to use as a reference */
{ {
if (SUCCEED == errcodes[j]) if (SUCCEED == errcodes[j])
break; break;
} }
if (j == num) /* all items already NOTSUPPORTED (with invalid key, port or SNMP parameters) */ if (j == num) /* all items already NOTSUPPORTED (with invalid key, port or SNMP parameters) */
goto out; goto out;
if (NULL == (ss = zbx_snmp_open_session(&items[j], error, sizeof(error))) ) if (NULL == (ss = zbx_snmp_open_session(&items[j], error, sizeof(error))) )
skipping to change at line 2179 skipping to change at line 2202
} }
} }
else if (SNMP_BULK_ENABLED == bulk && (0 != max_succeed || MAX_SNMP_ITEMS + 1 != min_fail)) else if (SNMP_BULK_ENABLED == bulk && (0 != max_succeed || MAX_SNMP_ITEMS + 1 != min_fail))
{ {
DCconfig_update_interface_snmp_stats(items[j].interface.interface id, max_succeed, min_fail); DCconfig_update_interface_snmp_stats(items[j].interface.interface id, max_succeed, min_fail);
} }
out: out:
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__); zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __func__);
} }
void zbx_init_snmp(void)
{
sigset_t mask, orig_mask;
sigemptyset(&mask);
sigaddset(&mask, SIGTERM);
sigaddset(&mask, SIGUSR2);
sigaddset(&mask, SIGHUP);
sigaddset(&mask, SIGQUIT);
sigprocmask(SIG_BLOCK, &mask, &orig_mask);
init_snmp(progname);
sigprocmask(SIG_SETMASK, &orig_mask, NULL);
}
static void zbx_shutdown_snmp(void) static void zbx_shutdown_snmp(void)
{ {
sigset_t mask, orig_mask; sigset_t mask, orig_mask;
sigemptyset(&mask); sigemptyset(&mask);
sigaddset(&mask, SIGTERM); sigaddset(&mask, SIGTERM);
sigaddset(&mask, SIGUSR2); sigaddset(&mask, SIGUSR2);
sigaddset(&mask, SIGHUP); sigaddset(&mask, SIGHUP);
sigaddset(&mask, SIGQUIT); sigaddset(&mask, SIGQUIT);
sigprocmask(SIG_BLOCK, &mask, &orig_mask); sigprocmask(SIG_BLOCK, &mask, &orig_mask);
snmp_shutdown(progname); snmp_shutdown(progname);
zbx_snmp_init_done = 0;
sigprocmask(SIG_SETMASK, &orig_mask, NULL); sigprocmask(SIG_SETMASK, &orig_mask, NULL);
} }
void zbx_clear_cache_snmp(unsigned char process_type, int process_num) void zbx_clear_cache_snmp(unsigned char process_type, int process_num)
{ {
zabbix_log(LOG_LEVEL_WARNING, "forced reloading of the snmp cache on [%s #%d]", get_process_type_string(process_type), zabbix_log(LOG_LEVEL_WARNING, "forced reloading of the snmp cache on [%s #%d]", get_process_type_string(process_type),
process_num); process_num);
if (0 == zbx_snmp_init_done)
return;
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PERSIST _STATE, 1); netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_DONT_PERSIST _STATE, 1);
zbx_shutdown_snmp(); zbx_shutdown_snmp();
zbx_init_snmp();
} }
#endif /* HAVE_NETSNMP */ #endif /* HAVE_NETSNMP */
 End of changes. 7 change blocks. 
17 lines changed or deleted 29 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)