Add input plugin for monit (#6850)

This commit is contained in:
SirishaGopigiri 2020-01-23 04:15:18 +05:30 committed by Daniel Nelson
parent 9747fa7f07
commit 9fd400c9ac
20 changed files with 2178 additions and 0 deletions

View File

@ -91,6 +91,7 @@ import (
_ "github.com/influxdata/telegraf/plugins/inputs/mesos"
_ "github.com/influxdata/telegraf/plugins/inputs/minecraft"
_ "github.com/influxdata/telegraf/plugins/inputs/mongodb"
_ "github.com/influxdata/telegraf/plugins/inputs/monit"
_ "github.com/influxdata/telegraf/plugins/inputs/mqtt_consumer"
_ "github.com/influxdata/telegraf/plugins/inputs/multifile"
_ "github.com/influxdata/telegraf/plugins/inputs/mysql"

View File

@ -0,0 +1,148 @@
# Monit Plugin
The monit plugin gathers metrics and status information about local processes,
remote hosts, file, file systems, directories and network interfaces managed and watched over by Monit.
To install Monit agent on the host please refer to the link https://mmonit.com/wiki/Monit/Installation
Minimum Version of Monit tested with is 5.16
### Configuration:
```toml
# Read metrics and status information about processes managed by Monit
[[inputs.monit]]
#SampleConfig
address = "http://127.0.0.1:2812"
basic_auth_username = "test"
basic_auth_password = "test"
```
### Tags:
All measurements have the following tags:
- address
- version
- service
- paltform_name
- status
- monitoring_status
- monitoring_mode
### Measurements & Fields:
<optional description>
### Fields:
Fields for all Monit service types:
- status_code
- monitoring_status_code
- monitoring_mode_code
### Measurement & Fields:
Fields for Monit service type Filesystem:
- Measurement:
- monit_filesystem
- Fields:
- mode
- block_percent
- block_usage
- block_total
- inode_percent
- inode_usage
- inode_total
Fields for Monit service type directory:
- Measurement:
- monit_directory
- Fields:
- permissions
Fields for Monit service type file:
- Measurement:
- monit_file
- Fields:
- size
- permissions
Fields for Monit service type process:
- Measurement:
- monit_process
- Fields:
- cpu_percent
- cpu_percent_total
- mem_kb
- mem_kb_total
- mem_percent
- mem_percent_total
- pid
- parent_pid
- threads
- children
Fields for Monit service type remote host:
- Measurement:
- monit_remote_host
- Fields:
- hostname
- port_number
- request
- protocol
- type
Fields for Monit service type system:
- Measurement:
- monit_system
- Fields:
- cpu_system
- cpu_user
- cpu_wait
- cpu_load_avg_1m
- cpu_load_avg_5m
- cpu_load_avg_15m
- mem_kb
- mem_percent
- swap_kb
- swap_percent
Fields for Monit service type fifo:
- Measurement:
- monit_fifo
- Fields:
- permissions
Fields for Monit service type program:
- Measurement:
- monit_program
- Fields:
- last_started_time
- program_status
Fields for Monit service type network:
- Measurement:
- monit_network
- Fields:
- link_state
- link_mode
- link_speed
- download_packets_now
- download_packets_total
- download_bytes_now
- download_bytes_total
- download_errors_now
- download_errors_total
- upload_packets_now
- upload_packets_total
- upload_bytes_now
- upload_bytes_total
- upload_errors_now
- upload_errors_total
### Example Output:
```
$ ./telegraf -config telegraf.conf -input-filter monit -test
monit_system,address=http://localhost:2812,host=verizon-onap,hostname=verizon-onap,monitoring_mode=Monitoring\ mode:\ \ active,monitoring_status=Monitoring\ status:\ \ Monitored,platform_name=Linux,service=verizon-onap,status=Running,version=5.16 status_code=0i,cpu_system=1.9,cpu_user=4.7,cpu_wait=1.5,cpu_load_avg_1m=1.24,cpu_load_avg_5m=1.68,mem_percent=67.1,monitoring_status_code=1i,monitoring_mode_code=0i,cpu_load_avg_15m=1.64,mem_kb=10961012i,swap_kb=2322688,swap_percent=13.9 1578636430000000000
monit_remote_host,address=http://localhost:2812,host=verizon-onap,hostname=verizon-onap,monitoring_mode=Monitoring\ mode:\ \ passive,monitoring_status=Monitoring\ status:\ \ Monitored,platform_name=Linux,service=testing,status=Failure,version=5.16 status_code=32i,monitoring_status_code=1i,monitoring_mode_code=1i,remote_hostname="192.168.10.49",port_number=2220i,request="",protocol="DEFAULT",type="TCP" 1578636430000000000
monit_fifo,address=http://localhost:2812,host=verizon-onap,hostname=verizon-onap,monitoring_mode=Monitoring\ mode:\ \ active,monitoring_status=Monitoring\ status:\ \ Monitored,platform_name=Linux,service=test2,status=Running,version=5.16 status_code=0i,monitoring_status_code=1i,monitoring_mode_code=0i,permissions=664i 1578636430000000000
monit_network,address=http://localhost:2812,host=verizon-onap,hostname=verizon-onap,monitoring_mode=Monitoring\ mode:\ \ active,monitoring_status=Monitoring\ status:\ \ Monitored,platform_name=Linux,service=test1,status=Failure,version=5.16 monitoring_status_code=1i,monitoring_mode_code=0i,download_packets_total=0i,upload_bytes_now=0i,download_errors_total=0i,status_code=8388608i,link_speed=-1i,link_mode="Unknown Mode",download_bytes_now=0i,download_bytes_total=0i,download_errors_now=0i,upload_packets_total=0i,upload_bytes_total=0i,upload_errors_now=0i,upload_errors_total=0i,link_state=0i,download_packets_now=0i,upload_packets_now=0i 1578636430000000000
monit_directory,address=http://localhost:2812,host=verizon-onap,hostname=verizon-onap,monitoring_mode=Monitoring\ mode:\ \ passive,monitoring_status=Monitoring\ status:\ \ Monitored,platform_name=Linux,service=test,status=Running,version=5.16 status_code=0i,monitoring_status_code=1i,monitoring_mode_code=1i,permissions=755i 1578636430000000000
```

View File

@ -0,0 +1,434 @@
package monit
import (
"encoding/xml"
"fmt"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/tls"
"github.com/influxdata/telegraf/plugins/inputs"
"golang.org/x/net/html/charset"
"net/http"
)
const (
fileSystem string = "0"
directory = "1"
file = "2"
process = "3"
remoteHost = "4"
system = "5"
fifo = "6"
program = "7"
network = "8"
)
var pendingActions = []string{"ignore", "alert", "restart", "stop", "exec", "unmonitor", "start", "monitor"}
type Status struct {
Server Server `xml:"server"`
Platform Platform `xml:"platform"`
Services []Service `xml:"service"`
}
type Server struct {
ID string `xml:"id"`
Version string `xml:"version"`
Uptime int64 `xml:"uptime"`
Poll int `xml:"poll"`
LocalHostname string `xml:"localhostname"`
StartDelay int `xml:"startdelay"`
ControlFile string `xml:"controlfile"`
}
type Platform struct {
Name string `xml:"name"`
Release string `xml:"release"`
Version string `xml:"version"`
Machine string `xml:"machine"`
CPU int `xml:"cpu"`
Memory int `xml:"memory"`
Swap int `xml:"swap"`
}
type Service struct {
Type string `xml:"type,attr"`
Name string `xml:"name"`
Status int `xml:"status"`
MonitoringStatus int `xml:"monitor"`
MonitorMode int `xml:"monitormode"`
PendingAction int `xml:"pendingaction"`
Memory Memory `xml:"memory"`
CPU CPU `xml:"cpu"`
System System `xml:"system"`
Size int64 `xml:"size"`
Mode int `xml:"mode"`
Program Program `xml:"program"`
Block Block `xml:"block"`
Inode Inode `xml:"inode"`
Pid int64 `xml:"pid"`
ParentPid int64 `xml:"ppid"`
Threads int `xml:"threads"`
Children int `xml:"children"`
Port Port `xml:"port"`
Link Link `xml:"link"`
}
type Link struct {
State int `xml:"state"`
Speed int64 `xml:"speed"`
Duplex int `xml:"duplex"`
Download Download `xml:"download"`
Upload Upload `xml:"upload"`
}
type Download struct {
Packets struct {
Now int64 `xml:"now"`
Total int64 `xml:"total"`
} `xml:"packets"`
Bytes struct {
Now int64 `xml:"now"`
Total int64 `xml:"total"`
} `xml:"bytes"`
Errors struct {
Now int64 `xml:"now"`
Total int64 `xml:"total"`
} `xml:"errors"`
}
type Upload struct {
Packets struct {
Now int64 `xml:"now"`
Total int64 `xml:"total"`
} `xml:"packets"`
Bytes struct {
Now int64 `xml:"now"`
Total int64 `xml:"total"`
} `xml:"bytes"`
Errors struct {
Now int64 `xml:"now"`
Total int64 `xml:"total"`
} `xml:"errors"`
}
type Port struct {
Hostname string `xml:"hostname"`
PortNumber int64 `xml:"portnumber"`
Request string `xml:"request"`
Protocol string `xml:"protocol"`
Type string `xml:"type"`
}
type Block struct {
Percent float64 `xml:"percent"`
Usage float64 `xml:"usage"`
Total float64 `xml:"total"`
}
type Inode struct {
Percent float64 `xml:"percent"`
Usage float64 `xml:"usage"`
Total float64 `xml:"total"`
}
type Program struct {
Started int64 `xml:"started"`
Status int `xml:"status"`
}
type Memory struct {
Percent float64 `xml:"percent"`
PercentTotal float64 `xml:"percenttotal"`
Kilobyte int64 `xml:"kilobyte"`
KilobyteTotal int64 `xml:"kilobytetotal"`
}
type CPU struct {
Percent float64 `xml:"percent"`
PercentTotal float64 `xml:"percenttotal"`
}
type System struct {
Load struct {
Avg01 float64 `xml:"avg01"`
Avg05 float64 `xml:"avg05"`
Avg15 float64 `xml:"avg15"`
} `xml:"load"`
CPU struct {
User float64 `xml:"user"`
System float64 `xml:"system"`
Wait float64 `xml:"wait"`
} `xml:"cpu"`
Memory struct {
Percent float64 `xml:"percent"`
Kilobyte int64 `xml:"kilobyte"`
} `xml:"memory"`
Swap struct {
Percent float64 `xml:"percent"`
Kilobyte float64 `xml:"kilobyte"`
} `xml:"swap"`
}
type Monit struct {
Address string `toml:"address"`
Username string `toml:"username"`
Password string `toml:"password"`
client HTTPClient
tls.ClientConfig
Timeout internal.Duration `toml:"timeout"`
}
type HTTPClient interface {
MakeRequest(req *http.Request) (*http.Response, error)
SetHTTPClient(client *http.Client)
HTTPClient() *http.Client
}
type Messagebody struct {
Metrics []string `json:"metrics"`
}
type RealHTTPClient struct {
client *http.Client
}
func (c *RealHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) {
return c.client.Do(req)
}
func (c *RealHTTPClient) SetHTTPClient(client *http.Client) {
c.client = client
}
func (c *RealHTTPClient) HTTPClient() *http.Client {
return c.client
}
func (m *Monit) Description() string {
return "Read metrics and status information about processes managed by Monit"
}
var sampleConfig = `
## Monit
address = "http://127.0.0.1:2812"
## Username and Password for Monit
username = ""
password = ""
## Amount of time allowed to complete the HTTP request
# timeout = "5s"
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
`
func (m *Monit) SampleConfig() string {
return sampleConfig
}
func (m *Monit) Init() error {
tlsCfg, err := m.ClientConfig.TLSConfig()
if err != nil {
return err
}
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsCfg,
Proxy: http.ProxyFromEnvironment,
},
Timeout: m.Timeout.Duration,
}
m.client.SetHTTPClient(client)
return nil
}
func (m *Monit) Gather(acc telegraf.Accumulator) error {
req, err := http.NewRequest("GET", fmt.Sprintf("%s/_status?format=xml", m.Address), nil)
if err != nil {
return err
}
if len(m.Username) > 0 || len(m.Password) > 0 {
req.SetBasicAuth(m.Username, m.Password)
}
resp, err := m.client.MakeRequest(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
var status Status
decoder := xml.NewDecoder(resp.Body)
decoder.CharsetReader = charset.NewReaderLabel
if err := decoder.Decode(&status); err != nil {
return fmt.Errorf("error parsing input: %v", err)
}
tags := map[string]string{
"version": status.Server.Version,
"source": status.Server.LocalHostname,
"platform_name": status.Platform.Name,
}
for _, service := range status.Services {
fields := make(map[string]interface{})
tags["status"] = serviceStatus(service)
fields["status_code"] = service.Status
tags["pending_action"] = pendingAction(service)
fields["pending_action_code"] = service.PendingAction
tags["monitoring_status"] = monitoringStatus(service)
fields["monitoring_status_code"] = service.MonitoringStatus
tags["monitoring_mode"] = monitoringMode(service)
fields["monitoring_mode_code"] = service.MonitorMode
tags["service"] = service.Name
if service.Type == fileSystem {
fields["mode"] = service.Mode
fields["block_percent"] = service.Block.Percent
fields["block_usage"] = service.Block.Usage
fields["block_total"] = service.Block.Total
fields["inode_percent"] = service.Inode.Percent
fields["inode_usage"] = service.Inode.Usage
fields["inode_total"] = service.Inode.Total
acc.AddFields("monit_filesystem", fields, tags)
} else if service.Type == directory {
fields["mode"] = service.Mode
acc.AddFields("monit_directory", fields, tags)
} else if service.Type == file {
fields["size"] = service.Size
fields["mode"] = service.Mode
acc.AddFields("monit_file", fields, tags)
} else if service.Type == process {
fields["cpu_percent"] = service.CPU.Percent
fields["cpu_percent_total"] = service.CPU.PercentTotal
fields["mem_kb"] = service.Memory.Kilobyte
fields["mem_kb_total"] = service.Memory.KilobyteTotal
fields["mem_percent"] = service.Memory.Percent
fields["mem_percent_total"] = service.Memory.PercentTotal
fields["pid"] = service.Pid
fields["parent_pid"] = service.ParentPid
fields["threads"] = service.Threads
fields["children"] = service.Children
acc.AddFields("monit_process", fields, tags)
} else if service.Type == remoteHost {
fields["remote_hostname"] = service.Port.Hostname
fields["port_number"] = service.Port.PortNumber
fields["request"] = service.Port.Request
fields["protocol"] = service.Port.Protocol
fields["type"] = service.Port.Type
acc.AddFields("monit_remote_host", fields, tags)
} else if service.Type == system {
fields["cpu_system"] = service.System.CPU.System
fields["cpu_user"] = service.System.CPU.User
fields["cpu_wait"] = service.System.CPU.Wait
fields["cpu_load_avg_1m"] = service.System.Load.Avg01
fields["cpu_load_avg_5m"] = service.System.Load.Avg05
fields["cpu_load_avg_15m"] = service.System.Load.Avg15
fields["mem_kb"] = service.System.Memory.Kilobyte
fields["mem_percent"] = service.System.Memory.Percent
fields["swap_kb"] = service.System.Swap.Kilobyte
fields["swap_percent"] = service.System.Swap.Percent
acc.AddFields("monit_system", fields, tags)
} else if service.Type == fifo {
fields["mode"] = service.Mode
acc.AddFields("monit_fifo", fields, tags)
} else if service.Type == program {
fields["program_started"] = service.Program.Started * 10000000
fields["program_status"] = service.Program.Status
acc.AddFields("monit_program", fields, tags)
} else if service.Type == network {
fields["link_state"] = service.Link.State
fields["link_speed"] = service.Link.Speed
fields["link_mode"] = linkMode(service)
fields["download_packets_now"] = service.Link.Download.Packets.Now
fields["download_packets_total"] = service.Link.Download.Packets.Total
fields["download_bytes_now"] = service.Link.Download.Bytes.Now
fields["download_bytes_total"] = service.Link.Download.Bytes.Total
fields["download_errors_now"] = service.Link.Download.Errors.Now
fields["download_errors_total"] = service.Link.Download.Errors.Total
fields["upload_packets_now"] = service.Link.Upload.Packets.Now
fields["upload_packets_total"] = service.Link.Upload.Packets.Total
fields["upload_bytes_now"] = service.Link.Upload.Bytes.Now
fields["upload_bytes_total"] = service.Link.Upload.Bytes.Total
fields["upload_errors_now"] = service.Link.Upload.Errors.Now
fields["upload_errors_total"] = service.Link.Upload.Errors.Total
acc.AddFields("monit_network", fields, tags)
}
}
} else {
return fmt.Errorf("received status code %d (%s), expected 200",
resp.StatusCode,
http.StatusText(resp.StatusCode))
}
return nil
}
func linkMode(s Service) string {
if s.Link.Duplex == 1 {
return "duplex"
} else if s.Link.Duplex == 0 {
return "simplex"
} else {
return "unknown"
}
}
func serviceStatus(s Service) string {
if s.Status == 0 {
return "running"
} else {
return "failure"
}
}
func pendingAction(s Service) string {
if s.PendingAction > 0 {
if s.PendingAction >= len(pendingActions) {
return "unknown"
}
return pendingActions[s.PendingAction-1]
} else {
return "none"
}
}
func monitoringMode(s Service) string {
switch s.MonitorMode {
case 0:
return "active"
case 1:
return "passive"
}
return "unknown"
}
func monitoringStatus(s Service) string {
switch s.MonitoringStatus {
case 1:
return "monitored"
case 2:
return "initializing"
case 4:
return "waiting"
}
return "not_monitored"
}
func init() {
inputs.Add("monit", func() telegraf.Input {
return &Monit{
client: &RealHTTPClient{},
}
})
}

View File

@ -0,0 +1,719 @@
package monit
import (
"errors"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type MockHTTPClient struct {
networkError string
}
func (c *MockHTTPClient) MakeRequest(req *http.Request) (*http.Response, error) {
return nil, errors.New(c.networkError)
}
func (c *MockHTTPClient) SetHTTPClient(client *http.Client) {
}
func (c *MockHTTPClient) HTTPClient() *http.Client {
return nil
}
func TestServiceType(t *testing.T) {
tests := []struct {
name string
filename string
expected []telegraf.Metric
}{
{
name: "check filesystem service type",
filename: "testdata/response_servicetype_0.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_filesystem",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"mode": 555,
"block_percent": 29.5,
"block_usage": 4424.0,
"block_total": 14990.0,
"inode_percent": 0.8,
"inode_usage": 59674.0,
"inode_total": 7680000.0,
},
time.Unix(0, 0),
),
},
},
{
name: "check directory service type",
filename: "testdata/response_servicetype_1.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_directory",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"mode": 755,
},
time.Unix(0, 0),
),
},
},
{
name: "check file service type",
filename: "testdata/response_servicetype_2.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_file",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"mode": 644,
"size": 1565,
},
time.Unix(0, 0),
),
},
},
{
name: "check process service type",
filename: "testdata/response_servicetype_3.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_process",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"cpu_percent": 0.0,
"cpu_percent_total": 0.0,
"mem_kb": 22892,
"mem_kb_total": 22892,
"mem_percent": 0.1,
"mem_percent_total": 0.1,
"pid": 5959,
"parent_pid": 1,
"threads": 31,
"children": 0,
},
time.Unix(0, 0),
),
},
},
{
name: "check remote host service type",
filename: "testdata/response_servicetype_4.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_remote_host",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"remote_hostname": "192.168.1.10",
"port_number": 2812,
"request": "",
"protocol": "DEFAULT",
"type": "TCP",
},
time.Unix(0, 0),
),
},
},
{
name: "check system service type",
filename: "testdata/response_servicetype_5.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_system",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"cpu_system": 0.1,
"cpu_user": 0.0,
"cpu_wait": 0.0,
"cpu_load_avg_1m": 0.00,
"cpu_load_avg_5m": 0.00,
"cpu_load_avg_15m": 0.00,
"mem_kb": 259668,
"mem_percent": 1.5,
"swap_kb": 0.0,
"swap_percent": 0.0,
},
time.Unix(0, 0),
),
},
},
{
name: "check fifo service type",
filename: "testdata/response_servicetype_6.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_fifo",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"mode": 664,
},
time.Unix(0, 0),
),
},
},
{
name: "check program service type",
filename: "testdata/response_servicetype_7.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_program",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"program_status": 0,
"program_started": int64(15728504980000000),
},
time.Unix(0, 0),
),
},
},
{
name: "check network service type",
filename: "testdata/response_servicetype_8.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_network",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"link_speed": 1000000000,
"link_mode": "duplex",
"link_state": 1,
"download_packets_now": 0,
"download_packets_total": 15243,
"download_bytes_now": 0,
"download_bytes_total": 5506778,
"download_errors_now": 0,
"download_errors_total": 0,
"upload_packets_now": 0,
"upload_packets_total": 8822,
"upload_bytes_now": 0,
"upload_bytes_total": 1287240,
"upload_errors_now": 0,
"upload_errors_total": 0,
},
time.Unix(0, 0),
),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/_status":
http.ServeFile(w, r, tt.filename)
default:
w.WriteHeader(http.StatusNotFound)
}
}))
defer ts.Close()
plugin := &Monit{
Address: ts.URL,
client: &RealHTTPClient{},
}
plugin.Init()
var acc testutil.Accumulator
err := plugin.Gather(&acc)
require.NoError(t, err)
testutil.RequireMetricsEqual(t, tt.expected, acc.GetTelegrafMetrics(),
testutil.IgnoreTime())
})
}
}
func TestMonitFailure(t *testing.T) {
tests := []struct {
name string
filename string
expected []telegraf.Metric
}{
{
name: "check monit failure status",
filename: "testdata/response_servicetype_8_failure.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_network",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "failure",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 8388608,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"link_speed": -1,
"link_mode": "unknown",
"link_state": 0,
"download_packets_now": 0,
"download_packets_total": 0,
"download_bytes_now": 0,
"download_bytes_total": 0,
"download_errors_now": 0,
"download_errors_total": 0,
"upload_packets_now": 0,
"upload_packets_total": 0,
"upload_bytes_now": 0,
"upload_bytes_total": 0,
"upload_errors_now": 0,
"upload_errors_total": 0,
},
time.Unix(0, 0),
),
},
},
{
name: "check passive mode",
filename: "testdata/response_servicetype_8_passivemode.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_network",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "passive",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 1,
"pending_action_code": 0,
"link_speed": 1000000000,
"link_mode": "duplex",
"link_state": 1,
"download_packets_now": 0,
"download_packets_total": 15243,
"download_bytes_now": 0,
"download_bytes_total": 5506778,
"download_errors_now": 0,
"download_errors_total": 0,
"upload_packets_now": 0,
"upload_packets_total": 8822,
"upload_bytes_now": 0,
"upload_bytes_total": 1287240,
"upload_errors_now": 0,
"upload_errors_total": 0,
},
time.Unix(0, 0),
),
},
},
{
name: "check initializing status",
filename: "testdata/response_servicetype_8_initializingmode.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_network",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "initializing",
"monitoring_mode": "active",
"pending_action": "none",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 2,
"monitoring_mode_code": 0,
"pending_action_code": 0,
"link_speed": 1000000000,
"link_mode": "duplex",
"link_state": 1,
"download_packets_now": 0,
"download_packets_total": 15243,
"download_bytes_now": 0,
"download_bytes_total": 5506778,
"download_errors_now": 0,
"download_errors_total": 0,
"upload_packets_now": 0,
"upload_packets_total": 8822,
"upload_bytes_now": 0,
"upload_bytes_total": 1287240,
"upload_errors_now": 0,
"upload_errors_total": 0,
},
time.Unix(0, 0),
),
},
},
{
name: "check pending action",
filename: "testdata/response_servicetype_8_pendingaction.xml",
expected: []telegraf.Metric{
testutil.MustMetric(
"monit_network",
map[string]string{
"version": "5.17.1",
"source": "localhost",
"platform_name": "Linux",
"service": "test",
"status": "running",
"monitoring_status": "monitored",
"monitoring_mode": "active",
"pending_action": "exec",
},
map[string]interface{}{
"status_code": 0,
"monitoring_status_code": 1,
"monitoring_mode_code": 0,
"pending_action_code": 5,
"link_speed": 1000000000,
"link_mode": "duplex",
"link_state": 1,
"download_packets_now": 0,
"download_packets_total": 15243,
"download_bytes_now": 0,
"download_bytes_total": 5506778,
"download_errors_now": 0,
"download_errors_total": 0,
"upload_packets_now": 0,
"upload_packets_total": 8822,
"upload_bytes_now": 0,
"upload_bytes_total": 1287240,
"upload_errors_now": 0,
"upload_errors_total": 0,
},
time.Unix(0, 0),
),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/_status":
http.ServeFile(w, r, tt.filename)
default:
w.WriteHeader(http.StatusNotFound)
}
}))
defer ts.Close()
plugin := &Monit{
Address: ts.URL,
client: &RealHTTPClient{},
}
plugin.Init()
var acc testutil.Accumulator
err := plugin.Gather(&acc)
require.NoError(t, err)
testutil.RequireMetricsEqual(t, tt.expected, acc.GetTelegrafMetrics(),
testutil.IgnoreTime())
})
}
}
func checkAuth(r *http.Request, username, password string) bool {
user, pass, ok := r.BasicAuth()
if !ok {
return false
}
return user == username && pass == password
}
func TestAllowHosts(t *testing.T) {
networkError := "Get http://127.0.0.1:2812/_status?format=xml: " +
"read tcp 192.168.10.2:55610->127.0.0.1:2812: " +
"read: connection reset by peer"
r := &Monit{
Address: "http://127.0.0.1:2812",
Username: "test",
Password: "test",
client: &MockHTTPClient{networkError},
}
var acc testutil.Accumulator
r.Init()
err := r.Gather(&acc)
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "read: connection reset by peer")
}
}
func TestConnection(t *testing.T) {
r := &Monit{
Address: "http://127.0.0.1:2812",
Username: "test",
Password: "test",
client: &RealHTTPClient{},
}
var acc testutil.Accumulator
r.Init()
err := r.Gather(&acc)
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "connect: connection refused")
}
}
func TestInvalidUsernameorPassword(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !checkAuth(r, "testing", "testing") {
http.Error(w, "Unauthorized.", 401)
return
}
switch r.URL.Path {
case "/_status":
http.ServeFile(w, r, "testdata/response_servicetype_0.xml")
default:
panic("Cannot handle request")
}
}))
defer ts.Close()
r := &Monit{
Address: ts.URL,
Username: "test",
Password: "test",
client: &RealHTTPClient{},
}
var acc testutil.Accumulator
r.Init()
err := r.Gather(&acc)
assert.EqualError(t, err, "received status code 401 (Unauthorized), expected 200")
}
func TestNoUsernameorPasswordConfiguration(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !checkAuth(r, "testing", "testing") {
http.Error(w, "Unauthorized.", 401)
return
}
switch r.URL.Path {
case "/_status":
http.ServeFile(w, r, "testdata/response_servicetype_0.xml")
default:
panic("Cannot handle request")
}
}))
defer ts.Close()
r := &Monit{
Address: ts.URL,
client: &RealHTTPClient{},
}
var acc testutil.Accumulator
r.Init()
err := r.Gather(&acc)
assert.EqualError(t, err, "received status code 401 (Unauthorized), expected 200")
}
func TestInvalidXMLAndInvalidTypes(t *testing.T) {
tests := []struct {
name string
filename string
}{
{
name: "check filesystem service type",
filename: "testdata/response_invalidxml_1.xml",
},
{
name: "check filesystem service type",
filename: "testdata/response_invalidxml_2.xml",
},
{
name: "check filesystem service type",
filename: "testdata/response_invalidxml_3.xml",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/_status":
http.ServeFile(w, r, tt.filename)
default:
w.WriteHeader(http.StatusNotFound)
}
}))
defer ts.Close()
plugin := &Monit{
Address: ts.URL,
client: &RealHTTPClient{},
}
plugin.Init()
var acc testutil.Accumulator
err := plugin.Gather(&acc)
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "error parsing input:")
}
})
}
}

View File

@ -0,0 +1,51 @@
<!--Missing element <block> closed-->
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="0">
<name>test</name>
<collected_sec>1572850498</collected_sec>
<collected_usec>709694</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<mode>555</mode>
<uid>0</uid>
<gid>0</gid>
<flags>4096</flags>
<block>
<percent>29.5</percent>
<usage>4424.0</usage>
<total>14990.0</total>
<inode>
<percent>0.8</percent>
<usage>59674</usage>
<total>7680000</total>
</inode>
</service>
</monit>

View File

@ -0,0 +1,52 @@
<!--Wrong status type-->
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="0">
<name>test</name>
<collected_sec>1572850498</collected_sec>
<collected_usec>709694</collected_usec>
<status>0.0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<mode>555</mode>
<uid>0</uid>
<gid>0</gid>
<flags>4096</flags>
<block>
<percent>29.5</percent>
<usage>4424.0</usage>
<total>14990.0</total>
</block>
<inode>
<percent>0.8</percent>
<usage>59674</usage>
<total>7680000</total>
</inode>
</service>
</monit>

View File

@ -0,0 +1,52 @@
<!--Unsupported encoding type-->
<?xml version="1.0" encoding="UTF-16"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="0">
<name>test</name>
<collected_sec>1572850498</collected_sec>
<collected_usec>709694</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<mode>555</mode>
<uid>0</uid>
<gid>0</gid>
<flags>4096</flags>
<block>
<percent>29.5</percent>
<usage>4424.0</usage>
<total>14990.0</total>
</block>
<inode>
<percent>0.8</percent>
<usage>59674</usage>
<total>7680000</total>
</inode>
</service>
</monit>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="0">
<name>test</name>
<collected_sec>1572850498</collected_sec>
<collected_usec>709694</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<mode>555</mode>
<uid>0</uid>
<gid>0</gid>
<flags>4096</flags>
<block>
<percent>29.5</percent>
<usage>4424.0</usage>
<total>14990.0</total>
</block>
<inode>
<percent>0.8</percent>
<usage>59674</usage>
<total>7680000</total>
</inode>
</service>
</monit>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="1">
<name>test</name>
<collected_sec>1572850342</collected_sec>
<collected_usec>546082</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<mode>755</mode>
<uid>0</uid>
<gid>0</gid>
<timestamp>1572272434</timestamp>
</service>
</monit>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="2">
<name>test</name>
<collected_sec>1476628305</collected_sec>
<collected_usec>302669</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<mode>644</mode>
<uid>1000</uid>
<gid>1000</gid>
<timestamp>1476518441</timestamp>
<size>1565</size>
</service>
</monit>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="3">
<name>test</name>
<collected_sec>1476628305</collected_sec>
<collected_usec>302552</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<pid>5959</pid>
<ppid>1</ppid>
<uptime>109870</uptime>
<children>0</children>
<threads>31</threads>
<memory>
<percent>0.1</percent>
<percenttotal>0.1</percenttotal>
<kilobyte>22892</kilobyte>
<kilobytetotal>22892</kilobytetotal>
</memory>
<cpu>
<percent>0.0</percent>
<percenttotal>0.0</percenttotal>
</cpu>
</service>
</monit>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="4">
<name>test</name>
<collected_sec>1572862451</collected_sec>
<collected_usec>947671</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<port>
<hostname>192.168.1.10</hostname>
<portnumber>2812</portnumber>
<request></request>
<protocol>DEFAULT</protocol>
<type>TCP</type>
<responsetime>0.000145</responsetime>
</port>
</service>
</monit>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="5">
<name>test</name>
<collected_sec>1476628305</collected_sec>
<collected_usec>302682</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<system>
<load>
<avg01>0.00</avg01>
<avg05>0.00</avg05>
<avg15>0.00</avg15>
</load>
<cpu>
<user>0.0</user>
<system>0.1</system>
<wait>0.0</wait>
</cpu>
<memory>
<percent>1.5</percent>
<kilobyte>259668</kilobyte>
</memory>
<swap>
<percent>0.0</percent>
<kilobyte>0</kilobyte>
</swap>
</system>
</service>
</monit>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="6">
<name>test</name>
<collected_sec>1572862451</collected_sec>
<collected_usec>947495</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<mode>664</mode>
<uid>1000</uid>
<gid>1000</gid>
<timestamp>1572271731</timestamp>
</service>
</monit>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="7">
<name>test</name>
<collected_sec>1572850498</collected_sec>
<collected_usec>710675</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<program>
<started>1572850498</started>
<status>0</status>
<output>Stats health check successful.</output>
</program>
</service>
</monit>

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="8">
<name>test</name>
<collected_sec>1572869770</collected_sec>
<collected_usec>807562</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<link>
<state>1</state>
<speed>1000000000</speed>
<duplex>1</duplex>
<download>
<packets>
<now>0</now>
<total>15243</total>
</packets>
<bytes>
<now>0</now>
<total>5506778</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</download>
<upload>
<packets>
<now>0</now>
<total>8822</total>
</packets>
<bytes>
<now>0</now>
<total>1287240</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</upload>
</link>
</service>
</monit>

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="8">
<name>test</name>
<collected_sec>1572869770</collected_sec>
<collected_usec>807562</collected_usec>
<status>8388608</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<link>
<state>0</state>
<speed>-1</speed>
<duplex>-1</duplex>
<download>
<packets>
<now>0</now>
<total>0</total>
</packets>
<bytes>
<now>0</now>
<total>0</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</download>
<upload>
<packets>
<now>0</now>
<total>0</total>
</packets>
<bytes>
<now>0</now>
<total>0</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</upload>
</link>
</service>
</monit>

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="8">
<name>test</name>
<collected_sec>1572869770</collected_sec>
<collected_usec>807562</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>2</monitor>
<monitormode>0</monitormode>
<pendingaction>0</pendingaction>
<link>
<state>1</state>
<speed>1000000000</speed>
<duplex>1</duplex>
<download>
<packets>
<now>0</now>
<total>15243</total>
</packets>
<bytes>
<now>0</now>
<total>5506778</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</download>
<upload>
<packets>
<now>0</now>
<total>8822</total>
</packets>
<bytes>
<now>0</now>
<total>1287240</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</upload>
</link>
</service>
</monit>

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="8">
<name>test</name>
<collected_sec>1572869770</collected_sec>
<collected_usec>807562</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>1</monitormode>
<pendingaction>0</pendingaction>
<link>
<state>1</state>
<speed>1000000000</speed>
<duplex>1</duplex>
<download>
<packets>
<now>0</now>
<total>15243</total>
</packets>
<bytes>
<now>0</now>
<total>5506778</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</download>
<upload>
<packets>
<now>0</now>
<total>8822</total>
</packets>
<bytes>
<now>0</now>
<total>1287240</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</upload>
</link>
</service>
</monit>

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<monit>
<server>
<id>0ed39c522be4c3971541412c43141613</id>
<incarnation>1476518435</incarnation>
<version>5.17.1</version>
<uptime>109878</uptime>
<poll>10</poll>
<startdelay>0</startdelay>
<localhostname>localhost</localhostname>
<controlfile>/var/vcap/bosh/etc/monitrc</controlfile>
<httpd>
<address>127.0.0.1</address>
<port>2822</port>
<ssl>0</ssl>
</httpd>
</server>
<platform>
<name>Linux</name>
<release>4.15.0-65-generic</release>
<version>#74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019</version>
<machine>x86_64</machine>
<cpu>8</cpu>
<memory>16432272</memory>
<swap>16432268</swap>
</platform>
<service type="8">
<name>test</name>
<collected_sec>1572869770</collected_sec>
<collected_usec>807562</collected_usec>
<status>0</status>
<status_hint>0</status_hint>
<monitor>1</monitor>
<monitormode>0</monitormode>
<pendingaction>5</pendingaction>
<link>
<state>1</state>
<speed>1000000000</speed>
<duplex>1</duplex>
<download>
<packets>
<now>0</now>
<total>15243</total>
</packets>
<bytes>
<now>0</now>
<total>5506778</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</download>
<upload>
<packets>
<now>0</now>
<total>8822</total>
</packets>
<bytes>
<now>0</now>
<total>1287240</total>
</bytes>
<errors>
<now>0</now>
<total>0</total>
</errors>
</upload>
</link>
</service>
</monit>