static int create_v2_inform_session (char *sink, u_short sinkport, char *com) { return create_trap_session( sink, sinkport, com, SNMP_VERSION_2c, SNMP_MSG_INFORM ); }
int main (int argc, char **argv) { std::vector<std::string> trap_ips; char* community = NULL; int c; opterr = 0; while ((c = getopt (argc, argv, "i:c:")) != -1) { switch (c) { case 'c': community = optarg; break; case 'i': Utils::split_string(optarg, ',', trap_ips); break; default: abort (); } } // Log SNMP library output to syslog snmp_enable_calllog(); // Set ourselves up as a subagent netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1); init_agent("clearwater-alarms"); // Connect to the informsinks for (std::vector<std::string>::iterator ii = trap_ips.begin(); ii != trap_ips.end(); ii++) { create_trap_session(const_cast<char*>(ii->c_str()), 161, community, SNMP_VERSION_2c, SNMP_MSG_INFORM); } // Initialise the ZMQ listeners and alarm tables // Pull in any local alarm definitions off the node. This is currently a // hard coded path to a single file - this should be a (configurable?) path // to a folder. std::string local_alarms_path = "/usr/share/clearwater/infrastructure/local_alarms.json"; AlarmTableDefs::get_instance().initialize(local_alarms_path); AlarmReqListener::get_instance().start(); init_alarmModelTable(); init_ituAlarmTable(); // Run forever init_snmp("clearwater-alarms"); signal(SIGTERM, terminate_handler); while (!done) { agent_check_and_process(1); } snmp_shutdown("clearwater-alarms"); return 0; }
static int create_v1_trap_session (char *sink, u_short sinkport, char *com) { return create_trap_session( sink, sinkport, com, SNMP_VERSION_1, SNMP_MSG_TRAP ); }