Add PC uptime tracking feature
- Database: Add lastboottime column to machines table - API: Accept lastBootUpTime parameter and store in lastboottime column - PowerShell: Collect LastBootUpTime from Win32_OperatingSystem - Update-PC-Minimal.ps1: Add last boot time collection - Update-ShopfloorPCs-Remote.ps1: Add last boot time collection and API posting - Display: Add Uptime column to displaypcs.asp with color-coded badges - > 90 days: red badge - > 30 days: yellow badge - > 7 days: blue badge - <= 7 days: muted text - Filter: Add "Uptime > X days" filter dropdown (7, 30, 90 days) - SQL: Production migration script for lastboottime column 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -39,11 +39,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
Dim currentPCStatus, recentFilter, deviceTypeFilter, pcTypeFilter, sel
|
||||
Dim currentPCStatus, recentFilter, deviceTypeFilter, pcTypeFilter, uptimeFilter, sel
|
||||
currentPCStatus = Request.QueryString("pcstatus")
|
||||
recentFilter = Request.QueryString("recent")
|
||||
deviceTypeFilter = Request.QueryString("devicetype")
|
||||
pcTypeFilter = Request.QueryString("pctype")
|
||||
uptimeFilter = Request.QueryString("uptime")
|
||||
|
||||
' Check for specialized PCs (CMM, Wax Trace, Measuring Tool) without equipment relationships
|
||||
Dim rsUnlinked, unlinkedCount
|
||||
@@ -110,7 +111,13 @@ Set rsStatus = Nothing
|
||||
<option value="">All Time</option>
|
||||
<option value="7"<% If recentFilter = "7" Then Response.Write(" selected") End If%>>Last 7 Days</option>
|
||||
</select>
|
||||
<% If currentPCStatus <> "" Or recentFilter <> "" Or deviceTypeFilter <> "" Or pcTypeFilter <> "" Or Request.QueryString("needsrelationship") <> "" Then %>
|
||||
<select id="uptimeFilter" class="btn btn-secondary btn-sm" onchange="updateFilter('uptime', this.value)">
|
||||
<option value="">All Uptimes</option>
|
||||
<option value="7"<% If uptimeFilter = "7" Then Response.Write(" selected") End If%>>Uptime > 7 Days</option>
|
||||
<option value="30"<% If uptimeFilter = "30" Then Response.Write(" selected") End If%>>Uptime > 30 Days</option>
|
||||
<option value="90"<% If uptimeFilter = "90" Then Response.Write(" selected") End If%>>Uptime > 90 Days</option>
|
||||
</select>
|
||||
<% If currentPCStatus <> "" Or recentFilter <> "" Or deviceTypeFilter <> "" Or pcTypeFilter <> "" Or uptimeFilter <> "" Or Request.QueryString("needsrelationship") <> "" Then %>
|
||||
<a href="displaypcs.asp" class="btn btn-outline-secondary btn-sm">
|
||||
<i class="zmdi zmdi-close"></i> Clear
|
||||
</a>
|
||||
@@ -129,6 +136,7 @@ Set rsStatus = Nothing
|
||||
<th scope="col">Model</th>
|
||||
<th scope="col">OS</th>
|
||||
<th scope="col">Equipment</th>
|
||||
<th scope="col">Uptime</th>
|
||||
<th scope="col">VNC</th>
|
||||
<th scope="col">WinRM</th>
|
||||
</tr>
|
||||
@@ -137,17 +145,19 @@ Set rsStatus = Nothing
|
||||
|
||||
<%
|
||||
' Build query based on filters
|
||||
Dim pcStatusFilter, recentDaysFilter, deviceTypeFilterSQL, pcTypeFilterSQL, needsRelationshipFilter, whereClause
|
||||
Dim displayName, hasVnc, vncHost, hasWinrm
|
||||
Dim pcStatusFilter, recentDaysFilter, deviceTypeFilterSQL, pcTypeFilterSQL, uptimeFilterSQL, needsRelationshipFilter, whereClause
|
||||
Dim displayName, hasVnc, vncHost, hasWinrm, uptimeDays
|
||||
pcStatusFilter = Request.QueryString("pcstatus")
|
||||
recentDaysFilter = Request.QueryString("recent")
|
||||
deviceTypeFilterSQL = Request.QueryString("devicetype")
|
||||
pcTypeFilterSQL = Request.QueryString("pctype")
|
||||
uptimeFilterSQL = Request.QueryString("uptime")
|
||||
needsRelationshipFilter = Request.QueryString("needsrelationship")
|
||||
|
||||
' Base query with LEFT JOINs to show all PCs
|
||||
strSQL = "SELECT m.machineid, m.hostname, m.serialnumber, m.machinenumber, m.machinestatusid, " & _
|
||||
"m.modelnumberid, m.osid, m.loggedinuser, m.lastupdated, m.isvnc, m.iswinrm, " & _
|
||||
"m.modelnumberid, m.osid, m.loggedinuser, m.lastupdated, m.isvnc, m.iswinrm, m.lastboottime, " & _
|
||||
"DATEDIFF(NOW(), m.lastboottime) AS uptime_days, " & _
|
||||
"vendors.vendor, models.modelnumber, operatingsystems.operatingsystem, " & _
|
||||
"c.address AS ipaddress, c.macaddress, " & _
|
||||
"machinestatus.machinestatus, " & _
|
||||
@@ -184,6 +194,11 @@ Set rsStatus = Nothing
|
||||
whereClause = whereClause & " AND m.pctypeid = " & pcTypeFilterSQL
|
||||
End If
|
||||
|
||||
' Filter by uptime (days since last boot)
|
||||
If uptimeFilterSQL <> "" And IsNumeric(uptimeFilterSQL) Then
|
||||
whereClause = whereClause & " AND m.lastboottime IS NOT NULL AND DATEDIFF(NOW(), m.lastboottime) > " & uptimeFilterSQL
|
||||
End If
|
||||
|
||||
' Filter for specialized PCs needing equipment relationships
|
||||
If needsRelationshipFilter = "1" Then
|
||||
whereClause = whereClause & " AND m.pctypeid = 7" & _
|
||||
@@ -216,6 +231,23 @@ Set rsStatus = Nothing
|
||||
Response.Write("<span class='text-muted'>-</span>")
|
||||
End If
|
||||
%></td>
|
||||
<td><%
|
||||
' Uptime column - show days since last boot
|
||||
If Not IsNull(rs("uptime_days")) And rs("uptime_days") <> "" Then
|
||||
uptimeDays = CLng(rs("uptime_days") & "")
|
||||
If uptimeDays > 90 Then
|
||||
Response.Write("<span class='badge badge-danger' title='Last boot: " & rs("lastboottime") & "'>" & uptimeDays & "d</span>")
|
||||
ElseIf uptimeDays > 30 Then
|
||||
Response.Write("<span class='badge badge-warning' title='Last boot: " & rs("lastboottime") & "'>" & uptimeDays & "d</span>")
|
||||
ElseIf uptimeDays > 7 Then
|
||||
Response.Write("<span class='badge badge-info' title='Last boot: " & rs("lastboottime") & "'>" & uptimeDays & "d</span>")
|
||||
Else
|
||||
Response.Write("<span class='text-muted' title='Last boot: " & rs("lastboottime") & "'>" & uptimeDays & "d</span>")
|
||||
End If
|
||||
Else
|
||||
Response.Write("<span class='text-muted'>-</span>")
|
||||
End If
|
||||
%></td>
|
||||
<td><%
|
||||
' VNC column with link
|
||||
hasVnc = False
|
||||
|
||||
Reference in New Issue
Block a user