inventory

package
v0.0.0-...-d228a98 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProcessCmd = &cobra.Command{
	Use:   "ps",
	Short: "",
	Run: func(cmd *cobra.Command, args []string) {
		info, err := ssm.GetInstanceInformation()
		if err != nil {
			log.Fatal().Err(err).Msg("cannot get instance information")
		}
		logger := log.With().Str("ManagedId", info.InstanceId).Logger()
		processes, err := sysmon.ListAllProcesses()
		if err != nil {
			log.Fatal().Err(err).Msg("cannot list processes")
		}
		inventory := map[string]interface{}{
			"SchemaVersion": "1.0",
			"TypeName":      "Custom:ProcessInfo",
			"CaptureTime":   time.Now().UTC().Format("2006-01-02T15:04:05Z"),
			"Content":       processes,
		}
		data, err := json.MarshalIndent(inventory, "", "   ")
		if err != nil {
			logger.Fatal().Err(err).Msg("cannot marshal inventory")
		}
		path := filepath.Join(appconfig.DefaultDataStorePath, info.InstanceId, "inventory/custom/ProcessInfo.json")
		if err := ioutil.WriteFile(path, data, 0644); err != nil {
			logger.Fatal().Err(err).Msgf("cannot write file: %#v", path)
		}
		logger.Info().Msg("process inventory completed successfully")
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL