Sending an Alarm Message

Sending a Nimsoft Alarm message can assist in the integration of existing scripts with event management, or when you choose to use Perl as the programming language for system administrative tasks (for example, monitoring and batch jobs).

Synopsis

use Nimbus::API;
my($retcode,$msgid) = =nimAlarm ($severity[,$msgtext [,$subsysid [,$supid[,$source]]]);

where:

API used in this example

Examples

A simple example showing how to send an alarm.

use Nimbus::API;
nimAlarm(NIML_CRITICAL, "This is a critical message from perl");

This next example is a bit more complicated showing how to integrate a simple file counting module with Nimsoft, that should give an alarm when the number of files in the /tmp directory exceeds 3, and clears it if the number of files is 3 or less.

use Nimbus::API;
use Monitor;	# Reference to module containing FileCount
use strict;
 
my $dir = "/tmp";
####################################################################
# The subsystem-id is maintained by the Alarm Server, you may however,
# also set it to any textstring like "DirMonitor". Here we use the id.
# Hint: launch the NAS configurator and find the string tied to the id by
# looking under the subsystem tab.

my $sid = "1.1.5";
####################################################################
# The suppression tag enables the Alarm Server to keep a severity state on
# the message so it is possible to escalate the severity and/or to clear it.

my $suptag = nimSuppToStr(0,0,0,"fileMonitor/$dir");
my $count  = FileCount($dir);
 
if ($count > 3) {
  nimAlarm(NIML_CRITICAL,"Directory $dir has too many files ($count)",$sid,$suptag);
}
else {
  nimAlarm(NIML_CLEAR,"Directory $dir is checked and ok",$sid,$suptag);
}