cups-snmp - Linux
Overview
cups-snmp
is a command-line utility that provides SNMP (Simple Network Management Protocol) management for CUPS (Common Unix Printing System). It allows you to monitor and control CUPS-managed printers and print jobs over a network.
Syntax
cups-snmp [options] [printer-name]
Options/Flags
General:
-h, --help
: Display help and exit.-V, --version
: Display version information and exit.-d, --debug
: Enable debug output.-v, --verbose
: Increase verbosity level.-q, --quiet
: Suppress normal output.
SNMP Configuration:
-c, --community
: SNMP community string (default: "public").-p, --port
: SNMP port number (default: 161).-n, --host
: SNMP host address (default: "localhost").
Printer-Specific:
-P, --printer-uri
: URI of the printer to target.-L, --list-printers
: List available printers.
Examples
Get printer status:
cups-snmp --printer-uri "ipp://myprinter.example.com" status
Set printer description:
cups-snmp --printer-uri "ipp://myprinter.example.com" set-printer-info name "My Printer"
Monitor print job progress:
cups-snmp --printer-uri "ipp://myprinter.example.com" get-job-status 5
Common Issues
SNMP Communication Errors:
- Ensure that the SNMP service is running on the host.
- Verify that the SNMP community string matches the configured value on the printer.
- Check that the SNMP port is not blocked by a firewall.
Printer Not Found:
- Confirm that the printer is powered on and connected to the network.
- Use the
-L
option to list available printers and verify that the target printer is listed.
Integration
cups-snmp
can be used in conjunction with other CUPS-related commands, such as lpstat
and lpr
, to create automated scripts for printer management. For example:
lpstat -p | grep "offline" | while read printer; do
cups-snmp --printer-uri "$printer" set-printer-state stopped
done
This script checks the printer status (lpstat -p
) and automatically stops any printers that are offline (grep "offline"
), using cups-snmp
.
Related Commands
lpstat
: List print jobs and printer status.lpr
: Send a print job to a printer.snmp
: Generic SNMP client tool.