项目作者: jozefrebjak

项目描述 :
This scipts will send scheduled report of open alerts in LibreNMS via SSMTP
高级语言: Python
项目地址: git://github.com/jozefrebjak/librenms-mail-report.git
创建时间: 2020-01-19T14:48:20Z
项目社区:https://github.com/jozefrebjak/librenms-mail-report

开源协议:

下载


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

  1. cd /opt
  2. git clone https://github.com/jozefrebjak/librenms-mail-report.git
  3. cd librenms-mail-report
  4. mkdir api-report && mkdir full-mail && mkdir log
  5. `

Dependencies

SSMTP

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

More information here

Installation

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

  1. sudo apt install python3-prettytable

On Ubuntu prior version if you want to install python3:

  1. sudo apt install python3-prettytable python3

On Ubuntu prior version if you want to install python2:

  1. sudo apt install python-prettytable python-requests python

Usage

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

  1. auth_token = "API_TOKEN"
  2. api_url = "https://LIBRENMS_URL/api/v0/"

Run the script:

  1. python ./open_alerts.py

Usage of Send Mail Report

  • You will be need to edit send-mail-report.sh
  1. nano send-mail-report.sh
  • Change variable MAIL_ADDRESS to your Email address.
  1. 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
  1. ./send-mail-report.sh
  • When is everything ok and you received Email succesfuly then you can set up cronjob