Tools for printer discovery and monitoring: - snmp_scanner.py: SNMP-based printer discovery - generate_printer_templates.py: Generate Zabbix templates - analyze_supplies.py: Analyze printer supply levels - extract_summary.py: Extract printer data summaries Includes Zabbix templates for: - HP Color/Mono printers - HP DesignJet T1700 - Xerox Color/Mono/Enterprise printers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Check the unknown Xerox printers"""
|
|
|
|
import os
|
|
|
|
SUPPLY_DESC_OID = "1.3.6.1.2.1.43.11.1.1.6.1"
|
|
SUPPLY_MAX_OID = "1.3.6.1.2.1.43.11.1.1.8.1"
|
|
SUPPLY_LEVEL_OID = "1.3.6.1.2.1.43.11.1.1.9.1"
|
|
MODEL_OID = "1.3.6.1.2.1.25.3.2.1.3.1"
|
|
|
|
def parse_csv(filepath):
|
|
"""Parse printer SNMP CSV file"""
|
|
data = {}
|
|
try:
|
|
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
|
|
for line in f:
|
|
parts = line.strip().split(',', 2)
|
|
if len(parts) >= 2:
|
|
oid = parts[0]
|
|
value = parts[1].strip('"')
|
|
data[oid] = value
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
return data
|
|
|
|
output_dir = '/home/camp/output'
|
|
|
|
# Check the unknown printers
|
|
for filename in ['printer-10-80-92-252.printer.geaerospace.net.csv',
|
|
'printer-10-80-92-253.printer.geaerospace.net.csv',
|
|
'printer-10-80-92-49.printer.geaerospace.net.csv',
|
|
'printer-10-80-92-62.printer.geaerospace.net.csv']:
|
|
|
|
filepath = os.path.join(output_dir, filename)
|
|
if not os.path.exists(filepath):
|
|
print(f"File not found: {filename}")
|
|
continue
|
|
|
|
data = parse_csv(filepath)
|
|
model = data.get(MODEL_OID, "Unknown")
|
|
|
|
print("=" * 100)
|
|
print(f"File: {filename}")
|
|
print(f"Model: {model}")
|
|
print("=" * 100)
|
|
|
|
# Get all supply descriptions
|
|
print(f"{'Index':<7} {'Description':<65} {'Level':<12} {'Max'}")
|
|
print("-" * 100)
|
|
|
|
for i in range(1, 25):
|
|
desc_oid = f"{SUPPLY_DESC_OID}.{i}"
|
|
level_oid = f"{SUPPLY_LEVEL_OID}.{i}"
|
|
max_oid = f"{SUPPLY_MAX_OID}.{i}"
|
|
|
|
if desc_oid in data:
|
|
desc = data[desc_oid][:63]
|
|
level = data.get(level_oid, "N/A")
|
|
max_cap = data.get(max_oid, "N/A")
|
|
print(f"{i:<7} {desc:<65} {level:<12} {max_cap}")
|
|
|
|
print()
|