Python app built to monitor statistics from network printers and send emails to report them
- It utilizes a three-level classification system consisting of WARNING, CRITICAL and ERROR categories
- Implements parallel execution when connecting to devices
- Implements parallel execution when sending emails
- Supported printer brand at the moment: Brother
- Python v3.11.1
-
- Brand: Brother Industries, Ltd
- Model: HL-1210W series
-
- Brand: Brother Industries, Ltd
- Model: DCP-1610NW series
-
About the full URI
You need to manually find out the full URI of the CSV resource for each printer in your network and then add it to the
devices.json
file as a new dictionary in the list, separating it in keys: values pairs- In this case, the full URI for the tested printers were:
http://192.168.1.5:80/etc/mnt_info.csv
andhttp://192.168.120.17:80/etc/mnt_info.csv
Tips:
-
Inspecting web
You can use the "Inspect" option when right-clicking on the button available in the web browser printer GUI when trying to download a CSV file (More useful and quicker tip)
Steps:
a) Go to the Network tab and now left-click the button.
b) Close the window that just opened
c) Under the Name column, click in the csv file and go to the Headers tab
d) You will find the full URI in the Request URL field
or
-
Using a sniffer tool
You can use a sniffer tool like Wireshark to inspect packets and find the full URI (Traffic could be encrypted in this situation)
- In this case, the full URI for the tested printers were:
a) Clone repository into your machine
git clone https://github.com/mvarrone/printer-monitoring.git && cd printer-monitoring
b) Create a virtual environment and install dependencies
On Windows
1.Creating a virtual environmentpython -m venv venv
2.Activating it
a) Using CMD
.\venv\Scripts\activate.bat
b) Using PowerShell
.\venv\Scripts\Activate.ps1
3.Installing dependencies
pip install -r requirements.txt
4.(OPTIONAL) Deactivating the virtual environment
deactivate
On Linux/Mac
1. Creating a virtual environmentpython3 -m venv venv
2.Activating it
source venv/bin/activate
3.Installing dependencies
pip install -r requirements.txt
4.(OPTIONAL) Deactivating the virtual environment
deactivate
-
This project was tested using a Gmail account so you need to create an
application password
inside Google Account settingsa) Go to Google Account
b) Security tab
c) How to access to Google > 2-step verification
d) App passwords
-
Once there, create an entry like this:
a) Select app: Other. Name it whatever you want, for example, Python script
b) Click on the Generate button
c) Copy the 16 characters in length code that was generated
d) Paste it in the
app_password
value in theconfig.json
-
Modify
sender_email
andreceiver_email
values inconfig.json
-
Modify
devices.json
in order to add your network printer devicesExample:
[ { "protocol": "http", "ip_address": "192.168.1.5", "port": 80, "path": "etc", "csv_filename": "mnt_info.csv", "brand": "brother" } ]
On Windows
cd app && python .\main.py
On Linux/Mac
cd app && python3 .\main.py
A Python 3 script and a CSV file were provided. See example
Also, a results.json
was recently provided
-
The intention of providing an example is for you to know how the data was originally downloaded from the printer device and how is processed in the Python file
-
I found it might be useful for cases where:
- there is no printer available in your network
- the printer exports some other format file
- the printer does not provide a way to export data and you want to test it anyway
- the CSV file has not the same structure
Contributions to this project are welcome. If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request
This project is licensed under the MIT License. See the file for details