sensord: rrd database and timeslots

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, May 01, 2004 at 04:25:43PM +0200, Mario 'BitKoenig' Holbe wrote:
> On Sat, May 01, 2004 at 02:32:44PM +0200, Jean Delvare wrote:
> > If it works for Mario, it's OK with me (modulo the few trivial comments
> 
> This is okay for me too.

Okay, here is the new patch including the few minor fixes discussed on
IRC.

Bye,
Aurelien

-- 
  .''`.  Aurelien Jarno	              GPG: 1024D/F1BCDB73
 : :' :  Debian GNU/Linux developer | Electrical Engineering Student 
 `. `'   aurel32 at debian.org         | aurelien at aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net
-------------- next part --------------
diff -urN lm_sensors2.orig/prog/sensord/args.c lm_sensors2/prog/sensord/args.c
--- lm_sensors2.orig/prog/sensord/args.c	2004-05-01 19:43:33.000000000 +0200
+++ lm_sensors2/prog/sensord/args.c	2004-05-01 19:43:55.000000000 +0200
@@ -39,6 +39,7 @@
 int scanTime = 60;
 int logTime = 30 * 60;
 int rrdTime = 5 * 60;
+int rrdNoAverage = 0;
 int syslogFacility = LOG_LOCAL4;
 int doScan = 0;
 int doSet = 0;
@@ -98,6 +99,7 @@
   "  -i, --interval <time>     -- interval between scanning alarms (default 60s)\n"
   "  -l, --log-interval <time> -- interval between logging sensors (default 30m)\n"
   "  -t, --rrd-interval <time> -- interval between updating RRD file (default 5m)\n"
+  "  -T, --rrd-no-average      -- switch RRD in non-average mode\n"
   "  -r, --rrd-file <file>     -- RRD file (default <none>)\n"
   "  -c, --config-file <file>  -- configuration file (default sensors.conf)\n"
   "  -p, --pid-file <file>     -- PID file (default /var/run/sensord.pid)\n"
@@ -135,12 +137,13 @@
   "\n"
   "If no chips are specified, all chip info will be printed.\n";
 
-static const char *daemonShortOptions = "i:l:t:f:r:c:p:advhg:";
+static const char *daemonShortOptions = "i:l:t:Tf:r:c:p:advhg:";
 
 static const struct option daemonLongOptions[] = {
   { "interval", required_argument, NULL, 'i' },
   { "log-interval", required_argument, NULL, 'l' },
   { "rrd-interval", required_argument, NULL, 't' },
+  { "rrd-no-average", no_argument, NULL, 'T' },
   { "syslog-facility", required_argument, NULL, 'f' },
   { "rrd-file", required_argument, NULL, 'r' },
   { "config-file", required_argument, NULL, 'c' },
@@ -191,6 +194,9 @@
         if ((rrdTime = parseTime (optarg)) < 0)
           return -1;
         break;
+      case 'T':
+        rrdNoAverage = 1;
+        break;
       case 'f':
         if ((syslogFacility = parseFacility (optarg)) < 0)
           return -1;
diff -urN lm_sensors2.orig/prog/sensord/rrd.c lm_sensors2/prog/sensord/rrd.c
--- lm_sensors2.orig/prog/sensord/rrd.c	2004-05-01 19:43:33.000000000 +0200
+++ lm_sensors2/prog/sensord/rrd.c	2004-05-01 19:43:55.000000000 +0200
@@ -256,7 +256,7 @@
         ret = -num;
       } else {
         sprintf (stepBuff, "%d", rrdTime);
-        sprintf (rraBuff, "RRA:AVERAGE:%f:%d:%d", 0.5 /* fraction of non-unknown samples needed per entry */, 1 /* samples per entry */, 7 * 24 * 60 * 60 / rrdTime /* 1 week */);
+        sprintf (rraBuff, "RRA:%s:%f:%d:%d", rrdNoAverage?"LAST":"AVERAGE", 0.5 /* fraction of non-unknown samples needed per entry */, 1 /* samples per entry */, 7 * 24 * 60 * 60 / rrdTime /* 1 week */);
         argc += num;
         argv[argc ++] = rraBuff;
         argv[argc] = NULL;
diff -urN lm_sensors2.orig/prog/sensord/sensord.8 lm_sensors2/prog/sensord/sensord.8
--- lm_sensors2.orig/prog/sensord/sensord.8	2004-05-01 19:43:34.000000000 +0200
+++ lm_sensors2/prog/sensord/sensord.8	2004-05-01 19:43:55.000000000 +0200
@@ -70,6 +70,9 @@
 a round-robin database is configured.
 
 The time is specified as before; e.g., `5m'.
+.IP "-T, --rrd-no-average"
+Specify that the round-robin database should not be averaged.
+
 .IP "-r, --rrd-file file"
 Specify a round-robin database into which to log all sensor readings;
 e.g., `/var/log/sensord.rrd'. This database will be created if it does
diff -urN lm_sensors2.orig/prog/sensord/sensord.c lm_sensors2/prog/sensord/sensord.c
--- lm_sensors2.orig/prog/sensord/sensord.c	2004-05-01 19:43:34.000000000 +0200
+++ lm_sensors2/prog/sensord/sensord.c	2004-05-01 19:52:54.000000000 +0200
@@ -28,6 +28,7 @@
 #include <signal.h>
 #include <syslog.h>
 #include <unistd.h>
+#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -75,7 +76,12 @@
 sensord
 (void) {
   int ret = 0;
-  int scanValue = 0, logValue = 0, rrdValue = 0;
+  int scanValue = 0, logValue = 0;
+  /*
+   * First RRD update at next RRD timeslot to prevent failures due
+   * one timeslot updated twice on restart for example.
+   */
+  int rrdValue = rrdTime - time(NULL) % rrdTime;
 
   sensorLog (LOG_INFO, "sensord started");
 
@@ -93,7 +99,11 @@
     }
     if ((ret == 0) && rrdTime && rrdFile && (rrdValue <= 0)) {
       ret = rrdUpdate ();
-      rrdValue += rrdTime;
+      /*
+       * The amount of time to wait is computed using the same method as
+       * in RRD instead of simply adding the interval.
+       */
+      rrdValue = rrdTime - time(NULL) % rrdTime;
     }
     if (!done && (ret == 0)) {
       int a = logTime ? logValue : INT_MAX;
diff -urN lm_sensors2.orig/prog/sensord/sensord.h lm_sensors2/prog/sensord/sensord.h
--- lm_sensors2.orig/prog/sensord/sensord.h	2004-05-01 19:43:34.000000000 +0200
+++ lm_sensors2/prog/sensord/sensord.h	2004-05-01 19:43:55.000000000 +0200
@@ -36,6 +36,7 @@
 extern int scanTime;
 extern int logTime;
 extern int rrdTime;
+extern int rrdNoAverage;
 extern int syslogFacility;
 extern int doScan;
 extern int doSet;


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux