OpsMgr: Displaying an ASCII Bar Chart on a Text Display Widget

This post features another example of how the PowerShell Text Display Widget Template (Download Here) can used to create a custom widget in the OpsMgr 2012 Operations Console, to display the list of the top 5 alerts with the longest downtime (outage) and closed within the last X hours, in a management group.

Apart from listing the top 5 alerts in text, an ASCII bar chart was also added to provide a visual comparison between the outage duration of the alerts, on a text display widget, as shown in the picture below: For more information on how to use a PowerShell script to generate a bar chart made up of ASCII characters, please check out the article that I contributed to the Hey, Scripting Guy! Blog, entitled Weekend Scripter: PowerShell ASCII Bar Charts

Note that for this instance, the outage duration is the time for an alert raised to be resolved, i.e. Alert Resolved Date – Alert Create Date.

To create an instance of the example above using a custom PowerShell text display widget, first create a dashboard layout with 1 cell, then Click to add widget on a cell, and select the Sample PowerShell Text Display Widgettemplate located under the "All Templates/WeiOutThere Text Display" folder , go through the UI pages of the template and enter the required information.

Here is the full PowerShell script used in the PowerShell Script page of the widget:

#///Main Part of the Script to retrieve the top 5 alerts with the longest outage within X hours ///

On the “Refresh Interval” page, enter a numerical value for the refresh interval of the widget (in seconds), then click the Finish button to create the custom PowerShell Text Display widget.

Additional Notes:

Because the text display widget displays ASCII characters in a different font compared to a regular PowerShell or ISE session, the ASCII bar chart may look distorted due to the way the widget handles the spacing between different characters. Hence, to save time in calibrating the spacing and size of characters for the text display widget, assign the numerical values from Bar1 to Bar 5 in descending order (after sorting), so that the ASCII bar chart would look like the left most example shown in the following picture:

Disclaimer: All information on this blog is provided on an as-is basis with no warranties and for informational purposes only. Use at your own risk. The opinions and views expressed in this blog are those of the author and do not necessarily state or reflect those of my employer.