From a2d9a66d8b56a629b44ad23eca6929680a75f042 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sat, 5 Aug 2006 23:59:37 +0000 Subject: Add SNMP version 2c support. See #55 --- ChangeLog | 1 + daemon/config.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1b6a8cc..6b39426 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ - Reduced memory usage of SNMP requests - Added asynchronous DNS resolver - Added support for RRD files not in the normal places + - Added SNMP version 2c support 0.3 - Initial public release diff --git a/daemon/config.c b/daemon/config.c index a47b5f2..4245279 100644 --- a/daemon/config.c +++ b/daemon/config.c @@ -75,7 +75,10 @@ config_ctx; #define CONFIG_INTERVAL "interval" #define CONFIG_TIMEOUT "timeout" #define CONFIG_SOURCE "source" + #define CONFIG_SNMP "snmp" +#define CONFIG_SNMP2 "snmp2" +#define CONFIG_SNMP2C "snmp2c" #define FIELD_VALID "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-0123456789." @@ -205,6 +208,7 @@ parse_item(const char* field, char* uri, config_ctx *ctx) rb_host *rhost; int r; + enum snmp_version version; const char *msg; char* copy; char* scheme; @@ -221,10 +225,14 @@ parse_item(const char* field, char* uri, config_ctx *ctx) ASSERT(host && path); - /* TODO: SNMP version support */ - /* Currently we only support SNMP pollers */ - if(strcmp(scheme, CONFIG_SNMP) != 0) + if(strcmp(scheme, CONFIG_SNMP) == 0) + version = SNMP_V1; + else if(strcmp(scheme, CONFIG_SNMP2) == 0) + version = SNMP_V2c; + else if(strcmp(scheme, CONFIG_SNMP2C) == 0) + version = SNMP_V2c; + else errx(2, "%s: invalid poll scheme: %s", ctx->confname, scheme); /* TODO: THis code assumes all hosts have the same community @@ -239,8 +247,7 @@ parse_item(const char* field, char* uri, config_ctx *ctx) if(!hsh_set(g_state.host_by_name, host, -1, rhost)) errx(1, "out of memory"); - /* TODO: Version support */ - rhost->version = 1; + rhost->version = version; rhost->name = host; rhost->community = user ? user : "public"; rhost->is_resolved = 1; -- cgit v1.2.3