From dce789db94bc5ad305189261f5c2ceae1e8cb6e3 Mon Sep 17 00:00:00 2001 From: sonderau Date: Tue, 4 Nov 2025 08:55:00 +0800 Subject: [PATCH] Resolved device list and IP addresses not working via osqueryi. Now also returning last boottime by doing bootup time and math from current time --- .claude/settings.local.json | 4 +--- LD-SysInfo/LD_SysInfo.csproj | 3 ++- LD-SysInfo/SystemInfo.cs | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 0e9a7b7..932a99a 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -1,9 +1,7 @@ { "permissions": { "allow": [ - "Bash(dotnet build:*)", - "Bash(git add:*)", - "Bash(git commit -m \"$(cat <<''EOF''\nRelease v1.2.0: Integrate osquery for enhanced system information\n\nMajor Features:\n- Integrated osquery for comprehensive system information gathering\n- Added OsqueryService for executing SQL queries against system tables\n- Implemented Osquery Console tab for interactive SQL queries\n\nSystem Info Improvements:\n- Enhanced system info collection using osquery tables\n- Added support for multiple GPU detection\n- Improved memory detection with proper GB formatting\n- Fixed OS Architecture detection (x64/x86)\n- Better network interface detection (IPv4 only)\n- Human-readable timestamp formatting\n\nUI/UX Enhancements:\n- Added window resizing with corner drag support\n- Implemented dynamic window sizing (SizeToContent)\n- Added ScrollViewer for content overflow\n- Improved IP address formatting with bullet points\n- Added field labels to all system info displays\n- Set minimum/maximum window size constraints\n\nBug Fixes:\n- Fixed XAML StackPanel Spacing property issue\n- Merged duplicate MainWindow constructors\n- Fixed non-nullable field warnings\n- Fixed EventHandler nullability signatures\n- Removed redundant hostname/OS name fields\n- Fixed GPU registry query to detect all GPUs\n\nšŸ¤– Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude \nEOF\n)\")" + "Bash(\"BuildDir\\bin\\Debug\\Assets\\osqueryi.exe\" --json \"SELECT datetime((SELECT CAST(unix_time AS INTEGER) FROM time) - total_seconds, ''unixepoch'') as boot_time FROM uptime;\")" ], "deny": [], "ask": [] diff --git a/LD-SysInfo/LD_SysInfo.csproj b/LD-SysInfo/LD_SysInfo.csproj index 20da03f..07e97a5 100644 --- a/LD-SysInfo/LD_SysInfo.csproj +++ b/LD-SysInfo/LD_SysInfo.csproj @@ -9,7 +9,8 @@ true LD_SysInfo.App Assets\LDShortcut.ico - C:\Users\Sonder\source\repos\psg-oversight-app\BuildDir\bin\Debug\net8.0-windows\ + C:\Users\Sonder\source\repos\psg-oversight-app\BuildDir\bin\Debug\ + false false diff --git a/LD-SysInfo/SystemInfo.cs b/LD-SysInfo/SystemInfo.cs index f5c185b..a48b66a 100644 --- a/LD-SysInfo/SystemInfo.cs +++ b/LD-SysInfo/SystemInfo.cs @@ -142,10 +142,10 @@ namespace LD_SysInfo } // āœ… Drives - info.Drives = OsqueryService.Query("SELECT device, size, free_space, type FROM logical_drives;") + info.Drives = OsqueryService.Query("SELECT device_id, size, free_space, type FROM logical_drives;") .Select(d => new DriveInfoSummary { - Name = d.GetValueOrDefault("device"), + Name = d.GetValueOrDefault("device_id"), TotalSizeGB = d.ContainsKey("size") && double.TryParse(d["size"], out double size) ? Math.Round(size / (1024.0 * 1024.0 * 1024.0), 2) : 0, FreeSpaceGB = d.ContainsKey("free_space") && double.TryParse(d["free_space"], out double free) @@ -179,9 +179,9 @@ namespace LD_SysInfo .Where(ni => !string.IsNullOrEmpty(ni.IpAddress)) .ToList(); - // āœ… Last boot time - info.LastBootTime = OsqueryService.Query("SELECT datetime(boot_time, 'unixepoch') AS last_boot FROM uptime;") - .FirstOrDefault()?.GetValueOrDefault("last_boot"); + // āœ… Last boot time - calculate from current time minus uptime + info.LastBootTime = OsqueryService.Query("SELECT datetime((SELECT CAST(unix_time AS INTEGER) FROM time) - total_seconds, 'unixepoch') as boot_time FROM uptime;") + .FirstOrDefault()?.GetValueOrDefault("boot_time"); // āœ… Installed apps (user + system) info.InstalledApplications = OsqueryService.Query("SELECT name, version, publisher FROM programs;")