utils

package
v0.0.0-...-e0ed648 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ok            = 0
	Warning       = 1
	Critical      = 2
	Unknown       = 3
	Timeout       = 124
	NotExecutable = 126
	NotFound      = 127
)

Unified exit codes

Variables

View Source
var SmcSensorNames = map[string]string{
	"TA0P": "Ambient 1",
	"TA1P": "Ambient 2",
	"TC0D": "CPU 0 Diode",
	"TC0H": "CPU 0 Heatsink",
	"TC0P": "CPU 0 Proximity",
	"TB0T": "Battery",
	"TB1T": "Battery 1",
	"TB2T": "Battery 2",
	"TB3T": "Battery",
	"TG0D": "GPU 0 Diode",
	"TG0H": "GPU 0 Heatsink",
	"TG0P": "GPU 0 Proximity",
	"TH0P": "TH0P Bay 1",
	"TM0S": "Memory Module 0",
	"TM0P": "Mainboard Proximity",
	"TN0H": "Northbridge Heatsink",
	"TN0D": "Northbridge Diode",
	"TN0P": "Northbridge Proximity",
	"TI0P": "Thunderbolt 0",
	"TI1P": "Thunderbolt 1",
	"TW0P": "Airport Proximity",
}

SmcSensorNames maps the names from the SMC chip to human readable names this list is taken from: https://github.com/shirou/gopsutil/blob/a1e77476b2bb7bbe6130fa1cbc39fe1635ff459c/v3/host/smc_darwin.h#L6-L26 Also a good source is: https://superuser.com/a/967056 or maybe https://github.com/dkorunic/iSMC

Functions

func CSRFromKeyFile

func CSRFromKeyFile(keyFile, subject string) ([]byte, error)

CSRFromKeyFile reads keyFile and generates a csr in PEM format

func CertPoolFromFiles

func CertPoolFromFiles(files ...string) (*x509.CertPool, []byte, error)

CertPoolFromFiles reads listed file names and returns the certpool for ca or other usage

func Chmod

func Chmod(name string, mode fs.FileMode) error

On Linux and macOS this is func just calls os.Chmod. This is only important for Windows systems

func ConcatStringSlice

func ConcatStringSlice(slices ...[]string) []string

func CopyFile

func CopyFile(src, dst string) error

func FileExists

func FileExists(path string) bool

func FileNotExists

func FileNotExists(path string) bool

func GeneratePrivateKeyIfNotExists

func GeneratePrivateKeyIfNotExists(keyFile string) error

GeneratePrivateKeyIfNotExists checks for keyFile and if it does not exist generates a rsa 4096 bits key

Types

type CommandArgs

type CommandArgs struct {
	Command       string
	Timeout       time.Duration
	Shell         string
	PowershellExe string
	Stdin         string
}

type CommandResult

type CommandResult struct {
	Stdout                    string `json:"stdout"`
	RC                        int    `json:"rc"`
	ExecutionUnixTimestampSec int64  `json:"execution_unix_timestamp_sec"`
}

CommandResult to return the information

func RunCommand

func RunCommand(ctx context.Context, commandArgs CommandArgs) (*CommandResult, error)

RunCommand in shell style with timeout on every platform

Jump to

Keyboard shortcuts

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