From 9e1b0c68677c537343cbe8b057ed4ecd52db8164 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 10 May 2013 09:04:27 +0200 Subject: [PATCH] cgroups plugin: Rename the "cgroups_cpuacct" plugin. The new name is sufficient and much easier to type / remember. --- configure.in | 6 ++++-- src/Makefile.am | 12 ++++++------ src/{cgroups_cpuacct.c => cgroups.c} | 22 ++++++++++++---------- src/collectd.conf.in | 2 +- src/collectd.conf.pod | 2 +- 5 files changed, 24 insertions(+), 20 deletions(-) rename src/{cgroups_cpuacct.c => cgroups.c} (90%) diff --git a/configure.in b/configure.in index 7a25a0d3..7e5407cf 100644 --- a/configure.in +++ b/configure.in @@ -4630,6 +4630,7 @@ dependency_error="no" plugin_ascent="no" plugin_battery="no" plugin_bind="no" +plugin_cgroups="no" plugin_conntrack="no" plugin_contextswitch="no" plugin_cpu="no" @@ -4673,6 +4674,7 @@ then plugin_battery="yes" plugin_conntrack="yes" plugin_contextswitch="yes" + plugin_cgroups="yes" plugin_cpu="yes" plugin_cpufreq="yes" plugin_disk="yes" @@ -4956,7 +4958,7 @@ AC_PLUGIN([csv], [yes], [CSV output plugin]) AC_PLUGIN([curl], [$with_libcurl], [CURL generic web statistics]) AC_PLUGIN([curl_json], [$plugin_curl_json], [CouchDB statistics]) AC_PLUGIN([curl_xml], [$plugin_curl_xml], [CURL generic xml statistics]) -AC_PLUGIN([cgroups_cpuacct], [yes], [CGroups CPU usage accounting]) +AC_PLUGIN([cgroups], [$plugin_cgroups], [CGroups CPU usage accounting]) AC_PLUGIN([dbi], [$with_libdbi], [General database statistics]) AC_PLUGIN([df], [$plugin_df], [Filesystem usage statistics]) AC_PLUGIN([disk], [$plugin_disk], [Disk usage statistics]) @@ -5287,7 +5289,7 @@ Configuration: bind . . . . . . . . $enable_bind conntrack . . . . . . $enable_conntrack contextswitch . . . . $enable_contextswitch - cgroups_cpuacct . . . $enable_cgroups_cpuacct + cgroups . . . . . . . $enable_cgroups cpu . . . . . . . . . $enable_cpu cpufreq . . . . . . . $enable_cpufreq csv . . . . . . . . . $enable_csv diff --git a/src/Makefile.am b/src/Makefile.am index 494b343b..1f57e523 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -230,12 +230,12 @@ collectd_LDADD += "-dlopen" bind.la collectd_DEPENDENCIES += bind.la endif -if BUILD_PLUGIN_CGROUPS_CPUACCT -pkglib_LTLIBRARIES += cgroups_cpuacct.la -cgroups_cpuacct_la_SOURCES = cgroups_cpuacct.c utils_mount.c utils_mount.h -cgroups_cpuacct_la_LDFLAGS = -module -avoid-version -collectd_LDADD += "-dlopen" cgroups_cpuacct.la -collectd_DEPENDENCIES += cgroups_cpuacct.la +if BUILD_PLUGIN_CGROUPS +pkglib_LTLIBRARIES += cgroups.la +cgroups_la_SOURCES = cgroups.c utils_mount.c utils_mount.h +cgroups_la_LDFLAGS = -module -avoid-version +collectd_LDADD += "-dlopen" cgroups.la +collectd_DEPENDENCIES += cgroups.la endif if BUILD_PLUGIN_CONNTRACK diff --git a/src/cgroups_cpuacct.c b/src/cgroups.c similarity index 90% rename from src/cgroups_cpuacct.c rename to src/cgroups.c index f4503894..ffb1740a 100644 --- a/src/cgroups_cpuacct.c +++ b/src/cgroups.c @@ -1,6 +1,7 @@ /** - * collectd - src/cgroups_cpuacct.c + * collectd - src/cgroups.c * Copyright (C) 2011 Michael Stapelberg + * Copyright (C) 2013 Florian Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -17,6 +18,7 @@ * * Authors: * Michael Stapelberg + * Florian Forster **/ #include "collectd.h" @@ -45,7 +47,7 @@ static void cgroups_submit_one (char const *plugin_instance, vl.values = &value; vl.values_len = 1; sstrncpy (vl.host, hostname_g, sizeof (vl.host)); - sstrncpy (vl.plugin, "cgroups_cpuacct", sizeof (vl.plugin)); + sstrncpy (vl.plugin, "cgroups", sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); sstrncpy (vl.type, "cpu", sizeof (vl.type)); @@ -76,7 +78,7 @@ static int read_cpuacct_procs (const char *dirname, char const *cgroup_name, status = lstat (abs_path, &statbuf); if (status != 0) { - ERROR ("cgroups_cpuacct plugin: stat (\"%s\") failed.", + ERROR ("cgroups plugin: stat (\"%s\") failed.", abs_path); return (-1); } @@ -91,7 +93,7 @@ static int read_cpuacct_procs (const char *dirname, char const *cgroup_name, if (fh == NULL) { char errbuf[1024]; - ERROR ("cgroups_cpuacct pluign: fopen (\"%s\") failed: %s", + ERROR ("cgroups pluign: fopen (\"%s\") failed: %s", abs_path, sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); @@ -153,7 +155,7 @@ static int read_cpuacct_root (const char *dirname, const char *filename, status = lstat (abs_path, &statbuf); if (status != 0) { - ERROR ("cgroups_cpuacct plugin: stat (%s) failed.", abs_path); + ERROR ("cgroups plugin: stat (%s) failed.", abs_path); return (-1); } @@ -207,7 +209,7 @@ static int cgroups_read (void) mnt_list = NULL; if (cu_mount_getlist (&mnt_list) == NULL) { - ERROR ("cgroups_cpuacct plugin: cu_mount_getlist failed."); + ERROR ("cgroups plugin: cu_mount_getlist failed."); return (-1); } @@ -232,7 +234,7 @@ static int cgroups_read (void) if (!cgroup_found) { - WARNING ("cgroups_cpuacct plugin: Unable to find cgroup " + WARNING ("cgroups plugin: Unable to find cgroup " "mount-point with the \"cpuacct\" option."); return (-1); } @@ -242,8 +244,8 @@ static int cgroups_read (void) void module_register (void) { - plugin_register_config ("cgroups_cpuacct", cgroups_config, + plugin_register_config ("cgroups", cgroups_config, config_keys, config_keys_num); - plugin_register_init ("cgroups_cpuacct", cgroups_init); - plugin_register_read ("cgroups_cpuacct", cgroups_read); + plugin_register_init ("cgroups", cgroups_init); + plugin_register_read ("cgroups", cgroups_read); } /* void module_register */ diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 736c9741..511244ef 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -72,7 +72,7 @@ #@BUILD_PLUGIN_BIND_TRUE@LoadPlugin bind #@BUILD_PLUGIN_CONNTRACK_TRUE@LoadPlugin conntrack #@BUILD_PLUGIN_CONTEXTSWITCH_TRUE@LoadPlugin contextswitch -#@BUILD_PLUGIN_CGROUPS_CPUACCT_TRUE@LoadPlugin cgroups_cpuacct +#@BUILD_PLUGIN_CGROUPS_TRUE@LoadPlugin cgroups @BUILD_PLUGIN_CPU_TRUE@@BUILD_PLUGIN_CPU_TRUE@LoadPlugin cpu #@BUILD_PLUGIN_CPUFREQ_TRUE@LoadPlugin cpufreq @LOAD_PLUGIN_CSV@LoadPlugin csv diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index d28810f3..c5d4f19f 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -852,7 +852,7 @@ By default no detailed zone information is collected. =back -=head2 Plugin C +=head2 Plugin C This plugin collects the CPU user/system time for each I by reading the F files in the first cpuacct-mountpoint (typically -- 2.30.2