:goberserk: go fmt all the things

This commit is contained in:
Enrico Stahn 2018-02-19 10:53:19 +11:00
parent fb9a7ebb02
commit 0bf1933886
No known key found for this signature in database
GPG key ID: 5263621C269A50DE
6 changed files with 34 additions and 33 deletions

View file

@ -14,13 +14,13 @@
package cmd
import (
"github.com/spf13/cobra"
"encoding/json"
"fmt"
"github.com/davecgh/go-spew/spew"
"github.com/gosuri/uitable"
"fmt"
"time"
"encoding/json"
"github.com/hipages/php-fpm_exporter/phpfpm"
"github.com/spf13/cobra"
"time"
)
// Configuration variables
@ -98,6 +98,6 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
getCmd.Flags().StringSliceVar(&scrapeURIs, "phpfpm.scrape-uri", []string{"tcp://127.0.0.1:9000/status"},"FastCGI address, e.g. unix:///tmp/php.sock;/status or tcp://127.0.0.1:9000/status")
getCmd.Flags().StringVar(&output, "out", "text","Output format. One of: text, json, spew")
getCmd.Flags().StringSliceVar(&scrapeURIs, "phpfpm.scrape-uri", []string{"tcp://127.0.0.1:9000/status"}, "FastCGI address, e.g. unix:///tmp/php.sock;/status or tcp://127.0.0.1:9000/status")
getCmd.Flags().StringVar(&output, "out", "text", "Output format. One of: text, json, spew")
}

View file

@ -17,11 +17,11 @@ import (
"fmt"
"os"
"github.com/hipages/php-fpm_exporter/phpfpm"
"github.com/mitchellh/go-homedir"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/sirupsen/logrus"
"github.com/hipages/php-fpm_exporter/phpfpm"
)
var log = logrus.New()

View file

@ -14,11 +14,11 @@
package cmd
import (
"github.com/spf13/cobra"
"github.com/prometheus/client_golang/prometheus"
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/hipages/php-fpm_exporter/phpfpm"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/spf13/cobra"
"net/http"
)
// Configuration variables
@ -79,7 +79,7 @@ func init() {
// is called directly, e.g.:
serverCmd.Flags().StringVar(&listeningAddress, "web.listen-address", ":9253", "Address on which to expose metrics and web interface.")
serverCmd.Flags().StringVar(&metricsEndpoint, "web.telemetry-path", "/metrics", "Path under which to expose metrics.")
serverCmd.Flags().StringSliceVar(&scrapeURIs, "phpfpm.scrape-uri", []string{"tcp://127.0.0.1:9000/status"},"FastCGI address, e.g. unix:///tmp/php.sock;/status or tcp://127.0.0.1:9000/status")
serverCmd.Flags().StringSliceVar(&customLabelNames, "phpfpm.label-name", []string{},"Name of the custom label that will be inserted.")
serverCmd.Flags().StringSliceVar(&customLabelValues, "phpfpm.label-value", []string{},"Value of the custom label that will be inserted.")
serverCmd.Flags().StringSliceVar(&scrapeURIs, "phpfpm.scrape-uri", []string{"tcp://127.0.0.1:9000/status"}, "FastCGI address, e.g. unix:///tmp/php.sock;/status or tcp://127.0.0.1:9000/status")
serverCmd.Flags().StringSliceVar(&customLabelNames, "phpfpm.label-name", []string{}, "Name of the custom label that will be inserted.")
serverCmd.Flags().StringSliceVar(&customLabelValues, "phpfpm.label-value", []string{}, "Value of the custom label that will be inserted.")
}

View file

@ -1,9 +1,9 @@
package phpfpm
import (
"sync"
"github.com/prometheus/client_golang/prometheus"
"net/http"
"sync"
)
const (

View file

@ -14,14 +14,14 @@
package phpfpm
import (
"net/url"
"encoding/json"
"fmt"
"github.com/tomasen/fcgi_client"
"io/ioutil"
"encoding/json"
"time"
"fmt"
"net/url"
"strconv"
"sync"
"time"
)
var log logger
@ -39,7 +39,6 @@ type Pool struct {
// The address of the pool, e.g. tcp://127.0.0.1:9000 or unix:///tmp/php-fpm.sock
Address string
CollectionError error
Name string `json:"pool"`
ProcessManager string `json:"process manager"`
StartTime Timestamp `json:"start time"`
@ -84,7 +83,7 @@ func (pm *PoolManager) Update() (err error) {
started := time.Now()
for idx, _ := range pm.pools {
for idx := range pm.pools {
wg.Add(1)
go func(p *Pool) {
defer wg.Done()
@ -107,7 +106,9 @@ func (pm *PoolManager) Pools() []Pool {
// Implement custom Marshaler due to "pools" being unexported
func (pm PoolManager) MarshalJSON() ([]byte, error) {
return json.Marshal(struct{Pools []Pool `json:"pools"` }{Pools: pm.pools})
return json.Marshal(struct {
Pools []Pool `json:"pools"`
}{Pools: pm.pools})
}
func (p *Pool) Update() (err error) {
@ -151,7 +152,7 @@ func (p *Pool) Update() (err error) {
return nil
}
func (p *Pool) error(err error) (error) {
func (p *Pool) error(err error) error {
p.CollectionError = err
log.Error(err)
return err
@ -174,6 +175,6 @@ func (t *Timestamp) UnmarshalJSON(b []byte) error {
return nil
}
func SetLogger(logger logger){
func SetLogger(logger logger) {
log = logger
}