summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--daemon/config.c17
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;