How to extract Foglight Alarms from the command line or script editor using groovy script?
Run the following from the Foglight Management Server:
<FMS installdir>\bin\fglcmd -srv hostname -port 8080 -usr foguser -pwd fogpwd -cmd script:run -f exportAlarms.groovy > currentAlarms.csv
where exportAlarms.groovy looks like:import com.quest.nitro.service.alarm.*;
import com.quest.nitro.service.sl.interfaces.alarm.*;
topSvc = server.get("TopologyService");
almSvc = server.get("AlarmService");
rulSvc = server.get("RuleService");
def getAlarmProperties(alarm) {
def props = []
id = null
try {
id = alarm.getID();
}
catch (Exception e){
}
props.add(id == null ? "" : id);
ti = null
try {
ti = alarm.getTopologyObjectID()
}
catch (Exception e){
}
props.add(ti == null ? "" : ti);
props.add(alarm.getCreatedTime());
props.add(alarm.getIsCleared());
props.add(alarm.getSourceName());
props.add(alarm.getSeverity());
props.add("\""+alarm.getMessage()+"\"");
to = null
hostname = null;
agentname = null;
try {
to = topSvc.getObject(ti);
hostname = (to == null) ? null : to.get("monitoredHost/name");
agentname = (to == null) ? null : to.get("monitoringAgent/name");
}
catch (Exception e){
}
props.add(hostname == null ? "" : hostname);
props.add(agentname == null ? "" : agentname );
ri = null;
rule = null
try {
ri = alarm.getRuleID();
rule = (ri == null) ? null : rulSvc.getRule(ri);
props.add(rule == null ? "" : rule.getName());
}
catch (Exception e){
}
return props
}
////////////////////////
// get Data and Export
////////////////////////
alarms = almSvc.getCurrentAlarms();
//alarmCount=alarms.size();
def expAlarms = []
alarms.each{ _alarm ->
expAlarms.add(getAlarmProperties(_alarm))
}
// Build Result
StringBuffer buffer = new StringBuffer();
buffer.append("AlarmID,TopologyID,Created,Cleared?,Source,Severity,Message,Host,Agent,Rule\n");
expAlarms.each{m->
int i = 0;
m.each{k->
buffer.append((i>0?",":"")+k)
i++
}
buffer.append("\n")
}
return buffer
or you can run it from the Foglight Script Editor.
The result looks likeAlarmID,TopologyID,Created,Cleared?,Source,Severity,Message,Host,Agent,Rule
7f152a43-35d8-414f-954e-6229914a74af,750043de-35c7-41ae-9407-7a662c533259,2010-01-26 15:06:55.813,false,Capacity_Status,2,"Filesystem /: free space remaining 8.00% (624320.00 Kb).",torpsv019.sitraka.com,FileSystem_FileSystem_on_torpsv019.sitraka.com@torpsv019.sitraka.com,Capacity_Status
9cc93e57-4f71-4ef1-9502-7795a2278a8e,383b81dc-e3a1-45af-81c9-60317403f1ac,2010-02-11 06:38:18.563,false,High_System_Usage,2,"Process 'quest_sc_collector.exe(SYSTEM, 4188)': is consuming 100.0% of the CPU. This may be a runaway process.",torpsv007orcl,Windows_System_Windows_System_on_torpsv007orcl@torpsv007orcl,High_System_Usage
88d4527e-c90a-43cc-9a4d-e7a118e52e29,16872746-01a6-4c81-91fe-636ffcb1097f,2010-02-11 09:07:52.843,false,DBO - Filesystem Estimated Full,3,"The file system E: contains datafiles and is about to run out of space in 1.73 hours.",torpsv007orcl,DBO-torpsv007orcl-orcl,DBO - Filesystem Estimated Full
10dc269b-3742-400a-b144-ed8e9375a01b,9e7b29e9-f556-4713-b251-84a5f150580f,2010-02-11 21:43:19.343,false,DB2_Client_Lock_Wait,2,"DB2 Instance DB2: Accumulated lock wait time of 113.55 seconds for Execution ID TFRITZ: Application ID *LOCAL.DB2.100212023843: Database AUTO_PRD.",torpsv007orcl,DB2_DB2_on_torpsv007orcl@torpsv007orcl,DB2_Client_Lock_Wait
f161a3ec-2d3d-43ef-b5b8-bb1a2e1d4b14,3cc2992f-1e64-47d8-8bdf-5048f1537b8b,2010-03-09 08:18:14.61,false,Page_Availability,2,"Web page tims.prod.quest.corp:8080/timsInfo/index.jsp is not available: Unauthorized",torpsv001sybase,WebMonitor_Web_Tims@torpsv001sybase,Page_Availability
d12e8070-7340-4449-be02-f13301fa5768,39d9e23c-2e6c-4fbf-8b79-85544689a43a,2010-03-09 10:01:18.593,false,DBSS - Batch Request Rate,2,"The batch request rate, 4412.00, is greater than or equal to the batch request threshold, which is 500.00.",torpsv001sybase,DBSS-torpsv001sybase,DBSS - Batch Request Rate
The same content can be found on this Foglight community discussion.
© 2021 Quest Software Inc. ALL RIGHTS RESERVED. Feedback Terms of Use Privacy