summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'daemon')
-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
5 files changed, 30 insertions, 8 deletions
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)