📄 target_counters.c
字号:
#include <net-snmp/net-snmp-config.h>#if HAVE_STRING_H#include <string.h>#else#include <strings.h>#endif#include <net-snmp/net-snmp-includes.h>#include <net-snmp/agent/net-snmp-agent-includes.h>#include "target_counters.h"#include <net-snmp/agent/instance.h>static oid unavailable_context_oid[] = { 1, 3, 6, 1, 6, 3, 12, 1, 4 };static oid unknown_context_oid[] = { 1, 3, 6, 1, 6, 3, 12, 1, 5 };voidinit_target_counters(void){ DEBUGMSGTL(("target_counters", "initializing\n")); /* * unknown contexts */ netsnmp_register_scalar( netsnmp_create_handler_registration("snmpUnknownContexts", get_unknown_context_count, unknown_context_oid, OID_LENGTH(unknown_context_oid), HANDLER_CAN_RONLY)); /* * unavailable contexts */ netsnmp_register_scalar( netsnmp_create_handler_registration("snmpUnavailableContexts", get_unavailable_context_count, unavailable_context_oid, OID_LENGTH(unavailable_context_oid), HANDLER_CAN_RONLY));}intget_unknown_context_count(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests){ /* * we're only called for GETs of the right node, so this is easy: */ u_long long_ret = snmp_get_statistic(STAT_SNMPUNKNOWNCONTEXTS); snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER, (u_char *) & long_ret, sizeof(long_ret)); return SNMP_ERR_NOERROR;}intget_unavailable_context_count(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests){ /* * we're only called for GETs of the right node, so this is easy: */ u_long long_ret = snmp_get_statistic(STAT_SNMPUNAVAILABLECONTEXTS); snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER, (u_char *) & long_ret, sizeof(long_ret)); return SNMP_ERR_NOERROR;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -