printer_levels is a small Python toolkit for discovering network printers and reading toner or ink supply levels from them.
The project focuses on practical, real-world printer troubleshooting:
- Scan one or more subnets for printers that respond to SNMP.
- Read supply data from standard Printer-MIB OIDs.
- Discover printers advertised by mDNS / Bonjour.
- Probe printer-like hosts by common printer ports before attempting SNMP.
- Try alternate vendor-specific and protocol-specific methods such as HP EWS XML endpoints and IPP.
This repository is useful when you want a lightweight way to inventory printers on a LAN and quickly answer questions like:
- Which printers are reachable?
- Which devices expose SNMP supply data?
- Which cartridge or toner is low?
- Is the printer discoverable by mDNS, IPP, SNMP, or HP web endpoints?
printer_levels.pyScans local subnets or user-provided CIDRs, queries printers over SNMP, and prints toner / ink levels using standard Printer-MIB OIDs.
-
discover_and_query_printers.pyFinds printer-like devices by checking common printer ports first, then tries to query SNMP supplies. -
mdsn_discover.pyUses Zeroconf / Bonjour service discovery to find printers advertised on the local network. -
ipp_levels.pyQueries IPP or IPPS printer attributes such asmarker-levelsand related supply metadata. -
hp_ews_levels.pyAttempts to extract HP supply levels from common HP Embedded Web Server pages using simple text matching. -
hp_ews_levels2.pyPulls structured HP consumable data from/DevMgmt/ConsumableConfigDyn.xml. -
snmp_supply_debug.pyWalks several printer supply OIDs directly to help debug missing or unexpected SNMP results.
dump/Contains captured HTTP and HTTPS responses from an HP printer used during troubleshooting and parser development.
The main workflow relies on standard SNMP Printer-MIB values:
- Printer name:
1.3.6.1.2.1.43.5.1.1.16.1 - Supply description:
1.3.6.1.2.1.43.11.1.1.6.1 - Supply level:
1.3.6.1.2.1.43.11.1.1.9.1 - Supply max capacity:
1.3.6.1.2.1.43.11.1.1.8.1
When both current level and max capacity are available, the script calculates a percentage. If a printer reports special values such as -2 or -3, those are treated as unknown supply levels.
Python 3.10+ is a safe target for this project.
Install the packages used by the scripts:
python -m pip install psutil pysnmp zeroconf pyipp requests urllib3If you prefer, create and activate a virtual environment first:
python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install psutil pysnmp zeroconf pyipp requests urllib3Run the main script against a specific subnet:
python .\printer_levels.py --cidr 192.168.50.0/24Use a custom SNMP community string if needed:
python .\printer_levels.py --cidr 192.168.50.0/24 --community mycommunityLet the script detect local non-loopback IPv4 networks automatically:
python .\printer_levels.pyExample output:
========================================================================
OfficeJet Pro 9015 (192.168.50.222)
- Black: 42% (42/100)
- Tri-Color: 18% (18/100)
Main network scanner and SNMP supply reader.
python .\printer_levels.py --cidr 192.168.50.0/24 --community public --timeout 0.8 --retries 0 --workers 128Key arguments:
--cidrCIDR to scan. Can be repeated.--communitySNMP community string. Defaults topublic.--timeoutSNMP timeout in seconds.--retriesSNMP retry count.--workersNumber of concurrent worker threads.--max-hostsSafety cap to prevent scanning very large address ranges by accident.
Useful when you are not sure which hosts are printers. It first looks for printer-like open ports such as 9100, 631, 515, 80, and 443, then attempts SNMP.
python .\discover_and_query_printers.py --cidr 192.168.50.0/24Discovers printers advertised via Bonjour / Zeroconf.
python .\mdsn_discover.pyNote: the filename is mdsn_discover.py in this repository, even though the protocol is mDNS.
Queries printer supplies using IPP or IPPS.
python .\ipp_levels.py --host 192.168.50.222 --path /ipp/print
python .\ipp_levels.py --host 192.168.50.222 --https --path /ipp/printBest option here for HP printers that expose XML consumable data:
python .\hp_ews_levels2.py --ip 192.168.50.222Walks raw OIDs and prints every returned value so you can inspect what the device is actually publishing:
python .\snmp_supply_debug.pyBefore running it, edit the hard-coded IP and COMMUNITY values in the file.
- If no printers are found, verify the subnet and VLAN are correct.
- If printer web pages open but SNMP fails, SNMP may be disabled or filtered.
- If SNMP responds but no supplies are reported, the printer may not implement the standard Printer-MIB supply table.
- If IPP returns no
marker-levels, try another path such as/ipp/printeror switch between IPP and IPPS. - Some HP printers expose better consumable data through
/DevMgmt/ConsumableConfigDyn.xmlthan through SNMP. - A combined
CMYreading means the printer reports a single tri-color cartridge instead of separate cyan, magenta, and yellow levels.
- Small office printer inventory checks
- Supply-level monitoring experiments
- Printer troubleshooting on home or business LANs
- Comparing SNMP, IPP, mDNS, and vendor web endpoints
- Building a future scheduled reporting or alerting workflow
- This project currently prints results to the console and does not store them in a database.
- Authentication beyond simple SNMP community strings is not implemented.
- Some printers expose supply levels only through vendor-specific interfaces.
- Large subnet scans can be noisy or slow depending on network conditions and device behavior.
These scripts perform active network discovery and query network services on your local environment. Run them only on networks you own or are authorized to assess.
Also note:
- Many printers still use SNMP v1/v2c community strings such as
public. - Some scripts intentionally disable TLS certificate verification for printer web or IPPS endpoints to work around self-signed certificates.
- Network segmentation, guest Wi-Fi isolation, or firewall rules may prevent discovery.
Possible enhancements for this project include:
requirements.txtorpyproject.toml- JSON or CSV output modes
- Better vendor-specific parsers
- Configurable logging
- Scheduled reporting
- Alerting on low-supply thresholds
This project was created in a practical troubleshooting spirit. If you want help with Python automation, printer and network diagnostics, or turning scripts like this into something more operational, visit ConsultingJoe.com.
No license file is currently included in this repository. If you plan to share or publish the project, adding a license is recommended.