A customer would like to forward alarms from Foglight with all the appropriate information, such as alarm time, source, severity, message, and the rule name, to a pager script which in turn pages the on-call DBA.
The content of this was written by my colleague Minh Nguyen. I validated the steps on Foglight 5.7.5 in October 2016.
Assumption: the Foglight Management Server (FMS) is running on Linux/Unix
- Login to your Foglight console
- Go to Dashboards => Administration => Rules & Notifications => Create Rule
- A rule wizard will started. Create a rule with the following info:
- Simple rule
- No scoping query
- Event driven
- Event Name => AlarmSystemEvent
- Give it a description
- Click Next. Under the Condition & Actions tab, enter the following codes block in the Condition area:
return @event.get("change/name").equals("Fire")
Click on the green icon to verify its syntax.
- Click Next. We will use the default schedule.
- Click Next. We will define the Action Behaviors to fire action after 1 consecutive evaluation.
- Click Next. We will leave Rule Variables blank.
- Click Finish. The rule is created and saved.
- Now we need to edit the rule to add severity variables and command action. Click Edit Rule.
- Go to the Condition & Actions tab => Severity Level Variables to define parameters to pass to the pager script.
- We will want to add the following variables:
How to add a severity level variable:
Step 1 – select the Type (in our case, all variables are Expression)
Step 2 – enter a name
Step 3 – enter the code blocks for the variable
Step 4 – add the variable
Repeats steps 1-4 above for the following parameters: (in RED are the code blocks). We recommended using
copy-and-paste to eliminate any typing errors:
- Message:
@event.get("message")
- Rule:
@event.get("ruleName")
- Severity:
severity = @event.get("severityName");
if(severity.equals("Fatal"))
{
severity = "FATAL";
}
if(severity.equals("Critical"))
{
severity = "CRITICAL";
}
if(severity.equals("Warning"))
{
severity = "WARNING";
}
return severity;
- Source:
obj = server["TopologyService"].getObject(@event.get("topologyObjectID"));
if (obj.get("monitoredHost")==null) {
return "Unknown";
}
return obj.get("monitoredHost/name");
- Time:
@event.get("createdTime")
The variables should look like those below:
- Click on the Action tab and add a Command Action.
- Once it is added, click on the CommandAction link. It should take you to the Command Action properties page.
- Click on Default link to change its value. It will pop up a separate Action Parameter Editor page.
- Click on the User Defined tab. Enter the command string:
<full path to location of pager script> "@Time" @Severity "@Source" "@Message" "@Rule"
The string essentially runs the script and passes the rule variables created above as parameters to the script (see below).
For scripting purposes, the parameters passed are as follows:
Time=$1
Severity=$2
Source=$3
Message=$4
Rule=$5
- Click Change. Click Go to Action List.
- Click Save All to save all changes. Click Go to Rule List.
- Go to Rule Management and enable the rule.
NOTE: that the customized rule is under the Non-Cartridge drop-down menu.