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

« back to all changes in this revision

Viewing changes to src/hddtemp.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:
121
121
        if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0)
122
122
        {
123
123
                char errbuf[1024];
124
 
                ERROR ("hddtemp: getaddrinfo (%s, %s): %s",
 
124
                ERROR ("hddtemp plugin: getaddrinfo (%s, %s): %s",
125
125
                                host, port,
126
126
                                (ai_return == EAI_SYSTEM)
127
127
                                ? sstrerror (errno, errbuf, sizeof (errbuf))
133
133
        for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
134
134
        {
135
135
                /* create our socket descriptor */
136
 
                if ((fd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol)) < 0)
 
136
                fd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype,
 
137
                                ai_ptr->ai_protocol);
 
138
                if (fd < 0)
137
139
                {
138
140
                        char errbuf[1024];
139
 
                        ERROR ("hddtemp: socket: %s",
 
141
                        ERROR ("hddtemp plugin: socket: %s",
140
142
                                        sstrerror (errno, errbuf, sizeof (errbuf)));
141
143
                        continue;
142
144
                }
143
145
 
144
146
                /* connect to the hddtemp daemon */
145
 
                if (connect (fd, (struct sockaddr *) ai_ptr->ai_addr, ai_ptr->ai_addrlen))
 
147
                if (connect (fd, (struct sockaddr *) ai_ptr->ai_addr,
 
148
                                        ai_ptr->ai_addrlen))
146
149
                {
147
150
                        char errbuf[1024];
148
 
                        INFO ("hddtemp: connect (%s, %s): %s", host, port,
 
151
                        INFO ("hddtemp plugin: connect (%s, %s) failed: %s",
 
152
                                        host, port,
149
153
                                        sstrerror (errno, errbuf, sizeof (errbuf)));
150
154
                        close (fd);
151
155
                        fd = -1;
161
165
 
162
166
        if (fd < 0)
163
167
        {
164
 
                ERROR ("hddtemp: Could not connect to daemon.");
 
168
                ERROR ("hddtemp plugin: Could not connect to daemon.");
165
169
                return (-1);
166
170
        }
167
171
 
178
182
                        if ((errno == EAGAIN) || (errno == EINTR))
179
183
                                continue;
180
184
 
181
 
                        ERROR ("hddtemp: Error reading from socket: %s",
 
185
                        ERROR ("hddtemp plugin: Error reading from socket: %s",
182
186
                                        sstrerror (errno, errbuf, sizeof (errbuf)));
183
187
                        close (fd);
184
188
                        return (-1);
192
196
        if (buffer_fill >= buffer_size)
193
197
        {
194
198
                buffer[buffer_size - 1] = '\0';
195
 
                WARNING ("hddtemp: Message from hddtemp has been truncated.");
 
199
                WARNING ("hddtemp plugin: Message from hddtemp has been "
 
200
                                "truncated.");
196
201
        }
197
202
        else if (buffer_fill == 0)
198
203
        {
199
 
                WARNING ("hddtemp: Peer has unexpectedly shut down the socket. "
200
 
                                "Buffer: `%s'", buffer);
 
204
                WARNING ("hddtemp plugin: Peer has unexpectedly shut down "
 
205
                                "the socket. Buffer: `%s'", buffer);
201
206
                close (fd);
202
207
                return (-1);
203
208
        }
273
278
 
274
279
        if ((fh = fopen ("/proc/partitions", "r")) != NULL)
275
280
        {
276
 
                DEBUG ("Looking at /proc/partitions...");
 
281
                DEBUG ("hddtemp plugin: Looking at /proc/partitions...");
277
282
 
278
283
                while (fgets (buf, sizeof (buf), fh) != NULL)
279
284
                {
349
354
 
350
355
                                /* Skip all other majors. */
351
356
                                default:
352
 
                                        DEBUG ("Skipping unknown major %i", major);
 
357
                                        DEBUG ("hddtemp plugin: Skipping unknown major %i", major);
353
358
                                        continue;
354
359
                        } /* switch (major) */
355
360
 
356
361
                        if ((name = strdup (fields[3])) == NULL)
357
362
                        {
358
 
                                ERROR ("hddtemp: strdup(%s) == NULL", fields[3]);
 
363
                                ERROR ("hddtemp plugin: strdup(%s) == NULL", fields[3]);
359
364
                                continue;
360
365
                        }
361
366
 
362
367
                        if ((entry = (hddname_t *) malloc (sizeof (hddname_t))) == NULL)
363
368
                        {
364
 
                                ERROR ("hddtemp: malloc (%u) == NULL",
 
369
                                ERROR ("hddtemp plugin: malloc (%u) == NULL",
365
370
                                                (unsigned int) sizeof (hddname_t));
366
371
                                free (name);
367
372
                                continue;
368
373
                        }
369
374
 
370
 
                        DEBUG ("Found disk: %s (%u:%u).", name, major, minor);
 
375
                        DEBUG ("hddtemp plugin: Found disk: %s (%u:%u).", name, major, minor);
371
376
 
372
377
                        entry->major = major;
373
378
                        entry->minor = minor;
390
395
        else
391
396
        {
392
397
                char errbuf[1024];
393
 
                DEBUG ("Could not open /proc/partitions: %s",
 
398
                DEBUG ("hddtemp plugin: Could not open /proc/partitions: %s",
394
399
                                sstrerror (errno, errbuf, sizeof (errbuf)));
395
400
        }
396
401
#endif /* COLLECT_DEBUG */
418
423
 
419
424
        if (list == NULL)
420
425
        {
421
 
                DEBUG ("Don't know %s, keeping name as-is.", drive);
 
426
                DEBUG ("hddtemp plugin: Don't know %s, keeping name as-is.", drive);
422
427
                return (strdup (drive));
423
428
        }
424
429