logo

Manual Pages


Table of Contents

NAME

na_filestats - collect file usage statistics

SYNOPSIS

filestats [-g] [-u] [async] [ ages <ages> ] [ expr <expression> ] [ timetype {a,m,c,cr} ] [ sizes <sizes> ] snapshot <snapshot_name> [ style <style> ] [ volume <vol_ume_name> ] [ file <output_file> ]

DESCRIPTION

The filestats utility provides a summary of file usage within a volume. It must be used on a snapshot, and the only required argument is the snapshot name. The volume name defaults to "vol0" if not specified. If the volume you are examining is named otherwise, specify the name explicitly.

The output of this command will contain a breakdown of the total number of files and their total size. You can control the set of ages and sizes that get used for this breakdown, with the "ages" and "sizes" arguments. The output also contains a breakdown of file usage by user-id and group-id.

The first line of the summary contains:

INODES
The total number of inodes scanned (this includes free and used inodes).

COUNTED_INODES
The total number of inodes included in the totals because they are in use (and because they satisfy the "expr" expression, if that option is used).

TOTAL_BYTES
The total number of bytes in the counted files.

TOTAL_KB
The total number of kilobytes consumed by the blocks of the counted files.

OPTIONS

The following options are supported.

async Run the scan independently of the console, best used with the file option. Care should be used to minimize the number of asynchronous scans running simultaneously. More than one can be a big drain on system performance.

-g
A per-group breakdown will be generated, containing separate tables of ages and sizes for each group id.

-u
A per-user breakdown will be generated, containing separate tables of ages and sizes for each user id.

ages ages
Specifies the breakdown of ages, as a set of commaseparated time values. The values are in seconds, but as a convenience you can add an H or D suffix to a number to get hours and days. For example, "900,4H,7D" would produce a breakdown with 4 categories - files accessed in the last 15 minutes, files accessed in the last four hours, files accessed in the last week, and all other files.

expr expression
(Warning, use of this option can be inefficient, and result in very long-running execution times.) This lets you specify a boolean expression that will be evaluated for each inode encountered, and if the expression is true, then the inode will be selected and included in the various breakdowns of file usage. The expression can contain "variables", which are merely the name of an inode attribute enclosed in curly braces. For example, {size} is evaluated as the size of the current inode. The valid inode attributes that you can use in expressions are:

tid
The tree id (for qtrees).

type
The file type (numeric, currently).

perm
Permissions.

flags
Additional flags.

nlink
Count of hard links.

uid
User id (numeric) of file owner.

gid
Group id (numeric) of file owner.

size
Size in bytes.

blkcnt
Size in blocks.

gen
Generation number.

atime
Time of last read or write (in seconds).

mtime
Time of last write (in seconds).

ctime
Time of last size/status change (in seconds).

crtime
Time file was created (in seconds).

atimeage
Age of last read or write (Now atime).

mtimeage
Age of last write (Now - mtime).

ctimeage
Age of last size/status change (Now ctime).

crtimeage
Age of file creation (Now - crtime).

timetype timetype
This lets you specify the type of time that will be used in the "age" comparison. Valid values for timetype are

a
Access time

m
Modification time

c
Change time (last size/status change)

cr
Creation time

sizes sizes
Specifies the breakdown of sizes, as a comma-separated set of size values. The values are in bytes, but as a convenience you can add a K, M, or G suffix to a number to get kilobytes, megabytes, and gigabytes. For example, "500K,2M,1G" would produce a breakdown with 4 categories - files less than 500K, files less than 2 megabytes, files less than 1 gigabyte, and all other files.

To produce a breakdown that includes all unique file sizes,
specify "*" for the sizes value.

style style
Controls the style of output - the possible value for style are "readable" (the default), "table" (colon-separated values suitable for processing by programs), and "html".

file output_file
Instead of printing the results on the console, print the results in output_file. The output_file will be created in the /etc/log directory.

EXAMPLES

1. Produce default file usage breakdowns for snapshot hourly.1 of volume vol0.

filestats volume vol0 snapshot hourly.1

2. Produce file usage breakdowns by monthly age values:

filestats volume vol0 snapshot hourly.1 ages "30D,60D,90D,120D,150D,180D"

3. Produce file usage breakdowns for inodes whose size is less than 100000 bytes and whose access time is less than a day old:

filestats volume vol0 snapshot hourly.1 expr "{size}<100000&&{atimeage}<86400)"

NOTES

On large volumes, this command may take a few minutes to execute. During that time, CPU usage will be high, often 100%. The impact of that CPU usage should be low, because the command is implemented in Java which has low priority. However, disk access to the inode file will have an effect on the throughput of file serving.

Currently, the expression-evaluating code does not do any optimizations, so although you can use arithmetic expressions, it is most efficient if you do not. Of course, it's most efficient if you don't use the expr option at all.


Table of Contents