summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-08-05 23:59:37 +0000
committerStef Walter <stef@memberwebs.com>2006-08-05 23:59:37 +0000
commita2d9a66d8b56a629b44ad23eca6929680a75f042 (patch)
treeb1d6cee9d17a0a3a91573dcb177779b6ddef1da9 /daemon
parent00bea63466b04190bd48bf7c984f303a92fbb8f5 (diff)
Add SNMP version 2c support. See #55
Diffstat (limited to 'daemon')
-rw-r--r--daemon/config.c17
1 files changed, 12 insertions, 5 deletions
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;