Skip to content

Commit

Permalink
feat: add host information logging to version command
Browse files Browse the repository at this point in the history
  • Loading branch information
dz0ny committed Jan 3, 2025
1 parent 76f2a61 commit 9eb2fe5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package cmd

import (
"encoding/json"
"os"
"runtime"

"github.com/ParetoSecurity/pareto-linux/shared"
"github.com/caarlos0/log"
"github.com/elastic/go-sysinfo"
"github.com/spf13/cobra"
)

Expand All @@ -22,6 +24,18 @@ var versionCmd = &cobra.Command{
log.Infof("OS Version: %s", device.OSVersion)
log.Infof("Model Name: %s", device.ModelName)
log.Infof("Model Serial: %s", device.ModelSerial)

hostInfo, err := sysinfo.Host()
if err != nil {
log.Warn("Failed to get process information")
}
envInfo := hostInfo.Info()
jsonOutput, err := json.MarshalIndent(envInfo, "", " ")
if err != nil {
log.Warn("Failed to marshal host info")
}
log.Infof("Host Info: %s", string(jsonOutput))

os.Exit(0)
},
}
Expand Down

0 comments on commit 9eb2fe5

Please sign in to comment.