snmpdf
Display disk space usage via SNMP
TLDR
Fetch the disk space usage
Display help
SYNOPSIS
snmpdf [Net-SNMP Common Options] [-ahHU] [-p path] [-P prefix] [-x dev|type] [-X dev|type] [-f format] [-F] AGENT
Net-SNMP Common Options often include:
-v 1|2c|3 (SNMP version)
-c COMMUNITY (SNMPv1/2c community string)
-t TIMEOUT (Timeout in seconds)
-r RETRIES (Number of retries)
...and various SNMPv3 authentication/privacy options.
PARAMETERS
AGENT
The hostname or IP address of the remote device running the SNMP agent to query.
-h
Displays a help message and exits.
-H
Displays the header line regardless of output format (e.g., when outputting in CSV or XML formats where a header might be suppressed).
-U
Does not display usage for mounted disks; instead, it focuses on the underlying physical partitions or logical volumes directly reported by the SNMP agent.
-p path
Only show partitions that are mounted at the specified absolute path.
-P prefix
Only show partitions whose mount point starts with the specified prefix.
-x dev|type
Excludes devices or filesystem types matching the provided pattern. Multiple patterns can be separated by commas (e.g., -x /dev/sda1,ext4).
-X dev|type
Includes only devices or filesystem types matching the provided pattern. Multiple patterns can be separated by commas (e.g., -X /dev/sdb*,xfs). This is the inverse of -x.
-f format
Specifies the output format. Common options include: table (default), csv, xml, javascript. Using table provides human-readable output, while others are for programmatic parsing.
-F
Forces the display of all partitions, even those that might appear to be non-existent or inaccessible. This can be useful for debugging or when an agent reports unusual or transient states.
-v 1|2c|3
Specifies the SNMP protocol version to use for the query (SNMPv1, SNMPv2c, or SNMPv3). SNMPv2c is commonly used due to its improved capabilities over v1, while v3 offers security features.
-c COMMUNITY
Sets the community string (password) for SNMPv1 or SNMPv2c requests. This string is used by the SNMP agent to authenticate incoming requests.
-t TIMEOUT
Sets the timeout in seconds for the SNMP request. If the agent does not respond within this time, the request is considered failed.
-r RETRIES
Sets the number of retries for the SNMP request. If the initial request times out, snmpdf will retry the specified number of times before giving up.
DESCRIPTION
snmpdf is a utility from the Net-SNMP suite that allows users to query disk space usage on remote hosts using the Simple Network Management Protocol (SNMP). It functions much like the local df command, but instead of reading local filesystem information, it communicates with an SNMP agent running on a target device. This makes snmpdf invaluable for network administrators and monitoring systems to gain insight into disk utilization across a large number of servers or network devices without needing direct shell access. It provides details such as total size, used space, available space, and percentage used for each mounted filesystem, making it a critical tool for proactive resource management and identifying potential storage bottlenecks remotely.
CAVEATS
snmpdf relies heavily on the remote host's SNMP agent being properly configured and running, with the necessary MIBs (especially the HOST-RESOURCES-MIB) enabled to expose disk usage information. Firewall rules between the querying machine and the target host must allow SNMP traffic (typically UDP port 161). Incorrect SNMP community strings (for v1/v2c) or authentication/privacy parameters (for v3) will result in "No Such Instance currently exists" or timeout errors. Querying a large number of hosts or frequently querying can impose a slight load on both the querying machine and the target agents. For security, SNMPv1 and SNMPv2c transmit community strings in plain text, making SNMPv3 the preferred choice for sensitive environments due to its authentication and encryption capabilities.
OUTPUT COLUMNS
By default, snmpdf outputs information in a tabular format with the following columns:
Filesystem: The mount point or device name.
Size: Total capacity of the filesystem.
Used: Amount of space currently in use.
Avail: Amount of space available for use.
%Used: Percentage of the total space that is used.
Mounted on: The directory where the filesystem is mounted.
HISTORY
snmpdf is an integral part of the Net-SNMP suite, an open-source collection of applications and libraries used for implementing SNMP. Its development stemmed from the need for remote system monitoring capabilities, specifically to replicate the functionality of the local df command over a network using the SNMP protocol. It is typically implemented as a Perl script that leverages the Net-SNMP Perl modules to interact with SNMP agents, making it a flexible and powerful tool for network management since its early days within the Net-SNMP project.