Monitoring Weather Conditions – Using SCOM
16-03-2013: This MP has been updated. the download link in this article has been updated. Details of the update can be found here.
Back in July this year, one day I was playing with PowerShell and discovered using New-WebProxyService to get various information from http://www.webservicex.net. I then had an idea to write a SCOM management pack to monitor weather conditions for cities around the world using the weather data from www.webservicex.net. And after I started writing it, I realised this idea wasn’t new. Pete Zerger has already blogged about it 2 years ago :
OpsMgr: Probing a Web Service with with PowerShell 2.0 in a Two-State Monitor
Anyways, I still went ahead and continued working on this management pack during my spare time. Initially, I’ve developed 2 methods in the MP, one using www.webservicex.net and another one using the famous Google weather API. I then got side-tracked and stopped the development for couple of months. Couple of weeks ago, I’ve started working on it again. But this time, I just realised Google actually shut down the weather api:
So I’ve completely removed Google Weather API functions from the MP and concentrated on the other method: using www.webservicex.net
Now, I finally completed the first release of the management pack. And I’m going to go through details of this MP now.
The “TYANG Weather Monitoring” management pack provides ability to monitor weather conditions and collect real time weather information for configured cities and locations. It utilise Windows PowerShell v2.0 to retrieve weather information from http://www.webservicex.net
This management pack provides:
- Various 3-state threshold monitors for weather readings such as temperature Celsius, temperature Fahrenheit, wind speed km/h, wind speed mile/h, etc.
- Performance collection rules to collect temperature, wind speed, relative humidity %, air pressure, dew point as performance data for each configured location
- Collect weather summary report as event data
- Alert generating rule to generate information alert when your favourite weather condition has detected for configured locations.
- Weather summary reports
- Ability to configure the weather probing node to use Metric or Imperial measuring units (or both) so only desired counters are collected for particular locations.
- SCOM agent is installed on all computers acting as weather probe computers.
- PowerShell version 2.0 (or 3.0) on all weather probe computers.
- Appropriate PowerShell execution policy to allow script executions.
- Internet Connection that allows connection to http://www.webservicex.net
I’ve designed the object model this way so in the future I can add other web services providers to the MP (i.e. I know that Weather Bug provides an awesome weather API.)
What Does This MP Offer?
Performance Collection Rules:
Various performance collections to collect the following weather information:
- Dew.Point (Fahrenheit)
- Dew.Point (Celsius)
- Temperature (Fahrenheit)
- Temperature (Celsius)
- Wind Speed (Mph)
- Wind Speed (KMph)
- % Relative Humidity
- Pressure (hPa)
- Pressure (In. Hg)
The data collected by these rules are viewable via various built-in performance views in the MP and also via the performance reports from the SCOM Generic report library.
Melbourne’s temperature for the last 24 hours:
New York City’s Wind Speed (in m/h) over the last 24 hours:
% Relative Humidity for Sydney over last 24 hours:
Event Collection Rule:
One event collection rule to collect weather summary for each location as event data.
The data is viewable via the built-in “Weahter Summary (Last 7 Days)” event view or via reports:
Alert Generating Rule:
One alert generating rule was created to run once a day and it detects a desired weather condition (based on sky conditions, wind speed and temperature range). It generates an information alert when desired weather condition is detected:
- TYANG Weather WebServiceX Probe Good Weather Condition Detection Rule
i.e. The “Good Weather” alert generated for Brisbane, Australia:
The purpose of this rule is to demonstrate how to alert on certain weather conditions. It is configured to run daily at 7:00 am(RMS local time) for all probe locations. Even though it utilise Cook Down feature and the data source module only run once for all locations in one country, you may choose to disable it and only enable it for a subset of probe locations. You may also use this rule as an example to build your own workflow. The data source for this rule is made public so you can reference it from other MPs.
Imagine setting up an email alert subscription for this alert for the city you live to email your boss telling him you are sick and won’t come in when a good weather is detected in the morning?
This MP also comes with various 3-state threshold monitors to generate alert when:
- Temperature is too low (too cold)
- Temperature is too high (too hot)
- Wind speed is too high (too windy)
Critical Low Temperature (Fahrenheit) alert for New York City, USA:
Warning High Temperature (Celsius) alert for Guangzhou, China:
I’ve also written 2 reports in this management pack:
- latest Weather Summary By Location
- the latest weather summary collected for a selected location
- Weather Summary By Location
- All the weather summary events for a selected location during a selected time frame
Several views are configured in the management pack:
State View for all Probe Locations:
An agent task called “Check Current Weather” is configured for WebServiceX Weather Probe Location class. You may run this manually to get the latest weather summary for a particular probe location:
I spent a lot of time to optimise workflows in this MP by fully utilise cook down. All the rules and monitors in this MP run on a schedule. They all use the same data source module. Except the alert generating rule, the PowerShell script inside the data source module only run once for each country in each probe node and feeds the data to all the performance collection rules, the event collection rule and all the monitors. When the data source runs, it creates a log entry in the Operations Manager log with Event ID 10000.
i.e. In my test environment, I have a computer configured as a probe node for 2 countries: Australia and China. Each country contains multiple cities.
The data source runs twice every 30 minutes (one for each country):
Therefore, if you wish to change the schedule (i.e. configure SyncTime or increase/decrease how frequent a workflow runs), I recommend you to change the schedule for ALL the rules and monitors to fully utilise cook down.
This shared data source module is called “TYANG Weather WebServiceX Probe Details by City and Country Data Source”, it has been made public and you can use this in other MPs.
Note: Even though the “WeatherStation” input parameter for this data source is different for each probe location, this data source contains another data source member module which retrieves weather information for ALL configured weather locations of this country. The “WeatherStation” input parameter is used in a condition detection member module inside the data source to filter the data for this specific probe location.
- Incorrect Event Descriptions are displayed in the Weather Summary (last 7 Days) Event View:
- Apparently this is a known issue (in both SCOM 2007 and 2012 Operations Console). The data is stored correct in the data base. It’s just they are displayed incorrectly in the console.
- This management pack MAY not work when the probe node computers require to use Proxy server to get to the Internet as the PowerShell Cmdlet New-WebServiceProxy does not support using Proxy servers. In the future, when I get more time, I might look at other ways to overcome this issue, but at this stage, I can’t really afford to spend more time on this.
www.WebserviceX.net only provides current weather information for cities outside of USA. It does not provide forecast information for places outside of USA. This is why I’m very disappointed that Google no longer provides the free weather API as it provided 5-day forecast and there are a lot more weather stations in the Google weather API than webservicex.net. I might choose another weather API in the future to further enhance this MP.
You can download both sealed and unsealed MP from below link along with a PDF documentation and few sample .reg files to help you configure the probe nodes and locations.
Leave a comment