Try to improve logging of snmp errors

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@38585 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2015-05-29 15:29:53 +00:00
parent 81b8112c91
commit f6adb66c4e
2 changed files with 27 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2015-05-29 Richard Frith-Macdonald <rfm@gnu.org>
* EcAlarmSinkSNMP.m: log SNMP errors via the main logging mechanism
or NSLog.
2015-03-26 Richard Frith-Macdonald <rfm@gnu.org> 2015-03-26 Richard Frith-Macdonald <rfm@gnu.org>
* Control.plist: * Control.plist:

View file

@ -225,6 +225,21 @@ static size_t trapSequenceNumber_len = 0;
static oid *trendIndicator_oid = 0; static oid *trendIndicator_oid = 0;
static size_t trendIndicator_len = 0; static size_t trendIndicator_len = 0;
static int
logSNMP(int major, int minor, void* server, void* client)
{
struct snmp_log_message *slm = (struct snmp_log_message *)server;
if (nil == EcProc)
{
NSLog(@"%s", slm->msg);
}
else
{
[EcProc cmdAlert: @"%s", slm->msg];
}
return 0;
}
static const char * static const char *
stringFromDate(NSDate *d) stringFromDate(NSDate *d)
@ -1087,8 +1102,14 @@ objectsTable_handler(netsnmp_mib_handler *handler,
NSString *p; NSString *p;
NSDictionary *d; NSDictionary *d;
init_snmp_logging();
snmp_disable_filelog();
snmp_disable_stderrlog();
snmp_enable_calllog(); snmp_enable_calllog();
snmp_enable_stderrlog();
/* register the callback function to record SNMP errors */
snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_LOGGING,
logSNMP, NULL);
/* Make us an agentx client. /* Make us an agentx client.
*/ */