Ubuntu: Alert Processor manual install

Ubuntu: Alert Processor Install Instructions

Prerequisites

The Alert Processor can be installed on any Linux (and Windows) system and requires about 550 MB of physical memory.

JavaScript Processor

The Alert Processor requires a JavaScript Processor which is installed on the same machine.

Email Server

The Alert Processor sends its emails via SMTP. You need an email server which receive and forward these SMTP messages.

Twilio SMS Gateway

The Alert Processor sends its SMS via the Twilio service provider.
You need a customer account for the Twilio SMS Gateway www.twilio.com/docs/sms external link

Install Dependencies

Install haveged

sudo apt-get update
sudo apt-get install haveged

Install SQLite

sudo apt-get update
sudo apt install sqlite

Install OpenJDK 11

Get the Java Installation Kit

wget https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz

Install OpenJDK Java 11

gunzip openjdk-11.0.1_linux-x64_bin.tar.gz
tar -xvf openjdk-11.0.1_linux-x64_bin.tar
rm openjdk-11.0.1_linux-x64_bin.tar
sudo bash
mkdir /opt/OpenJDK
mv jdk-11.0.1 /opt/OpenJDK
cd /opt/OpenJDK
ls -al
chown root -R jdk-11.0.1
chgrp root -R jdk-11.0.1

Execute the following commands (still as sudo bash):

update-alternatives --install "/usr/bin/java" "java" "/opt/OpenJDK/jdk-11.0.1/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/opt/OpenJDK/jdk-11.0.1/bin/javac" 1
update-alternatives --install "/usr/bin/keytool" "keytool" "/opt/OpenJDK/jdk-11.0.1/bin/keytool" 1
update-alternatives --install "/usr/bin/jar" "jar" "/opt/OpenJDK/jdk-11.0.1/bin/jar" 1
update-alternatives --set "java" "/opt/OpenJDK/jdk-11.0.1/bin/java"
update-alternatives --set "javac" "/opt/OpenJDK/jdk-11.0.1/bin/javac"
update-alternatives --set "keytool" "/opt/OpenJDK/jdk-11.0.1/bin/keytool"
update-alternatives --set "jar" "/opt/OpenJDK/jdk-11.0.1/bin/jar"
exit # end sudo bash

Verify the Java 11 installation.

java -version

openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

Install the Alert Processor

Create the DKFQS account which is running the Alert Processor

sudo adduser dkfqs    # follow the questions, remember or write down the password

Install the Alert Processor

Login with the dkfqs account (SSH) - or - Enter: sudo -u dkfqs bash | OR: Install Samba to get convenient access to /home/dkfqs as Samba dkfqs user

Create the directory /home/dkfqs/alertprocessor (as dkfqs user):

cd /home/dkfqs
mkdir alertprocessor

Create the following sub-directories at /home/dkfqs/alertprocessor (as dkfqs user):

  • bin
  • db
  • config
  • internalData
  • jks
  • log
  • usersData
cd /home/dkfqs/alertprocessor
mkdir bin db config internalData jks log usersData

Copy the following files to the bin directory /home/dkfqs/alertprocessor/bin

  • bcpkix-jdk15on-160.jar
  • bcprov-jdk15on-160.jar
  • bctls-jdk15on-160.jar
  • com.dkfqs.oshialertprocessor.jar

Copy the following files to the db directory /home/dkfqs/alertprocessor/db

  • CreateNewSystemMonitoringDB.sql
  • CreateNewUserReplicationDB.sql

Navigate to /home/dkfqs/alertprocessor/db and create the two databases (as dkfqs user):

sqlite3 SystemMonitoring.db < CreateNewSystemMonitoringDB.sql
sqlite3 UserReplication.db < CreateNewUserReplicationDB.sql

After that delete CreateNewSystemMonitoringDB.sql and CreateNewUserReplicationDB.sql

Copy the following files to the config directory /home/dkfqs/alertprocessor/config

  • alertprocessor.properties
  • twilio.properties

Modify the alertprocessor.properties file. Set the following properties:

  • ServerName
  • ServerDNSName
  • HTTPSExternalServerPort
  • HTTPSInternalServerPort
  • AuthTokenValue
  • JavaScriptProcessorAuthToken
  • The properties at [#The email server configuration]

Modify the twilio.properties file. Set the following properties:

  • sid
  • authToken
  • fromTwilioPhoneNumber
  • fromTwilioAlphanumericSenderID

Copy the following file to the jks directory /home/dkfqs/alertprocessor/jks

  • dkfqscom.jks

Example: alertprocessor.properties

ServerName=alertprocessor.realload.com
ServerDNSName=192.168.0.54
HTTPSExternalServerPort=8099
HTTPSInternalServerPort=8099
HTTPSKeyStoreFile=/home/dkfqs/alertprocessor/jks/dkfqscom.jks
HTTPSKeyStorePassword=topsecret
LogLevel=info

# AuthTokenEnabled: true or false
AuthTokenEnabled=true
# If AuthTokenEnabled is true, but AuthTokenValue is undefined or an empty string, then the (permanent) AuthTokenValue is automatically generated and printed at the log output
AuthTokenValue=c***********

# The max time in minutes where the measured data of the OSHI daemons are cached
AlertProcessorDataCacheMaxStorageTimeMinutes=60

# The internal data directory of the alert processor
InternalDataDirectory=/home/dkfqs/alertprocessor/internalData

# The SQLite DB directory
SQLiteDBDirectory=/home/dkfqs/alertprocessor/db

# The users data root directory
UsersDataRootDirectory=/home/dkfqs/alertprocessor/usersData

# Security: IP black list block time in seconds
SecurityIpBlacklistBlockTime=300

# WebSockets security settings | inbound WebSocket connections are initiated by OSHI daemons and by the portal server
MaxWebSocketConnectTimeSeconds=43200
MaxInboundWebSocketTrafficPerConnection=10000000000
MaxInboundWebSocketPayloadPerFrame=10000000
MaxInboundWebSocketFramesPerIPTimeFrame=10
MaxInboundWebSocketFramesPerIPLimit=1000
MaxUnwantedWebSocketFramesPerIpTimeFrame=60
MaxUnwantedWebSocketFramesPerIpLimit=20

# The max age in seconds for static HTML content
StaticContentMaxAgeTime=7200

# The JavaScript Processor configuration
ConnectToJavaScriptProcessor=true
JavaScriptProcessorHost=127.0.0.1
JavaScriptProcessorPort=8098
JavaScriptProcessorAuthToken=b***********

# The supported alert device types
SupportEmailAlertDevices=true
SupportMobileCompanionAlertDevices=true
SupportSmsAlertDevices=true

# The email server configuration
UsersMailServerHost=192.168.1.4
UsersMailFrom=**********
UsersMailServerAuthUser=**********
UsersMailServerAuthPassword=**********
UsersMailTransmitterThreads=2
UsersMailDebugSMTP=false
# UsersMailServerPort=587
# UsersMailServerStartTLS=true

# The class to support the SMS gateway
smsGatewaysClassNames=com.dkfqs.oshialertprocessor.sms.twilio.TwilioSMSGateway

Create the Alert Processor Startup Script (as root)

sudo bash # become root
cd /etc/init.d
vi AlertProcessor

Edit - create /etc/init.d/AlertProcessor

#!/bin/sh
# /etc/init.d/AlertProcessor
# install with: update-rc.d AlertProcessor defaults

### BEGIN INIT INFO
# Provides:          AlertProcessor
# Required-Start:    $local_fs $network $time $syslog
# Required-Stop:     $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start AlertProcessor at boot time
# Description:       AlertProcessor
### END INIT INFO

case "$1" in
  start)
    if [ -f /home/dkfqs/alertprocessor/log/AlertProcessor.log ]; then
       mv /home/dkfqs/alertprocessor/log/AlertProcessor.log /home/dkfqs/alertprocessor/log/AlertProcessor.log_$(date +"%Y_%m_%d_%H_%M")
    fi
    sudo -H -u dkfqs bash -c 'CLASSPATH=/home/dkfqs/alertprocessor/bin/bcpkix-jdk15on-160.jar:/home/dkfqs/alertprocessor/bin/bcprov-jdk15on-160.jar:/home/dkfqs/alertprocessor/bin/bctls-jdk15on-160.jar:/home/dkfqs/alertprocessor/bin/com.dkfqs.oshialertprocessor.jar;export CLASSPATH;nohup java -Xmx512m -DoshiAlertProcessorProperties=/home/dkfqs/alertprocessor/config/alertprocessor.properties -Dnashorn.args="--no-deprecation-warning" com.dkfqs.oshialertprocessor.internal.StartOshiAlertProcessor 1>/home/dkfqs/alertprocessor/log/AlertProcessor.log 2>&1 &'
    ;;
  stop)
       PID=`ps -o pid,args -e | grep "StartOshiAlertProcessor" | egrep -v grep | awk '{print $1}'`
       if [ ! -z "$PID" ] ; then
          echo "AlertProcessor stopped with pid(s) : $PID"
          kill -9 ${PID} 1> /dev/null 2>&1
       fi
    ;;
  status)
       PID=`ps -o pid,args -e | grep "StartOshiAlertProcessor" | egrep -v grep | awk '{print $1}'`
       if [ ! -z "$PID" ] ; then
          echo "AlertProcessor running with pid(s) : $PID"
       else
          echo "No AlertProcessor running"
       fi
    ;;
  *)
    echo "Usage: /etc/init.d/AlertProcessor {start|stop|status}"
    exit 1
    ;;
esac

exit 0

Change owner and file protection of /etc/init.d/AlertProcessor (root at /etc/init.d):

chown root AlertProcessor
chgrp root AlertProcessor
chmod 755 AlertProcessor

Register /etc/init.d/AlertProcessor to be started at system boot (root at /etc/init.d):

update-rc.d AlertProcessor defaults

Reboot the system. Login as dkfqs and check /home/dkfqs/alertprocessor/log/AlertProcessor.log

Registration of the Alert Processor in the RealLoad Portal Server

Sign in to the Portal Server as Administrator and navigate to "OSHI Alert Processors":

“alt attribute”

Click the "Add OSHI Alert Processors" button and enter the Alert Processor data:

“alt attribute”

Ping the Alert Processor at application level:

“alt attribute”

“alt attribute”

Then click "Replicate Portal Server Settings to Alert Processor":

“alt attribute”

Switch on the options "Replicate Portal Server ID" and "Replicate Mobile Companion API Settings" and submit the form:

“alt attribute”

Testing the Alert Processor

You now need a Portal Server user account and one or more OSHI daemons that are configured to connect to the Alert Processor.

First adjust the oshi-daemon.properties of the OSHI daemons and then restart them:

# The outbound connections to OSHI alert processor(s), multiple alert processors are supported | OshiAlertProcessorHosts is a list of <host>[<port>], separated by semicolons or commas
ConnectToOshiAlertProcessors=true
OshiAlertProcessorHosts=192.168.0.54[8099]
In the log files of the OSHI daemons you can see that they are trying to establish a connection to the Alert Processor, but this is not possible at this point because there is no authorization to do so.

“alt attribute”

In the first lines of the log file you can also see the Unique Daemon ID

“alt attribute”

Now assign a Portal Server user to the Alert Processor in the administrator menu.

“alt attribute”

“alt attribute”

“alt attribute”

Now sign in to the Portal Server with the user account:

“alt attribute”

Click on "System Monitoring" in the navigation bar at the top:

“alt attribute”

Click the "OSHI Systems" tab and then click "Add OSHI System":

“alt attribute”

Enter the description of the system on which the OSHI Daemon is installed and enter the OSHI Daemon Unique ID. All other input fields can be left empty.

“alt attribute”

Wait 15 seconds and then click on the Refresh Icon:

“alt attribute”

The OSHI Daemon is now connected to the Alert Processor. Switch it to active and then click the Dashboard tab.

“alt attribute”

“alt attribute”

Testing the Alert Devices (Email, Mobile Companion App, SMS)

The OSHI Daemon is now connected to the Alert Processor. Switch it to active and then click the Dashboard tab.

“alt attribute”

Add an Email alert device

“alt attribute”

“alt attribute”

Test the Email alert device

“alt attribute”

“alt attribute”

>Check if you received the email. Then also test a Mobile Companion alert device and an SMS alert device. Also check the Alert Notifications Log

“alt attribute”

Testing the JavaScript Processors

The JavaScript Processors are always/only called indirectly via the Alert Processor. For this purpose, a system monitoring rule is created and its execution is tested.