Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add response_time to monit plugin #8056

Merged
merged 7 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/inputs/monit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Minimum Version of Monit tested with is 5.16.
- hostname
- port_number
- request
- response_time
- protocol
- type

Expand Down Expand Up @@ -232,4 +233,5 @@ monit_file,monitoring_mode=active,monitoring_status=monitored,pending_action=non
monit_process,monitoring_mode=active,monitoring_status=monitored,pending_action=none,platform_name=Linux,service=rsyslog,source=xyzzy.local,status=running,version=5.20.0 children=0i,cpu_percent=0,cpu_percent_total=0,mem_kb=3148i,mem_kb_total=3148i,mem_percent=0.2,mem_percent_total=0.2,monitoring_mode_code=0i,monitoring_status_code=1i,parent_pid=1i,pending_action_code=0i,pid=318i,status_code=0i,threads=4i 1579735047000000000
monit_program,monitoring_mode=active,monitoring_status=initializing,pending_action=none,platform_name=Linux,service=echo,source=xyzzy.local,status=running,version=5.20.0 monitoring_mode_code=0i,monitoring_status_code=2i,pending_action_code=0i,program_started=0i,program_status=0i,status_code=0i 1579735047000000000
monit_system,monitoring_mode=active,monitoring_status=monitored,pending_action=none,platform_name=Linux,service=debian-stretch-monit.virt,source=xyzzy.local,status=running,version=5.20.0 cpu_load_avg_15m=0,cpu_load_avg_1m=0,cpu_load_avg_5m=0,cpu_system=0,cpu_user=0,cpu_wait=0,mem_kb=42852i,mem_percent=2.1,monitoring_mode_code=0i,monitoring_status_code=1i,pending_action_code=0i,status_code=0i,swap_kb=0,swap_percent=0 1579735047000000000
monit_remote_host,dc=new-12,host=palladium,monitoring_mode=active,monitoring_status=monitored,pending_action=none,platform_name=Linux,rack=rack-0,service=blog.kalvad.com,source=palladium,status=running,version=5.27.0 monitoring_status_code=1i,monitoring_mode_code=0i,response_time=0.664412,type="TCP",pending_action_code=0i,remote_hostname="blog.kalvad.com",port_number=443i,request="/",protocol="HTTP",status_code=0i 1599138990000000000
```
12 changes: 7 additions & 5 deletions plugins/inputs/monit/monit.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ type Upload struct {
}

type Port struct {
Hostname string `xml:"hostname"`
PortNumber int64 `xml:"portnumber"`
Request string `xml:"request"`
Protocol string `xml:"protocol"`
Type string `xml:"type"`
Hostname string `xml:"hostname"`
PortNumber int64 `xml:"portnumber"`
Request string `xml:"request"`
ResponseTime float64 `xml:"responsetime"`
Protocol string `xml:"protocol"`
Type string `xml:"type"`
}

type Block struct {
Expand Down Expand Up @@ -301,6 +302,7 @@ func (m *Monit) Gather(acc telegraf.Accumulator) error {
fields["remote_hostname"] = service.Port.Hostname
fields["port_number"] = service.Port.PortNumber
fields["request"] = service.Port.Request
fields["response_time"] = service.Port.ResponseTime
fields["protocol"] = service.Port.Protocol
fields["type"] = service.Port.Type
acc.AddFields("monit_remote_host", fields, tags)
Expand Down
1 change: 1 addition & 0 deletions plugins/inputs/monit/monit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func TestServiceType(t *testing.T) {
"request": "",
"protocol": "DEFAULT",
"type": "TCP",
"response_time": 0.000145,
},
time.Unix(0, 0),
),
Expand Down