PrintAudit is a modern Python rewrite of the historical PrintAnalyzer Perl utility. It ingests CUPS page_log files, produces comprehensive usage, cost, and behavior reports, and supports modular outputs (CLI, CSV, HTML, email).
- Comprehensive Analysis: Queue usage, user activity, temporal patterns, cost allocation, and more
- Cost Tracking: Currency-agnostic cost calculation with configurable rates per printer, department, or label
- Flexible Outputs: Multiple output formats (CLI, CSV, HTML, email) with plugin architecture
- Date Filtering: Analyze specific time ranges with
--start-dateand--end-date - Work Hours Detection: Identify printing activity within configured business hours
- Modular Design: Easy to extend with custom output modules
pip install printauditgit clone https://github.com/vhsantos/PrintAudit.git
cd printaudit
python3 -m venv .venv
source .venv/bin/activate
pip install -e .PYTHONPATH=src python3 -m printaudit --config printaudit.conf.sample --dry-runPrintAudit searches for configuration files in this order:
--config /path/to/printaudit.conf(command-line override)$PRINTAUDIT_CONFIG(environment variable)/etc/printaudit/printaudit.conf/etc/printaudit.conf./printaudit.conf(current directory)
-
Copy the sample configuration:
sudo cp printaudit.conf.sample /etc/printaudit.conf
-
Edit
/etc/printaudit.confand adjust:page_log_path: Path to your CUPS page_log filework_start/work_end: Business hours (7-22 = 7 AM to 10 PM)outputs: Comma-separated list of output modulesenabled_sections: Which analysis sections to include
[core]
page_log_path=/var/log/cups/page_log
work_start=7
work_end=22
enabled_sections=queue,queue_user,user,temporal,job,cost
outputs=cli,csv,html,email
cli_mode=rich # or "plain"
cli_max_rows=15
csv_dir=/var/spool/printaudit/reports
html_path=/var/spool/printaudit/reports/printaudit.html
html_use_chartjs=false # Use Chart.js for graphs (optional)[email]
enabled=true
smtp_host=mail.example.com
smtp_port=587
smtp_user=printaudit@example.com
smtp_password=secret
use_tls=true
recipients=ops@example.com,finance@example.com
subject=PrintAudit Report
from=printaudit@example.com
attach_csv=true
attach_html=true
report_in_body=true # Include full report text in email body[costs]
# Default cost per page (unitless, use your local currency)
default=0.02
# Currency display settings (optional)
currency_symbol=CLP$
currency_code=CLP
# Printer-specific rates (optional)
printer.Printer01=0.01
printer.Printer02=0.05
# Department/label-specific rates (optional)
label.accounting=0.03
label.marketing=0.05
label.IT=0.04[cost_rules]
# Map users/queues to cost labels for department allocation
accounting=accounting1,accounting2,accounting3
sales=bob
platform=charlie,diana,eve
it=aliceprintauditprintaudit --start-date 2025-04-01 --end-date 2025-04-30printaudit --outputs cli,htmlprintaudit --list-outputsprintaudit --dry-runPrintAudit supports multiple output formats:
cli: Terminal report with plain or rich formattingcsv: One CSV file per analysis section incsv_dirhtml: Interactive HTML dashboard with chartsemail: SMTP delivery of summary and attachments
See Creating Output Modules for extending with custom formats.
PrintAudit provides comprehensive analysis across multiple dimensions:
- Queue Analysis: Usage by printer/queue with percentages
- User Analysis: Per-user statistics with pages per request
- Temporal Analysis: Hourly and daily usage patterns
- Job Analysis: Distribution of job sizes and copy counts
- Cost Analysis: Department/label-based cost allocation
- Media Analysis: Paper/media type usage
- Client Analysis: Source hostname tracking
- Document Types: File extension analysis
- Duplex Analysis: Two-sided vs. one-sided printing
See Analysis Modules Documentation for detailed explanations and expected outputs.
-c, --config PATH Path to configuration file
-o, --outputs LIST Comma-separated output modules override
--cli-mode MODE CLI renderer style (plain/rich)
--start-date DATE Filter start date (YYYY-MM-DD)
--end-date DATE Filter end date (YYYY-MM-DD)
--dry-run Test configuration without running
--list-outputs List available output modules
-h, --help Show help messageprintauditThis creates:
- CLI output to terminal
- CSV files in
csv_dir - HTML report at
html_path - Email delivery (if enabled)
printaudit --start-date 2025-04-01 --end-date 2025-04-30printaudit --outputs htmlSee example reports to understand the output format:
- Text Report Example - Plain text CLI output example
- HTML Report Example - Formatted HTML report example
- Python 3.10+
- CUPS
page_logfile access - Optional: SMTP server for email delivery
rich>=13.0.0- Enhanced terminal outputclick>=8.0.0- Command-line interface
MIT License - see LICENSE file for details.
Contributions are welcome! Please see the documentation for:
PrintAudit can be integrated with logrotate to automatically generate reports when CUPS logs are rotated. See Logrotate Setup Guide for detailed examples including:
- Weekly and monthly rotation configurations
- Automated email reporting
- Issues: GitHub Issues
- Repository: GitHub Repository