Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MonitAgent ¶
type MonitAgent struct { Auth bool // Authentication needed AuthString string // Authentication info ex: admin:monit URL string // Monit httpd url, can be unix:///var/run/monit.sock, httpd://<host>:<port> Status *MonitStatus // Last Status Obtained from Monit // contains filtered or unexported fields }
MonitAgent Agent class that can :
- retrieve status from Monit Daemon
- Invoke Action on service (start / stop / monitor / unmonitor)
func NewMonitAgent ¶
func NewMonitAgent(url string, authString string) (*MonitAgent, error)
NewMonitAgent Create new MonitAgent instance and automatically try to connect to daemon and retrieve current status.
func (*MonitAgent) CmdService ¶
func (m *MonitAgent) CmdService(service string, action string) error
CmdService Perform command on service
func (*MonitAgent) RequestStatus ¶
func (m *MonitAgent) RequestStatus() error
RequestStatus Requests Monit daemon to retrieve current status
func (*MonitAgent) StartService ¶
func (m *MonitAgent) StartService(service string) error
StartService perform monit start <service> command
func (*MonitAgent) StopService ¶
func (m *MonitAgent) StopService(service string) error
StopService perform monit stop <service> command
type MonitStatus ¶
type MonitStatus struct { XMLName xml.Name `xml:"monit" json:"-"` Server Server `xml:"server" json:"server"` Platform Platform `xml:"platform" json:"platform"` Services []Service `xml:"service" json:"service"` }
MonitStatus This structure embedded all data returned by monit daemon
func (*MonitStatus) GetService ¶
func (r *MonitStatus) GetService(name string) *Service
GetService : Get Service info from Status
func (*MonitStatus) Load ¶
func (r *MonitStatus) Load(file io.Reader) error
Load : Load MonitStatus from io.Reader
func (*MonitStatus) Print ¶
func (r *MonitStatus) Print(w io.Writer)
Print : Dump Status to File (json format)
type NetStatElem ¶
NetStatElem parts of NetStats
type NetStats ¶
type NetStats struct { Packet *NetStatElem `xml:"packets" json:"packets"` Bytes *NetStatElem `xml:"bytes" json:"bytes"` Errors *NetStatElem `xml:"errors" json:"errors"` }
NetStats Link network statistics
type Platform ¶
type Platform struct { Memory int64 `xml:"memory" json:"memory"` Swap int64 `xml:"swap" json:"swap"` Name string `xml:"name" json:"name"` Release string `xml:"release" json:"release"` Version string `xml:"version" json:"version"` Machine string `xml:"machine" json:"machine"` CPU int `xml:"cpu" json:"cpu"` }
Platform "platform" part of MonitStatus
type Server ¶
type Server struct { Hostname string `xml:"localhostname" json:"localhostname"` ControlFile string `xml:"controlfile" json:"controlfile"` HTTPd struct { Address string `xml:"address" json:"address"` Port int `xml:"port" json:"port"` SSL int `xml:"ssl" json:"ssl"` } `xml:"httpd" json:"httpd"` Incarnation int64 `xml:"incarnation" json:"incarnation"` Version string `xml:"version" json:"version"` Uptime int `xml:"uptime" json:"uptime"` ID string `xml:"id" json:"id"` Poll int `xml:"poll" json:"poll"` StartDelay int `xml:"startdelay" json:"startdelay"` }
Server "server" part of MonitStatus
type Service ¶
type Service struct { Type int `xml:"type,attr" json:"type"` Name string `xml:"name" json:"name"` CollectedUsec int `xml:"collected_usec" json:"collected_usec"` Status int `xml:"status" json:"status"` MonitorMode int `xml:"monitormode" json:"monitormode"` Pid int `xml:"pid" json:"pid"` PPid *int `xml:"ppid" json:"ppid,omitempty"` UID *int `xml:"uid" json:"uid,omitempty"` EUID *int `xml:"euid" json:"euid,omitempty"` GID *int `xml:"gid,omitempty" json:"gid,omitempty"` Uptime int `xml:"uptime" json:"uptime"` Threads int `xml:"threads" json:"threads"` Children int `xml:"children" json:"children"` StatusHint int `xml:"status_hint" json:"status_hint"` OnReboot int `xml:"onreboot" json:"onreboot"` CollectedSec int `xml:"collected_sec" json:"collected_sec"` Monitor int `xml:"monitor" json:"monitor"` PendingAction int `xml:"pendingaction" json:"pendingaction"` CPU *struct { Percent float32 `xml:"percent" json:"percent"` PercentTotal float32 `xml:"percenttotal" json:"percenttotal"` } `xml:"cpu,omitempty" json:"cpu,omitempty"` // TODO <read></read> <write></write> Memory *struct { Percent float32 `xml:"percent" json:"percent"` PercentTotal float32 `xml:"percenttotal" json:"percenttotal"` KiloBytes int64 `xml:"kilobyte" json:"kilobyte"` KiloBytesTotal int64 `xml:"kilobytetotal" json:"kilobytetotal"` } `xml:"memory" json:"memory,omitempty"` System *struct { Swap struct { Percent float32 `xml:"percent" json:"percent"` KiloBytes int64 `xml:"kilobyte" json:"kilobyte"` } `xml:"swap" json:"swap"` Load struct { Avg01 float32 `xml:"avg01" json:"avg01"` Avg05 float32 `xml:"avg05" json:"avg05"` Avg15 float32 `xml:"avg15" json:"avg15"` } `xml:"load" json:"load"` CPU struct { User float32 `xml:"user" json:"user"` System float32 `xml:"system" json:"system"` Wait float32 `xml:"wait" json:"wait"` } `xml:"cpu" json:"cpu"` Memory struct { Percent float32 `xml:"percent" json:"percent"` KiloBytes int64 `xml:"kilobyte" json:"kilobyte"` } `xml:"memory" json:"memory"` } `xml:"system" json:"system,omitempty"` Link *struct { State int `xml:"state" json:"state"` Speed int64 `xml:"speed" json:"speed"` Duplex int `xml:"duplex" json:"duplex"` Download *NetStats `xml:"download" json:"download"` Upload *NetStats `xml:"upload" json:"upload"` } `xml:"link" json:"link,omitempty"` }
Service service entry which contains service status