filecount plugin¶
| Plugin name | filecount |
| Type | read |
| Callbacks | config, init, read |
| Status | supported |
| Since | 4.5 |
| Copyright | 2008 Alessandro Iurlano, 2008 Florian octo Forster |
| License | GPLv2 |
| Configuration | collectd.conf(5) |
The FileCount plugin does something very simple: Count the number of files in a directory and all its subdirectories. This can be used for a variety of statistics, for example the queue length of an MTA, the number of PHP sessions of a web server or simply the number of files in your home directory.
In addition to the number of files, the plugin also collects the total size of all files. Think: du(1).
In come cases collecting all files in a directory is not desired. For instance, the session files of the CGI::Session Perl module reside in /tmp. But counting all files in /tmp doesn't tell you anything about the number of sessions. For this reason the plugin also allows you to specify which files to count. Files can be selected by:
- Name (shell wildcards)
- Size
- Modification time
This plugin is a generic plugin, i.e. it cannot work without configuration, because there is no reasonable default behavior. Please read the Plugin filecount section of the collectd.conf(5) manual page for an in-depth description of the plugin's configuration.
Synopsis¶
<Plugin "filecount">
<Directory "/var/qmail/queue/mess">
Instance "qmail-message"
</Directory>
<Directory "/var/qmail/queue/todo">
Instance "qmail-todo"
</Directory>
<Directory "/var/lib/php5">
Instance "php5-sessions"
Name "sess_*"
</Directory>
</Plugin>
Example graphs¶
None yet. Add one now!
Dependencies¶
- None
Configuration¶
Configuration options · from collectd.conf(5)
See this section in the full configuration reference
The filecount plugin counts the number of files in a certain directory (and its subdirectories) and their combined size. The configuration is very straight forward:
<Plugin "filecount">
<Directory "/var/qmail/queue/mess">
Instance "qmail-message"
</Directory>
<Directory "/var/qmail/queue/todo">
Instance "qmail-todo"
</Directory>
<Directory "/var/lib/php5">
Instance "php5-sessions"
Name "sess_*"
</Directory>
</Plugin>
The example above counts the number of files in QMail's queue directories and the number of PHP5 sessions. Jfiy: The "todo" queue holds the messages that QMail has not yet looked at, the "message" queue holds the messages that were classified into "local" and "remote".
As you can see, the configuration consists of one or more Directory blocks, each of which specifies a directory in which to count the files. Within those blocks, the following options are recognized:
- Plugin Plugin
- Use Plugin as the plugin name when submitting values. Defaults to filecount.
- Instance Instance
- Sets the plugin instance to Instance. If not given, the instance is set to the directory name with all slashes replaced by underscores and all leading underscores removed. Empty value is allowed.
- Name Pattern
- Only count files that match Pattern, where Pattern is a shell-like wildcard as understood by
fnmatch(3). Only the filename is checked against the pattern, not the entire path. In case this makes it easier for you: This option has been named after the -name parameter tofind(1). - MTime Age
-
Count only files of a specific age: If Age is greater than zero, only files that haven't been touched in the last Age seconds are counted. If Age is a negative number, this is inversed. For example, if -60 is specified, only files that have been modified in the last minute will be counted.
The number can also be followed by a "multiplier" to easily specify a larger timespan. When given in this notation, the argument must in quoted, i. e. must be passed as string. So the -60 could also be written as "-1m" (one minute). Valid multipliers are
s(second),m(minute),h(hour),d(day),w(week), andy(year). There is no "month" multiplier. You can also specify fractional numbers, e. g. "0.5d" is identical to "12h". - Size Size
-
Count only files of a specific size. When Size is a positive number, only files that are at least this big are counted. If Size is a negative number, this is inversed, i. e. only files smaller than the absolute value of Size are counted.
As with the MTime option, a "multiplier" may be added. For a detailed description see above. Valid multipliers here are
b(byte),k(kilobyte),m(megabyte),g(gigabyte),t(terabyte), andp(petabyte). Please note that there are 1000 bytes in a kilobyte, not 1024. - Recursive true|false
- Controls whether or not to recurse into subdirectories. Enabled by default.
- IncludeHidden true|false
- Controls whether or not to include "hidden" files and directories in the count. "Hidden" files and directories are those, whose name begins with a dot. Defaults to false, i.e. by default hidden files and directories are ignored.
- RegularOnly true|false
- Controls whether or not to include only regular files in the count. Defaults to true, i.e. by default non regular files are ignored.
- FilesSizeType Type
- Sets the type used to dispatch files combined size. Empty value ("") disables reporting. Defaults to bytes.
- FilesCountType Type
- Sets the type used to dispatch number of files. Empty value ("") disables reporting. Defaults to files.
- TypeInstance Instance
- Sets the type instance used to dispatch values. Defaults to an empty string (no plugin instance).