/** Initializes the cpqHost module */ void init_cpqHost(void) { DEBUGMSGTL(("cpqHost", "Initializing\n")); myDistro = getDistroInfo(); cpqHostMibStatusArray[CPQMIB].major = CPQMIBREVMAJOR; cpqHostMibStatusArray[CPQMIB].minor = CPQMIBREVMINOR; netsnmp_register_scalar_group( netsnmp_create_handler_registration("cpqHostMib", cpqHostMib_handler, cpqHostMib_oid, OID_LENGTH(cpqHostMib_oid), HANDLER_CAN_RONLY), CPQHOSTMIBREVMAJOR, CPQHOSTMIBCONDITION); netsnmp_register_scalar_group( netsnmp_create_handler_registration("cpqHostInfo", cpqHostInfo_handler, cpqHostInfo_oid, OID_LENGTH(cpqHostInfo_oid), HANDLER_CAN_RONLY), CPQHOSTNAME, CPQHOSTSYSDESCR); init_cpqHoFileSysTable(); init_cpqHoSwVerTable(); init_cpqHostOsMem(); init_cpqHoSWRunningTable(); /* * register ourselves with the agent to handle our mib tree */ REGISTER_MIB("cpqHostOs", cpqHostOs_variables, variable7, cpqHostOs_variables_oid); /* * place any other initialization junk you need here */ cpqHostMibStatusArray[CPQMIB].stat = MIB_STATUS_AVAILABLE; cpqHostMibStatusArray[CPQMIB].cond = MIB_CONDITION_OK; DEBUGMSGTL(("cpqHost", "Checkinging periodic test trap interval = %d\n", testtrap_interval)); if (testtrap_interval >= 0) { if ((GenericDataStr = getenv(GenericDataEnv)) != (char *) 0) GenericData = GenericDataStr; DEBUGMSGTL(("cpqHost", "Registering periodic test trap alarm\n")); SendcpqHostGenericTrap(); if (testtrap_interval > 0) { if (snmp_alarm_register(testtrap_interval, SA_REPEAT, (SNMPAlarmCallback *) &SendcpqHostGenericTrap, NULL) == 0 ) DEBUGMSGTL(("cpqHost", "Alarm register failed\n")); } } }
/** Initializes the snmp module */ void init_snmp_mib(void) { DEBUGMSGTL(("snmp", "Initializing\n")); netsnmp_register_scalar_group( netsnmp_create_handler_registration( "mibII/snmp", handle_snmp, snmp_oid, OID_LENGTH(snmp_oid), HANDLER_CAN_RONLY), 1, 32); { const oid snmpEnableAuthenTraps_oid[] = { 1, 3, 6, 1, 2, 1, 11, 30, 0 }; static netsnmp_watcher_info enableauthen_info; netsnmp_handler_registration *reg = netsnmp_create_update_handler_registration( "mibII/snmpEnableAuthenTraps", snmpEnableAuthenTraps_oid, OID_LENGTH(snmpEnableAuthenTraps_oid), HANDLER_CAN_RWRITE, &snmp_enableauthentrapsset); netsnmp_inject_handler(reg, netsnmp_get_truthvalue()); netsnmp_register_watched_instance( reg, netsnmp_init_watcher_info( &enableauthen_info, &snmp_enableauthentraps, sizeof(snmp_enableauthentraps), ASN_INTEGER, WATCHER_FIXED_SIZE)); } #ifdef USING_MIBII_SYSTEM_MIB_MODULE if (++system_module_count == 3) REGISTER_SYSOR_TABLE(system_module_oid, system_module_oid_len, "The MIB module for SNMPv2 entities"); #endif snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA, snmp_enableauthentraps_store, NULL); }
/** Initializes the memory module */ void init_memory(void) { const oid memory_oid[] = { 1, 3, 6, 1, 4, 1, 2021, 4 }; const oid memSwapError_oid[] = { 1, 3, 6, 1, 4, 1, 2021, 4, 100 }; const oid memSwapErrMsg_oid[] = { 1, 3, 6, 1, 4, 1, 2021, 4, 101 }; DEBUGMSGTL(("memory", "Initializing\n")); netsnmp_register_scalar_group( netsnmp_create_handler_registration("memory", handle_memory, memory_oid, OID_LENGTH(memory_oid), HANDLER_CAN_RONLY), 1, 17); netsnmp_register_scalar( netsnmp_create_handler_registration("memSwapError", handle_memory, memSwapError_oid, OID_LENGTH(memSwapError_oid), HANDLER_CAN_RONLY)); netsnmp_register_scalar( netsnmp_create_handler_registration("memSwapErrMsg", handle_memory, memSwapErrMsg_oid, OID_LENGTH(memSwapErrMsg_oid), HANDLER_CAN_RONLY)); snmpd_register_config_handler("swap", memory_parse_config, memory_free_config, "min-avail"); }
/** Initializes the cpqScsi module */ void init_cpqScsi(void) { DEBUGMSGTL(("cpqScsi", "Initializing\n")); cpqHostMibStatusArray[CPQMIB].major = CPQMIBREVMAJOR; cpqHostMibStatusArray[CPQMIB].minor = CPQMIBREVMINOR; cpqHoMibHealthStatusArray[CPQMIBHEALTHINDEX] = MIB_CONDITION_OK; /* * register ourselves with the agent to handle our mib tree */ netsnmp_register_scalar_group( netsnmp_create_handler_registration("cpqScsi", cpqScsi_handler, cpqScsiMib_oid, cpqScsiMib_oid_len, HANDLER_CAN_RONLY), CPQSCSIMIBREVMAJOR, CPQSCSIMIBCONDITION); initialize_table_cpqSasHbaTable(); initialize_table_cpqSasPhyDrvTable(); /* * place any other initialization junk you need here */ cpqHostMibStatusArray[CPQMIB].stat = MIB_STATUS_AVAILABLE; cpqHostMibStatusArray[CPQMIB].cond = MIB_CONDITION_OK; }
int netsnmp_register_statistic_handler(netsnmp_handler_registration *reginfo, oid start, int begin, int end) { netsnmp_inject_handler(reginfo, netsnmp_get_statistic_handler(begin - start)); return netsnmp_register_scalar_group(reginfo, start, start + (end - begin)); }
void init_vmstat (void) { const oid vmstat_oid[] = { NETSNMP_UCDAVIS_MIB, 11 }; DEBUGMSGTL (("vmstat", "Initializing\n")); netsnmp_register_scalar_group (netsnmp_create_handler_registration ("vmstat", vmstat_handler, vmstat_oid, OID_LENGTH (vmstat_oid), HANDLER_CAN_RONLY), MIBINDEX, CPURAWGUESTNICE); }
void init_ip(void) { netsnmp_handler_registration *reginfo; /* * register ourselves with the agent as a group of scalars... */ DEBUGMSGTL(("mibII/ip", "Initialising IP group\n")); reginfo = netsnmp_create_handler_registration("ip", ip_handler, ip_oid, OID_LENGTH(ip_oid), HANDLER_CAN_RONLY); netsnmp_register_scalar_group(reginfo, IPFORWARDING, IPROUTEDISCARDS); /* * .... with a local cache * (except for HP-UX 11, which extracts objects individually) */ #ifndef hpux11 netsnmp_inject_handler( reginfo, netsnmp_get_cache_handler(IP_STATS_CACHE_TIMEOUT, ip_load, ip_free, ip_oid, OID_LENGTH(ip_oid))); #endif /* * register (using the old-style API) to handle the IP tables */ REGISTER_MIB("mibII/ipaddr", ipaddr_variables, variable1, ipaddr_variables_oid); REGISTER_MIB("mibII/iproute", iproute_variables, variable1, iproute_variables_oid); REGISTER_MIB("mibII/ipmedia", ipmedia_variables, variable1, ipmedia_variables_oid); if (++ip_module_count == 2) REGISTER_SYSOR_ENTRY(ip_module_oid, "The MIB module for managing IP and ICMP implementations"); /* * for speed optimization, we call this now to do the lookup */ #ifdef IPSTAT_SYMBOL auto_nlist(IPSTAT_SYMBOL, 0, 0); #endif #ifdef IP_FORWARDING_SYMBOL auto_nlist(IP_FORWARDING_SYMBOL, 0, 0); #endif #ifdef TCP_TTL_SYMBOL auto_nlist(TCP_TTL_SYMBOL, 0, 0); #endif #ifdef MIB_IPCOUNTER_SYMBOL auto_nlist(MIB_IPCOUNTER_SYMBOL, 0, 0); #endif #ifdef solaris2 init_kernel_sunos5(); #endif }
/** Initializes the sctp_scalars module */ void init_sctpScalars (void) { netsnmp_handler_registration *reginfo_stats; netsnmp_handler_registration *reginfo_params; int rc; DEBUGMSGTL (("sctp:scalars:init", "Initializing\n")); reginfo_stats = netsnmp_create_handler_registration ("sctpStats", sctp_stats_handler, sctp_stats_oid, OID_LENGTH (sctp_stats_oid), HANDLER_CAN_RONLY); if (!reginfo_stats) return; rc = netsnmp_register_scalar_group (reginfo_stats, SCTP_CURRESTAB, SCTP_DISCONTINUITYTIME); if (rc != SNMPERR_SUCCESS) return; netsnmp_inject_handler (reginfo_stats, netsnmp_get_cache_handler (SCTP_STATS_CACHE_TIMEOUT, netsnmp_access_sctp_stats_load, netsnmp_access_sctp_stats_free, sctp_stats_oid, OID_LENGTH (sctp_stats_oid))); reginfo_params = netsnmp_create_handler_registration ("sctpParams", sctp_params_handler, sctp_params_oid, OID_LENGTH (sctp_params_oid), HANDLER_CAN_RONLY); if (!reginfo_params) return; rc = netsnmp_register_scalar_group (reginfo_params, SCTP_RTOALGORITHM, SCTP_MAXINITRETR); if (!rc) return; netsnmp_inject_handler (reginfo_params, netsnmp_get_cache_handler (SCTP_PARAMS_CACHE_TIMEOUT, netsnmp_access_sctp_params_load, netsnmp_access_sctp_params_free, sctp_params_oid, OID_LENGTH (sctp_params_oid))); }
void init_subagent(switch_memory_pool_t *pool) { static oid identity_oid[] = { 1,3,6,1,4,1,27880,1,1 }; static oid systemStats_oid[] = { 1,3,6,1,4,1,27880,1,2 }; static oid channelList_oid[] = { 1,3,6,1,4,1,27880,1,9 }; DEBUGMSGTL(("init_subagent", "mod_snmp subagent initializing\n")); netsnmp_register_scalar_group(netsnmp_create_handler_registration("identity", handle_identity, identity_oid, OID_LENGTH(identity_oid), HANDLER_CAN_RONLY), 1, 2); netsnmp_register_scalar_group(netsnmp_create_handler_registration("systemStats", handle_systemStats, systemStats_oid, OID_LENGTH(systemStats_oid), HANDLER_CAN_RONLY), 1, 11); ch_table_info = switch_core_alloc(pool, sizeof(netsnmp_table_registration_info)); netsnmp_table_helper_add_indexes(ch_table_info, ASN_INTEGER, 0); ch_table_info->min_column = CH_INDEX; ch_table_info->max_column = CH_WRITE_BITRATE; ch_table = netsnmp_tdata_create_table("channelList", 0); ch_reginfo = netsnmp_create_handler_registration("channelList", handle_channelList, channelList_oid, OID_LENGTH(channelList_oid), HANDLER_CAN_RONLY); netsnmp_tdata_register(ch_reginfo, ch_table, ch_table_info); netsnmp_inject_handler(ch_reginfo, netsnmp_get_cache_handler(5, channelList_load, channelList_free, channelList_oid, OID_LENGTH(channelList_oid))); }
void init_tcp(void) { netsnmp_handler_registration *reginfo; int rc; /* * register ourselves with the agent as a group of scalars... */ DEBUGMSGTL(("mibII/tcpScalar", "Initialising TCP scalar group\n")); reginfo = netsnmp_create_handler_registration("tcp", tcp_handler, tcp_oid, OID_LENGTH(tcp_oid), HANDLER_CAN_RONLY); rc = netsnmp_register_scalar_group(reginfo, TCPRTOALGORITHM, TCPOUTRSTS); if (rc != SNMPERR_SUCCESS) return; /* * .... with a local cache * (except for HP-UX 11, which extracts objects individually) */ #ifndef hpux11 netsnmp_inject_handler( reginfo, netsnmp_get_cache_handler(TCP_STATS_CACHE_TIMEOUT, tcp_load, tcp_free, tcp_oid, OID_LENGTH(tcp_oid))); #endif REGISTER_SYSOR_ENTRY(tcp_module_oid, "The MIB module for managing TCP implementations"); #if !defined(_USE_FIRST_PROTOCOL) #ifdef TCPSTAT_SYMBOL auto_nlist(TCPSTAT_SYMBOL, 0, 0); #endif #ifdef TCP_SYMBOL auto_nlist(TCP_SYMBOL, 0, 0); #endif #ifdef freebsd4 hz = sysconf(_SC_CLK_TCK); /* get ticks/s from system */ #endif #ifdef solaris2 init_kernel_sunos5(); #endif #endif }
void init_udp(void) { netsnmp_handler_registration *reginfo; int rc; /* * register ourselves with the agent as a group of scalars... */ DEBUGMSGTL(("mibII/udpScalar", "Initialising UDP scalar group\n")); reginfo = netsnmp_create_handler_registration("udp", udp_handler, udp_oid, OID_LENGTH(udp_oid), HANDLER_CAN_RONLY); rc = netsnmp_register_scalar_group(reginfo, UDPINDATAGRAMS, UDPOUTDATAGRAMS); if (rc != SNMPERR_SUCCESS) return; /* * .... with a local cache * (except for HP-UX 11, which extracts objects individually) */ #ifndef hpux11 netsnmp_inject_handler( reginfo, netsnmp_get_cache_handler(UDP_STATS_CACHE_TIMEOUT, udp_load, udp_free, udp_oid, OID_LENGTH(udp_oid))); #endif REGISTER_SYSOR_ENTRY(udp_module_oid, "The MIB module for managing UDP implementations"); #if !defined(_USE_PERFSTAT_PROTOCOL) #ifdef UDPSTAT_SYMBOL auto_nlist(UDPSTAT_SYMBOL, 0, 0); #endif #ifdef UDB_SYMBOL auto_nlist(UDB_SYMBOL, 0, 0); #endif #ifdef solaris2 init_kernel_sunos5(); #endif #endif }
void initialize_cpqNicIfLogMapOverallCondition(void) { const oid cpqNicIfLogMapOverallCondition_oid[] = { 1, 3, 6, 1, 4, 1, 232, 18, 2, 2 }; const size_t cpqNicIfLogMapOverallCondition_oid_len = OID_LENGTH(cpqNicIfLogMapOverallCondition_oid); DEBUGMSGTL(("cpqNic", "Initializing cpqNicIfLogMapOverallCondition\n")); /* * register ourselves with the agent to handle our mib tree */ netsnmp_register_scalar_group( netsnmp_create_handler_registration("cpqNicIfLogMapOverallCondition", cpqNicIfLogMapOverallCondition_handler, cpqNicIfLogMapOverallCondition_oid, cpqNicIfLogMapOverallCondition_oid_len, HANDLER_CAN_RONLY), CPQNICIFLOGMAPOVERALLCONDITION, CPQNICIFLOGMAPOVERALLCONDITION); }
void init_icmp(void) { netsnmp_handler_registration *reginfo; /* * register ourselves with the agent as a group of scalars... */ DEBUGMSGTL(("mibII/icmp", "Initialising ICMP group\n")); reginfo = netsnmp_create_handler_registration("icmp", icmp_handler, icmp_oid, OID_LENGTH(icmp_oid), HANDLER_CAN_RONLY); netsnmp_register_scalar_group(reginfo, ICMPINMSGS, ICMPOUTADDRMASKREPS); /* * .... with a local cache * (except for HP-UX 11, which extracts objects individually) */ #ifndef hpux11 netsnmp_inject_handler( reginfo, netsnmp_get_cache_handler(ICMP_STATS_CACHE_TIMEOUT, icmp_load, icmp_free, icmp_oid, OID_LENGTH(icmp_oid))); #endif #ifdef USING_MIBII_IP_MODULE if (++ip_module_count == 2) REGISTER_SYSOR_TABLE(ip_module_oid, ip_module_oid_len, "The MIB module for managing IP and ICMP implementations"); #endif #ifdef ICMPSTAT_SYMBOL auto_nlist(ICMPSTAT_SYMBOL, 0, 0); #endif #ifdef solaris2 init_kernel_sunos5(); #endif }
void init_netflow(void) { netsnmp_handler_registration *reg; struct snmp_vars *sys; /* snmpd -f -L -Dnetflow,dlmod */ DEBUGMSGTL(("netflow", "init_netflow\n")); netsnmp_register_scalar_group( netsnmp_create_handler_registration( "iptNetflowModule", iptNetflowModule_handler, iptNetflowModule_oid, OID_LENGTH(iptNetflowModule_oid), HANDLER_CAN_RONLY), 1, var_max(modinfos)); netsnmp_register_scalar_group( netsnmp_create_handler_registration( "iptNetflowSysctl", iptNetflowSysctl_handler, iptNetflowSysctl_oid, OID_LENGTH(iptNetflowSysctl_oid), HANDLER_CAN_RWRITE), 1, var_max(sysctls)); netsnmp_register_scalar_group( netsnmp_create_handler_registration( "iptNetflowTotals", iptNetflowTotals_handler, iptNetflowTotals_oid, OID_LENGTH(iptNetflowTotals_oid), HANDLER_CAN_RONLY), 1, var_max(totals)); /* Register first table. */ reg = netsnmp_create_handler_registration( "iptNetflowCpuTable", /* no handler */ NULL, iptNetflowCpuTable_oid, OID_LENGTH(iptNetflowCpuTable_oid), HANDLER_CAN_RONLY); /* set up columns */ cpu_data_set = netsnmp_create_table_data_set("iptNetflowCpuDataSet"); netsnmp_table_set_add_indexes(cpu_data_set, ASN_INTEGER, 0); /* I include cpuIndex into columns, which is not SMIv2'ish */ for (sys = cputable; sys->obj; sys++) netsnmp_table_set_add_default_row(cpu_data_set, sys->obj, sys->type, 0, NULL, 0); netsnmp_register_table_data_set(reg, cpu_data_set, NULL); /* cache handler will load actual data, and it needs to be * injected in front of dataset handler to be called first */ stat_cache = netsnmp_cache_create( /* no timeout */ -1, stat_cache_load, dummy_cache_free, iptNetflowCpuTable_oid, OID_LENGTH(iptNetflowCpuTable_oid)); netsnmp_inject_handler(reg, netsnmp_cache_handler_get(stat_cache)); /* Register second table. */ reg = netsnmp_create_handler_registration( "iptNetflowSockTable", /* no handler */ NULL, iptNetflowSockTable_oid, OID_LENGTH(iptNetflowSockTable_oid), HANDLER_CAN_RONLY); /* set up columns */ sock_data_set = netsnmp_create_table_data_set("iptNetflowSockDataSet"); /* I don't include sockIndex into columns, which is more SMIv2'ish */ netsnmp_table_set_add_indexes(sock_data_set, ASN_INTEGER, 0); for (sys = &socktable[1]; sys->obj; sys++) netsnmp_table_set_add_default_row(sock_data_set, sys->obj, sys->type, 0, NULL, 0); netsnmp_register_table_data_set(reg, sock_data_set, NULL); /* as before, cache handler will load actual data, and it needs * to be injected in front of dataset handler to be called first */ stat_cache = netsnmp_cache_create( /* no timeout */ -1, stat_cache_load, dummy_cache_free, iptNetflowSockTable_oid, OID_LENGTH(iptNetflowSockTable_oid)); netsnmp_inject_handler(reg, netsnmp_cache_handler_get(stat_cache)); }
void init_icmp(void) { netsnmp_handler_registration *reginfo; netsnmp_handler_registration *msg_stats_reginfo; netsnmp_iterator_info *iinfo; netsnmp_iterator_info *msg_stats_iinfo; netsnmp_table_registration_info *table_info; netsnmp_table_registration_info *msg_stats_table_info; /* * register ourselves with the agent as a group of scalars... */ DEBUGMSGTL(("mibII/icmp", "Initialising ICMP group\n")); reginfo = netsnmp_create_handler_registration("icmp", icmp_handler, icmp_oid, OID_LENGTH(icmp_oid), HANDLER_CAN_RONLY); netsnmp_register_scalar_group(reginfo, ICMPINMSGS, ICMPOUTADDRMASKREPS); /* * .... with a local cache * (except for HP-UX 11, which extracts objects individually) */ #ifndef hpux11 netsnmp_inject_handler( reginfo, netsnmp_get_cache_handler(ICMP_STATS_CACHE_TIMEOUT, icmp_load, icmp_free, icmp_oid, OID_LENGTH(icmp_oid))); #endif #ifdef linux /* register icmpStatsTable */ reginfo = netsnmp_create_handler_registration("icmpStatsTable", icmp_stats_table_handler, icmp_stats_tbl_oid, OID_LENGTH(icmp_stats_tbl_oid), HANDLER_CAN_RONLY); table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); if (!table_info) { return; } netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, 0); table_info->min_column = ICMP_STAT_INMSG; table_info->max_column = ICMP_STAT_OUTERR; iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info); if (!iinfo) { return; } iinfo->get_first_data_point = icmp_stats_first_entry; iinfo->get_next_data_point = icmp_stats_next_entry; iinfo->table_reginfo = table_info; netsnmp_register_table_iterator(reginfo, iinfo); /* register icmpMsgStatsTable */ msg_stats_reginfo = netsnmp_create_handler_registration("icmpMsgStatsTable", icmp_msg_stats_table_handler, icmp_msg_stats_tbl_oid, OID_LENGTH(icmp_msg_stats_tbl_oid), HANDLER_CAN_RONLY); msg_stats_table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info); if (!msg_stats_table_info) { return; } netsnmp_table_helper_add_indexes(msg_stats_table_info, ASN_INTEGER, ASN_INTEGER, 0); msg_stats_table_info->min_column = ICMP_MSG_STAT_IN_PKTS; msg_stats_table_info->max_column = ICMP_MSG_STAT_OUT_PKTS; msg_stats_iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info); if (!msg_stats_iinfo) { return; } msg_stats_iinfo->get_first_data_point = icmp_msg_stats_first_entry; msg_stats_iinfo->get_next_data_point = icmp_msg_stats_next_entry; msg_stats_iinfo->table_reginfo = msg_stats_table_info; netsnmp_register_table_iterator(msg_stats_reginfo, msg_stats_iinfo); netsnmp_inject_handler( msg_stats_reginfo, netsnmp_get_cache_handler(ICMP_STATS_CACHE_TIMEOUT, icmp_load, icmp_free, icmp_msg_stats_tbl_oid, OID_LENGTH(icmp_msg_stats_tbl_oid))); #ifndef hpux11 netsnmp_inject_handler( reginfo, netsnmp_get_cache_handler(ICMP_STATS_CACHE_TIMEOUT, icmp_load, icmp_free, icmp_stats_tbl_oid, OID_LENGTH(icmp_stats_tbl_oid))); #endif /* ! hpux11 */ #endif /* linux */ #ifdef USING_MIBII_IP_MODULE if (++ip_module_count == 2) REGISTER_SYSOR_TABLE(ip_module_oid, ip_module_oid_len, "The MIB module for managing IP and ICMP implementations"); #endif #if !defined(_USE_PERFSTAT_PROTOCOL) #ifdef ICMPSTAT_SYMBOL auto_nlist(ICMPSTAT_SYMBOL, 0, 0); #endif #ifdef solaris2 init_kernel_sunos5(); #endif #endif }