From da09ec0ebaf7537453c2a0bd7a9670d52eca3d7b Mon Sep 17 00:00:00 2001 From: Merlin Hughes Date: Sun, 28 Apr 2002 00:21:49 +0000 Subject: [PATCH] Added RRD support to sensord; can automatically create /configure database based on detected/configured sensors, logs libsensors-processed readings to the database, has a command-line option for generating a basic rrdcgi script. Removed sensord from all target because it has an external dependency on librrd. This just makes using RRD with sensors easier; you don't need to figure out what sensors are available and configure the database with computations that are already in sensors.conf. To install: make install-prog-sensord To create and start logging to database: sensord --rrd-file /var/log/sensord.rrd To create a CGI script: sensord --rrd-file /var/log/sensord.rrd \ --rrd-cgi /var/www/sensord \ > /usr/lib/cgi-bin/sensord.cgi man sensord for more details. Kudos to Mark for doing the hard work ;} -- merlin git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1357 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/sensord/Module.mk | 6 +- prog/sensord/args.c | 65 +++++++- prog/sensord/chips.c | 346 ++++++++++++++++++++++++----------------- prog/sensord/lib.c | 2 +- prog/sensord/rrd.c | 315 +++++++++++++++++++++++++++++++++++++ prog/sensord/sense.c | 91 ++++++++--- prog/sensord/sensord.8 | 171 +++++++++++++++++--- prog/sensord/sensord.c | 47 ++++-- prog/sensord/sensord.h | 32 +++- 9 files changed, 862 insertions(+), 213 deletions(-) create mode 100644 prog/sensord/rrd.c diff --git a/prog/sensord/Module.mk b/prog/sensord/Module.mk index 7556b66a..9e989778 100644 --- a/prog/sensord/Module.mk +++ b/prog/sensord/Module.mk @@ -27,17 +27,17 @@ PROGSENSORDMAN1FILES := $(MODULE_DIR)/sensord.8 # Regrettably, even 'simply expanded variables' will not put their currently # defined value verbatim into the command-list of rules... PROGSENSORDTARGETS := $(MODULE_DIR)/sensord -PROGSENSORDSOURCES := $(MODULE_DIR)/args.c $(MODULE_DIR)/chips.c $(MODULE_DIR)/lib.c $(MODULE_DIR)/sense.c $(MODULE_DIR)/sensord.c +PROGSENSORDSOURCES := $(MODULE_DIR)/args.c $(MODULE_DIR)/chips.c $(MODULE_DIR)/lib.c $(MODULE_DIR)/rrd.c $(MODULE_DIR)/sense.c $(MODULE_DIR)/sensord.c # Include all dependency files. We use '.rd' to indicate this will create # executables. INCLUDEFILES += $(PROGSENSORDSOURCES:.c=.rd) $(PROGSENSORDTARGETS): $(PROGSENSORDSOURCES:.c=.ro) lib/$(LIBSHBASENAME) - $(CC) -o $@ $(PROGSENSORDSOURCES:.c=.ro) -Llib -lsensors + $(CC) -o $@ $(PROGSENSORDSOURCES:.c=.ro) -Llib -lsensors -lrrd all-prog-sensord: $(PROGSENSORDTARGETS) -all :: all-prog-sensord +# all :: all-prog-sensord install-prog-sensord: all-prog-sensord $(MKDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(PROGSENSORDMAN1DIR) diff --git a/prog/sensord/args.c b/prog/sensord/args.c index 572b1c32..b2c6bafb 100644 --- a/prog/sensord/args.c +++ b/prog/sensord/args.c @@ -3,7 +3,7 @@ * * A daemon that periodically logs sensor information to syslog. * - * Copyright (c) 1999-2001 Merlin Hughes + * Copyright (c) 1999-2002 Merlin Hughes * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,11 +34,15 @@ int isDaemon = 0; const char *sensorsCfgFile = "sensors.conf"; const char *pidFile = "/var/run/sensord.pid"; +const char *rrdFile = NULL; +const char *cgiDir = NULL; int scanTime = 60; int logTime = 30 * 60; +int rrdTime = 5 * 60; int syslogFacility = LOG_LOCAL4; int doScan = 0; int doSet = 0; +int doCGI = 0; int debug = 0; sensors_chip_name chipNames[MAX_CHIP_NAMES]; int numChipNames = 0; @@ -92,24 +96,32 @@ parseFacility static const char *daemonSyntax = " -i, --interval