func (o *OpenSIPS) GetStatistics(targets ...string) (map[string]Statistic, error) {
	msg := []byte(":get_statistics:\n")
	for _, target := range targets {
		msg = append(msg, []byte(target)...)
		msg = append(msg, '\n')
	}
	resp, err := o.roundtrip(msg)
	if err != nil {
		return nil, err
	}
	buf := bytes.NewBuffer(resp)
	line, err := buf.ReadString('\n')
	if err != nil {
		return nil, err
	}
	if line != firstLineOK {
		return nil, fmt.Errorf("expected %q, got %q", firstLineOK, line)
	}
	var rv []string
	for err == nil {
		rv = append(rv, line)
		line, err = buf.ReadString('\n')
	}
	statistics, err := parseStatistics(rv[1:])
	if err != nil {
		return nil, fmt.Errorf("error while parsing statistics: %v", err)
	}
	return statistics, nil
}
GetStatistics calls the get_statistics management function and returns the
statistics OpenSIPS sends back. The targets can be "all", "group:" or
"name" (e.g. "shmem:" or "rcv_requests").
package opensips
import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"net"
	"os"
	"path"
	"strconv"
	"strings"
	"sync/atomic"
	"time"
)
const firstLineOK = "200 OK\n"
type OpenSIPS struct {
	socket string
	tmpdir string
	count int64
}
type Statistic struct {
	Module, Name string
	Value        float64
}
func New(socket string) (*OpenSIPS, error) {
	tmpdir, err := ioutil.TempDir(path.Dir(socket), "opensips_exporter")
	if err != nil {
		return nil, err
	}
	return &OpenSIPS{
		socket: socket,
		tmpdir: tmpdir,
	}, nil
}