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

« back to all changes in this revision

Viewing changes to src/disk.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:
1
1
/**
2
2
 * collectd - src/disk.c
3
 
 * Copyright (C) 2005-2007  Florian octo Forster
 
3
 * Copyright (C) 2005-2008  Florian octo Forster
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify it
6
6
 * under the terms of the GNU General Public License as published by the
22
22
#include "collectd.h"
23
23
#include "common.h"
24
24
#include "plugin.h"
 
25
#include "utils_ignorelist.h"
25
26
 
26
27
#if HAVE_MACH_MACH_TYPES_H
27
28
#  include <mach/mach_types.h>
58
59
#  define UINT_MAX 4294967295U
59
60
#endif
60
61
 
 
62
#if HAVE_STATGRAB_H
 
63
# include <statgrab.h>
 
64
#endif
 
65
 
61
66
#if HAVE_IOKIT_IOKITLIB_H
62
67
static mach_port_t io_master_port = MACH_PORT_NULL;
63
68
/* #endif HAVE_IOKIT_IOKITLIB_H */
97
102
static int numdisk = 0;
98
103
/* #endif HAVE_LIBKSTAT */
99
104
 
 
105
#elif defined(HAVE_LIBSTATGRAB)
 
106
/* #endif HAVE_LIBKSTATGRAB */
 
107
 
100
108
#else
101
109
# error "No applicable input method."
102
110
#endif
103
111
 
 
112
static const char *config_keys[] =
 
113
{
 
114
        "Disk",
 
115
        "IgnoreSelected"
 
116
};
 
117
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
 
118
 
 
119
static ignorelist_t *ignorelist = NULL;
 
120
 
 
121
static int disk_config (const char *key, const char *value)
 
122
{
 
123
  if (ignorelist == NULL)
 
124
    ignorelist = ignorelist_create (/* invert = */ 1);
 
125
  if (ignorelist == NULL)
 
126
    return (1);
 
127
 
 
128
  if (strcasecmp ("Disk", key) == 0)
 
129
  {
 
130
    ignorelist_add (ignorelist, value);
 
131
  }
 
132
  else if (strcasecmp ("IgnoreSelected", key) == 0)
 
133
  {
 
134
    int invert = 1;
 
135
    if ((strcasecmp ("True", value) == 0)
 
136
        || (strcasecmp ("Yes", value) == 0)
 
137
        || (strcasecmp ("On", value) == 0))
 
138
      invert = 0;
 
139
    ignorelist_set_invert (ignorelist, invert);
 
140
  }
 
141
  else
 
142
  {
 
143
    return (-1);
 
144
  }
 
145
 
 
146
  return (0);
 
147
} /* int disk_config */
 
148
 
104
149
static int disk_init (void)
105
150
{
106
151
#if HAVE_IOKIT_IOKITLIB_H
158
203
        value_t values[2];
159
204
        value_list_t vl = VALUE_LIST_INIT;
160
205
 
 
206
        /* Both `ignorelist' and `plugin_instance' may be NULL. */
 
207
        if (ignorelist_match (ignorelist, plugin_instance) != 0)
 
208
          return;
 
209
 
161
210
        values[0].counter = read;
162
211
        values[1].counter = write;
163
212
 
617
666
                                        kio.KIO_ROPS, kio.KIO_WOPS);
618
667
                }
619
668
        }
620
 
#endif /* defined(HAVE_LIBKSTAT) */
 
669
/* #endif defined(HAVE_LIBKSTAT) */
 
670
 
 
671
#elif defined(HAVE_LIBSTATGRAB)
 
672
        sg_disk_io_stats *ds;
 
673
        int disks, counter;
 
674
        char name[DATA_MAX_NAME_LEN];
 
675
        
 
676
        if ((ds = sg_get_disk_io_stats(&disks)) == NULL)
 
677
                return (0);
 
678
                
 
679
        for (counter=0; counter < disks; counter++) {
 
680
                strncpy(name, ds->disk_name, sizeof(name));
 
681
                name[sizeof(name)-1] = '\0'; /* strncpy doesn't terminate longer strings */
 
682
                disk_submit (name, "disk_octets", ds->read_bytes, ds->write_bytes);
 
683
                ds++;
 
684
        }
 
685
#endif /* defined(HAVE_LIBSTATGRAB) */
621
686
 
622
687
        return (0);
623
688
} /* int disk_read */
624
689
 
625
690
void module_register (void)
626
691
{
627
 
        plugin_register_init ("disk", disk_init);
628
 
        plugin_register_read ("disk", disk_read);
 
692
  plugin_register_config ("disk", disk_config,
 
693
      config_keys, config_keys_num);
 
694
  plugin_register_init ("disk", disk_init);
 
695
  plugin_register_read ("disk", disk_read);
629
696
} /* void module_register */