summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rrdbotd.c2
-rw-r--r--src/rrdbotd.h12
-rw-r--r--src/snmp-engine.c29
3 files changed, 32 insertions, 11 deletions
diff --git a/src/rrdbotd.c b/src/rrdbotd.c
index a28f0b0..95ab092 100644
--- a/src/rrdbotd.c
+++ b/src/rrdbotd.c
@@ -193,7 +193,7 @@ main(int argc, char* argv[])
g_state.rrddir = "/data/projects/rrdui/work";
g_state.confdir = "/data/projects/rrdui/conf";
g_state.retries = 3;
- g_state.timeout = 5000;
+ g_state.timeout = 5;
/* Parse the arguments nicely */
while((ch = getopt(argc, argv, "v")) != -1)
diff --git a/src/rrdbotd.h b/src/rrdbotd.h
index 974c8f4..8c826e1 100644
--- a/src/rrdbotd.h
+++ b/src/rrdbotd.h
@@ -90,7 +90,7 @@ typedef struct _rb_host
/* Host resolving and book keeping */
struct sockaddr_any address;
- uint32_t interval;
+ uint64_t interval;
uint64_t last_resolved;
/* Next in list of hosts */
@@ -106,8 +106,8 @@ typedef struct _rb_poller
/* This points into the memory above */
const char* rrdname;
- uint32_t interval;
- uint32_t timeout;
+ uint64_t interval;
+ uint64_t timeout;
/* The things to poll. rb_poller owns this list */
rb_item* items;
@@ -171,4 +171,10 @@ int rb_snmp_parse_mib(const char* oid, struct snmp_value* value);
void rb_snmp_engine_init();
void rb_snmp_engine_uninit();
+/* -----------------------------------------------------------------------------
+ * RRD UPDATE CODE (rrd-update.c)
+ */
+
+void rb_rrd_update(rb_poller *poll);
+
#endif /* __RRDBOTD_H__ */
diff --git a/src/snmp-engine.c b/src/snmp-engine.c
index fef7ad4..8d39991 100644
--- a/src/snmp-engine.c
+++ b/src/snmp-engine.c
@@ -67,7 +67,7 @@ typedef struct _rb_request
uint32_t id;
uint64_t next_retry; /* Time of the next retry */
- uint32_t interval; /* How long between retries */
+ uint64_t interval; /* How long between retries */
uint64_t timeout; /* When this request times out */
uint32_t sent; /* How many times we've sent */
@@ -129,7 +129,6 @@ new_req()
/* Reallocate the request block */
/* TODO: Once we use less memory this can be higher */
num = nrequests ? nrequests * 2 : 32;
- fprintf(stderr, "REALLOCATING: %d!!!\n", nrequests);
requests = (rb_request*)realloc(requests, sizeof(rb_request) * num);
if(!requests)
{
@@ -139,12 +138,17 @@ new_req()
}
/* Clear out the new ones */
- fprintf(stderr, "clearing: %d %d\n", sizeof(rb_request), num - nrequests);
memset(requests + nrequests, 0, sizeof(rb_request) * (num - nrequests));
/* We return the next one */
req = requests + nrequests;
+
nrequests = num;
+
+ if(reqhigh == -1)
+ reqhigh = 0;
+ if(reqlow == -1)
+ reqlow = nrequests - 1;
}
/* A incrementing counter for each request */
@@ -216,7 +220,7 @@ finish_poll(rb_poller* poll, uint64_t when)
rb_messagex(LOG_DEBUG, "collected poll values. sending them to rrd");
/* And send off our collection of values */
- // rb_rrd_update(poll);
+ rb_rrd_update(poll);
}
static void
@@ -274,6 +278,8 @@ timeout_req(rb_request* req, uint64_t when)
incomplete = 1;
}
+ free_req(req);
+
if(!incomplete)
finish_poll(poll, when);
}
@@ -284,8 +290,11 @@ check_req(rb_request* req, uint64_t when)
ASSERT(req->id);
/* See if it's timed out */
- if(when <= req->timeout)
+ if(when >= req->timeout)
+ {
+fprintf(stderr, "check_req timeout_req %lld %lld\n", when, req->timeout);
timeout_req(req, when);
+ }
if(!req->next_retry)
return;
@@ -359,6 +368,9 @@ respond_req(rb_request* req, struct snmp_pdu* pdu, uint64_t when)
}
}
+ /* We're done with this request */
+ free_req(req);
+
/* Now see if the entire request is done */
for(item = poll->items; item; item = item->next)
{
@@ -366,6 +378,7 @@ respond_req(rb_request* req, struct snmp_pdu* pdu, uint64_t when)
return;
}
+
/* And if so then hand off */
finish_poll(poll, when);
}
@@ -436,10 +449,12 @@ poller_timer(uint64_t when, void* arg)
req->pdu.nbindings = 0;
/* Send interval is 200 ms when poll interval is below 2 seconds */
- req->interval = (poll->interval < 3) ? 200 : 600;
+ req->interval = (poll->interval <= 2000) ? 200L : 600L;
/* Timeout is for the last packet sent, not first */
- req->timeout = when + (req->interval * g_state.retries) + poll->timeout;
+fprintf(stderr, "timeout info: %lld %lld %d\n", when, req->interval, g_state.retries);
+ req->timeout = when + ((uint64_t)req->interval * (uint64_t)g_state.retries) + poll->timeout;
+fprintf(stderr, "new request with timeout: %lld %lld %lld\n", poll->timeout, req->timeout, req->interval);
req->sent = 0;
last_host = it->host;