Knowledge Base/SM : Server Management (NNM, SiteScope, SPLUNK, etc)

Creating an init.d script for SiteScope on RHEL

DB Cummings
posted this on Aug-12 2011 08:39 pm

Installation

Unlike in Windows, SiteScope (SiS) 11.10 for Linux does not install a service or daemon by default.  When the server reboots, the administrator must manually navigate to the installation directory (by default /opt/HP/SiteScope) and run the start shell script ‘start’.  In addition, a ‘stop’ script is provided in the same directory.  The SiS 11.10 Deployment Guide suggests using an init.d script to start SiteScoop during the boot process, but it doesn’t provide an example.


The script below is a working sample init.d script for SiS 11.10 on RHEL.


#!/bin/bash

#

# chkconfig: 345 95 20

# description:  starts and stops Sitescope

# processname:  sitescope

#

# /etc/rc.d/init.d/

#

# This is a sample init start up script for SiteScope 11.10

# This script uses the start and stop scripts provided by HP

# to create a service for RHEL

# The HP scripts are located in the SiteScope directory

# /opt/HP/SiteScope

#

#

# Source function library

. /etc/init.d/functions

# SiteScope Scripts

SS_Start="su sis -c /opt/HP/SiteScope/start"

SS_Stop=/opt/HP/SiteScope/stop

start() {

echo -n "Started SiteScope: "

daemon $SS_Start

touch /var/lock/subsys/SiteScope

return

}

stop() {

echo -n "Shutting down SiteScope: "

$SS_Stop

rm -f /var/lock/subsys/SiteScope

return

}

case "$1" in

start)

start

;;

stop)

stop

;;

restart)

stop

start

;;

*)

echo "Usage:  SiteScope {start|stop|restart}"

esac

exit $?


In the commented section, the chkconfig, description, and process name entries, will be used later to allow the chkconfig command to add the sitescope script to the runlevels as a start up service.  In our example, 345 means that SiS 11.10 will start in runlevels 3, 4, and 5.  There is no reason for SiS 11.10 to run in single-user mode (1) or multi-user mode without networking (2), but those levels can be added if desired.  


In addition, the start priority has been set to 95 so that SiteScope will start after all the other supporting services.  Its priority is set to 20 to make sure that it is one of the first services to be stopped before the server shuts down or reboots.  The description and process name can be changed as desired.  The process name will be visible as a running process during start up or if it is restarted manually (/etc/init.d/sitescope restart).  The command ‘ps -e | grep sitescope’ would result in something similar to:

25409 ttys000    0:00.00 grep sitescope

Once the SiS 11.10 is started, you can see the active running SiS 11.10 service with the command ‘ps -e | grep start’.

The script primarily uses the ‘start’ and ‘stop’ shell scripts provided in the SiS 11.10 installation.  The default installation directory for SiS 11.10 in Linux is /opt/HP/SiteScope.  It cannot be changed during the installation process, and HP does not recommend moving it after installation.  The SS_Start and SS_Stop variables point to the relevant script in the SiS 11.10 installation directory.  The SS_Start variable runs the ‘start’ script as a user dedicated to SiS 11.10.  HP recommends that the application be run by a highly privileged account other than root.  The SS_Start variable accomplishes this by running the ‘start’ script with this command, ‘su sis -c /opt/HP/SiteScope/start’.

At this point, the script is a basic init script running the ‘start’ script as a background daemon to start SiteScope.  It stops SiS 11.10 by using the ‘stop’ script.  Like any other init script, the ‘sitescope’ script can be run manually by running /etc/init.d/sitescope and appending start, stop, or restart.

When started manually with this command, ‘/etc/init.d/sitescope start’, the following is displayed:

Started SiteScope:

The start process can take some time, but eventually ‘[OK]” will be displayed indicating that the process has begun successfully.  You can then navigate your web browser to ‘sitescopeserver:8080/SiteScope’ and access the SiS 11.10 web interface.  

When stopped manually with this command, ‘/etc/init.d/sitescope stop’, something similar to the following is displayed:

/opt/HP/SiteScope/start:  line 55:  6000 killed ./start-server -x $@ /dev/null 2>&1

Stopped SiteScope monitoring process (6015)

The stop and start commands are combined in the restart command, ‘/etc/init.d/sitescope restart’.

Installation

Perform the following actions as root (or sudo) to add init script to the runlevels for the server start up:

  1. Create the script in the editor of your choice and name it sitescope with no extension.

  2. Copy the script to the /etc/init.d/ directory.  

  3. Run the command, ‘chmod +x sitescope’ to make it executable.  

  4. Run chkconfig --add /etc/init.d/sitescope.

When the server is started, the SiS 11.10 process will start.  In addition, the SiS 11.10 service can be stopped, started, or restarted using the /etc/init.d/sitescope command with stop, start, or restart.  If a user attempts to run the /etc/init.d/sitescope script without using start, stop, or restart, they will be prompted with a help message:

Usage:  SiteScope {start|stop|restart}