func (n NginxPlugin) FetchMetrics() (map[string]interface{}, error) {
	req, err := http.NewRequest("GET", n.URI, nil)
	if err != nil {
		return nil, err
	}
	for _, h := range n.Header {
		kv := strings.SplitN(h, ":", 2)
		var k, v string
		k = strings.TrimSpace(kv[0])
		if len(kv) == 2 {
			v = strings.TrimSpace(kv[1])
		}
		if http.CanonicalHeaderKey(k) == "Host" {
			req.Host = v
		} else {
			req.Header.Set(k, v)
		}
	}
	if _, ok := req.Header["User-Agent"]; !ok {
		req.Header.Set("User-Agent", "mackerel-plugin-nginx")
	}
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	return n.parseStats(resp.Body)
}
% wget -qO- http://localhost:8080/nginx_status
Active connections: 123
server accepts handled requests
1693613501 1693613501 7996986318
Reading: 66 Writing: 16 Waiting: 41
FetchMetrics interface for mackerelplugin
package mpnginx
import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"errors"
	"net/http"
	"regexp"
	"strconv"
	"strings"
	mp "github.com/mackerelio/go-mackerel-plugin-helper"
)
var graphdef = map[string]mp.Graphs{
	"nginx.connections": {
		Label: "Nginx Connections",
		Unit:  "integer",
		Metrics: []mp.Metrics{
			{Name: "connections", Label: "Active connections", Diff: false},
		},
	},
	"nginx.requests": {
		Label: "Nginx requests",
		Unit:  "float",
		Metrics: []mp.Metrics{
			{Name: "accepts", Label: "Accepted connections", Diff: true, Type: "uint64"},
			{Name: "handled", Label: "Handled connections", Diff: true, Type: "uint64"},
			{Name: "requests", Label: "Handled requests", Diff: true, Type: "uint64"},
		},
	},
	"nginx.queue": {
		Label: "Nginx connection status",
		Unit:  "integer",
		Metrics: []mp.Metrics{
			{Name: "reading", Label: "Reading", Diff: false},
			{Name: "writing", Label: "Writing", Diff: false},
			{Name: "waiting", Label: "Waiting", Diff: false},
		},
	},
}
type stringSlice []string
func (s *stringSlice) Set(v string) error {
	*s = append(*s, v)
	return nil
}
func (s *stringSlice) String() string {
	return fmt.Sprintf("%v", *s)
}
type NginxPlugin struct {
	URI    string
	Header stringSlice
}