The only way to send traps to all configured trap sinks is to first initialize as a net-snmp agent. More...
#include <string>
#include <SNMPpp/OID.hpp>
#include <SNMPpp/PDU.hpp>
#include <SNMPpp/Varlist.hpp>
#include <SNMPpp/net-snmppp.hpp>
#include <sys/types.h>
#include <time.h>
Go to the source code of this file.
Namespaces | |
SNMPpp | |
Constant Groups | |
SNMPpp | |
Functions | |
long | SNMPpp::centisecondsNetSnmpUptime (void) |
Return the uptime in centiseconds. More... | |
long | SNMPpp::centisecondsPidStarted (pid_t pid=0) |
Return the uptime in centiseconds. More... | |
long | SNMPpp::centisecondsSince (const time_t t) |
Return the time since t . More... | |
long | SNMPpp::centisecondsUptime (void) |
Return the number of centiseconds since the last reboot. More... | |
SNMPpp::Varlist | SNMPpp::createV2TrapVarlist (const SNMPpp::OID &o, const long uptime=SNMPpp::centisecondsNetSnmpUptime()) |
Initialize a varlist to be eventually used with one of the sendV2Trap() functions. More... | |
void | SNMPpp::initializeNetSnmpAgent (const std::string &name="snmppp") |
Initialize net-snmp AgentX. More... | |
void | SNMPpp::sendV2Trap (const SNMPpp::OID &o, const long uptime=SNMPpp::centisecondsNetSnmpUptime()) |
Send a SNMPv2 trap to all configured trapsinks in net-snmp. More... | |
void | SNMPpp::sendV2Trap (SNMPpp::Varlist &varlist) |
Send a SNMPv2 trap to alll configured trapsinks in net-snmp. More... | |
void | SNMPpp::sendV2Trap (SNMPpp::PDU &pdu) |
Similar to SNMPpp::sendV2Trap( SNMPpp::Varlist &vl ). More... | |
void | SNMPpp::shutdownNetSnmpAgent (const std::string &name="snmppp") |
De-initialize net-snmp AgentX. More... | |
The only way to send traps to all configured trap sinks is to first initialize as a net-snmp agent.
If the process you are writing is already an net-snmp agent, then all is fine. But if the process is NOT already a SNMP agent, then you need to make the following call to initialize a connection to SNMPD prior to sending out a trap.
Calling SNMPpp::initializeNetSnmpAgent() will make your application a net-snmp agent by calling init_agent(), init_snmp(), and init_traps().
If your application is logging errors of this sort when trying to send a SNMP trap:
Warning: Failed to connect to the agentx master agent ([NIL])
...then it means there are permission problems. You either need to run your application as "root", or you need to open up the permissions on AgentX in /etc/snmp/snmpd.conf. Search for "agentXPerms" for details.
If your application is logging errors of this sort when trying to send a SNMP trap:
Cannot rename /var/lib/snmp/snmppp.conf to /var/lib/snmp/snmppp.0.conf Cannot unlink /var/lib/snmp/snmppp.conf read_config_store open failure on /var/lib/snmp/snmppp.conf
...then it means you either have to run as "root", or you need to ensure that /var/lib/snmp is writeable by the same user/group as your application.
If your application is logging errors of this sort when trying to send a SNMP trap:
truncating integer value > 32 bits send_trap: no v2 trapOID varbind provided
...then it means net-snmp traps haven't been initialized. Are you certain you've called SNMPpp::initializeNetSnmpAgent()?