شائع شدہ سورس
سورس ZIP ڈاؤن لوڈ کریں
CH-J Tools
ایپلیکیشن کی کسی مخصوص ریلیز کی ڈائریکٹریز اور فائلیں دیکھیں۔
CH-J / Server Manager
872 فائلیں
core-20261030T220507Z-61e4558d889f
شامل کیا گیا: · بلڈ کیا گیا:
1
param([string]$ArgsJson)2
$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'3
$A = $ArgsJson | ConvertFrom-Json4
$out = [ordered]@{ errors = @() }5
function Try-Cim([string]$Class, [string]$Filter) {6
try { if ($Filter) { return @(Get-CimInstance -ClassName $Class -Filter $Filter -ErrorAction Stop) } else { return @(Get-CimInstance -ClassName $Class -ErrorAction Stop) } }7
catch { $script:out.errors += "$($Class): $($_.Exception.Message)"; return $null }8
}9
if ($A.static) {10
$nt = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -ErrorAction SilentlyContinue11
$cpuKey = Get-ItemProperty 'HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0' -ErrorAction SilentlyContinue12
$static = [ordered]@{ caption = [string]$nt.ProductName; build = [string]$nt.CurrentBuildNumber; ubr = [string]$nt.UBR; displayVersion = [string]$nt.DisplayVersion13
installationType = [string]$nt.InstallationType; hostname = [Environment]::MachineName; architecture = [string]$env:PROCESSOR_ARCHITECTURE14
cpuModel = ([string]$cpuKey.ProcessorNameString).Trim(); logical = [Environment]::ProcessorCount; physical = $null; sockets = $null; memoryTotal = $null }15
$os = Try-Cim 'Win32_OperatingSystem'16
if ($os) { $static.caption = [string]$os[0].Caption; $static.memoryTotal = [double]$os[0].TotalVisibleMemorySize * 1024 }17
$cpu = Try-Cim 'Win32_Processor'18
if ($cpu) { $static.sockets = $cpu.Count; $static.physical = [int](($cpu | Measure-Object -Property NumberOfCores -Sum).Sum); $static.logical = [int](($cpu | Measure-Object -Property NumberOfLogicalProcessors -Sum).Sum) }19
$video = Try-Cim 'Win32_VideoController'20
if ($video) { $static.gpus = @($video | ForEach-Object { [ordered]@{ name = [string]$_.Name; vendor = [string]$_.AdapterCompatibility; driverVersion = [string]$_.DriverVersion; pnp = [string]$_.PNPDeviceID; adapterRam = $(if ($null -ne $_.AdapterRAM) { [double]$_.AdapterRAM } else { $null }) } }) }21
if (-not $static.memoryTotal) { try { Add-Type -AssemblyName Microsoft.VisualBasic; $static.memoryTotal = [double](New-Object Microsoft.VisualBasic.Devices.ComputerInfo).TotalPhysicalMemory } catch { $out.errors += "ComputerInfo: $($_.Exception.Message)" } }22
$out.static = $static23
}24
# Uptime: CIM boot time, otherwise the monotonic performance counter since boot.25
$out.uptimeSeconds = $null26
$os = Try-Cim 'Win32_OperatingSystem'27
if ($os) {28
$out.uptimeSeconds = [math]::Floor(((Get-Date) - $os[0].LastBootUpTime).TotalSeconds)29
$out.memoryTotal = [double]$os[0].TotalVisibleMemorySize * 1024; $out.memoryAvailable = [double]$os[0].FreePhysicalMemory * 102430
} else {31
$out.uptimeSeconds = [math]::Floor([Diagnostics.Stopwatch]::GetTimestamp() / [Diagnostics.Stopwatch]::Frequency)32
try { Add-Type -AssemblyName Microsoft.VisualBasic; $ci = New-Object Microsoft.VisualBasic.Devices.ComputerInfo; $out.memoryTotal = [double]$ci.TotalPhysicalMemory; $out.memoryAvailable = [double]$ci.AvailablePhysicalMemory } catch { $out.errors += "ComputerInfo: $($_.Exception.Message)" }33
}34
# Raw CPU counter; Core computes the usage from the difference between two refreshes.35
$cpu = Try-Cim 'Win32_PerfRawData_PerfOS_Processor' "Name='_Total'"36
if ($cpu) { $out.cpuRaw = [ordered]@{ busyInverse = [string]$cpu[0].PercentProcessorTime; time = [string]$cpu[0].Timestamp_Sys100NS } }37
# Each CPU package separately.38
$packages = Try-Cim 'Win32_Processor'39
if ($packages) { $out.cpuPackages = @($packages | ForEach-Object { [ordered]@{ id = [string]$_.DeviceID; name = ([string]$_.Name).Trim(); cores = [int]$_.NumberOfCores; logical = [int]$_.NumberOfLogicalProcessors; load = $(if ($null -ne $_.LoadPercentage) { [double]$_.LoadPercentage } else { $null }); mhz = [double]$_.CurrentClockSpeed } }) }40
# GPU metrics: nvidia-smi where installed, Windows GPU performance counters otherwise (absent on systems without WDDM counters).41
$smi = $null42
try { $smi = (Get-Command 'nvidia-smi.exe' -ErrorAction Stop).Source } catch { $candidate = Join-Path ([string]$env:ProgramFiles) 'NVIDIA Corporation\NVSMI\nvidia-smi.exe'; if (Test-Path -LiteralPath $candidate) { $smi = $candidate } }43
if ($smi) {44
try {45
$ErrorActionPreference = 'Continue'46
$out.nvidia = @(& $smi '--query-gpu=pci.bus_id,name,utilization.gpu,utilization.memory,memory.total,memory.used,temperature.gpu,power.draw,power.limit,clocks.current.graphics,fan.speed,driver_version' '--format=csv,noheader,nounits' 2>$null | ForEach-Object { [string]$_ })47
} catch {} finally { $ErrorActionPreference = 'Stop' }48
}49
$engines = $null; $adapterMemory = $null50
try { $engines = @(Get-CimInstance -ClassName Win32_PerfFormattedData_GPUPerformanceCounters_GPUEngine -ErrorAction Stop); $adapterMemory = @(Get-CimInstance -ClassName Win32_PerfFormattedData_GPUPerformanceCounters_GPUAdapterMemory -ErrorAction Stop) } catch {}51
if ($adapterMemory) {52
$busy = @{}53
foreach ($engine in $engines) {54
if ($engine.Name -match '(luid_0x[0-9A-Fa-f]+_0x[0-9A-Fa-f]+).*engtype_(.*)$') { $key = "$($Matches[1])|$($Matches[2])"; $busy[$key] = [double]$busy[$key] + [double]$engine.UtilizationPercentage }55
}56
$out.gpuCounters = @($adapterMemory | ForEach-Object {57
$luid = if ($_.Name -match '(luid_0x[0-9A-Fa-f]+_0x[0-9A-Fa-f]+)') { $Matches[1] } else { [string]$_.Name }58
$peak = $null; foreach ($key in $busy.Keys) { if ($key.StartsWith("$luid|") -and ($null -eq $peak -or $busy[$key] -gt $peak)) { $peak = $busy[$key] } }59
[ordered]@{ luid = $luid; usage = $peak; dedicated = [double]$_.DedicatedUsage; shared = [double]$_.SharedUsage } })60
}61
$system = Try-Cim 'Win32_PerfRawData_PerfOS_System'62
if ($system) { $out.processorQueueLength = [int]$system[0].ProcessorQueueLength; $out.processes = [int]$system[0].Processes }63
# Physical memory lists (gauges, no second sample needed).64
$memory = Try-Cim 'Win32_PerfRawData_PerfOS_Memory'65
if ($memory) {66
$m = $memory[0]67
$out.memoryCounters = [ordered]@{ available = [double]$m.AvailableBytes; cache = [double]$m.CacheBytes; systemCacheResident = [double]$m.SystemCacheResidentBytes68
standbyCore = [double]$m.StandbyCacheCoreBytes; standbyNormal = [double]$m.StandbyCacheNormalPriorityBytes; standbyReserve = [double]$m.StandbyCacheReserveBytes69
modified = [double]$m.ModifiedPageListBytes; freeZero = [double]$m.FreeAndZeroPageListBytes; committed = [double]$m.CommittedBytes; commitLimit = [double]$m.CommitLimit70
poolPaged = [double]$m.PoolPagedResidentBytes; poolNonpaged = [double]$m.PoolNonpagedBytes; systemCode = [double]$m.SystemCodeResidentBytes; systemDriver = [double]$m.SystemDriverResidentBytes71
pagesInput = [string]$m.PagesInputPersec; pagesOutput = [string]$m.PagesOutputPersec; time = [string]$m.Timestamp_Sys100NS; frequency = [string]$m.Frequency_Sys100NS }72
}73
# Pagefiles: allocated size, current and peak usage (MB as reported by Windows).74
$usage = Try-Cim 'Win32_PageFileUsage'75
if ($null -ne $usage) { $out.pagefiles = @($usage | ForEach-Object { [ordered]@{ name = [string]$_.Name; allocatedMb = [double]$_.AllocatedBaseSize; currentMb = [double]$_.CurrentUsage; peakMb = [double]$_.PeakUsage; temporary = [bool]$_.TempPageFile } }) }76
# Fixed disks through .NET (no WMI rights required).77
$out.disks = @([IO.DriveInfo]::GetDrives() | Where-Object { $_.DriveType -eq 'Fixed' -and $_.IsReady } | ForEach-Object { [ordered]@{ name = $_.Name.TrimEnd('\'); total = [double]$_.TotalSize; available = [double]$_.AvailableFreeSpace; free = [double]$_.TotalFreeSpace; format = [string]$_.DriveFormat; label = [string]$_.VolumeLabel } })78
$out.systemDrive = [string]$env:SystemDrive79
# Network adapters through .NET: status, MAC, unicast addresses and cumulative byte counters.80
$adapters = @()81
foreach ($nic in [Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()) {82
if ($nic.NetworkInterfaceType -in @('Loopback', 'Tunnel')) { continue }83
$props = $nic.GetIPProperties()84
$stats = $null; try { $stats = $nic.GetIPStatistics() } catch {}85
$addresses = @($props.UnicastAddresses | Where-Object { -not $_.Address.IsIPv6LinkLocal } | ForEach-Object { "$($_.Address.IPAddressToString)/$($_.PrefixLength)" })86
$mac = ($nic.GetPhysicalAddress().GetAddressBytes() | ForEach-Object { $_.ToString('x2') }) -join ':'87
$adapters += [ordered]@{ name = $nic.Name; description = $nic.Description; state = [string]$nic.OperationalStatus; mac = $mac; speed = [double]$nic.Speed88
rx = $(if ($stats) { [double]$stats.BytesReceived } else { $null }); tx = $(if ($stats) { [double]$stats.BytesSent } else { $null })89
rxPackets = $(if ($stats) { [double]$stats.UnicastPacketsReceived + [double]$stats.NonUnicastPacketsReceived } else { $null })90
txPackets = $(if ($stats) { [double]$stats.UnicastPacketsSent + [double]$stats.NonUnicastPacketsSent } else { $null })91
addresses = $addresses; gateway = [bool](@($props.GatewayAddresses | Where-Object { $_.Address.ToString() -notin @('0.0.0.0', '::') }).Count) }92
}93
$out.adapters = $adapters94
[Console]::Out.WriteLine('CHJ_RESULT:' + [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -InputObject $out -Depth 6 -Compress))))SHA-256
496a32c5cea43268225a5239ac0906e2ca47ab7ce0ef50a058e1151fb9faa2a9CH-J Proprietary Software License 1.14 · سورس CH-J Proprietary Software License 1.14 کے تحت فراہم کیا جاتا ہے۔ اس کی دستیابی لائسنس کی شرائط نہیں بدلتی اور نہ ہی اضافی حقوق دیتی ہے۔
آرکائیو کا SHA-256
77380d4805485ffa4027fbe7858b5836f197a4aa9d52358a43e2d12d018744df