To get started, you need
A client coded in C or C++ language, such as the example in this section.
A make file, based on the sample make file in this section (UNIX systems only).
The files in the Event Server API library. See Section 4 for the location of the Event Server API files.
In This Example
In this example, the client raises an alert, which is displayed in an Alerts window of Operations Sentinel Console.
How to Code the Example
The example uses a client that is coded in C language, as follows:
main( int argc, char **argv ) { /* Initialize the API. Application name = "alarm sender" No application qualifier. */ SPD_InitClient("alarm sender", NULL); /* client processing... */ /* Send an alarm: System is UNIX system named host02 (in the configuration). Alarm identifier is "alarm01". No alarm qualifier. Alarm text is "Emergency...". No alarm help text (default help file is "alarm01"). External action is "plan9". Severity is critical. Application name and qualifier are defaults specified for SPD_InitClient. No time stamp. */ SPD_SendAlarm("host", "host02", "alarm01", NULL, "Emergency in computer center", NULL, "plan9", SPD_criticalCN, NULL, NULL, 0); /* no event loop required if events are only sent, but not received. */ }
Using a Make File
For a client that runs on a UNIX system, in addition to the coded client program, you must use a make file similar to the following to complete the programming of your client.
CAUTION
Use tabs instead of spaces before commands in a make file. A command is any executable line following a target/dependency specification. Using spaces results in program failures.
#************************************************************************
# *
# This is the sample Makefile for API client programs. *
# *
#************************************************************************
############################################################
### MACRO DEFINITIONS ###
############################################################
SHELL = /bin/sh
# API location
SPD=API-installation-directory
# C compiler
CC = cc
STDH = /usr/include
# INCLUDES
INCLUDE = -I$(SPD) -I$(STDH)
# LIBRARIES
UCBDIR = /usr/ucblib
UCBLIB = -L $(UCBDIR) -lucb
SPDLIB = -L $(SPD) -lspd
SYSLIBS = -lsocket -lnsl -lc -lm -lxml2 -pthread
# The -lucb library must be linked last
STDLIB = $(SPDLIB) $(SYSLIBS) $(UCBLIB)
# FLAGS
# debugging on/off
DBGFLG = -g -DDEBUG
# common C flags
CFLAGS = -c $(DBGFLG) $(INCLUDE)
# additional C flags
CPPFLAGS = -P $(INCLUDE) -DDEBUG
############################################################
### OBJECT FILE DEFINITIONS ###
############################################################
APISAMPLE = \
apisample.o
############################################################
### TARGETS ###
############################################################
all: apisample
apisample: $(APISAMPLE)
$(CC) $(DBGFLG) $(APISAMPLE) \
$(STDLIB) && mv a.out $@
apisample.o: \
apisample.c
$(CC) $(CFLAGS) apisample.c
Note:
When building a Client on Solaris System do not include the -pthread library as this may cause an error.
When building a Client on Linux System do not include -lsocket library as this may cause an error.
When building a Client on Linux Systems, the libxml2 and libxml2-devel libraries should be installed.
On SLES machines, libraries can be installed by using the following commands: zypper install libxml2; zypper install libxml2-devel
On CentOS machines, libraries can be installed using the following commands: yum install libxml2; yum install libxml2-devel
On RHEL machines, libraries can be installed using the following commands: yum install libxml2; yum install libxml2-devel
Customizing the Make File
Customize the make file to reflect the location of your Operations Sentinel files and directories. Change API-installation-directory to the name of the directory or folder in which the Event Server API library and header files are located. See Section 4.
Effect of the Client on Operations Sentinel
The client sends an alert through the Event Server API to the Operations Sentinel server. On Operations Sentinel workstations, the Operations Sentinel Console application then displays the alert in one of its Alerts windows. The Operations Sentinel workstation operator can view the contents of the Alerts window by clicking the highlighted alert icon, the exclamation point in the main window of Operations Sentinel Console. The text of the message reads, “Emergency in computer center.” The operator can then respond to the emergency in the computer center and clear the alert from the Alerts window.
Data Flow Diagram of the Example
This illustration shows the architecture underlying this example. The diagram shows how the client sends the alert through the Event Server API. From the Event Server API, the alert is sent to the Operations Sentinel server. The Operations Sentinel Console application displays the alert to the operator on an Operations Sentinel workstation in one of its Alerts windows.