Skip to content

Commit

Permalink
Merge pull request #44 from saphoooo/dev
Browse files Browse the repository at this point in the history
remove dead code
  • Loading branch information
saphoooo authored Oct 4, 2020
2 parents a813f29 + 5ab0b2b commit 62a0ffd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
29 changes: 9 additions & 20 deletions gauges.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var (
// XXX: see https://dev.freebox.fr/sdk/os/ for API documentation
// XXX: see https://prometheus.io/docs/practices/naming/ for metric names

// connectionXdsl gauges
// connectionXdsl
connectionXdslStatusUptimeGauges = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "freebox_connection_xdsl_status_uptime_seconds_total",
},
Expand Down Expand Up @@ -63,7 +63,7 @@ var (
},
)

// RRD dsl gauges
// RRD dsl [unstable]
rateUpGauge = promauto.NewGauge(prometheus.GaugeOpts{
Name: "freebox_dsl_up_bytes",
Help: "Available upload bandwidth (in byte/s)",
Expand All @@ -81,7 +81,7 @@ var (
Help: "Download signal/noise ratio (in 1/10 dB)",
})

// freeplug gauges
// freeplug
freeplugRxRateGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "freebox_freeplug_rx_rate_bits",
Help: "rx rate (from the freeplugs to the \"cco\" freeplug) (in bits/s) -1 if not available",
Expand All @@ -107,7 +107,7 @@ var (
},
)

// RRD net gauges
// RRD Net [unstable]
bwUpGauge = promauto.NewGauge(prometheus.GaugeOpts{
Name: "freebox_net_bw_up_bytes",
Help: "Upload available bandwidth (in byte/s)",
Expand All @@ -133,19 +133,17 @@ var (
Help: "Vpn client download rate (in byte/s)",
})

// lan gauges
// Lan
lanReachableGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_lan_reachable",
Help: "Hosts reachable on LAN",
},
[]string{
// Hostname
"name",
"name", // hostname
},
)

// system temp gauges
systemTempGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_system_temp_celsius",
Expand All @@ -156,7 +154,6 @@ var (
},
)

// system fan gauges
systemFanGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_system_fan_rpm",
Expand All @@ -167,7 +164,6 @@ var (
},
)

// system uptime gauges
systemUptimeGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_system_uptime_seconds_total",
Expand All @@ -177,14 +173,13 @@ var (
},
)

// wifi station labels
// wifi
wifiLabels = []string{
"access_point",
"hostname",
"state",
}

// wifi station signal gauges
wifiSignalGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_wifi_signal_attenuation_db",
Expand All @@ -193,7 +188,6 @@ var (
wifiLabels,
)

// wifi station inactive gauges
wifiInactiveGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_wifi_inactive_duration_seconds",
Expand All @@ -202,7 +196,6 @@ var (
wifiLabels,
)

// wifi station conn_duration gauges
wifiConnectionDurationGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_wifi_connection_duration_seconds",
Expand All @@ -211,7 +204,6 @@ var (
wifiLabels,
)

// wifi station rx_bytes gauges
wifiRXBytesGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_wifi_rx_bytes",
Expand All @@ -220,7 +212,6 @@ var (
wifiLabels,
)

// wifi station tx_bytes gauges
wifiTXBytesGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_wifi_tx_bytes",
Expand All @@ -229,7 +220,6 @@ var (
wifiLabels,
)

// wifi station rx_rate gauges
wifiRXRateGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_wifi_rx_rate",
Expand All @@ -238,7 +228,6 @@ var (
wifiLabels,
)

// wifi station rx_rate gauges
wifiTXRateGauges = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "freebox_wifi_tx_rate",
Expand All @@ -247,7 +236,7 @@ var (
wifiLabels,
)

// vpn server connections list
// vpn server connections list [unstable]
vpnServerConnectionsList = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "vpn_server_connections_list",
Expand All @@ -258,7 +247,7 @@ var (
"vpn",
"src_ip",
"local_ip",
"name",
"name", // rx_bytes|tx_bytes
},
)
)
6 changes: 0 additions & 6 deletions getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func (l *lan) status() error {
return apiErrors[l.ErrorCode]
}

// setFreeboxToken ensure that there is an active token for a call
func setFreeboxToken(authInf *authInfo, xSessionToken *string) (string, error) {
token := os.Getenv("FREEBOX_TOKEN")

Expand Down Expand Up @@ -106,7 +105,6 @@ func getConnectionXdsl(authInf *authInfo, pr *postRequest, xSessionToken *string
return connectionXdslResp, nil
}

// getDsl get dsl statistics
func getDsl(authInf *authInfo, pr *postRequest, xSessionToken *string) ([]int64, error) {
d := &database{
DB: "dsl",
Expand Down Expand Up @@ -172,7 +170,6 @@ func getDsl(authInf *authInfo, pr *postRequest, xSessionToken *string) ([]int64,
return result, nil
}

// getTemp get temp statistics
func getTemp(authInf *authInfo, pr *postRequest, xSessionToken *string) ([]int64, error) {
d := &database{
DB: "temp",
Expand Down Expand Up @@ -238,7 +235,6 @@ func getTemp(authInf *authInfo, pr *postRequest, xSessionToken *string) ([]int64
return []int64{rrdTest.Result.Data[0]["cpum"], rrdTest.Result.Data[0]["cpub"], rrdTest.Result.Data[0]["sw"], rrdTest.Result.Data[0]["hdd"], rrdTest.Result.Data[0]["fan_speed"]}, nil
}

// getNet get net statistics
func getNet(authInf *authInfo, pr *postRequest, xSessionToken *string) ([]int64, error) {
d := &database{
DB: "net",
Expand Down Expand Up @@ -304,7 +300,6 @@ func getNet(authInf *authInfo, pr *postRequest, xSessionToken *string) ([]int64,
return []int64{rrdTest.Result.Data[0]["bw_up"], rrdTest.Result.Data[0]["bw_down"], rrdTest.Result.Data[0]["rate_up"], rrdTest.Result.Data[0]["rate_down"], rrdTest.Result.Data[0]["vpn_rate_up"], rrdTest.Result.Data[0]["vpn_rate_down"]}, nil
}

// getSwitch get switch statistics
func getSwitch(authInf *authInfo, pr *postRequest, xSessionToken *string) ([]int64, error) {
d := &database{
DB: "switch",
Expand Down Expand Up @@ -370,7 +365,6 @@ func getSwitch(authInf *authInfo, pr *postRequest, xSessionToken *string) ([]int
return []int64{rrdTest.Result.Data[0]["rx_1"], rrdTest.Result.Data[0]["tx_1"], rrdTest.Result.Data[0]["rx_2"], rrdTest.Result.Data[0]["tx_2"], rrdTest.Result.Data[0]["rx_3"], rrdTest.Result.Data[0]["tx_3"], rrdTest.Result.Data[0]["rx_4"], rrdTest.Result.Data[0]["tx_4"]}, nil
}

// getLan get lan statistics
func getLan(authInf *authInfo, pr *postRequest, xSessionToken *string) ([]lanHost, error) {
freeboxToken, err := setFreeboxToken(authInf, xSessionToken)
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func main() {
mafreebox = mafreebox + "/"
}

// myAuthInfo contains all auth data
endpoint := mafreebox + "api/v4/login/"
myAuthInfo := &authInfo{
myAPI: api{
Expand Down Expand Up @@ -95,7 +94,6 @@ func main() {

var mySessionToken string

// infinite loop to get all statistics
go func() {
for {
// There is no DSL metric on fiber Freebox
Expand Down Expand Up @@ -258,7 +256,7 @@ func main() {
}
}

// VPN Client Status Metrics
// VPN Server Connections List
getVpnServerResult, err := getVpnServer(myAuthInfo, myVpnRequest, &mySessionToken)
if err != nil {
log.Printf("An error occured with VPN station metrics: %v", err)
Expand All @@ -272,7 +270,6 @@ func main() {
}
}()

// expose the registered metrics via HTTP OpenMetrics
log.Println("freebox_exporter started on port", listen)
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(listen, nil))
Expand Down

0 comments on commit 62a0ffd

Please sign in to comment.