~ubuntu-branches/ubuntu/oneiric/collectd/oneiric

« back to all changes in this revision

Viewing changes to src/utils_cmd_putval.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Harl
  • Date: 2008-06-17 10:35:51 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080617103551-9d0ym3zejc7agtt3
Tags: 4.4.1-1
* New upstream release.
  - Fixed another issue of the sensors plugin affecting some chip types
    (Closes: #468143).
  - Fixed creation of "vserver" graphs in collection.cgi (Closes: #475120).
  - Fixed a segfault when using libperl 5.10.
  - collectd now ships libiptc itself.
  New plugins:
  - Ascent server statistics: ascent
  - IPMI sensors information: ipmi
  - PowerDNS name server statistics: powerdns
  - incremental parsing of logfiles: tail
  - TeamSpeak2 server statistics: teamspeak2
  - detailed virtual memory statistics: vmem
* Disable "tcpconns" plugin by default (Closes: #478759).
* Reenabled iptables plugin on all architectures (Closes: #473435).
  - Added the plugin to collectd.conf.
  - Added /usr/share/doc/collectd/examples/iptables/.
  - Added build dependency on linux-libc-dev (>= 2.6.25-4) - that version is
    required because of #479899.
* New debconf template translations:
  - gl.po, thanks to Jacobo Tarrio (Closes: #482667).
* Added a work around for #474087 (broken openipmi .pc files) by forcing the
  inclusion of the ipmi plugin and manually specifying the dependencies.
* Updated standards-version to 3.8.0 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "common.h"
24
24
#include "plugin.h"
25
25
 
 
26
#define print_to_socket(fh, ...) \
 
27
        if (fprintf (fh, __VA_ARGS__) < 0) { \
 
28
                char errbuf[1024]; \
 
29
                WARNING ("handle_putval: failed to write to socket #%i: %s", \
 
30
                                fileno (fh), sstrerror (errno, errbuf, sizeof (errbuf))); \
 
31
                return -1; \
 
32
        }
 
33
 
26
34
static int parse_value (const data_set_t *ds, value_list_t *vl,
27
35
                const char *type,
28
36
                FILE *fh, char *buffer)
36
44
        char *value_str = strchr (time_str, ':');
37
45
        if (value_str == NULL)
38
46
        {
39
 
                fprintf (fh, "-1 No time found.\n");
 
47
                print_to_socket (fh, "-1 No time found.\n");
40
48
                return (-1);
41
49
        }
42
50
        *value_str = '\0'; value_str++;
76
84
                                "Number of values incorrect: "
77
85
                                "Got %i, expected %i. Identifier is `%s'.",
78
86
                                i, vl->values_len, identifier);
79
 
                fprintf (fh, "-1 Number of values incorrect: "
 
87
                print_to_socket (fh, "-1 Number of values incorrect: "
80
88
                                "Got %i, expected %i.\n",
81
89
                                i, vl->values_len);
82
90
                return (-1);
130
138
        {
131
139
                DEBUG ("cmd putval: Wrong number of fields: %i",
132
140
                                fields_num);
133
 
                fprintf (fh, "-1 Wrong number of fields: Got %i, "
 
141
                print_to_socket (fh, "-1 Wrong number of fields: Got %i, "
134
142
                                "expected at least 3.\n",
135
143
                                fields_num);
136
 
                fflush (fh);
137
144
                return (-1);
138
145
        }
139
146
 
147
154
        if (status != 0)
148
155
        {
149
156
                DEBUG ("cmd putval: Cannot parse `%s'", fields[1]);
150
 
                fprintf (fh, "-1 Cannot parse identifier.\n");
151
 
                fflush (fh);
 
157
                print_to_socket (fh, "-1 Cannot parse identifier.\n");
152
158
                sfree (identifier_copy);
153
159
                return (-1);
154
160
        }
160
166
                        || ((type_instance != NULL)
161
167
                                && (strlen (type_instance) >= sizeof (vl.type_instance))))
162
168
        {
163
 
                fprintf (fh, "-1 Identifier too long.\n");
164
 
                fflush (fh);
 
169
                print_to_socket (fh, "-1 Identifier too long.\n");
165
170
                sfree (identifier_copy);
166
171
                return (-1);
167
172
        }
183
188
        vl.values = (value_t *) malloc (vl.values_len * sizeof (value_t));
184
189
        if (vl.values == NULL)
185
190
        {
186
 
                fprintf (fh, "-1 malloc failed.\n");
187
 
                fflush (fh);
 
191
                print_to_socket (fh, "-1 malloc failed.\n");
188
192
                sfree (identifier_copy);
189
193
                return (-1);
190
194
        }
204
208
                {
205
209
                        if (parse_option (&vl, fields[i]) != 0)
206
210
                        {
207
 
                                fprintf (fh, "-1 Error parsing option `%s'\n",
 
211
                                print_to_socket (fh, "-1 Error parsing option `%s'\n",
208
212
                                                fields[i]);
209
213
                                break;
210
214
                        }
220
224
        /* Done parsing the options. */
221
225
 
222
226
        if (i == fields_num)
223
 
                fprintf (fh, "0 Success\n");
224
 
        fflush (fh);
 
227
                print_to_socket (fh, "0 Success\n");
225
228
 
226
229
        sfree (vl.values); 
227
230
        sfree (identifier_copy);