• Products
    • View all products
    • Free trials
    • Buy online
    • Product lines
      • ApexSQL
      • Change Auditor
      • Enterprise Reporter
      • Foglight Database Monitoring
      • Foglight Evolve
      • KACE
      • Metalogix
      • Migration Manager
      • NetVault Backup
      • One Identity
      • QoreStor
      • Quest On Demand
      • Rapid Recovery
      • Recovery Manager
      • RemoteScan
      • SharePlex
      • Spotlight
      • Stat
      • Toad
    • Featured products
      • Cloud Management
        • Cloud Access Manager
        • Foglight for Virtualization, Enterprise Edition
        • Identity Manager
        • On Demand Migration for Email
        • Quest On Demand
        • Rapid Recovery
      • Data Protection
        • Foglight for Virtualization
        • NetVault
        • NetVault for Office 365
        • QorePortal
        • QoreStor
        • Rapid Recovery
        • vRanger
      • Database Management
        • Foglight for Databases
        • Litespeed for SQL Server
        • SharePlex
        • Spotlight SQL Server Enterprise
        • Toad Data Point
        • Toad DevOps Toolkit
        • Toad Edge
        • Toad for Oracle
        • Toad for SQL Server
      • Identity & Access Management
        • Active Roles
        • Defender
        • Identity Manager
        • Identity Manager Data Governance
        • One Identity Safeguard
        • Password Manager
        • Privileged Access Suite for Unix
        • Starling Connect
        • Starling Two-Factor Authentication
        • syslog-ng
      • Microsoft Platform Management
        • Active Administrator
        • Change Auditor
        • Enterprise Reporter
        • GPOADmin
        • InTrust
        • Metalogix
        • Migration Manager
        • On Demand Migration for Email
        • Quest On Demand
        • Recovery Manager
      • Performance Monitoring
        • Foglight Capacity Director
        • Foglight Hybrid Cloud Manager
        • Foglight for Databases
        • Foglight for Operating Systems
        • Foglight for Oracle
        • Foglight for PostgreSQL
        • Foglight for SQL Server
        • Foglight for Storage Management
        • Foglight for Virtualization
        • Spotlight on SQL Server
      • Unified Endpoint Management
        • Desktop Authority Management Suite
        • KACE Cloud Mobile Device Manager
        • KACE Desktop Authority
        • KACE Privilege Manager
        • KACE Systems Deployment Appliance
        • KACE Systems Management Appliance
        • RemoteScan
  • Solutions
    • View all Solutions
    • Industries
      • Education
      • Energy
      • Federal Government
      • Financial Services
      • Healthcare
      • State & Local Government
    • Platforms
      • Active Directory
      • Cisco
      • DB2
      • Exchange
      • Google
      • Hyper-v
      • Lotus Notes
      • OneDrive for Business
      • Office 365
      • Oracle
      • SAP/Sybase
      • SharePoint
      • SQL Server
      • Teams
      • Unix/Linux
      • VMware
      • Windows Server
    • Cloud Management
    • Data Protection
      • Overview
      • Backup & Recovery
      • Cloud Management
      • Deduplication & Compression
      • Disaster Recovery
      • Office 365 Data Protection
      • Virtualization Management
    • Database Management
      • Overview
      • Administration
      • Cloud Migration
      • Data Preparation and Provisioning
      • Development
      • DevOps
      • Performance Monitoring
      • Replication
      • Supported Platforms
        • IBM DB2
        • MySQL
        • Oracle
        • PostgreSQL
        • SAP Solutions
        • SQL Server
    • GDPR Compliance
    • Identity & Access Management
      • Overview
      • Identity Administration
      • Identity Governance
      • Privileged Access Management
      • AD Account Lifecycle Management
      • Access Control
      • Cloud
      • Log Management
    • Microsoft Platform Management
      • Overview
      • Mergers & Acquisitions
      • Migration & Consolidation
      • Office 365 Migration & Management
      • Security & Compliance
      • Windows Backup & Recovery
      • Supported Platforms
        • Active Directory
        • Cisco
        • Exchange
        • Google
        • Groupwise
        • Lotus Notes
        • Office 365
        • OneDrive for Business
        • SharePoint
        • SQL Server
        • Teams
        • Unix/Linux
        • Windows Server
    • Performance Monitoring
      • Overview
      • Database Performance Monitoring
      • Operating System Monitoring
      • Storage Performance & Utilization Management
      • Supported Platforms
        • Active Directory
        • DB2
        • Exchange
        • Java
        • Hyper-V
        • .NET
        • Oracle
        • SAP/Sybase
        • Storage
        • SQL Server
        • VMware
    • Unified Endpoint Management
      • Overview
      • Endpoint Compliance
      • Endpoint Security
      • Endpoint Visibility
      • Industries
        • Education
        • Healthcare
      • Supported Platforms
        • Internet of things
        • Microsoft® Windows
        • MAC
        • UNIX/LinuX
  • Resources
    • Blogs
      • Data Protection
      • Database Management
      • IT industry Insights
      • IT Ninja
      • Microsoft Platform Management
      • Performance Monitoring
      • Toad World Blog
      • Unified Endpoint Management
    • Customer Stories
    • Documents
    • Events
    • Webcasts
    • Technical Documentation
    • Videos
    • Whitepapers
  • Trials
  • Services
    • Consulting Services
      • Overview
      • Microsoft Platform Services
      • Data Protection Services
      • Unified Endpoint Management
      • Performance Monitoring Services
      • Database Management Services
    • Educational Services
    • Support Services
  • Support
    • Support Home
    • By Product
      • All Products
      • AppAssure
      • Archive Manager
      • Change Auditor
      • Desktop Authority
      • DR Series
      • Foglight
      • KACE
      • Migration Manager
      • NetVault
      • Rapid Recovery
      • SharePlex
      • Toad
      • vRanger
    • Contact Support
      • Overview
      • Customer Service
      • Licensing Assistance
      • Renewal Assistance
      • Technical Support
    • Download Software
    • Knowledge Base
    • My Account
      • My Products
      • My Service Requests
      • My Licenses
      • My Groups
      • My Profile
    • Policies & Procedures
    • Consulting Services
      • Microsoft Platform Management
      • Data Protection
      • Unified Endpoint Management
      • Performance Monitoring
      • Database Management
    • Technical Documentation
    • Educational Services
    • User Forums
    • Video Tutorials
  • Partners
    • Overview
    • Partner Circle Log In
    • Become a Partner
    • Find a Partner
    • Partner Community
  • Blogs
    • IT Industry Insights
    • Quest Solution Blogs
      • Data Protection
      • Database Management
      • ITNinja
      • Microsoft Platform Management
      • Performance Monitoring
      • Toad World Blog
      • Unified Endpoint Management
  • Forums
  • 製品情報
    • すべての製品情報を見る
    • Change Auditor
    • Foglight
    • KACE
    • Metalogix
    • Migration Manager
    • Migrator for Notes to SharePoint
    • NetVault Backup
    • On Demand Migration for Email
    • QoreStor
    • Rapid Recovery
    • Recovery Manager
    • SharePlex
    • Spotlight
    • Toad
  • ソリューション
    • すべてのプラットフォームを見る
    • クラウド管理
    • GDPRコンプライアンス
    • データ保護
      • 概要
      • クラウド管理
      • ディザスタリカバリ
      • バックアップとリカバリ
      • Office 365 データ保護
      • 仮想化管理
      • 重複除外と複製
    • データベース管理
      • 概要
      • DevOps
      • データの準備と分析
      • データベースのクラウド移行
      • データベースパフォーマンス監視
      • データベース管理
      • データベース複製ソフトウェアツール
    • 統合エンドポイント管理
      • 概要
      • エンドポイントコンプライアンス
      • エンドポイントセキュリティ
      • エンドポイントの可視化
    • Microsoftプラットフォーム管理
      • 概要
      • ハイブリッドActive Directoryのセキュリティとガバナンス
      • Microsoftプラットフォームの移行計画と統合
      • セキュリティとコンプライアンス
      • 情報アーカイブおよびストレージ管理ソリューション
      • Windowsのバックアップとリカバリ
      • Microsoft Serverのパフォーマンスと可用性
      • レポート作成機能
      • グループポリシーと権限
    • パフォーマンス監視
  • サービス
    • コンサルティングサービス
      • 概要
      • Microsoftプラットフォーム管理
      • データ保護
      • 統合エンドポイント管理
      • パフォーマンス監視
      • データベース管理
    • トレーニングと認定資格
    • サポートサービス
  • サポート
    • サポートホーム
    • 製品で検索
      • All Products
      • AppAssure
      • Archive Manager
      • Change Auditor
      • Desktop Authority
      • DR Series
      • Foglight
      • KACE
      • Migration Manager
      • NetVault
      • Rapid Recovery
      • SharePlex
      • Toad
      • vRanger
    • お問い合わせ
      • すべて
      • カスタマサービス
      • ライセンス アシスタンス
      • 更新のアシスタンス
      • 技術サポート
    • コミュニティフォーラム
    • ソフトウェアのダウンロード
    • ナレッジベ%E3%83%BCス
    • マイアカウント
      • マイ プロダクト
      • Myサービスリクエスト
      • マイ ライセンス
      • マイ グループ
      • マイ プロファイル
    • ポリシーおよび手順
    • コンサルティングサービス
      • Microsoftプラットフォーム管理
      • データ保護
      • 統合エンドポイント管理
      • パフォーマンス監視
      • データベース管理
    • リリースノートおよびガイド
    • 教育サービス
    • ビデオチュートリアル
  • トライアル
  • パートナー
    • 概要
    • Partner Circleへのログイン
    • パートナーになる
    • Find a Partner
    • パートナーコミュニティ
  • コミュニティ
Quest Community
Quest Community
  • Site
  • User
  • Site
  • Search
  • User
Foglight
Foglight
Foglight Administrators Foglight Reporting using Metric Queries or Groovy
  • Forum
  • Wikis
  • Sub-Groups
  • More
  • Cancel
  • New
  • -Foglight Administrators
    • A New Foglight Service Status Widget - Text with Colored Background
    • Adding APM views to an existing Foglight Java cartridge installation
    • Adventures in Agent Creation - Part 1
    • Adventures in Agent Creation - Part 2
    • Adventures in Agent Creation - Part 3
    • Anonymizing the Foglight End User Monitoring Solution
    • Another Foglight Service Status Widget - Colored Text
    • Building a custom dashboard to summarize LogFilter alarms
    • Building a geo drag and drop Foglight dashboard for a service
    • Building Complex Schedules with Foglight
    • Busting Frame Busters in Foglight Experience Viewer (FxV)
    • Community Cartridge: Notification Management Cartridge
    • Compatibility for Navigation Timing API
    • Configuring Internet Explorer 9 (IE9), to best work with Foglight
    • Converting Foglight 4 Script Agents to Foglight 5
    • Creating Load Testing Scripts from FxM and FxV Session Data
    • Custom Agents - Introduction to Script Agents
    • Custom Agents - Script Agent Data Modeling and Units
    • Custom Foglight Dashboards: adding alarm colors to spinners, jelly beans and other gauges
    • Custom Script Agent 1: Leverage an Existing Monitoring Script To Push Data into Foglight
    • Custom Script Agent 2: Build a WCF Dashboard to View the Custom Agent Data
    • Custom Script Agent 3: Add a Metric and Build a WCF Chart to Display it
    • Custom Script Agent 4: Add a Metric to a Table
    • Customizing Foglight – Expert Services Discount Available for a Limited Time!
    • Customizing the out-of-the-box Host Status view
    • Dashboard speed-up
    • Deploying Two FglAMs to the Same Windows Host and running each as a Windows Service
    • Different Thresholds for Different Tablespaces
    • Different Thresholds for Different Tablespaces - Part 2
    • Emailing reports with the proper name and format
    • FGL IDE (Export Customizations & more)
    • Flexible, Cost-effective Remote Administration Services
    • Foglight 5 - Topology Localization
    • Foglight Advanced Administration Training - Limited Space for February 2012
    • Foglight APM Basics (Videos)
    • Foglight APM Features (videos)
    • +Foglight Best Practices
    • Foglight Best Practices (videos)
    • Foglight Best Practices Monthly Webcast – Sign Up for Session 1!
    • Foglight Best Practices: Dashboards and Reports Webcast Registration Open Now!
    • Foglight dashboard as a SharePoint WebPart
    • Foglight Dev Camp & Hackathon 2017
    • Foglight End User Management: Using Network TAPs versus a Switch SPAN Port
    • Foglight End User Service Availability Reporting, Foglight Experience Monitor or Foglight Transaction Recorder which one to use?
    • Foglight Event Synchronization Solution for HP Operations Manager Services Pack Available Now!
    • Foglight Experience Viewer (FxV) URL Search Shortcuts
    • Foglight Host OS Monitoring (videos)
    • Foglight iGoogle Gadget
    • Foglight nologinuser dashboard in SharePoint
    • Foglight Public Virtual Training Courses
    • Foglight Quickstart Services Offering
    • Foglight Reporting using Metric Queries or Groovy
    • Foglight Training Classes -- Public and Private Options Available
    • Foglight Training Packages with Free Healthcheck Services - Limited Time Offer
    • Fraud Support with FxV
    • FxM and Apache Proxy Server (X-Forwarded-Host)
    • FxM: IP Multicasting and Sessionizing
    • FxV Storage Tier Expansion & Analysis Repository Considerations
    • Getting the most out of Foglight's .NET Monitoring - Part 1
    • Getting the most out of Foglight's .NET Monitoring - Part 2: Agent Configuration Specifics and Best Practices
    • Getting the most out of Foglight's .NET Monitoring - Part 3: Monitoring a .NET Executable Application
    • HDIDT - View an Exported Real User Session File
    • How are your Java components processing?
    • How to Handle NTLM within UEM
    • Improve Organizational Adoption of Your APM Solution
    • January Foglight Best Practices Thursday, January 5 - Register Now!
    • Java APM
    • June 2012 Best Practices Webcast Open for Registration!
    • Migrating your Foglight Management Server
    • Monitoring .NET Request Memory Usage with Foglight
    • Monitoring an independent Java process using Foglight
    • Monitoring application availability using Foglight Utility Agents
    • New Foglight Services Packs Available
    • New Sizing Guide for FxM and FxV
    • New UEM Sizing Guide
    • Predicting the Impact of Moving a Guest to Another Host
    • +Quest Application Performance Monitoring (APM) Implementation Methodology
    • Reading a XML File with a powershell script agent
    • Really Simple (Foglight) Syndication
    • Services Section of Quest.com Gets a Facelift
    • Setting the value of a Registry Variable from the Command Line
    • SNMP trap variables in Foglight Alarms
    • The End-User as an Instrument...
    • Thoughts from the road - Foglight Java agent Tag and Follow
    • Thoughts from the road – User session replay - YOU CAN ACTUALLY DO THAT???
    • Training Update - New Foglight Reporting Course Available
    • Understanding Foglight Metrics
    • Updates to Quest's Foglight Public Virtual Training Calendar
    • Use a Foglight to monitor itself
    • Use Foglight to Drive Business Performance
    • Use Foglight to monitor itself
    • User Experience Mgmt Overview
    • Using telnet or wget to check connectivity
    • Using the ConfigService API to setup agent properties (ASPs)
    • Utilizing MS Exchange distribution lists to help with user attribute maintenance
    • We've Redesigned SupportLink to Get You Answers Faster Than Ever - See for Yourself and Enter to Win an iPad!
    • [Case Scenario] - How to avoid duplicate rows when building a report with 5 min granular data
  • (iNdOrE) && (GwAlIoR) +91-9915786526 ##LoVe Marriage Specialist Pandit ji kota
  • Custom Script Agent - Counting Files in a Windows Folder - How-To
  • Foglight Admin 101
  • Foglight monitoring application components running on Docker Containers
  • Foglight User 101
  • Memory Utilization for all processes over X months
  • NetMonitor - Quick How-To Guide
  • Setting JBoss Server name and domain in Foglight
  • Setting Tomcat server name and domain in Foglight
  • testing a bug - Do not publish
  • WebMonitor - Quick How-To Guide
  • WebMonitor agent installation

Foglight Reporting using Metric Queries or Groovy

Metric Queries

Foglight has a built in metric query language for extracting data from Foglight models.
Metric queries can be run in the Script Editor in Administration/Tooling.
Metric queries can also be run from the command line using 'fglcmd'.

Here is some examples of metric queries:

#utilization from Memory where host.name = 'torpsv011.sitraka.com' for 5 hours#
#utilization from HostCPUs where host.name like '%.sitraka.com' for 5 hours 2 days ago#

The first example extracts all observations of 'utilization' from a table called 'Memory' from a specific host over the last five hours. The second example extracts average CPU utilization across all CPUs for a set of hosts that match the given filter ('%' is a wildcard). All matching observations over a five hour period from two days ago are selected.

The result of queries like this can be aggregated using functions like avg(), max(), sum() when run from the Script Editor in Adminstration/Tooling:

avg(#utilization from Memory where host.name = 'torpsv010.sitraka.com' spanning 1.5 hours ending at 14:30 on 2010-07-15#)

max(#utilization from HostCPUs where host.name = 'torpsv010.sitraka.com' spanning 1.5 hours starting at 14:30 1 day ago#)

This type of calculation is commonly used in Derived Metrics and Rules, as well as for reporting.

Metric Queries can be used to export data in either CSV or XML format from the Foglight Management Server (FMS) using the command line 'fglcmd'.

You can run 'fglcmd' from any host, not only the FMS and monitored hosts.

In $FMSHOME/tools/, you'll find fglcmd.zip. You can extract this file on any host, and run it from there.

You'll need to have the JAVA_HOME environment variable set when you run it, because the package does not includes a JRE.

Windows (CSV):

C:\Quest_Software\Foglight555\bin>fglcmd.bat -srv 10.4.118.101 -port 8080
-usr fgluser -pwd fgl1pwd
-cmd util:metricexport -output_format csv -f torCPUmetrics.csv
-metric_query
"CPU_Utilization from Windows_System_System_Table where agent.host.name like 'tor%' for 30 minutes"

generates:

Unix (XML):

$ /opt/foglight55/bin/fglcmd.sh -srv 10.4.118.110 -usr foglight -pwd foglight
-cmd util:metricexport -output_format xml -f torCPUmetrics.xml
-metric_query "utilization from HostCPUs where host.name like 'torpsv%' for 30 minutes"

generates:

In both examples, the query matches metrics from two different hosts and writes the selected metric from both hosts to the output CSV or XML file.

uniqueID is an FMS-specific reference to the object.
For example, using the uniqueId generated in the XML file, run this Groovy in the Script Editor:

uniqueId = '0efaf2b4-a910-4ff2-92ca-9483c77fe3d3'
def topSvc = server[TopologyService] topSvc.getObject(uniqueId).getContainer().getName() + +
topSvc.getObject(uniqueId).getName()

The result is (for example):
torpsv010.sitraka.com CPUs

The startTime and endTime refer to the time range for the observation.
The samplePeriod, in milliseconds, is the difference between the startTime and endTime.
'count' refers to the number of observations in the time range. Recently collected observations will show a count of '1'. As data ages in the FMS, data persistence policies will trigger aggregation of a number of observations and count will increase.
min, max, avg, and sum represent the range of values in the time period. For recently collected metrics, these values will all be the same. As the data ages, the observations will be aggregated, but these key indicators will persist.

sumSquares is used internally by the FMS for calculating the aggregations.
stdDev indicates the 'volatility' of the data.

For more information about Metric Queries and Topology Queries in Foglight, search for "Query language tutorial" or "Query language examples" in Foglight's Help. For more information about 'fglcmd', review the "Command-Line Reference Guide" in the Foglight Administration Guide or Foglight's Help.

This export capability is useful, but it has some limitations.

  1. You can only export one metric from one or more topology objects. So you can export the CPU Utilization for one host or for all Windows hosts but not CPU, Memory and and FileSystem metrics in one query.
  2. The exported CSV or XML file contains a uniqueId that's meaningful to the FMS that exported it, but the value is not human readable and requires additional processing to make it easy to understand.
  3. The exported CSV or XML file contains all the metric fields. There
    is no way to remove or re-order these columns.

For more flexible reporting that overcomes these limitations, we need to use Groovy.

Groovy

Metric queries are powerful, concise and relatively simple, but they don't offer the kind of flexibility often required for reporting.

If we want to extract metrics from Foglight into well-designed, easy-to-read CSV reports, then we need to leverage the power and flexibility of Groovy.

Groovy is a Java-based scripting language that you can download from http://groovy.codehaus.org.
Groovy is based on Java and includes all Java operations and libraries, but also a number of 'shortcuts' that make it more concise and easy to read. Although it's helpful to know basic Java syntax, Groovy users don't need to know Java.

To learn more about Groovy, see: Getting Started Guide

Reference Card (PDF) (registration necessary)
Groovy In Action Book: http://www.manning.com/koenig/

Foglight uses Groovy for many functions, including:

  • Rules
  • Derived Metrics
  • Actions
  • Functions
  • Persistence policies

Groovy can be run on the FMS via 'fglcmd' command line to generate reports. You can also use the Script Editor in Administration/Tooling to prototype and test the following reports.

I'd like to thank Stefan Marx for providing the foundation on which most of these reports are based.

Groovy Report Examples

The following examples represent a few of the more common types of reports that have been created for various clients.

With some practice and some trial and error in the Script Editor and the Data Browser, many of these resports can be adapted to other agent and metric types as well as other formats.

As noted, these scripts are unsupported. But if you have questions or comments, please post a comment on this page or post a new topic in the discussion forum.

Generate a list of all current alarms with details

Example output .csv in Excel:

Run the following script from the command line using:

fglcmd.sh -srv 10.4.118.110 -port 8080 -usr foguser -pwd fog1pwd -cmd script:run -f expAlarms.groovy >alarmExport.csv

expAlarms.groovy

// This script comes with no support, expressed or implied.
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

Generate a list of "CPU max, min, avg" for all hosts in the specified time range by hour

Example output:

This report was created with a command line and script like:

D:\Quest_Software\Foglight55\bin\fglcmd.bat -srv 10.4.118.110 -port 8080 -usr foguser -pwd fog1pwd -cmd script:run -f exportHourlyMetrics.groovy "2010.07.14 18:00:00" "2010.07.14 22:00:00" > TorHostCPU1.csv

exportHourlyMetrics.groovy

// This script comes with no support, expressed or implied.
import java.sql.Timestamp.*;
import java.text.SimpleDateFormat

////////////////////
// Change the following lines according to your needs
/////////////////////

// Host model example
metric_parent = "HostCPUs where host.name like 'tor%'"
parent_label = "host/name"
metric_names = ["utilization"]
column_titles = "Host,Start Time,Max CPU,Min CPU,Avg CPU\n"

// Timing Setup
format = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
//startTime = new Timestamp(System.currentTimeMillis()-(24*60*60*1000)) // 24 hours ago
//endTime = new Timestamp(System.currentTimeMillis())
//startTime = new Timestamp(format.parse("2010.03.30 18:00:00").getTime())
//endTime = new Timestamp(format.parse("2010.03.30 22:00:00").getTime())
startTime = new Timestamp(format.parse(args[1]).getTime());
endTime = new Timestamp(format.parse(args[2]).getTime());
step = 1000*60*60 // 1 hour

// Report generating code follows

def getMetricsFor(aInstance) {
def metrics = []
def windowStart = new Timestamp(startTime.getTime())
def windowStop = new Timestamp(startTime.getTime()+step)
while (windowStart < endTime) {
metrics.add(getMetricsFor(aInstance, windowStart, windowStop))
windowStart.setTime(windowStop.getTime())
windowStop.setTime(windowStop.getTime()+step)
}
return metrics
}

def getMetricsFor(aInstance, windowStart, windowStop) {
def ds = server["DataService"]
def metric = []
metric.add(aInstance.get(parent_label))
metric.add(format.format(windowStart))
metric_names.each{metric_name->
metric.add(ds.retrieveAggregate(aInstance, metric_name, windowStart, windowStop).getValue().getMax())
metric.add(ds.retrieveAggregate(aInstance, metric_name, windowStart, windowStop).getValue().getMin())
metric.add(ds.retrieveAggregate(aInstance, metric_name, windowStart, windowStop).getValue().getAvg())
}
return metric
}

////////////////////////
// get Data and Export
////////////////////////
def expMetrics = []
def instances = server.get("QueryService").queryTopologyObjects(metric_parent);
instances.each{ _instance ->
expMetrics.addAll(getMetricsFor(_instance))
}

// Build Result
StringBuffer buffer = new StringBuffer();
// Change the following line to label the metric parent and metric columns
buffer.append(column_titles);
expMetrics.each{m->
int i = 0;
m.each{k->
buffer.append((i>0?",":"")+k)
i++
}
buffer.append("\n")
}
return buffer

For each host, generate the avg CPU and Memory for each day including only business hours

Example output:

We add command line arguments to specify which days we want to export:

C:\Quest_Software\Foglight55\bin\fglcmd.bat -srv 10.4.118.110 -port 8080 -usr foguser -pwd fog1pwd -cmd script:run -f exportBusinessHours.groovy "2012.04.30" "2010.05.15" > TorHostBusinessHours1.csv

exportBusinessHours.groovy

// This script comes with no support, expressed or implied.

import java.sql.Timestamp

import java.text.SimpleDateFormat

//args = ["thisprogram", "2012.04.30", "2012.05.04"]

////////////////////

// Change the following lines according to your needs

/////////////////////

// Host model example

metric_parent = "Host where name like 'torpsv0%'"

parent_label = "name"

metric_names = ["cpus/utilization", "memory/utilization"]

column_titles = "Host,Start Time,End Time,Avg CPU,Avg Memory\n"

def output = new StringBuffer(column_titles)

// Timing Setup

format = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");

//startTime = new Timestamp(System.currentTimeMillis()-(24*60*60*1000)) // 24 hours ago

//endTime = new Timestamp(System.currentTimeMillis())

//startTime = new Timestamp(format.parse("2010.04.30 08:00:00").getTime())

//endTime = new Timestamp(format.parse("2010.05.04 22:00:00").getTime())

startTime = new Timestamp(format.parse(args[1] + " 09:00:00").getTime());

endTime = new Timestamp(format.parse(args[2] + " 17:00:00").getTime());

step = 1000*60*60*8 // 8 hour

// Report generating script follows

def getMetricsFor(aInstance) {

def metrics = []

def windowStart = new Timestamp(startTime.getTime())

def windowStop = new Timestamp(startTime.getTime()+step)

metrics.add(getMetricsFor(aInstance, windowStart, windowStop))

windowStart.setTime(windowStop.getTime())

windowStop.setTime(windowStop.getTime()+step)

return metrics

}

def getMetricsFor(aInstance, windowStart, windowStop) {

def ds = server["DataService"]

def metric = []

metric.add(aInstance.get(parent_label))

metric.add(format.format(windowStart))

metric.add(format.format(windowStop))

metric_names.each{metric_name->

parentIndex = metric_name.lastIndexOf("/")

if (parentIndex >= 0) {

metricParent = aInstance.get(metric_name.substring(0, parentIndex))

metric_name = metric_name.substring(parentIndex+1)

}

else {

metricParent = aInstance

}

if (metricParent != null)

metric.add(ds.retrieveAggregate(metricParent, metric_name, windowStart, windowStop)?.getValue()?.getAvg())

}

return metric

}

////////////////////////

// get Data and Export

////////////////////////

def expMetrics = []

def instances = server.QueryService.queryTopologyObjects(metric_parent);

def origStart = new Timestamp(startTime.getTime())

instances.each{ _instance ->

while (startTime < endTime) {

expMetrics.addAll(getMetricsFor(_instance))

startTime = startTime.plus(1) // add one day

}

startTime = new Timestamp(origStart.getTime())

}

expMetrics.each{m->

int i = 0;

m.each{k->

output.append((i>0?",":"")+k)

i++

}

output.append("\n")

}

return output

For every host, generate the current Total disk space available together with the space available for every monitored disk on that host

Example output:

exportHostSpaceAvailable.groovy

// This script comes with no support, expressed or implied.

import java.sql.Timestamp
import java.text.SimpleDateFormat

////////////////////
// Please change this to your needs
/////////////////////
// Topology Query
def metric_query = "Host where name like 'tor%'"
//def metric_query = "Host"
column_titles = "Host,Disk,Space Available (MB)"

def getMetricsFor(aHost) {
def metrics = []
results = getSpaceMetricsFor(aHost, metrics)
return metrics
}

def getSpaceMetricsFor(aHost, metrics) {
def ds = server["DataService"]
def metric = []
storage = aHost.get("storage")
if (storage == null) return
hostname = aHost.get("name")
metric.add(hostname)
metric.add("Total")

metric.add(ds.retrieveLatestValue(storage, "spaceAvailable").getValue().getMin())
metrics.add(metric)
disks = storage.get("logicalDisks")
if (disks != null) {
disks.each{ _disk->
spaceAvailable = ds.retrieveLatestValue(_disk, "spaceAvailable")
if (spaceAvailable != null) {
metric = []
metric.add(hostname)
metric.add(_disk.get("name"))
metric.add(spaceAvailable.getValue().getMin());
metrics.add(metric)
}
}
}
}

////////////////////////
// get Data and Export
////////////////////////
def expMetrics = []
def hosts = server.get("QueryService").queryTopologyObjects(metric_query);
hosts.each{ _host->
expMetrics.addAll(getMetricsFor(_host))

}

// Build Result
StringBuffer buffer = new StringBuffer();
buffer.append(column_titles+"\n");
expMetrics.each{m->
int i = 0;
m.each{k->
buffer.append((i>0?",":"")+k)
i++ }
buffer.append("\n")
}
return buffer

Foglight Administration: List of Foglight Users and their Groups

Example output:

User: foglight

Last login: 1 days ago

Groups:

[DG] Foglight Users

[DG] Cartridge Developers

[DG] Foglight Security Administrators

[DG] DbOnly

[DG] Foglight Administrators

User: jcurrier

Last login: 15 days ago

Groups:

[DG] Foglight Operators

[DG] Foglight Users

[DG] Cartridge Developers

[DG] Foglight Administrators

User: DbUser

Last login: 296 days ago

Groups:

[DG] Foglight Users

[DG] DbOnly

User: shealy

Last login: never

Groups:

[DG] Foglight Operators

[DG] Cartridge Developers

[DG] Foglight Administrators


This output was generated by:

getUsersAndGroups.groovy

// This script comes with no support, expressed or implied.
// A script to list all Foglight users and their groups

def secSvc = server["SecurityService"]
def allUsers = secSvc.findAllUsers()
def result = new StringBuilder()

def output(result, secUser, directGroups, parentGroups) {
// print the output
def lineSep = "\n"
def fillerD = "[DG] "
def fillerP = "[PG] "
def today = new Date()

result.append(lineSep + "User: ${secUser.name}" + lineSep)

lastLogon = secUser.getLastLogonTS()
logonTime = (lastLogon.getTime() < 40000000000) ? "never" : '' + (today - lastLogon) + " days ago"
result.append("Last login: " + logonTime + lineSep)

result.append("Groups: " + lineSep)
directGroups.each { g ->
if (g != null) result.append(fillerD + g.name + "\n")
}
parentGroups.each { g ->
if (g != null) result.append(fillerP + g.name + "\n")
}
}

allUsers.each { u ->
def secUser = secSvc.findUserById(u.id)

// find those groups that are directly assigned to the user
def directGroups = secUser.getSecGroups()

// find the parent groups of those directly assigned groups
def maxGroupNestingLevels = 15
def parentGroupIds = []
if (directGroups.size() > 0) {
parentGroupIds = secSvc.getAllParentGroupIds(directGroups, maxGroupNestingLevels)
}
def parentGroups = parentGroupIds.collect { secSvc.findGroupById(it) }
output(result, secUser, directGroups, parentGroups)
}

return result.toString()

Foglight Administration: List all Foglight Agent Managers and associated Agent by Host

Example output:

The output is a .csv report with one line per FglAM (Foglight Agent Manager). The columns are Hostname, Arch, OS, version, Agents.

The Agents cell has a list of all agents on that FglAM with an indication of whether the agent is active or not (":A" or ":I").

The script can be run like:

C:\Quest_Software\Foglight\bin\fglcmd.bat -srv fmshost.acme.com -port 8080 -usr foglight -pwd f&gL!ght2 -cmd script:run -f agentReport.groovy > agent_report.csv

agentReport.groovy

// This script comes with no support, expressed or implied.

agentService = server.get("AgentService");

managerService = server.get("RemoteAgentManagementService");

agents = agentService.findAll();

clients = managerService.findAllRemoteClients();

clients.sort({it.getHostName()});

output = 'Hostname, Arch, OS, version, Agents\n'

clients.each() {client ->

// basic information about each fglam: hostname, hardware arch, OS name, OS version

output += client.getHostName() + ',' + client.getArchitecture() + ',' + client.getOSName() + ',' + client.getOSVersion() +','

// get all agents associated with this fglam, sort by the agent type

clientagents = agents.findAll{it.getRemoteClientId() == client.getId() }

clientagents.sort{it.getTypeId()}

// for each agent, write the name and whether it is active or not (:A or :I)

clientagents.each{agent->

output += agent.getTypeId() + (agent.getIsActive()?':A':':I') + ' '

}

output += '\n'

}

return output

If you have a useful scripted report or use the examples on this page to create a new interesting report, please post a comment below.

Happy reporting!

  • scripting
  • foglight tips & tricks
  • Foglight Administration administration
  • groovy
  • Reports
  • Command-line
  • query
  • Share
  • History
  • More
  • Cancel
Related
Recommended
  • Company
    • About Us
    • Buy
    • Contact Us
    • Careers
    • News
  • Resources
    • Industry Insights Blog
    • Communities
    • Customer Stories
    • Documents
    • Events
  • Support
    • Professional Services
    • Renew Support
    • Technical Support
    • Training & Certification
    • Support Services
  • Social Networks
    • Facebook
    • LinkedIn
    • Twitter
    • YouTube
  • © 2023 Quest Software Inc. ALL RIGHTS RESERVED.
  • Legal
  • Terms of Use
  • Privacy
  • Community Feedback & Support
  • Cookie Preference Center
  • 会社名
    • 会社情報
    • 購入
    • お問い合わせ
    • 採用情報
    • ニュース
  • リソース
    • ブログ
    • お客様の事例
    • ドキュメント
    • イベント
    • ビデオ
  • サポート
    • プロフェッショナルサービス
    • サポートの更新
    • テクニカルサポート
    • トレーニングと認定資格
    • サポートサービス
  • ソーシャルネットワーク
    • Facebook
    • Instagram
    • LinkedIn
    • Twitter
    • YouTube
  • © 2023 Quest Software Inc. ALL RIGHTS RESERVED.
  • 「法務」
  • ご利用規約
  • 個人情報保護方針
  • コミュニティのフィードバックとサポート