From 7fcead4473bc224bc8c6a66e2db3b3ee87f751d4 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 25 Jan 2006 04:07:04 +0000 Subject: Configuration file parsing for rrdbotd. --- src/rrdbotd.h | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'src/rrdbotd.h') diff --git a/src/rrdbotd.h b/src/rrdbotd.h index 61aef40..9c4f2b4 100644 --- a/src/rrdbotd.h +++ b/src/rrdbotd.h @@ -39,14 +39,24 @@ #ifndef __RRDBOTD_H__ #define __RRDBOTD_H__ +#include "asn1.h" #include "snmp.h" #include "sock_any.h" #include "hash.h" +/* ----------------------------------------------------------------------------- + * DATA + */ + struct _rb_item; struct _rb_poller; struct _rb_host; +/* + * Note that all the members are either in the config memory + * or inline. This helps us keep memory management simple. + */ + typedef struct _rb_item { /* Specific to this item */ @@ -57,13 +67,15 @@ typedef struct _rb_item /* Pointers to related */ const struct _rb_poller* poller; const struct _rb_host* host; + + /* Next in list of items */ + struct _rb_item* next; } rb_item; - typedef struct _rb_host { - const char* host; + const char* name; /* Host resolving and book keeping */ struct sockaddr_any address; @@ -75,13 +87,17 @@ typedef struct _rb_host } rb_host; - typedef struct _rb_poller { + /* The hash key is interval-rrdname */ + char key[MAXPATHLEN]; + + /* This points into the memory above */ const char* rrdname; + uint32_t interval; - /* The things to poll */ + /* The things to poll. rb_poller owns this list */ rb_item* items; /* Book keeping */ @@ -92,9 +108,12 @@ typedef struct _rb_poller } rb_poller; - typedef struct _rb_state { + /* Settings from command line */ + const char* confdir; + const char* rrddir; + /* All the pollers/hosts */ rb_poller* polls; rb_host* hosts; @@ -105,13 +124,30 @@ typedef struct _rb_state } rb_state; +/* One global rb_state with all the main settings */ +extern rb_state g_state; /* ----------------------------------------------------------------------------- - * LOGGING + * UTILITIES (rrdbotd.c) */ void rb_messagex (int level, const char* msg, ...); void rb_message (int level, const char* msg, ...); +typedef void (*voidfunc)(void*); +void rb_atexit (voidfunc func, void* data); + +/* ----------------------------------------------------------------------------- + * CONFIG (config.c) + */ + +void rb_config_parse(); +void rb_config_free(); + +/* ----------------------------------------------------------------------------- + * SNMP HELPERS (snmp-help.c) + */ + +int rb_parse_mib(const char* oid, struct snmp_value* value); #endif /* __RRDBOTD_H__ */ -- cgit v1.2.3