File Metrics

File.Content(path)

First line of file content (max 255 characters). Requires master server session.

Data Type

String

Platforms

All

Table 1. Arguments
Argument Type Description

path

String

File path

File.LineCount(path)

Number of lines in file.

Data Type

Unsigned Integer 64

Platforms

All

Table 2. Arguments
Argument Type Description

path

String

File path

File.Size(path)

File size in bytes. When path is a directory, returns the total size of matching files in it; recursion into subdirectories is controlled by the recursive argument (see File Count and Size Filtering).

Data Type

Unsigned Integer 64

Platforms

All

Table 3. Arguments
Argument Type Description

path

String

File path (or directory path when used with filters, see File Count and Size Filtering)

File.Type(path)

File type identifier.

Data Type

Unsigned Integer

Platforms

All

Table 4. Arguments
Argument Type Description

path

String

File path

Table 5. Return Values
Value Description

0

Does not exist

1

Directory

2

Device

3

Regular file

4

Other

File.Count(path, pattern, recursive, size, age)

Number of files matching criteria. See File Count and Size Filtering for argument details.

Data Type

Unsigned Integer

Platforms

All

File.FolderCount(path, pattern, recursive, size, age)

Number of subdirectories matching criteria. See File Count and Size Filtering for argument details.

Data Type

Unsigned Integer

Platforms

All

File.Time.Access(path)

Last access time (seconds since epoch).

Data Type

Unsigned Integer 64

Platforms

All

Table 6. Arguments
Argument Type Description

path

String

File path

File.Time.Change(path)

Last metadata change time (seconds since epoch).

Data Type

Unsigned Integer 64

Platforms

All

Table 7. Arguments
Argument Type Description

path

String

File path

File.Time.Modify(path)

Last modification time (seconds since epoch).

Data Type

Unsigned Integer 64

Platforms

All

Table 8. Arguments
Argument Type Description

path

String

File path

File.Hash.CRC32(path)

CRC32 checksum.

Data Type

Unsigned Integer

Platforms

All

Table 9. Arguments
Argument Type Description

path

String

File path

File.Hash.MD5(path)

MD5 hash digest.

Data Type

String

Platforms

All

Table 10. Arguments
Argument Type Description

path

String

File path

File.Hash.SHA1(path)

SHA-1 hash digest.

Data Type

String

Platforms

All

Table 11. Arguments
Argument Type Description

path

String

File path

File.Hash.SHA256(path)

SHA-256 hash digest.

Data Type

String

Platforms

All

Table 12. Arguments
Argument Type Description

path

String

File path

File Count and Size Filtering

The File.Count, File.Size, and File.FolderCount metrics share the same 5-argument signature for filtering files:

File.Count(path, pattern, recursive, size, age)
Table 13. Arguments
Argument Description

path

Directory path to search (required)

pattern

File name glob pattern (e.g., .log). Prefix with ! for inverse match (files NOT matching the pattern). Default:

recursive

Search subdirectories: 0 or false (no), 1 or true (yes). Default: 0

size

Size filter in bytes. Positive value: only files larger than this size. Negative value: only files smaller than abs(value). 0 = no filter.

age

Age filter in seconds. Positive value: only files older than this many seconds. Negative value: only files newer than abs(value) seconds. 0 = no filter.

The age parameter uses sign convention: positive = "older than N seconds" (modified before now - N), negative = "newer than N seconds" (modified within the last N seconds). For example, -1800 means files modified within the last 30 minutes.

Path Macro Support

The following macros are supported in path and pattern arguments for all File.* parameters:

  • Environment variables as {ENV_VAR_NAME}

  • strftime(3C) macros for date/time substitution

  • Text inside backtick (`) characters is executed as a command and the first line of output is used (requires the requesting server to be listed in MasterServers in agent configuration)

Examples
File.Count(/var/spool/myapp)
File.Count(/data/incoming,*.xml,0,1048576)
File.Count(/var/spool/queue,*,0,0,3600)
File.Count(/var/spool/queue,*,1,0,-1800)
File.Count(/var/log,!*.log,0)
File.Size(/var/log/app.log)