Select Git revision
main.go 10.43 KiB
package main
import (
"github.com/namsral/flag"
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
"fmt"
"os"
"github.com/prometheus/common/log"
"github.com/prometheus/common/version"
"github.com/prometheus/client_golang/prometheus"
"sync"
"crypto/tls"
"io/ioutil"
"encoding/json"
"bytes"
"strconv"
"strings"
)
const (
namespace = "nexenta" // For Prometheus metrics.
apiPath = "/rest/nms"
)
var (
listenAddr = flag.String("listen-address", ":9457", "The address to listen on for HTTP requests.")
metricsEndpoint = flag.String("metrics-endpoint", "/metrics", "Path under which to expose metrics.")
apiHost = flag.String("api-host", "nexenta", "Nexenta API host.")
apiPort = flag.String("api-port", "8457", "Nexenta API port.")
apiUser = flag.String("api-user", "admin", "Nexenta API username.")
apiPass = flag.String("api-password", "password", "Nexenta API password.")
apiSsl = flag.Bool("api-ssl", false, "Use SSL for the Nexenta API.")
insecure = flag.Bool("insecure", false, "Ignore server certificate if using https.")
showVersion = flag.Bool("version", false, "Print version information.")
)
type ApiRequest struct {
Object string `json:"object"`
Method string `json:"method"`
Params []string `json:"params"`
}
type ApiResponse struct {
TGFlash string `json:"tg_flash"`
Result interface{} `json:"result"`
Error ApiError `json:"error"`
}
type ApiError struct {
Message string `json:"message"`
}
type VolumeStatus struct {
State []string `json:"state"`
Errors []string `json:"errors"`
}
type Sensor struct {
Name string `json:"name"`
Value string `json:"value"`
State string `json:"state"`
Dev string `json:"dev"`
Units string `json:"units"`
Type string `json:"type"`
}
type LicenseInfo struct {
DaysLeft string `json:"license_days_left"`
}