Skip to content

Commit

Permalink
:goberserk: go fmt all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
estahn committed Feb 18, 2018
1 parent fb9a7eb commit 0bf1933
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 32 deletions.
12 changes: 6 additions & 6 deletions cmd/get.go
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
10 changes: 5 additions & 5 deletions cmd/root.go
Expand Up @@ -17,25 +17,25 @@ 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()

var (
cfgFile string
cfgFile string
logLevel string
)

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "php-fpm_exporter",
Short: "Exports php-fpm metrics for prometheus",
Long: `php-fpm_exporter exports prometheus compatible metrics from php-fpm.`,
Long: `php-fpm_exporter exports prometheus compatible metrics from php-fpm.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
Expand Down Expand Up @@ -101,4 +101,4 @@ func initLogger() {
}

log.SetLevel(lvl)
}
}
16 changes: 8 additions & 8 deletions cmd/server.go
Expand Up @@ -14,11 +14,11 @@
package cmd

import (
"github.com/spf13/cobra"
"github.com/hipages/php-fpm_exporter/phpfpm"
"github.com/prometheus/client_golang/prometheus"
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/hipages/php-fpm_exporter/phpfpm"
"github.com/spf13/cobra"
"net/http"
)

// Configuration variables
Expand Down Expand Up @@ -77,9 +77,9 @@ func init() {

// Cobra supports local flags which will only run when this command
// 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().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.")
}
2 changes: 1 addition & 1 deletion cmd/version.go
Expand Up @@ -23,7 +23,7 @@ import (
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of php-fpm_exporter",
Long: `All software has versions. This is php-fpm_exporter's'`,
Long: `All software has versions. This is php-fpm_exporter's'`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("php-fpm_exporter v0.9 -- HEAD")
},
Expand Down
2 changes: 1 addition & 1 deletion phpfpm/exporter.go
@@ -1,9 +1,9 @@
package phpfpm

import (
"sync"
"github.com/prometheus/client_golang/prometheus"
"net/http"
"sync"
)

const (
Expand Down
23 changes: 12 additions & 11 deletions phpfpm/phpfpm.go
Expand Up @@ -14,14 +14,14 @@
package phpfpm

import (
"net/url"
"github.com/tomasen/fcgi_client"
"io/ioutil"
"encoding/json"
"time"
"fmt"
"github.com/tomasen/fcgi_client"
"io/ioutil"
"net/url"
"strconv"
"sync"
"time"
)

var log logger
Expand All @@ -32,14 +32,13 @@ type logger interface {
}

type PoolManager struct {
pools []Pool `json:"pools"`
pools []Pool `json:"pools"`
}

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"`
Expand Down Expand Up @@ -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()
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -174,6 +175,6 @@ func (t *Timestamp) UnmarshalJSON(b []byte) error {
return nil
}

func SetLogger(logger logger){
func SetLogger(logger logger) {
log = logger
}
}

0 comments on commit 0bf1933

Please sign in to comment.