-
Notifications
You must be signed in to change notification settings - Fork 183
/
nginx.go
61 lines (50 loc) · 2.07 KB
/
nginx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// +build linux
package nginx
//go:generate collectd-template-to-go nginx.tmpl
import (
"github.com/signalfx/signalfx-agent/internal/core/config"
"github.com/signalfx/signalfx-agent/internal/monitors"
"github.com/signalfx/signalfx-agent/internal/monitors/collectd"
)
const monitorType = "collectd/nginx"
// MONITOR(collectd/nginx): Monitors an nginx instance using our fork of the
// collectd nginx plugin based on the [collectd nginx
// plugin](https://collectd.org/wiki/index.php/Plugin:nginx).
//
// See the [integrations
// doc](https://github.com/signalfx/integrations/tree/master/collectd-nginx)
// for more information.
// CUMULATIVE(connections.accepted): Connections accepted by Nginx Web Server
// CUMULATIVE(connections.handled): Connections handled by Nginx Web Server
// GAUGE(nginx_connections.active): Connections active in Nginx Web Server
// GAUGE(nginx_connections.reading): Connections being read by Nginx Web Server
// GAUGE(nginx_connections.waiting): Connections waited on by Nginx Web Server
// GAUGE(nginx_connections.writing): Connections being written by Nginx Web Server
// CUMULATIVE(nginx_requests): Requests handled by Nginx Web Server
func init() {
monitors.Register(monitorType, func() interface{} {
return &Monitor{
*collectd.NewMonitorCore(CollectdTemplate),
}
}, &Config{})
}
// Config is the monitor-specific config with the generic config embedded
type Config struct {
config.MonitorConfig `yaml:",inline" acceptsEndpoints:"true"`
Host string `yaml:"host" validate:"required"`
Port uint16 `yaml:"port" validate:"required"`
Name string `yaml:"name"`
// The full URL of the status endpoint; can be a template
URL string `yaml:"url" default:"http://{{.Host}}:{{.Port}}/nginx_status"`
Username string `yaml:"username"`
Password string `yaml:"password" neverLog:"true"`
Timeout int `yaml:"timeout"`
}
// Monitor is the main type that represents the monitor
type Monitor struct {
collectd.MonitorCore
}
// Configure configures and runs the plugin in collectd
func (m *Monitor) Configure(conf *Config) error {
return m.SetConfigurationAndRun(conf)
}