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

« back to all changes in this revision

Viewing changes to src/collectd-nagios.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:
142
142
        struct sockaddr_un sa;
143
143
        int status;
144
144
        int fd;
145
 
        FILE *fh;
 
145
        FILE *fh_in, *fh_out;
146
146
        char buffer[4096];
147
147
 
148
148
        int values_num;
172
172
                return (-1);
173
173
        }
174
174
 
175
 
        fh = fdopen (fd, "r+");
176
 
        if (fh == NULL)
 
175
        fh_in = fdopen (fd, "r");
 
176
        if (fh_in == NULL)
177
177
        {
178
178
                fprintf (stderr, "fdopen failed: %s\n",
179
179
                                strerror (errno));
181
181
                return (-1);
182
182
        }
183
183
 
184
 
        fprintf (fh, "GETVAL %s/%s\n", hostname_g, value_string_g);
185
 
        fflush (fh);
186
 
 
187
 
        if (fgets (buffer, sizeof (buffer), fh) == NULL)
 
184
        fh_out = fdopen (fd, "w");
 
185
        if (fh_out == NULL)
 
186
        {
 
187
                fprintf (stderr, "fdopen failed: %s\n",
 
188
                                strerror (errno));
 
189
                fclose (fh_in);
 
190
                return (-1);
 
191
        }
 
192
 
 
193
        fprintf (fh_out, "GETVAL %s/%s\n", hostname_g, value_string_g);
 
194
        fflush (fh_out);
 
195
 
 
196
        if (fgets (buffer, sizeof (buffer), fh_in) == NULL)
188
197
        {
189
198
                fprintf (stderr, "fgets failed: %s\n",
190
199
                                strerror (errno));
191
 
                close (fd);
192
 
                return (-1);
193
 
        }
194
 
        close (fd); fd = -1;
195
 
 
196
 
        values_num = atoi (buffer);
197
 
        if (values_num < 1)
198
 
                return (-1);
 
200
                fclose (fh_in);
 
201
                fclose (fh_out);
 
202
                return (-1);
 
203
        }
 
204
 
 
205
        {
 
206
                char *ptr = strchr (buffer, ' ');
 
207
 
 
208
                if (ptr != NULL)
 
209
                        *ptr = '\0';
 
210
 
 
211
                values_num = atoi (buffer);
 
212
                if (values_num < 1)
 
213
                        return (-1);
 
214
        }
199
215
 
200
216
        values = (double *) malloc (values_num * sizeof (double));
201
217
        if (values == NULL)
214
230
                return (-1);
215
231
        }
216
232
 
 
233
        i = 0;
 
234
        while (fgets (buffer, sizeof (buffer), fh_in) != NULL)
217
235
        {
218
 
                char *ptr = strchr (buffer, ' ') + 1;
219
236
                char *key;
220
237
                char *value;
221
238
 
222
 
                i = 0;
223
 
                while ((key = strtok (ptr, " \t")) != NULL)
224
 
                {
225
 
                        ptr = NULL;
226
 
                        value = strchr (key, '=');
227
 
                        if (value == NULL)
228
 
                                continue;
229
 
                        *value = '\0'; value++;
230
 
 
231
 
                        if (ignore_ds (key) != 0)
232
 
                                continue;
233
 
 
234
 
                        values_names[i] = strdup (key);
235
 
                        values[i] = atof (value);
236
 
 
237
 
                        i++;
238
 
                        if (i >= values_num)
239
 
                                break;
240
 
                }
241
 
                values_num = i;
 
239
                key = buffer;
 
240
 
 
241
                value = strchr (key, '=');
 
242
                if (value == NULL)
 
243
                        continue;
 
244
                *value = '\0'; value++;
 
245
 
 
246
                if (ignore_ds (key) != 0)
 
247
                        continue;
 
248
 
 
249
                values_names[i] = strdup (key);
 
250
                values[i] = atof (value);
 
251
 
 
252
                i++;
 
253
                if (i >= values_num)
 
254
                        break;
242
255
        }
 
256
        values_num = i;
 
257
 
 
258
        fclose (fh_in); fh_in = NULL; fd = -1;
 
259
        fclose (fh_out); fh_out = NULL;
243
260
 
244
261
        *ret_values_num = values_num;
245
262
        *ret_values = values;