Ubuntu: OSHI Daemon manual install

Ubuntu: OSHI Daemon Install Instructions

Prerequisites

The OSHI Daemon can be installed on any Linux (and Windows) system and requires about 300 MB of physical memory.

Install Dependencies

Install haveged

sudo apt-get update
sudo apt-get install haveged

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
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 OSHI Daemon

Create the DKFQS account which is running the OSHI Daemon

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

Install the OSHI Daemon

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/oshi (as dkfqs user):

cd /home/dkfqs
mkdir oshi

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

  • bin
  • config
  • internalData
  • log
cd /home/dkfqs/oshi
mkdir bin config internalData log

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

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

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

  • oshi-daemon.properties

Modify the oshi-daemon.properties file. Set the following properties:

  • HttpsPort (the OSHI Daemon port)
  • HttpsCertificateCN (set the public DNS name or the IP address for the automatically generated SSL/TLS server certificate)
  • HttpsCertificateIP (set the public IP address for the automatically generated SSL/TLS server certificate)
  • AuthTokenValue (the value of the OSHI Daemon authentication token)

Example: oshi-daemon.properties

HttpsPort=8087
HttpsCertificateCN=192.168.1.27
HttpsCertificateIP=192.168.1.27
LogLevel=info

OshiDaemonInternalDataDirectory=/home/dkfqs/oshi/internalData

# 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=aaa

# WebSockets security settings
MaxWebSocketConnectTimeSeconds=43200
MaxInboundWebSocketTrafficPerConnection=1000000
MaxInboundWebSocketPayloadPerFrame=10000
MaxInboundWebSocketFramesPerIPTimeFrame=10
MaxInboundWebSocketFramesPerIPLimit=1000

# The OSHI subjects to collect periodically - meaning that historical data are available - don't confuse with OSHI subjects snapshots which can be made at any time
# Possible values are: OPERATING_SYSTEM,CPU,MEMORY,NETWORK,NETWORK_CONNECTIONS_LIST,DISK,FILE_SYSTEM,PROCESS_LIST
CollectOshiSubjectsList=CPU,MEMORY,NETWORK
CollectOshiSubjectsIntervalSeconds=5
CollectOshiSubjectsMaxStorageTimeSeconds=43200

# The (optional) plain text that is displayed in the 'About' tab
AboutThisOshiDaemonText=This daemon runs in unprivileged mode, so some detailed values may not be captured or displayed.

# The (optional) support email address in the 'About' tab
AboutThisOshiDaemonSupportEmailAddress=support@realload.com

Create the OSHI Daemon Startup Script (as root)

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

Edit - create /etc/init.d/OshiDaemon

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

### BEGIN INIT INFO
# Provides:          OshiDaemon
# 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 OshiDaemon at boot time
# Description:       OshiDaemon
### END INIT INFO

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

exit 0

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

chown root OshiDaemon
chgrp root OshiDaemon
chmod 755 OshiDaemon

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

update-rc.d OshiDaemon defaults

Reboot the system. Login as dkfqs and check /home/dkfqs/oshi/log/OshiDaemon.log

Verify the OSHI Daemon installation

Start a Firefox web browser and connect to the OSHI Daemon at HTTPS port.

Ignore the SSL certificate waring:

“alt attribute”

Enter the OSHI Daemon authentication token:

“alt attribute”

The main page of the OSHI daemon is then displayed. In the top navigation you can select additional system performance metrics:

“alt attribute”