Notification

Icon
Error

Workstation: Last reported boot time - This is the BOOT time, not the uptime

Posted: Friday, August 18, 2017 1:19:25 AM(UTC)
jperry

jperry

Member Original PosterPosts: 15
0
Like
The uptime is great if your workstations are reliably checking in.
Code:
Convert(Decimal(7,2),tblAssets.Uptime / 60 / 60 / 24) As [Days up]


The issue is when you want to know WHEN was the last reported reboot.
Laptops may not have reported in for a couple weeks, yet still show an uptime of less than one day.

You can calculate the last boot time with the tblAssets.Uptime and blAssets.Lastseen
Code:
tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24)   As [Boot Time]


I tend to be fairly verbose in my reports.
Code:
Select Top 1000000 tblAssets.AssetID,
  tblAssets.AssetName,
  tsysAssetTypes.AssetTypeIcon10 As icon,
  Convert(Decimal(7,2),tblAssets.Uptime / 60 / 60 / 24) As [Days up],
  tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24)   As [Boot Time],
  tblAssetCustom.Location,
  tblAssets.Lastseen,
  Left(tblADComputers.OU, CharIndex(',', tblADComputers.OU) - 1) As OU,
  '<img src="thumbnail.aspx?user=' + tblADusers.Username + '&domain=' +
  tblADusers.Userdomain + '&size=12" class="rimage"/>' As Picture,
  tblADusers.Displayname,
  tblADusers.Username,
  tblADusers.Userdomain,
  tblAssetCustom.Model,
  tblOperatingsystem.Version As [OS Version],
  tblOperatingsystem.Caption As [OS Name],
  tsysIPLocations.IPLocation,
  tblAssets.Description As [LS Description],
  tblADComputers.Description As [AD Description]
From tblAssets
  Left Outer Join tblComputersystem On tblAssets.AssetID =
    tblComputersystem.AssetID
  Left Outer Join tblADusers On tblAssets.Username = tblADusers.Username
  Left Outer Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
  Left Outer Join tsysAssetTypes On tsysAssetTypes.AssetType =
    tblAssets.Assettype
  Left Outer Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
  Left Outer Join tblOperatingsystem On tblAssets.AssetID =
    tblOperatingsystem.AssetID
  Left Outer Join tsysIPLocations On tsysIPLocations.LocationID =
    tblAssets.LocationID
Where tblComputersystem.Domainrole < 2 And tblAssetCustom.State = 1 And
  tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) < Getdate() - 14
Order By tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) Asc, tblAssets.Uptime Desc,
  tblAssets.AssetName
William382
#1William382 Member Posts: 16  
posted: 1/15/2019 10:54:19 PM(UTC)
Originally Posted by: jperry Go to Quoted Post
The uptime is great if your workstations are reliably checking in.
Code:
Convert(Decimal(7,2),tblAssets.Uptime / 60 / 60 / 24) As [Days up]


The issue is when you want to know WHEN was the last reported reboot.
Laptops may not have reported in for a couple weeks, yet still show an uptime of less than one day.

You can calculate the last boot time with the tblAssets.Uptime and blAssets.Lastseen
Code:
tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24)   As [Boot Time]


I tend to be fairly verbose in my reports.
Code:
Select Top 1000000 tblAssets.AssetID,
  tblAssets.AssetName,
  tsysAssetTypes.AssetTypeIcon10 As icon,
  Convert(Decimal(7,2),tblAssets.Uptime / 60 / 60 / 24) As [Days up],
  tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24)   As [Boot Time],
  tblAssetCustom.Location,
  tblAssets.Lastseen,
  Left(tblADComputers.OU, CharIndex(',', tblADComputers.OU) - 1) As OU,
  '<img src="thumbnail.aspx?user=' + tblADusers.Username + '&domain=' +
  tblADusers.Userdomain + '&size=12" class="rimage"/>' As Picture,
  tblADusers.Displayname,
  tblADusers.Username,
  tblADusers.Userdomain,
  tblAssetCustom.Model,
  tblOperatingsystem.Version As [OS Version],
  tblOperatingsystem.Caption As [OS Name],
  tsysIPLocations.IPLocation,
  tblAssets.Description As [LS Description],
  tblADComputers.Description As [AD Description]
From tblAssets
  Left Outer Join tblComputersystem On tblAssets.AssetID =
    tblComputersystem.AssetID
  Left Outer Join tblADusers On tblAssets.Username = tblADusers.Username
  Left Outer Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
  Left Outer Join tsysAssetTypes On tsysAssetTypes.AssetType =
    tblAssets.Assettype
  Left Outer Join tblADComputers On tblAssets.AssetID = tblADComputers.AssetID
  Left Outer Join tblOperatingsystem On tblAssets.AssetID =
    tblOperatingsystem.AssetID
  Left Outer Join tsysIPLocations On tsysIPLocations.LocationID =
    tblAssets.LocationID
Where tblComputersystem.Domainrole < 2 And tblAssetCustom.State = 1 And
  tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) < Getdate() - 14
Order By tblAssets.Lastseen - Convert(Decimal,tblAssets.Uptime / 60 / 60 / 24) Asc, tblAssets.Uptime Desc,
  tblAssets.AssetName


This now generates an error: There was an error parsing the query. [ Token line number = 1,Token line offset = 315,Token in error = Left ]
jsfCyber
#2jsfCyber Member Posts: 1  
posted: 5/17/2019 7:44:52 AM(UTC)
Hi
This is just what I'm looking for, finding uptime since either restart or power on.
But i get the same error as William382.
Any solution or maybe other report i can use?
Victor Heijmerikx
#3Victor Heijmerikx Member Posts: 3  
posted: 9/10/2019 8:21:37 AM(UTC)
I changed the code in line 10 from class="rimage"/> to class="rimage"/img> and get a working report.

Active Discussions

Action Change Windows domain PC Name
by  max204   Go to last post Go to first unread
Last post: 9/19/2019 10:28:29 AM(UTC)
Lansweeper Launch PowerShell remote PSSession
by  Ian  
Go to last post Go to first unread
Last post: 9/9/2019 12:10:56 PM(UTC)
Action Remote print management
by  CyberCitizen   Go to last post Go to first unread
Last post: 9/4/2019 3:53:00 AM(UTC)
Lansweeper Infopath installer help
by  CyberCitizen  
Go to last post Go to first unread
Last post: 9/2/2019 8:18:06 AM(UTC)
Lansweeper Remote Registry 2019
by  EB   Go to last post Go to first unread
Last post: 8/22/2019 3:47:10 PM(UTC)
Lansweeper lspush smtp direct send
by  Danilo Ferrari  
Go to last post Go to first unread
Last post: 8/1/2019 1:39:26 PM(UTC)
Action Delete old user profiles
by  DaveDischord   Go to last post Go to first unread
Last post: 7/30/2019 6:18:28 PM(UTC)
Lansweeper Best way to delete multiple registries
by  Corcos  
Go to last post Go to first unread
Last post: 7/25/2019 8:18:23 PM(UTC)