PrinterWatchdog is a small website project to monitor and notify printer in your network.
- responsive dashboard to get the live information
- LDAP / ActiveDirectory Authentication
- get notification via Slack
- get notification via EMail
- configure your own notification level
- custom printer images
- Monitoring API for Nagios
- > PHP 7.2
- SNMP Module
- LDAP Module (if you want to use LDAP Auth)
- goto https://github.com/svenkuegler/printerwatchdog/releases
- download the latest version
- upload the unpacked files to your server
Download latest Version from GitHub.
$ cd /tmp
$ git clone https://github.com/svenkuegler/printerwatchdog.git
$ mv -r printerwatchdog /var/www/printerwatchdog
$ cd /var/www/printerwatchdog
$ composer install --no-dev
To let Chihuahua (Watchdog) collect some printer information or notify the users, you need to add some cronjobs in your system. On a Linux machine (Debian, Ubuntu, ...) you can modify with
$ sudo -u www-data crontab -e
Note: Run the cronjob as www-data prevents some file/folder-permission problems.
# Get Printer information 5 minutes after full hour
5 * * * * php /path/to/printerwatchdog/bin/console app:get-printer-info
# Send Slack Notification 3 times on a working day
0 8,12,16 * * 1-6 php /path/to/printerwatchdog/bin/console app:send-notification --slack
# Send E-Mail Notification every day 6am
0 6 * * * php /path/to/printerwatchdog/bin/console app:send-notification --email
cd /path/to/printerwatchdog
php bin/console app:get-printer-info [<Printer IP>]
- Without Argument all saved Printer will requested
- Add a IP to request a single printer. If the printer doesnt exist in DB you will be prompted to add.
cd /path/to/printerwatchdog
php bin/console app:send-notification [--email] [--slack]
- Send a Mail to all recipients With option --email
- Send Slack Messages to the configured Group with option --slack
cd /path/to/printerwatchdog
php bin/console app:user:create <username> <email>
cd /path/to/printerwatchdog
php bin/console app:ldap-test [--full]
- Get all LDAP query results with option --full
There are currently the following methods available.
- Register a webhook for your Slack Group.
- Add the webhook to your .env.local
SLACK_WEBHOOK=https://hooks.slack.com/services/xxx/yyy/zzz
- modify your configuration in .env.local
MAILER_URL=smtp://user:password@smtpservername:25
Note: This is a optional feature! If you want to use the PrinterWatchdog without SnipeIT - skip this section!
At work we use SnipeIT to manage our Assets. So i decided to collect some information from SnipeIT API and show it.
- Generate a API Key in your SnipeIT Environment.
- modify your configuration in .env.local
SNIPEIT_API_URL=https://my.snipeit.url/
SNIPEIT_API_KEY=HERE-COMES-THE-ULTRA-LONG-API-KEY
Again: If you dont want to use SnipeIT leave both values at null
Note: This is a optional feature! If you want to use PrinterWatchdog without LDAP - skip this section!
To enable LDAP functions, add the followed example to your configuration in .env.local
LDAP_SERVER=<NAME_OR_IPADRESS>
LDAP_PORT=389
LDAP_BIND_USER='binduser@mydomain.com'
LDAP_BIND_PASSWD='secret'
LDAP_QUERY_DN='ou=user,dc=mydomain,dc=com'
LDAP_QUERY_STRING='(&(objectCategory=person)(objectClass=user))'
Again: If you dont want to use LDAP leave LDAP_SERVER=null
PrinterWatchdog comes with an integrated api for external monitoring tools like Nagios. The page http://mydomain/monitoring/status returns the state of monitored printers in json format. You can define the notification level on Notification page. Define the ip(s) of your monitoring Tool(s) as allowed ip(s) in .env file to increase the security.
- Define the IP address of your Nagios installation in the .env file
- Copy
/extras/nagios_plugin/check_printerwatchdog
to your Nagios plugins folder. (eg. /var/lib/nagios/plugins) - Create a service command template
- Create a service check on your host
Command Template
define command {
command_name check_printerwatchdog
command_line $USER1$/check_printerwatchdog $ARG1$
}
Service Template
define service{
use generic-service
host_name mydomain.com
service_description My PrinterWatchdog Install
check_command check_printerwatchdog!http://mydomain.com/monitoring/status
}
I decided to use vagrant as platform independent development environment. More information at Vagrant and Virtualbox.
Bring the machine up with:
$ vagrant up
If the machine is up and running open: http://192.168.1.44 or http://127.0.0.1:8080
I switched the default TestSMTP Server to MailCatcher (More stable and better to check HTML Mails, Mailslurper is still available). By Default MailCatcher will be installed, configured and started via Vagrant. The values in .env file pointed to MailCatcher.
Open your browser and navigate to: http://192.168.1.44:1080
To use Mailslurper to test the Mails.
MailSlurper is a small SMTP mail server that slurps mail into oblivion! MailSlurper is perfect for individual developers or small teams writing mail-enabled applications that wish to test email functionality without the risk or hassle of installing and configuring a full blown email server. It's simple to use! Simply setup MailSlurper, configure your code and/or application server to send mail through the address where MailSlurper is running, and start sending emails! MailSlurper will capture those emails into a database for you to view at your leisure.
more information on mailslurper.com
# Login to your Vagrant Machine, for example with ...
$ vagrant up
# Start Mailslurper in background and drop messages to /dev/null
$ /opt/mailslurper/mailslurper &>/dev/null &
Now you can open http://192.168.1.44:8080 to look into your Mails.
Help to translate on POEditor.
Join the public project: https://poeditor.com/join/project/5C3qSMNOPo
Find the Translation files in /translations/* folder.
Simply run the following command:
$ php bin/phpunit
List of used frameworks and libraries.
- Symfony v4.3.8
- Bootstrap v4.3.1
- Font Awesome Free v5.9.0
- jQuery v3.4.1
- Chart.js v2.8
- Chihuahua Icon from www.flaticon.com
- Full Documentation
- Add more translations
- Unit Tests