diff options
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | configure.in | 31 | ||||
-rw-r--r-- | tools/rrdui-collect.py | 119 |
3 files changed, 2 insertions, 149 deletions
diff --git a/Makefile.am b/Makefile.am index 16fa9ed..34c3b01 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,5 @@ EXTRA_DIST = graphics html tools -SUBDIRS = src dist-hook: rm -rf `find $(distdir)/ -name .svn` diff --git a/configure.in b/configure.in index b99d015..35b7628 100644 --- a/configure.in +++ b/configure.in @@ -2,44 +2,17 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(rrdui, 0.2, nielsen@memberwebs.com) AM_INIT_AUTOMAKE(rrdui, 0.2) -LDFLAGS="$LDFLAGS -L/usr/local/lib" -CFLAGS="$CFLAGS -I/usr/local/include" - -AC_CONFIG_SRCDIR([src/rrdbotd.c]) +AC_CONFIG_SRCDIR([html/index.html]) AM_CONFIG_HEADER([config.h]) -# Debug mode -AC_ARG_ENABLE(debug, - AC_HELP_STRING([--enable-debug], - [Compile binaries in debug mode])) - -if test "$enable_debug" = "yes"; then - CFLAGS="$CFLAGS -g -O0" - AC_DEFINE_UNQUOTED(_DEBUG, 1, [In debug mode]) - echo "enabling debug compile mode" -fi - dnl Check for programs. -AC_PROG_CC AC_PROG_INSTALL -AC_PROG_RANLIB - -dnl Checks for libraries -AC_CHECK_LIB(rrd, rrd_update, , - [echo "ERROR: librrd not found."; exit 1]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE -dnl Check for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([rrd.h], , [echo "ERROR: rrd headers not found"]) -dnl TODO: AC_CHECK_HEADERS - AC_MSG_RESULT() -AC_CONFIG_FILES([Makefile - src/Makefile - src/bsnmp/Makefile]) +AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/tools/rrdui-collect.py b/tools/rrdui-collect.py deleted file mode 100644 index 0585812..0000000 --- a/tools/rrdui-collect.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/python - -import os, sys, time, math -import rrdtool - -from rrdui import * - -# This entire module is nasty. Don't do this at home. It's a python interim -# replacement for a C daemon that needs writing. It's about the least efficient -# way to go about SNMP polling. - -class Timer: - def __init__(self, interval, cmds, item): - self.interval = interval - self.cmds = cmds - self.item = item - self.last = 0 - -def logMsg(msg): - stamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) - print >> sys.stderr, "%s: %s" % (stamp, msg) - - -def readItemValue(cmd): - p = os.popen(cmd, "r") - out = p.read() - (pid, status) = os.wait() - status = status >> 8 - - try: - p.close() - except IOError: - pass - - if status != 0: - logMsg("WARNING: Couldn't query %s for %s" % (host, oid)) - out = "U" - return out.strip() - - -def loadTimers(items): - timers = [] - - for item in items: - (fields, interval) = item.getPollingInfo() - - if not len(fields): - continue - - if interval < 10: - logMsg("WARNING: Ignoring interval less than 10 seconds") - interval = 10 - - cmds = {} - for fieldname in fields.keys(): - field = fields[fieldname] - info = field.split("/") - if len(info) != 4: - logMsg("ERROR: Bad src format: %s" % field) - sys.exit(1) - if info[0] != "SNMP": - logMsg("ERROR: Unknown src method: %s" % info[0]) - sys.exit(1) - - # TODO: Note that we don't check our arguments ... - # Nasty and temporary untill we get the C daemon going - cmd = "snmpget -c %s -Ov -OQ -v 2c %s %s" % (info[2], info[1], info[3]) - cmds[fieldname] = cmd - - timer = Timer(interval, cmds, item) - timers.append(timer) - - return timers - -def updateItem(timer): - - if not os.path.exists(timer.item.filedata): - logMsg("WARNING: RRD file does not exist: %s" % timer.item.filedata) - return - - values = {} - for field in timer.cmds.keys(): - values[field] = readItemValue(timer.cmds[field]) - - args = [timer.item.filedata, "--template", ":".join(values.keys()), - "N:%s" % ":".join(values.values())] - try: - rrdtool.update(*args) - print args - except Error, e: - logMsg("ERROR: Couldn't update RRD file: %s (args: %s)", e.value, args) - - - -graphs = loadGraphs() -timers = loadTimers(graphs) - -while True: - - # Update when and where necessary. Note we keep calling - # time.time() as updating takes time - for timer in timers: - if (timer.last + timer.interval) < time.time(): - updateItem(timer) - timer.last = time.time() - - # Now figure out how long to sleep - next = 0 - for timer in timers: - if not timer.last: - continue - if not next or (timer.last + timer.interval) < next: - next = timer.last + timer.interval - - secs = next - time.time() - print "%d %d %d" % (secs, next, time.time()) - if(secs > 0): - print "sleeping for %d" % secs - time.sleep(secs) |