Alerta

DOC : http://docs.alerta.io/en/latest/

1
apt-get install postfix
apt-get install mongodb
apt-get install python-pip
pip install --upgrade pip
pip install alerta-server
1
export ALERTA_SVR_CONF_FILE=/etc/alertad.conf
mkdir /var/log/alerta/
1
cat /etc/alertad.conf

# Conf Alerta
# http://docs.alerta.io/en/latest/configuration.html

# BASIC
DEBUG = False
BASE_URL = ''
LOGGER_NAME = 'alerta'
LOG_FILE = '/var/log/alerta/alertad.log'

# MONGODB
MONGO_URI = 'mongodb://localhost:27017/monitoring'
MONGO_DATABASE = 'monitoring'

# CORS
CORS_ORIGINS = [
    'http://127.0.0.1',
    'http://localhost',
    'http://192.168.50.45:8000',
    'http://192.168.50.45',
    'http://192.168.50.40'
]

# AUTH
AUTH_REQUIRED = False
SECRET_KEY = ''

ADMIN_USERS = ['astreinte@mail.fr']
CUSTOMER_VIEWS = False

#OAUTH2_CLIENT_ID = None  # Google or GitHub OAuth2 client ID and secret
#OAUTH2_CLIENT_SECRET = None
#ALLOWED_EMAIL_DOMAINS = ['*']
#ALLOWED_GITHUB_ORGS = ['*']
#
#GITLAB_URL = None
#ALLOWED_GITLAB_GROUPS = ['*']

TOKEN_EXPIRE_DAYS = 7

# API
QUERY_LIMIT = 10000
HISTORY_LIMIT = 100
API_KEY_EXPIRE_DAYS = 365

AUTO_REFRESH_ALLOW = 'ON'
SENDER_API_ALLOW = 'ON'

# EMAIL
EMAIL_VERIFICATION = False
SMTP_HOST = 'localhost'
SMTP_PORT = 25
MAIL_FROM = 'alerta@plop.com'
SMTP_PASSWORD = ''

# SUP
BLACKOUT_DURATION = 86400

SEVERITY_MAP = {
    'security': 0,
    'critical': 1,
    'major': 2,
    'minor': 3,
    'warning': 4,
    'indeterminate': 5,
    'cleared': 5,
    'normal': 5,
    'ok': 5,
    'informational': 6,
    'debug': 7,
    'trace': 8,
    'unknown': 9
}
DEFAULT_SEVERITY = 'indeterminate'

# Plug-ins
PLUGINS = ['reject','amqp','alerta-mailer']

# amqp https://github.com/alerta/alerta-contrib/tree/master/plugins/amqp
AMQP_URL = 'mongodb://localhost:27017/kombu'
AMQP_TOPIC = 'notify'

ORIGIN_BLACKLIST = ['foo/bar$', '.*/qux']  # reject all foo alerts from bar, and everything from qux
ALLOWED_ENVIRONMENTS = ['blabla']  # reject alerts without allowed environments
1
cat alertad.sh 
#!/bin/bash


### BEGIN INIT INFO
# Provides: alertad
# Required-Start: $remote_fs $all
# Should-Start:
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 6
# Description: Starts and stops alertad
### END INIT INFO


ABIN=/usr/local/bin/alertad


case $1 in

# Startup alertad
        start)

                $ABIN &
                echo "starting..."
        ;;

# Stop alertad
        stop)
                killall alertad
                echo "stopping..."
        ;;

        *)
                echo "stop ou start c'est tout"
        ;;
esac

alerta webui

DOC : http://docs.alerta.io/en/latest/webui.html

1
cd /opt
git clone https://github.com/alerta/angular-alerta-webui
cd /opt/angular-alerta-webui/app/
1
cat config.js

'use strict';

angular.module('config', [])
  .constant('config', {
    'endpoint'    : "http://"+window.location.hostname+":8080",
    'provider'    : "basic", // google, github, gitlab or basic
//    'client_id'   : "",
//    'gitlab_url'  : "https://gitlab.com",  // replace with your gitlab server
    'colors'      : {}, // use default colors
//    'colors'      : {
//      'severity': {
//        'critical'     : '#D8122A',
//        'major'        : '#EA680F',
//        'minor'        : '#FFBE1E',
//        'warning'      : '#BA2222',
//        'indeterminate': '#A6ACA8',
//        'cleared'      : '#00AA5A',
//        'normal'       : '#00AA5A',
//        'ok'           : '#00AA5A',
//        'informational': '#00A1BC',
//        'debug'        : '#9D006D',
//        'security'     : '#333333',
//        'unknown'      : '#A6ACA8'
//      },
//      'text': 'white',
//      'highlight': 'lightgray'
//    },
    'severity'    : {}, // use default severity codes
//    'severity'    : {
//      'fatal': 0
//    },
    'audio'       : {}, // no audio
//    'audio'       : {
//      'new'  : '/audio/Bike Horn.mp3'
//    }
//    'tracking_id' : ""  // Google Analytics tracking ID eg. UA-NNNNNN-N
  });
1
cat /etc/init.d/alerta-webui.sh
#!/bin/bash


### BEGIN INIT INFO
# Provides: alerta-webui
# Required-Start: $remote_fs $all
# Should-Start:
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 6
# Description: Starts and stops alerta-webui
### END INIT INFO


AWDIR=/opt/angular-alerta-webui/app/


case $1 in

# Startup alerta-webui
        start)

                cd $AWDIR && python -m SimpleHTTPServer 8000 &
                echo "starting..."
        ;;

# Stop alerta-webui
        stop)
                for i in  ` ps auxw | grep SimpleHTTPServer | grep -v grep | /usr/bin/awk '{print $2}'` ; do kill -9 $i ; done
                echo "stopping..."
        ;;

        *)
                echo "stop ou start c'est tout"
        ;;
esac

alerta mailer (& alerta-amqp)

Doc : https://github.com/alerta/alerta-contrib/tree/master/integrations/mailer

1
git clone https://github.com/alerta/alerta-contrib.git
cd /opt/alerta-contrib/plugins/amqp
python setup.py install
1
cd /opt/alerta-contrib/integrations/mailer
vi mailer.py
-    'config_file':   '~/.alerta.conf',
+    'config_file':   '/etc/alerta-mailer.conf',
1
python setup.py install
1
cat /etc/alerta-mailer.conf

[alerta-mailer]
key = 
mail_to = astreinte@mail.fr
mail_from = alerta@plop.com
dashboard_url = http://192.168.50.45:8000
endpoint =  http://192.168.50.45:8080
smtp_host = 127.0.0.1
smtp_port = 25
smtp_password = 
smtp_use_ssl = False
debug = True
skip_mta = False
email_type = html
mail_localhost = plop.com
amqp_url = mongodb://127.0.0.1:27017/kombu
amqp_topic = notify
mail_template = /opt/alerta-contrib/integrations/mailer/email.tmpl
mail_template_html = /opt/alerta-contrib/integrations/mailer/email.html.tmpl

alerta-mailer

1
cat /etc/cron.d/alerta-mailer_restart 
0 */2 * * * root /etc/init.d/alerta-mailer-init.sh stop && /bin/sleep 2 && /etc/init.d/alerta-mailer-init.sh start >> /var/log/alerta/restart 2>&1
1
cat /etc/init.d/alerta-mailer-init.sh

#!/bin/bash


### BEGIN INIT INFO
# Provides: alerta-mailer
# Required-Start: $remote_fs $all
# Should-Start:
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 6
# Description: Starts and stops alerta-mailer.
### END INIT INFO


AMBIN=/usr/local/bin/alerta-mailer


case $1 in

# Startup alerta-mailer
        start)

                $AMBIN &
                echo "starting..."
        ;;

# Stop alerta-mailer
        stop)
                killall alerta-mailer
                echo "stopping..."
        ;;

        *)
                echo "stop ou start c'est tout"
        ;;
esac