func NewExporter(uri string, timeout time.Duration) *Exporter {
	return &Exporter{
		URI: uri,
		up: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "up",
			Help:      "Was the last scrape of Icecast successful.",
		}),
		totalScrapes: prometheus.NewCounter(prometheus.CounterOpts{
			Namespace: namespace,
			Name:      "exporter_total_scrapes",
			Help:      "Current total Icecast scrapes.",
		}),
		jsonParseFailures: prometheus.NewCounter(prometheus.CounterOpts{
			Namespace: namespace,
			Name:      "exporter_json_parse_failures",
			Help:      "Number of errors while parsing JSON.",
		}),
		serverStart: prometheus.NewGauge(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "server_start",
			Help:      "Timestamp of server startup.",
		}),
		listeners: prometheus.NewGaugeVec(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "listeners",
			Help:      "The number of currently connected listeners.",
		}, labelNames),
		streamStart: prometheus.NewGaugeVec(prometheus.GaugeOpts{
			Namespace: namespace,
			Name:      "stream_start",
			Help:      "Timestamp of when the currently active source client connected to this mount point.",
		}, labelNames),
		client: &http.Client{
			Transport: &http.Transport{
				Dial: func(netw, addr string) (net.Conn, error) {
					c, err := net.DialTimeout(netw, addr, timeout)
					if err != nil {
						return nil, err
					}
					if err := c.SetDeadline(time.Now().Add(timeout)); err != nil {
						return nil, err
					}
					return c, nil
				},
			},
		},
	}
}
NewExporter returns an initialized Exporter.
package main
import (
	"bytes"
	"encoding/json"
	"flag"
	"io/ioutil"
	"net"
	"net/http"
	"os"
	"os/signal"
	"sync"
	"syscall"
	"time"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/promhttp"
	"github.com/prometheus/common/log"
)
const (
	namespace = "icecast"
)
var (
	labelNames = []string{"listenurl", "server_type"}
)
type ISO8601 time.Time
func (ts ISO8601) Time() time.Time {
	return time.Time(ts)
}
func (ts *ISO8601) UnmarshalJSON(data []byte) error {
	parsed, err := time.Parse(`"2006-01-02T15:04:05-0700"`, string(data))
	if err != nil {
		return err
	}
	*ts = ISO8601(parsed)
	return nil
}
type IcecastStatusSource struct {
	Listeners   int     `json:"listeners"`
	Listenurl   string  `json:"listenurl"`
	ServerType  string  `json:"server_type"`
	StreamStart ISO8601 `json:"stream_start_iso8601"`
}
type IcecastStatus struct {
	Icestats struct {
		ServerStart ISO8601					`json:"server_start_iso8601"`
		Source      []IcecastStatusSource 	`json:"source,omitifempty"`
	} `json:"icestats"`
}
type IcecastStatusSingle struct {
	Icestats struct {
		ServerStart ISO8601 				`json:"server_start_iso8601"`
		Source      IcecastStatusSource 	`json:"source"`
	} `json:"icestats"`
}
type Exporter struct {
	URI   string
	mutex sync.RWMutex
	up                              prometheus.Gauge
	totalScrapes, jsonParseFailures prometheus.Counter
	serverStart                     prometheus.Gauge
	listeners                       *prometheus.GaugeVec
	streamStart                     *prometheus.GaugeVec
	client                          *http.Client
}