commands

package
v0.0.0-...-a9a17b8 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name  string
	Value string
}

Argument is the struct for command arguments/flags

type CPUCommand

type CPUCommand struct {
}

CPUCommand retrieves information about the CPU

func (CPUCommand) Description

func (c CPUCommand) Description() string

func (CPUCommand) Name

func (c CPUCommand) Name() string

func (CPUCommand) Run

func (c CPUCommand) Run(cmd Command) Output

func (CPUCommand) Usage

func (c CPUCommand) Usage() string

type CPUOutput

type CPUOutput struct {
	Cores     int32
	ModelName string
	Procent   float64
	// contains filtered or unexported fields
}

CPUOutput contains information about the CPU

func (CPUOutput) Error

func (CPUOutput) Error() string

func (CPUOutput) Message

func (c CPUOutput) Message() OutputMessage

type Command

type Command struct {
	Name       string
	Arguments  []*Argument
	RawMessage string
}

Command is a struct for a command

func ParseCommand

func ParseCommand(command string) Command

ParseCommand parses a raw command string and create a Command struct from the string Example:

Input: Check_cpu -cpu=1
Output: {
	Name: "Check_cpu"
	Params: [
		{ Name: "-cpu", Value: "1" }
	]
}

func (Command) GetArgument

func (c Command) GetArgument(name string) *Argument

GetArgument tries to find a specific argument in the argument list

func (Command) HasArgument

func (c Command) HasArgument(name string) bool

HasArgument first tries to find a specific argument and if found it will check if the value is a bool if so it will return the value

type CommandHandler

type CommandHandler struct {
	// contains filtered or unexported fields
}

CommandHandler manages all of the commands

func NewCommandHandler

func NewCommandHandler() *CommandHandler

NewCommandHandler creates a new instance of CommandHandler and adds all existing commands to the handler

func (CommandHandler) GetHelp

func (c CommandHandler) GetHelp() string

GetHelp will return a string with a help page of all description, usage etc. of all the commands

func (CommandHandler) RunCommand

func (c CommandHandler) RunCommand(command Command) Output

RunCommand will try to find the correct command and run the command

type ErrorOutput

type ErrorOutput struct {
	// contains filtered or unexported fields
}

Error Output is a simple struct for the Output interface when you need to return a simple error

func (ErrorOutput) Error

func (e ErrorOutput) Error() string

func (ErrorOutput) Message

func (e ErrorOutput) Message() OutputMessage

type File

type File struct {
	Name    string    `json:"name"`
	Size    int64     `json:"size"`
	IsDir   bool      `json:"is_dir"`
	Perms   string    `json:"perms"`
	LastMod time.Time `json:"last_mod"`
}

File contains information about a specific file

type FileCommand

type FileCommand struct {
}

FileCommand checks information about a specific file

func (FileCommand) Description

func (c FileCommand) Description() string

func (FileCommand) Name

func (c FileCommand) Name() string

func (FileCommand) Run

func (c FileCommand) Run(cmd Command) Output

func (FileCommand) Usage

func (c FileCommand) Usage() string

type FileOutput

type FileOutput struct {
	File File
}

FileOutput contains information about a file

func (FileOutput) Error

func (FileOutput) Error() string

func (FileOutput) Message

func (f FileOutput) Message() OutputMessage

type ICommand

type ICommand interface {
	Run(Command) Output
	Name() string
	Description() string
	Usage() string
}

ICommand is the interface for all internal commands

type InfoCommand

type InfoCommand struct {
	Version string
}

InfoCommand gathers information about the client

func (InfoCommand) Description

func (InfoCommand) Description() string

func (InfoCommand) Name

func (InfoCommand) Name() string

func (InfoCommand) Run

func (i InfoCommand) Run(cmd Command) Output

func (InfoCommand) Usage

func (InfoCommand) Usage() string

type InfoOutput

type InfoOutput struct {
	Hostname      string
	OS            string
	Platform      string
	ClientVersion string
	Interfaces    []NetworkInterface
}

InfoOutput contains information about uptime of a client

func (InfoOutput) Error

func (InfoOutput) Error() string

func (InfoOutput) Message

func (i InfoOutput) Message() OutputMessage

type MemoryCommand

type MemoryCommand struct {
	Version string
}

MemoryCommand checks the usage of a specific memory type (Swap or RAM)

func (MemoryCommand) Description

func (MemoryCommand) Description() string

func (MemoryCommand) Name

func (MemoryCommand) Name() string

func (MemoryCommand) Run

func (i MemoryCommand) Run(cmd Command) Output

func (MemoryCommand) Usage

func (MemoryCommand) Usage() string

type MemoryOutput

type MemoryOutput struct {
	Size uint64
	Type MemoryType
}

MemoryOutput contains information about RAM/Swap

func (MemoryOutput) Error

func (MemoryOutput) Error() string

func (MemoryOutput) Message

func (i MemoryOutput) Message() OutputMessage

type MemoryType

type MemoryType int

MemoryType is the type for which type of memory that should be checked

const (
	RAM  MemoryType = iota // 0
	SWAP                   // 1
)

type NetworkCommand

type NetworkCommand struct {
	Version string
}

NetworkCommand gathers the clients network I/O usage

func (NetworkCommand) Description

func (NetworkCommand) Description() string

func (NetworkCommand) Name

func (NetworkCommand) Name() string

func (NetworkCommand) Run

func (i NetworkCommand) Run(cmd Command) Output

func (NetworkCommand) Usage

func (NetworkCommand) Usage() string

type NetworkInterface

type NetworkInterface struct {
	Name string   `json:"name"`
	IPs  []string `json:"ips"` // Can be both ipv4 and ipv6
}

NetworkInterface contains information about a network interface

type NetworkOutput

type NetworkOutput struct {
	Sent uint64
	Recv uint64
}

NetworkOutput contains information about a clients Network I/O

func (NetworkOutput) Error

func (NetworkOutput) Error() string

func (NetworkOutput) Message

func (i NetworkOutput) Message() OutputMessage

type Output

type Output interface {
	Error() string
	Message() OutputMessage
}

Output is the interface when a command outputs a message

type OutputMessage

type OutputMessage map[string]interface{}

OutputMessage is a simple map[string]interface{} when outputting a message

type Partition

type Partition struct {
	Name string `json:"name"`
	Size uint64 `json:"size"`
	Type string `json:"type"`
}

Partition contains information about a specific partition

type PartitionCommand

type PartitionCommand struct {
}

PartitionCommand gathers information about partitions on the current system

func (PartitionCommand) Description

func (c PartitionCommand) Description() string

func (PartitionCommand) Name

func (c PartitionCommand) Name() string

func (PartitionCommand) Run

func (c PartitionCommand) Run(cmd Command) Output

func (PartitionCommand) Usage

func (c PartitionCommand) Usage() string

type PartitionOutput

type PartitionOutput struct {
	Partitions []Partition
}

PartitionOutput contains information about partitions

func (PartitionOutput) Error

func (PartitionOutput) Error() string

func (PartitionOutput) Message

func (p PartitionOutput) Message() OutputMessage

type PingCommand

type PingCommand struct {
}

PingCommand returns "pong" if the client is responsive

func (PingCommand) Description

func (PingCommand) Description() string

func (PingCommand) Name

func (PingCommand) Name() string

func (PingCommand) Run

func (i PingCommand) Run(cmd Command) Output

func (PingCommand) Usage

func (PingCommand) Usage() string

type PingOutput

type PingOutput struct {
	// contains filtered or unexported fields
}

PingOutput returns "pong" if the client is responsive

func (PingOutput) Error

func (PingOutput) Error() string

func (PingOutput) Message

func (i PingOutput) Message() OutputMessage

type UptimeCommand

type UptimeCommand struct {
}

UptimeCommand checks how long a client has been on

func (UptimeCommand) Description

func (UptimeCommand) Description() string

func (UptimeCommand) Name

func (UptimeCommand) Name() string

func (UptimeCommand) Run

func (u UptimeCommand) Run(cmd Command) Output

func (UptimeCommand) Usage

func (UptimeCommand) Usage() string

type UptimeOutput

type UptimeOutput struct {
	Uptime uint64 `json:"uptime"`
}

UptimeOutput contains information about uptime of a client

func (UptimeOutput) Error

func (UptimeOutput) Error() string

func (UptimeOutput) Message

func (u UptimeOutput) Message() OutputMessage

Jump to

Keyboard shortcuts

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