Skip to content

Latest commit

 

History

History
110 lines (73 loc) · 2.56 KB

README.md

File metadata and controls

110 lines (73 loc) · 2.56 KB

How to get this work

  • You will be need to have installed and configured SSMTP and RaymiiOrg's python scipt.
  • After that you can run BASH script to send HTML Email with informations about open alerts in LibreNMS.
  • For HTML Email I am using little bit edited Free Responsive Simple HTML Email Template

Installation

cd /opt
git clone https://github.com/jozefrebjak/librenms-mail-report.git
cd librenms-mail-report
mkdir api-report && mkdir full-mail && mkdir log

Dependencies

SSMTP

  • Install SSMTP (Ubuntu 18)
apt install -y ssmtp
  • Edit configuration for SSMTP
echo "">/etc/ssmtp/ssmtp.conf
nano /etc/ssmtp/ssmtp.conf
  • Paste and edit configuration (Office 365 Example)
root=<RCPT_EMAIL>
mailhub=smtp.office365.com:587
AuthUser=<OFFICE365_EMAIL>
AuthPass=<OFFICE365_PASSWORD>
UseTLS=YES
UseSTARTTLS=YES
  • Edit aditional configuration
nano /etc/ssmtp/revaliases:
  • Add your configuration
root:<OFFICE365_EMAIL>:smtp.office365.com:587

RaymiiOrg's python script

This script talks to the LibreNMS API to receive a list of down devices and alerts. The LibreNMS dashboard provides widgets for alerts and host statusses, but there is no easy way to access that output via the API. Using Python I was able to get certain information and output it as HTML or text using PrettyTable. It can be included in other systems or be used in a chain of monitoring customizations.

Installation

On Ubuntu 18.04 with default pvthon3 you need to install prettytable:

sudo apt install python3-prettytable

On Ubuntu prior version if you want to install python3:

sudo apt install python3-prettytable python3

On Ubuntu prior version if you want to install python2:

sudo apt install python-prettytable python-requests python

Usage

Add your API token in the script and change the API URL:

auth_token = "API_TOKEN"
api_url = "https://LIBRENMS_URL/api/v0/"

Run the script:

python ./open_alerts.py

Usage of Send Mail Report

  • You will be need to edit send-mail-report.sh
nano send-mail-report.sh
  • Change variable MAIL_ADDRESS to your Email address.
MAIL_ADDRESS="MAIl_ADDRESS"
  • When you have installed all what is needed and edited Variables then you can run Bash script to send your first Email
./send-mail-report.sh
  • When is everything ok and you received Email succesfuly then you can set up cronjob