utils

package
v0.0.0-...-ae8cef7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHosts

func CheckHosts(config *Config, hostList []string) (map[string]*ConfigHost, error)

func FileExists

func FileExists(file string) bool

func FindConfigFile

func FindConfigFile() string

FindConfigFile will locate the a configuration file by looking at the following places and choosing the first: SATURN_CONFIG env variable, $PWD/config.toml, $PWD/config/config.toml, $HOME/.saturn/config.toml, and /etc/saturn/config.toml.

Types

type ArpCache

type ArpCache struct {
	Addr   string `json:"addr"`
	HwType string `json:"hw_type"`
	HwAddr string `json:"hw_addr"`
	Mask   string `json:"mask"`
}

type Bandwidth

type Bandwidth struct {
	Interface string `json:"interface"`
	Tx        int    `json:"tx"`
	Rx        int    `json:"rx"`
}

type CommonApplications

type CommonApplications struct {
	Binary    string `json:"binary"`
	Location  string `json:"location"`
	Installed bool   `json:"installed"`
}

type Config

type Config struct {
	Core struct {
		Debug         bool
		SpecialDebug  bool
		TempDir       string
		ModuleDir     string
		RemoteBaseDir string
		KeepTempFiles bool
		HaltOnError   bool
	}
	SSH struct {
		Username   string
		Password   string
		PrivateKey string
		Timeout    string
		UseAgent   bool
	}
	Hosts    []*ConfigHost
	HostsMap map[string]*ConfigHost
	// contains filtered or unexported fields
}

Config is a project-wide struct that holds configuration information

func NewConfig

func NewConfig(configFile string) (conf *Config, err error)

NewConfig will load a Config object using the given TOML file.

type ConfigHost

type ConfigHost struct {
	Name          string            `json:"name"`
	Address       string            `json:"address"`
	Username      string            `json:"username"`
	Password      string            `json:"-"`
	PrivateKey    string            `json:"-"`
	Disable       bool              `json:"disabled"`
	SSHConnection *ssh.Client       `json:"-"`
	SSHConfig     *ssh.ClientConfig `json:"-"`
	// contains filtered or unexported fields
}

func (*ConfigHost) ConnectSSH

func (c *ConfigHost) ConnectSSH(clientConfig *ssh.ClientConfig) error

type CpuInfo

type CpuInfo struct {
	Architecture   string `json:"Architecture"`
	CPUOpModeS     string `json:"CPU op-mode(s)"`
	ByteOrder      string `json:"Byte Order"`
	CPUS           string `json:"CPU(s)"`
	OnLineCPUSList string `json:"On-line CPU(s) list"`
	ThreadSPerCore string `json:"Thread(s) per core"`
	CoreSPerSocket string `json:"Core(s) per socket"`
	SocketS        string `json:"Socket(s)"`
	NUMANodeS      string `json:"NUMA node(s)"`
	VendorID       string `json:"Vendor ID"`
	CPUFamily      string `json:"CPU family"`
	Model          string `json:"Model"`
	ModelName      string `json:"Model name"`
	Stepping       string `json:"Stepping"`
	CPUMHz         string `json:"CPU MHz"`
	CPUMaxMHz      string `json:"CPU max MHz"`
	CPUMinMHz      string `json:"CPU min MHz"`
	BogoMIPS       string `json:"BogoMIPS"`
	Virtualization string `json:"Virtualization"`
	L1dCache       string `json:"L1d cache"`
	L1iCache       string `json:"L1i cache"`
	L2Cache        string `json:"L2 cache"`
	L3Cache        string `json:"L3 cache"`
	NUMANode0CPUS  string `json:"NUMA node0 CPU(s)"`
	Flags          string `json:"Flags"`
}

type CpuIntensiveProcesses

type CpuIntensiveProcesses struct {
	Pid        int     `json:"pid"`
	User       string  `json:"user"`
	CpuPercent float64 `json:"cpu_percent"`
	Rss        int     `json:"rss"`
	Vsz        int     `json:"vsz"`
	Cmd        string  `json:"cmd"`
}

type CpuTemp

type CpuTemp struct {
	Temp float64 `json:"temp"`
}

type CpuUtilization

type CpuUtilization struct {
	Util int `json:"util"`
}

type CronHistory

type CronHistory struct {
	Time    string `json:"time"`
	User    string `json:"user"`
	Message string `json:"message"`
}

type CurrentRam

type CurrentRam struct {
	Total     float64 `json:"total"`
	Used      float64 `json:"used"`
	Available float64 `json:"available"`
}

type DiskPartitions

type DiskPartitions struct {
	FileSystem  string `json:"file_system"`
	Size        string `json:"size"`
	Used        string `json:"used"`
	Avail       string `json:"avail"`
	UsedPercent int    `json:"used_percent"`
	Mounted     string `json:"mounted"`
}

type DockerProcesses

type DockerProcesses struct {
	Cname      string  `json:"cname"`
	Pid        int     `json:"pid"`
	User       string  `json:"user"`
	CpuPercent float64 `json:"cpu_percent"`
	MemPercent float64 `json:"mem_percent"`
	Cmd        string  `json:"cmd"`
}

type DownloadTransferRate

type DownloadTransferRate struct {
	Interface    string `json:"interface"`
	TransferRate int    `json:"transfer_rate"`
}

type EnabledServices

type EnabledServices struct {
	Name string `json:"name"`
}

type GeneralInfo

type GeneralInfo struct {
	Os            string `json:"os"`
	OsVersion     string `json:"os_version"`
	CurrentKernel string `json:"current_kernel"`
	LatestKernel  string `json:"latest_kernel"`
	Hostname      string `json:"hostname"`
	Uptime        string `json:"uptime"`
	ServerTime    string `json:"server_time"`
	Path          string `json:"path"`
	Installed     string `json:"installed"`
}

type HostResponse

type HostResponse struct {
	Host                  *ConfigHost              `json:"host"`
	ArpCache              []*ArpCache              `json:"arp_cache,omitempty"`
	Bandwidth             []*Bandwidth             `json:"bandwidth,omitempty"`
	CommonApplications    []*CommonApplications    `json:"common_applications,omitempty"`
	CpuInfo               *CpuInfo                 `json:"cpu_info,omitempty"`
	CpuIntensiveProcesses []*CpuIntensiveProcesses `json:"cpu_intensive_processes,omitempty"`
	CpuTemp               *CpuTemp                 `json:"cpu_temp,omitempty"`
	CpuUtilization        *CpuUtilization          `json:"cpu_utilization,omitempty"`
	CronHistory           []*CronHistory           `json:"cron_history,omitempty"`
	CurrentRam            *CurrentRam              `json:"current_ram,omitempty"`
	DiskPartitions        []*DiskPartitions        `json:"disk_partitions,omitempty"`
	DockerProcesses       []*DockerProcesses       `json:"docker_processes,omitempty"`
	DownloadTransferRate  []*DownloadTransferRate  `json:"download_transfer_rate,omitempty"`
	EnabledServices       []*EnabledServices       `json:"enabled_services,omitempty"`
	GeneralInfo           *GeneralInfo             `json:"general_info,omitempty"`
	IoStats               []*IoStats               `json:"io_stats,omitempty"`
	ListeningPorts        []*ListeningPorts        `json:"listening_ports,omitempty"`
	LoadAvg               *LoadAvg                 `json:"load_avg,omitempty"`
	LoggedInUsers         []*LoggedInUsers         `json:"logged_in_users,omitempty"`
	Memcached             *Memcached               `json:"memcached,omitempty"`
	MemoryInfo            *MemoryInfo              `json:"memory_info,omitempty"`
	NeedsUpgrades         []*NeedsUpgrades         `json:"needs_upgrades,omitempty"`
	NetworkConnections    []*NetworkConnections    `json:"network_connections,omitempty"`
	NetworkInterfaces     []*NetworkInterfaces     `json:"network_interfaces,omitempty"`
	NumberOfCpuCores      *NumberOfCpuCores        `json:"number_of_cpu_cores,omitempty"`
	Pm2Stats              []*Pm2Stats              `json:"pm2_stats,omitempty"`
	RamIntensiveProcesses []*RamIntensiveProcesses `json:"ram_intensive_processes,omitempty"`
	RecentAccountLogins   []*RecentAccountLogins   `json:"recent_account_logins,omitempty"`
	Redis                 *Redis                   `json:"redis,omitempty"`
	ScheduledCrons        []*ScheduledCrons        `json:"scheduled_crons,omitempty"`
	Swap                  []*Swap                  `json:"swap,omitempty"`
	UploadTransferRate    []*UploadTransferRate    `json:"upload_transfer_rate,omitempty"`
	UserAccounts          []*UserAccounts          `json:"user_accounts,omitempty"`
}

func (*HostResponse) Print

func (r *HostResponse) Print(short bool)

type IoStats

type IoStats struct {
	Device string `json:"device"`
	Reads  int    `json:"reads"`
	Writes int    `json:"writes"`
	InProg int    `json:"in_prog"`
	Time   int    `json:"time"`
}

type ListeningPorts

type ListeningPorts struct {
	Process string `json:"process"`
	Pid     string `json:"pid"`
	Type    string `json:"type"`
	Proto   string `json:"proto"`
	Address string `json:"address"`
	Port    string `json:"port"`
}

type LoadAvg

type LoadAvg struct {
	Avg1Min  int `json:"avg_1_min"`
	Avg5Min  int `json:"avg_5_min"`
	Avg15Min int `json:"avg_15_min"`
}

type LoggedInUsers

type LoggedInUsers struct {
	User string `json:"user"`
	From string `json:"from"`
	When string `json:"when"`
}

type Memcached

type Memcached struct {
	Bytes        int `json:"bytes"`
	BytesRead    int `json:"bytes_read"`
	BytesWritten int `json:"bytes_written"`
}

type MemoryInfo

type MemoryInfo struct {
	MemTotal          string `json:"MemTotal"`
	MemFree           string `json:"MemFree"`
	MemAvailable      string `json:"MemAvailable"`
	Buffers           string `json:"Buffers"`
	Cached            string `json:"Cached"`
	SwapCached        string `json:"SwapCached"`
	Active            string `json:"Active"`
	Inactive          string `json:"Inactive"`
	ActiveAnon        string `json:"Active(anon)"`
	InactiveAnon      string `json:"Inactive(anon)"`
	ActiveFile        string `json:"Active(file)"`
	InactiveFile      string `json:"Inactive(file)"`
	Unevictable       string `json:"Unevictable"`
	Mlocked           string `json:"Mlocked"`
	SwapTotal         string `json:"SwapTotal"`
	SwapFree          string `json:"SwapFree"`
	Dirty             string `json:"Dirty"`
	Writeback         string `json:"Writeback"`
	AnonPages         string `json:"AnonPages"`
	Mapped            string `json:"Mapped"`
	Shmem             string `json:"Shmem"`
	Slab              string `json:"Slab"`
	SReclaimable      string `json:"SReclaimable"`
	SUnreclaim        string `json:"SUnreclaim"`
	KernelStack       string `json:"KernelStack"`
	PageTables        string `json:"PageTables"`
	NFSUnstable       string `json:"NFS_Unstable"`
	Bounce            string `json:"Bounce"`
	WritebackTmp      string `json:"WritebackTmp"`
	CommitLimit       string `json:"CommitLimit"`
	CommittedAS       string `json:"Committed_AS"`
	VmallocTotal      string `json:"VmallocTotal"`
	VmallocUsed       string `json:"VmallocUsed"`
	VmallocChunk      string `json:"VmallocChunk"`
	HardwareCorrupted string `json:"HardwareCorrupted"`
	AnonHugePages     string `json:"AnonHugePages"`
	CmaTotal          string `json:"CmaTotal"`
	CmaFree           string `json:"CmaFree"`
	HugePagesTotal    string `json:"HugePages_Total"`
	HugePagesFree     string `json:"HugePages_Free"`
	HugePagesRsvd     string `json:"HugePages_Rsvd"`
	HugePagesSurp     string `json:"HugePages_Surp"`
	Hugepagesize      string `json:"Hugepagesize"`
	DirectMap4k       string `json:"DirectMap4k"`
	DirectMap2M       string `json:"DirectMap2M"`
	DirectMap1G       string `json:"DirectMap1G"`
}

type NeedsUpgrades

type NeedsUpgrades struct {
	Package   string `json:"package"`
	Installed string `json:"installed"`
	Available string `json:"available"`
}

type NetworkConnections

type NetworkConnections struct {
	Connections int    `json:"connections"`
	Address     string `json:"address"`
}

type NetworkInterfaces

type NetworkInterfaces struct {
	Interface  string                      `json:"interface"`
	MacAddress string                      `json:"mac_address"`
	Ipv4       []*NetworkInterfacesAddress `json:"ipv4"`
	Ipv6       []*NetworkInterfacesAddress `json:"ipv6"`
}

type NetworkInterfacesAddress

type NetworkInterfacesAddress struct {
	Address   string `json:"address"`
	Broadcast string `json:"broadcast"`
	Mask      string `json:"mask"`
}

type NumberOfCpuCores

type NumberOfCpuCores struct {
	Cores int `json:"cores"`
}

type Pm2Stats

type Pm2Stats struct {
	AppName  string `json:"appName"`
	Id       string `json:"id"`
	Mode     string `json:"mode"`
	Pid      string `json:"pid"`
	Status   string `json:"status"`
	Restart  string `json:"restart"`
	Uptime   string `json:"uptime"`
	Memory   string `json:"memory"`
	Watching string `json:"watching"`
}

type RamIntensiveProcesses

type RamIntensiveProcesses struct {
	Pid        int     `json:"pid"`
	User       string  `json:"user"`
	MemPercent float64 `json:"mem_percent"`
	Rss        int     `json:"rss"`
	Vsz        int     `json:"vsz"`
	Cmd        string  `json:"cmd"`
}

type RecentAccountLogins

type RecentAccountLogins struct {
	User string `json:"user"`
	Ip   string `json:"ip"`
	Date string `json:"date"`
}

type Redis

type Redis struct {
	RedisVersion             string `json:"redis_version"`
	ConnectedClients         string `json:"connected_clients"`
	ConnectedSlaves          string `json:"connected_slaves"`
	UsedMemoryHuman          string `json:"used_memory_human"`
	TotalConnectionsReceived string `json:"total_connections_received"`
	TotalCommandsProcessed   string `json:"total_commands_processed"`
}

type ScheduledCrons

type ScheduledCrons struct {
	Min   string `json:"min"`
	Hrs   string `json:"hrs"`
	Day   string `json:"day"`
	Month string `json:"month"`
	Wkday string `json:"wkday"`
	User  string `json:"user"`
	Cmd   string `json:"cmd"`
}

type Swap

type Swap struct {
	Filename string `json:"filename"`
	Type     string `json:"type"`
	Size     string `json:"size"`
	Used     string `json:"used"`
	Priority string `json:"priority"`
}

type UploadTransferRate

type UploadTransferRate struct {
	Interface    string `json:"interface"`
	TransferRate int    `json:"transfer_rate"`
}

type UserAccounts

type UserAccounts struct {
	Type string `json:"type"`
	User string `json:"user"`
	Home string `json:"home"`
}

Jump to

Keyboard shortcuts

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