~ubuntu-branches/debian/sid/xymon/sid

« back to all changes in this revision

Viewing changes to hobbitd/rrd/do_trends.c

  • Committer: Package Import Robot
  • Author(s): Axel Beckert, Christoph Berg, Axel Beckert
  • Date: 2014-05-20 22:56:11 UTC
  • mfrom: (2.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20140520225611-zvwepcgu1cwc21v1
Tags: 4.3.17-2
* Upload to unstable again.

[ Christoph Berg ]
*  Always write /var/run/xymon/xymonclient-include.cfg on clients

[ Axel Beckert ]
* Add build-dependency on libc-ares-dev to avoid using embedded code
  copy at xymonnet/c-ares-1.7.3.tar.gz
* Fix includes for graph definitions (xymongraph.d → graphs.d)
  + Add a Breaks for hobbit-plugins << 20140519~
* Remove reference to /etc/apache2/ from xymon-client.NEWS
* Fix remaining issues of the Apache 2.2 → 2.4 transition
  (modifies mostly debian/rules, xymon.postinst and xymon.maintscript)
  + Fix conffile paths in README.Debian and xymon.maintscript
  + Use dh_apache2 and apache2-maintscript-helper
  + Add build-dependency on dh-apache2.
  + Add lintian override for missing-build-dependency-for-dh_-command
    (see #748688)
  + Enable Apache's mod_rewrite + CGI support automatically in postinst
  + Add patch to switch default configuration to Apache 2.4 style
    authorization.
  + Closes: #669776
* Let xymon depend on perl until after the Jessie release to make sure
  prename is there for the data migration from hobbit to xymon.
* Add lintian override for apache2-reverse-dependency-calls-invoke-rc.d
  -- it finds the fallback for apache2-maintscript-helper unavailability

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*----------------------------------------------------------------------------*/
2
 
/* Hobbit RRD handler module.                                                 */
3
 
/*                                                                            */
4
 
/* This module handles custom "trends" data.                                  */
5
 
/*                                                                            */
6
 
/* Copyright (C) 2007-2009 Henrik Storner <henrik@hswn.dk>                    */
7
 
/*                                                                            */
8
 
/* This program is released under the GNU General Public License (GPL),       */
9
 
/* version 2. See the file "COPYING" for details.                             */
10
 
/*                                                                            */
11
 
/*----------------------------------------------------------------------------*/
12
 
 
13
 
static char trends_rcsid[] = "$Id: do_trends.c 6125 2009-02-12 13:09:34Z storner $";
14
 
 
15
 
/* 
16
 
 * This module was inspired by a mail from Stef Coene:
17
 
 *
18
 
 * ---------------------------------------------------------------------------
19
 
 * Date: Wed, 17 Jan 2007 14:04:29 +0100
20
 
 * From: Stef Coene
21
 
 * Subject: Re: [hobbit] hobbit monitoring
22
 
 * 
23
 
 * Just wondering, how hard would it be to create an extra channel for trending?
24
 
 * So you can use the bb client to send "numbers" to the hobbit server together
25
 
 * with some extra control information.
26
 
 * 
27
 
 * bb <bb server> trends <server name>
28
 
 * <rrd file name> <ds name> <number> <options>
29
 
 * -----------------------------------------------------------------------------
30
 
 *
31
 
 * Instead of a dedicated Hobbit channel for this, I decided to use the 
32
 
 * existing "data" message type. To use this, send a "data" message to 
33
 
 * hobbit formatted like this:
34
 
 *
35
 
 *    data $MACHINE.trends
36
 
 *    [filename.rrd]
37
 
 *    DS-definition1 VALUE2
38
 
 *    DS-definition2 VALUE2
39
 
 *
40
 
 * E.g. to create/update a custom RRD file "weather.rrd" with two 
41
 
 * GAUGE datasets "temp" and "wind", with current values "21" and 
42
 
 * "8" respectively, send this message:
43
 
 *
44
 
 *    [weather.rrd]
45
 
 *    DS:temp:GAUGE:600:0:U 21
46
 
 *    DS:wind:GAUGE:600:0:U 8
47
 
 */
48
 
 
49
 
 
50
 
static int do_trends_rrd(char *hostname, char *testname, char *classname, char *pagepaths, char *msg, time_t tstamp) 
51
 
52
 
        char *boln, *eoln, *p;
53
 
        int dscount;
54
 
        char **creparams;
55
 
 
56
 
        creparams = (char **)calloc(1, sizeof(char *));
57
 
        dscount = 0;
58
 
 
59
 
        boln = strchr(msg, '\n'); if (boln) boln++;
60
 
        while (boln && *boln) {
61
 
                eoln = strchr(boln, '\n'); if (eoln) *eoln = '\0';
62
 
 
63
 
                if (*boln == '[') {
64
 
                        /* Flush the current RRD file */
65
 
                        if (creparams[0]) create_and_update_rrd(hostname, testname, classname, pagepaths, creparams, NULL);
66
 
 
67
 
                        creparams = (char **)realloc(creparams, 1*sizeof(char *));
68
 
                        creparams[0] = NULL;
69
 
                        dscount = 0;
70
 
 
71
 
                        /* Get the RRD filename */
72
 
                        p = strchr(boln+1, ']'); if (p) *p = '\0';
73
 
                        setupfn("%s", boln+1);
74
 
 
75
 
                        /* And setup the initial rrdvalues string */
76
 
                        sprintf(rrdvalues, "%d", (int)tstamp);
77
 
                }
78
 
                else if (strncmp(boln, "DS:", 3) == 0) {
79
 
                        char *valptr = boln + strcspn(boln, " \t");
80
 
 
81
 
                        if ((*valptr == ' ') || (*valptr == '\t')) {
82
 
                                *valptr = '\0'; valptr += 1 + strspn(valptr+1, " \t");
83
 
                                creparams[dscount] = boln;
84
 
                                dscount++;
85
 
                                creparams = (char **)realloc(creparams, (1+dscount)*sizeof(char **));
86
 
                                creparams[dscount] = NULL;
87
 
                                sprintf(rrdvalues+strlen(rrdvalues), ":%s", valptr);
88
 
                        }
89
 
                }
90
 
 
91
 
                boln = (eoln ? eoln+1 : NULL);
92
 
        }
93
 
 
94
 
        /* Do the last RRD set */
95
 
        if (creparams[0]) create_and_update_rrd(hostname, testname, classname, pagepaths, creparams, NULL);
96
 
        xfree(creparams);
97
 
 
98
 
        return 0;
99
 
}
100