From 6227fc584da9bd623686d22e806eeeb03d6e25fb Mon Sep 17 00:00:00 2001 From: Max Altgelt Date: Wed, 29 Oct 2025 13:17:45 +0100 Subject: [PATCH] feat: more startup information --- thorlog/v3/hostinfo.go | 2 +- thorlog/v3/scaninfo.go | 44 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/thorlog/v3/hostinfo.go b/thorlog/v3/hostinfo.go index 975e12a..0b929b8 100644 --- a/thorlog/v3/hostinfo.go +++ b/thorlog/v3/hostinfo.go @@ -16,7 +16,7 @@ type HostInfo struct { Platform PlatformInfo `json:"platform" textlog:",expand"` Uptime time.Duration `json:"uptime" textlog:"uptime"` Cpus int `json:"cpu_count" textlog:"cpu_count"` - Memory uint64 `json:"memory" textlog:"memory"` + Memory Memory `json:"memory" textlog:"memory"` Timezone string `json:"timezone" textlog:"timezone"` Language string `json:"language" textlog:"language"` Interfaces []InterfaceInfo `json:"interfaces" textlog:",expand"` diff --git a/thorlog/v3/scaninfo.go b/thorlog/v3/scaninfo.go index 2c07fae..b3c383d 100644 --- a/thorlog/v3/scaninfo.go +++ b/thorlog/v3/scaninfo.go @@ -1,7 +1,9 @@ package thorlog import ( + "fmt" "strings" + "time" "github.com/NextronSystems/jsonlog" ) @@ -24,8 +26,15 @@ type ScanInfo struct { Outputs []ScannerOutput `json:"outputs"` - ActiveModules []string `json:"active_modules"` - ActiveFeatures []string `json:"active_features"` + ActiveModules StringList `json:"active_modules" textlog:"active_modules"` + ActiveFeatures StringList `json:"active_features" textlog:"active_features"` + + Threads int `json:"threads" textlog:"threads"` + + Timeout time.Duration `json:"timeout" textlog:"timeout"` + CPULimit int `json:"cpu_limit" textlog:"cpu_limit"` + FreeMemoryLimit Memory `json:"free_memory_limit" textlog:"free_memory_limit"` + FileSizeLimit Memory `json:"file_size_limit" textlog:"file_size_limit"` License LicenseInfo `json:"license" textlog:"license,expand"` @@ -64,3 +73,34 @@ type VersionInfo struct { Signatures string `json:"signatures" textlog:"signature_version"` Sigma string `json:"sigma_rules" textlog:"sigma_version"` } + +type Memory uint64 + +func (m Memory) String() string { + var usedSuffix = "B" + var divisor uint64 = 1 + bytes := uint64(m) + for suffix, multiplier := range multipliers { + if multiplier < bytes && multiplier > divisor { + divisor = multiplier + usedSuffix = suffix + "B" + } + } + return fmt.Sprintf("%d%s", int64(float64(bytes)/float64(divisor)), usedSuffix) +} + +const ( + kb = 1024 + mb = 1024 * kb + gb = 1024 * mb + tb = 1024 * gb + pb = 1024 * tb +) + +var multipliers = map[string]uint64{ + "K": kb, + "M": mb, + "G": gb, + "T": tb, + "P": pb, +}