Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

How to create a report to show the last time a client computer was restarted

Created: 25 Mar 2013 | 8 comments

I'm running Altiris 7.1 with patch management in my enterprise environment. We've been having issues with the MS 497 day bug, so I would like to create a report that will list my managed servers by the last time they restarted.

I did find the built in report for system uptime, although it doesn't return any results, it also seems to give time as a percentage, and I would really like to see, ideally a date for the last restart, but failing that, the number of days since the last restart.

Thanks,
Erica

Operating Systems:

Comments 8 CommentsJump to latest comment

Ludovic Ferre's picture

Hello Erica,

I'm not sure how the system uptime data is collected, but worse case scenario you can get it from WMI or using POwerSDhell:

 http://gallery.technet.microsoft.com/scriptcenter/Get-Server-Uptime-Using-WMI-15aaa8ac

I am currently off-net, on a retreat of some kind. I'll be back real soon, and you sure will hear from me then ;-).

Ludovic FERRÉ
Principal Remote Product Specialist
Symantec

karthik-tnj's picture

Hi

When i try to run system uptime report (% uptime over a period of time), it's showing "no results found".

Got any idea of what's going wrong in this?

Thanks in advance.

andrew.novak's picture

If i remember correctly the system uptime % report is based off a monitor. If you dont use the uptime monitor you wont get any results in that report.

Erica_Palmer's picture

Does this mean that Uptime.exe needs to be installed on each client or just on the notification server?

rldupriest's picture

As long as your getting inventory you can use the "last boot up time" from the operating system inventory table to see when the last time it rebooted.  Getting the down swing of the reboot even is a little more difficult as in my experence the reboot event table mainly catches reboots from patch managment. 

andrew.novak's picture

In my experience the "last boot up time" in OS inventory table wasn't very reliable as you had to initiate an inventory collection in order to get that populated into the database.  Being a managed services company with very, very tight patch windows and complex application, we found it clunky to patch, and constantly run inventory after inventory to actually know when the computer rebooted.

 

This is my setup using an uptime monitor, (which isn't by any means a great solution...but gets the job done...):

1.Monitor Policy

  • Monitor Policy-agent based Name:  Uptime
  • Type:  Metric Collect

2.Rule

  • Rule Name:  System Uptime (seconds)
  • Rule Metric:  System - System Uptime (seconds) 

3. Metric

  • Metric Name:  System - System Uptime (seconds)
  • Type:  Perfmon Counter
  • Poll:  600 seconds
  • Performance Counter Builder:
  • Performance object:  \system
  • Counter:  System Uptime
     

After this is applied, in the uptime % report if you set the report to today's date only, it will show 100% uptime for all computers in your filter (if htey have not been rebooted that day).  When the computer reboots that will drop down to 87-90% uptime for the day. If the computers still show 100% during the patch window, it has not yet rebooted.

If anyone has a better solution i'm all for it.  I would love to see a realtime uptime report showing the last reboot time, not %.  I've been looking at a custom script to populate a custom dataclass with the wmi last reboot data that executes as a Managed Software Delivery on computer startup whether a user is logged in or not...

Thoughts?

HighTower's picture

We use a custom inventory:

'********************************************************************************
' NS7 Custinv to return OS install date from the win32_operatingsystem wmi class
'********************************************************************************

'Create instance of Wbem service object, connect to namespace and run wmi query
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Create instance of DateTime object
Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")

'===================================================================================================================

'Create instance of Altiris NSE component
dim nse
set nse = WScript.CreateObject ("Altiris.AeXNSEvent")

' Set the header data of the NSE
' Please don't modify this GUID
nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
nse.Priority = 1

'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server
dim objDCInstance
set objDCInstance = nse.AddDataClass ("{22c12ff5-4166-4c33-9ab7-f630cb949878}")

dim objDataClass
set objDataClass = nse.AddDataBlock (objDCInstance)
cnt=0
  
Set objWMIObj = objWMIService.ExecQuery("SELECT * FROM win32_operatingsystem")
For each objInfo in objWMIObj

                                              
 'Add a new row
 dim objDataRow
 set objDataRow = objDataClass.AddRow

 'Set columns
         LastBootUpTime = FormatFileDate(objInfo.LastBootUpTime)
 Wscript.echo LastBootUpTime
 objDataRow.SetField 0, LastBootUpTime

' objDataRow.SetField 5, FormatFileDate(objInfo.LastBootUpTime)

' WScript.echo "Parsed LastBootUpTime: "  & objInfo.LastBootUpTime  & " ---> " & ParseWMIDate(objInfo.LastBootUpTime)
' WScript.echo "Object LastBootUpTime: "  & objInfo.LastBootUpTime  & " ---> " & FormatFileDate(objInfo.LastBootUpTime)
Next

' Send the NSE data to the NS server
nse.SendQueued

' Method 1: Manually parse out date & time in correct order & build CDate object
Function ParseWMIDate(dtmLastBootUpTime)
    ParseWMIDate = _
        CStr(Mid(dtmLastBootUpTime, 5, 2) &_
        "/" &_
        Mid(dtmLastBootUpTime, 7, 2) &_
        "/" &_
        Left(dtmLastBootUpTime, 4) &_
        " " &_
        Mid (dtmLastBootUpTime, 9, 2) &_
        ":" &_
        Mid(dtmLastBootUpTime, 11, 2) &_
        ":" &_
        Mid(dtmLastBootUpTime, 13, 2))
End Function

' Method 2: Use wbem objects to get wbem-formatted date
Function FormatFileDate (strDate)
 objSWbemDateTime.Value = strDate
 FormatFileDate = CStr(objSWbemDateTime.GetVarDate(False))
End Function

I didn't write this from scratch.  I think that there was another forum posting on Connect that I lifted this from.

I have the custom inventory running daily and at system startup.

bbiggs's picture

This query isn't limited to servers but will give you the last boot time for all clients:

 

select c.Guid as _ItemGuid, c.Name, os.[Last Boot Up Time] from vcomputer c
left join Inv_OS_Operating_System os on c.Guid = os._ResourceGuid
order by os.[Last Boot Up Time]