summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-01-27 23:42:46 +0000
committerStef Walter <stef@memberwebs.com>2006-01-27 23:42:46 +0000
commite29f497cf007bae88b852fcc5e6c8ce2dbef66e5 (patch)
treecf5b21ff6455552d2eb3e76a624797c32079328f
parentcadd830e5aca1f208541ea6d38da5b4a863db5cc (diff)
Make the MIB directory configurable.
-rw-r--r--configure.in7
-rw-r--r--daemon/Makefile.am3
-rw-r--r--daemon/config.c5
-rw-r--r--daemon/rrdbotd.c23
-rw-r--r--daemon/rrdbotd.h2
-rw-r--r--daemon/snmp-help.c5
-rw-r--r--mib/parse-compat.inc.c4
7 files changed, 32 insertions, 17 deletions
diff --git a/configure.in b/configure.in
index 5f4f5bd..9c84543 100644
--- a/configure.in
+++ b/configure.in
@@ -37,13 +37,6 @@ AC_HEADER_STDC
AC_CHECK_HEADERS([rrd.h], , [echo "ERROR: rrd headers not found"])
dnl TODO: AC_CHECK_HEADERS
-# Have to resolve this for the path below
-if test "${prefix}" = "NONE"; then
- prefix=$ac_default_prefix
-fi
-
-AC_DEFINE_UNQUOTED(CONF_PREFIX, "`eval echo ${sysconfdir}`", [Installation Prefix] )
-
AC_MSG_RESULT()
AC_CONFIG_FILES([Makefile
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 969bafb..18b1217 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -8,5 +8,6 @@ rrdbotd_SOURCES = rrdbotd.c rrdbotd.h config.c usuals.h \
../common/stringx.h ../common/stringx.c \
../common/hash.h ../common/hash.c \
../mib/parse.c
-rrdbotd_CFLAGS = -I${top_srcdir}/common/ -I${top_srcdir}/bsnmp/ -I${top_srcdir}
+rrdbotd_CFLAGS = -I${top_srcdir}/common/ -I${top_srcdir}/bsnmp/ -I${top_srcdir} \
+ -DCONF_PREFIX=\"$(sysconfdir)\" -DDATA_PREFIX=\"$(datadir)\"
rrdbotd_LDADD = $(top_builddir)/bsnmp/libbsnmp-custom.a
diff --git a/daemon/config.c b/daemon/config.c
index d33ab69..39c5a37 100644
--- a/daemon/config.c
+++ b/daemon/config.c
@@ -528,7 +528,7 @@ rb_config_parse()
dir = opendir(g_state.confdir);
if(!dir)
- err("couldn't read config directory: %s", g_state.confdir);
+ err(1, "couldn't list config directory: %s", g_state.confdir);
while((dire = readdir(dir)) != NULL)
{
@@ -545,6 +545,9 @@ rb_config_parse()
parse_config_file(configfile, &ctx);
}
+ if(!g_state.polls)
+ errx(1, "no config files found in config directory: %s", g_state.confdir);
+
closedir(dir);
}
diff --git a/daemon/rrdbotd.c b/daemon/rrdbotd.c
index 8434e35..9ba17a4 100644
--- a/daemon/rrdbotd.c
+++ b/daemon/rrdbotd.c
@@ -52,6 +52,7 @@
/* The default command line options */
#define DEFAULT_CONFIG CONF_PREFIX "/rrdbot"
#define DEFAULT_WORK "/var/db/rrdbot"
+#define DEFAULT_MIB DATA_PREFIX "/mib"
#define DEFAULT_RETRIES 3
#define DEFAULT_TIMEOUT 5
@@ -63,6 +64,7 @@
rb_state g_state;
/* Whether we print warnings when loading MIBs or not */
+const char* g_mib_directory = DEFAULT_MIB;
int g_mib_warnings = 0;
/* Some logging flags */
@@ -207,12 +209,23 @@ rb_message (int level, const char* msg, ...)
static void
usage()
{
- fprintf(stderr, "usage: rrdbotd [-M] [-c confdir] [-w workdir] [-d level] [-p pidfile] [-r retries] [-t timeout]\n");
+ fprintf(stderr, "usage: rrdbotd [-M] [-c confdir] [-w workdir] [-m mibdir] \n");
+ fprintf(stderr, " [-d level] [-p pidfile] [-r retries] [-t timeout]\n");
fprintf(stderr, " rrdbotd -v\n");
exit(2);
}
static void
+version()
+{
+ printf("rrdbotd (version %s)\n", VERSION);
+ printf(" default config directory: %s\n", DEFAULT_CONFIG);
+ printf(" default work directory: %s\n", DEFAULT_WORK);
+ printf(" default mib directory: %s\n", DEFAULT_MIB);
+ exit(0);
+}
+
+static void
on_quit(int signal)
{
fprintf(stderr, "rrdbotd: got signal to quit\n");
@@ -273,6 +286,11 @@ main(int argc, char* argv[])
debug_level += LOG_ERR;
break;
+ /* mib directory */
+ case 'm':
+ g_mib_directory = optarg;
+ break;
+
/* MIB load warnings */
case 'M':
g_mib_warnings = 1;
@@ -304,8 +322,7 @@ main(int argc, char* argv[])
/* Print version number */
case 'v':
- printf("rrdbotd (version %s)\n", VERSION);
- exit(0);
+ version();
break;
/* Usage information */
diff --git a/daemon/rrdbotd.h b/daemon/rrdbotd.h
index ce16ebd..1a9782b 100644
--- a/daemon/rrdbotd.h
+++ b/daemon/rrdbotd.h
@@ -187,7 +187,7 @@ void rb_rrd_update(rb_poller *poll);
typedef void* mib_node;
-void rb_mib_init(int warnings);
+void rb_mib_init(const char* dir, int warnings);
mib_node rb_mib_lookup(const char* match);
int rb_mib_subid(mib_node n, const char* name);
void rb_mib_oid(mib_node n, struct asn_oid* oid);
diff --git a/daemon/snmp-help.c b/daemon/snmp-help.c
index 8a54bb1..4ae7cb1 100644
--- a/daemon/snmp-help.c
+++ b/daemon/snmp-help.c
@@ -48,6 +48,7 @@
/* Whether we print warnings when loading MIBs or not */
extern int g_mib_warnings;
+extern const char* g_mib_directory;
static int
parse_mixed_mib(const char* mib, struct asn_oid* oid)
@@ -84,7 +85,7 @@ parse_mixed_mib(const char* mib, struct asn_oid* oid)
if(*t || sub < 0)
{
/* Only initializes first time around */
- rb_mib_init(g_mib_warnings);
+ rb_mib_init(g_mib_directory, g_mib_warnings);
/*
* If we haven't parsed anything yet, try a symbolic
@@ -154,7 +155,7 @@ rb_snmp_parse_mib(const char* mib, struct snmp_value* value)
/* Next try a symolic search */
if(ret == -1)
{
- rb_mib_init(g_mib_warnings);
+ rb_mib_init(g_mib_directory, g_mib_warnings);
n = rb_mib_lookup(mib);
if(n == NULL)
diff --git a/mib/parse-compat.inc.c b/mib/parse-compat.inc.c
index c520c7a..56b42d4 100644
--- a/mib/parse-compat.inc.c
+++ b/mib/parse-compat.inc.c
@@ -140,7 +140,7 @@ clear_tree_flags(struct tree *tp)
}
void
-rb_mib_init(int warnings)
+rb_mib_init(const char* dir, int warnings)
{
if(initialized)
return;
@@ -148,7 +148,7 @@ rb_mib_init(int warnings)
with_warnings = warnings;
init_mib_internals();
- add_mibdir("/usr/share/snmp/mibs");
+ add_mibdir(dir);
read_all_mibs();
rb_messagex(LOG_DEBUG, "loaded all MIB files");