Reporting on Percent of Monthly Server Uptime with SCCM

Introduction

One of the things I like the most about SCCM is that it is very flexible and extensible.  I am constantly amazed at all the things it can be used for in an environment.

Recently, I was asked by a client to create an SCCM web report that would display the Percent of uptime for a group of servers within the last month.  Currently, this is partially a manual process for this customer, so they were really eager to get this automated and working.

I delivered a multi-part solution to them that will satisfy this need.  It was kind of fun to create, so I figured I would share how it works with you.

Part 1 – Calculating uptime on a given server

I decided to use a PowerShell script to gather the data from each server locally.  I’ve included the script below in the post, but I’ll step through the process here also.

Note: This will not work if your servers keep less than one months events in the System Event Log

1) Determine the Month and Year that was just completed (the one before now).

2) Capture the following events from the System Event Log that meet any of following criteria (within the previous month):

  • List current server uptime (the server’s uptime is xxxxxx seconds)
  • Indicate that the server is being shut down, and whether it was planned or unplanned
  • Indicate the server started back up again

I used the event information I collected to build out a hash table in PowerShell that lists the Startup Time, Shutdown Time, and Shutdown Type of each session.

Once built, the data looked something like the following:

Startup TimeShutdown TimeShutdown Type
4/1/2016 12:00:00 AM4/2/2016 12:30:00 AMNone
4/2/2016 12:30:00 AM4/13/2016 11:31:00 PMPlanned
4/13/2016 11:33:00 PM4/25/2016 1:30:00 PMUnPlanned
4/25/2016 1:33:00 PM4/29/2016 11:31:00 PMPlanned
4/29/2016 1:33:00 PM5/1/2016 12:00:00 AMNone

The two rows with Shutdown Type of “None” were added to fill the gaps in time, since the server was up when the month started and ended.

Next, I went through the hash table and added the number of seconds between the “Startup Time” and “Shutdown” time on each line.  This became the total “Uptime” for the server.

To get downtime, I looked at any shutdown with a type of “Planned” or “UnPlanned”.  I took the time of shutdown and determined the number of seconds until the server next came back up.  I used these to build the total “Planned Downtime” and “UnPlanned Downtime”.

My customer wanted the data to reflect a percent of the month, so I calculated the number of seconds between 4/1/2016 12:00:00 AM and 5/1/2016 12:00:00 AM.  Then I divided the number of seconds for “Uptime”, “Planned Downtime” and “Unplanned Downtime” to get the percentage for each.

To store the data, I had the script create a registry key under HKLM\Software\ModelTechnology\Uptime named with the month and year like so “2016-04”.  Into that key, I inserted values for the monthly Uptime, Planned Downtime, and UnPlanned Downtime in seconds and percentage.  I also added the date the script was run in case we needed to verify that.

The script can be deployed as a package to all servers (it will not return any results on a workstation). It should be set to run the 1st of each month, to ensure that there is enough history in the System Event Log.

Part 2 – Importing the Data into SCCM

Once the servers were generating the data and storing it locally, the next step was to get it into SCCM where it could be used.  In order to do this, I added two new classes to SCCM Hardware Inventory.  I modeled them off of the “Add Remove Programs” classes that were already there, since I wanted to capture any sub keys under the “Uptime” registry key that were added in the future.  This would allow the history of the server’s uptime to be viewed if desired.

In order to extend Hardware Inventory, I created two MOF files.  The first one was added to the end of the Configuration.mof file in  “Program Files/Microsoft Configuration Manager/inboxes/clifiles.src/hwinv” folder.  This caused SCCM to create the database tables and views that were needed to store the client information.

The second MOF file was imported from inside the SCCM console.  To do this, you open up the “Default Client Settings”, and under “Hardware Inventory” choose “Select Classes”.

Click the “Import” button and select your 2nd MOF file which will instruct the client on how to provide the data to SCCM.

Once the MOF was imported, I enabled the new class in Client Settings.

Uptime-HWInvClasses

 

Next, I forced a hardware inventory on one of my clients and was able to see the data in Resource Explorer.

Uptime-HWInv

Part 3 – Viewing the Data via SCCM Web Report

I created a custom Web report via Report Manager 3.0 to show the data that was captured for a given month on all servers.  Once it was done, I imported it into the SCCM Reporting site and VOILA!.  Now uptime for a server can be viewed by month going forward.

Here is a screenshot of the web report:

UptimeReport

So there you have it!  Now you can track monthly server uptime via SCCM.

As promised, here is the PowerShell script:

By |2016-05-23T13:47:33+00:00May 23rd, 2016|PowerShell, SCCM, Uncategorized|Comments Off on Reporting on Percent of Monthly Server Uptime with SCCM

About the Author:

steve bowman

Model Technology

Let us help you get your end point and data center strategy on cruise control!  Ask about our Calibration Assessment.

CONTACT US

  • 12125 Woodcrest Executive Drive, Ste. 204 Creve Coeur, MO 63141
  • (314) 254-4138
  • sales@model-technology.com

RECENT TWEETS