Skip to content

Commit

Permalink
Merge pull request #40 from rokett/add-lbvs-state
Browse files Browse the repository at this point in the history
Added LBVS and GSLB VS state metrics
  • Loading branch information
rokett authored Jul 2, 2020
2 parents f6a3a7a + 75024c1 commit 0a70835
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.4.0] - 2020-07-02
### Added
- #37 Added LBVS and GSLB VS state metric.

## [4.3.1] - 2020-07-02
### Fixed
- #13 Error when trying to retrieve stats for servicegroups which have multiple members, where each member is the same server but on different ports. We now include the port as a label to avoid duplicates.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:alpine as builder

ENV VERSION="4.3.1"
ENV VERSION="4.4.0"

WORKDIR $GOPATH/src/github.com/rokett
RUN \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: build

APP = Citrix-NetScaler-Exporter
VERSION = 4.3.1
VERSION = 4.4.0
BINARY-LINUX = ${APP}_${VERSION}_Linux_amd64

BUILD_VER = $(shell git rev-parse HEAD)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ For each virtual server, the following metrics are retrieved.
| Metric | Metric Type | Unit |
| ---------------------------| ----------- | ------- |
| Name | N/A | None |
| State | Gauge | None |
| Waiting requests | Gauge | None |
| Health | Gauge | Percent |
| Inactive services | Gauge | None |
Expand Down Expand Up @@ -201,6 +202,7 @@ For each GSLB virtual server, the following metrics are retrieved.
| Metric | Metric Type | Unit |
| ---------------------------| ----------- | ------- |
| Name | N/A | None |
| State | Gauge | None |
| Health | Gauge | Percent |
| Inactive services | Gauge | None |
| Active services | Gauge | None |
Expand Down
9 changes: 8 additions & 1 deletion collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"strconv"
"strings"

"citrix-netscaler-exporter/netscaler"

"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/rokett/citrix-netscaler-exporter/netscaler"
)

// Collect is initiated by the Prometheus handler and gathers the metrics
Expand Down Expand Up @@ -158,6 +159,9 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
e.collectInterfacesErrorPacketsRx(interfaces)
e.interfacesErrorPacketsRx.Collect(ch)

e.collectVirtualServerState(virtualServers)
e.virtualServersState.Collect(ch)

e.collectVirtualServerWaitingRequests(virtualServers)
e.virtualServersWaitingRequests.Collect(ch)

Expand Down Expand Up @@ -269,6 +273,9 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
e.collectGSLBServicesVirtualServerServiceHits(gslbServices)
e.gslbServicesVirtualServerServiceHits.Collect(ch)

e.collectGSLBVirtualServerState(gslbVirtualServers)
e.gslbVirtualServersState.Collect(ch)

e.collectGSLBVirtualServerHealth(gslbVirtualServers)
e.gslbVirtualServersHealth.Collect(ch)

Expand Down
3 changes: 2 additions & 1 deletion collector/cs_virtual_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package collector
import (
"strconv"

"citrix-netscaler-exporter/netscaler"

"github.com/prometheus/client_golang/prometheus"
"github.com/rokett/citrix-netscaler-exporter/netscaler"
)

var (
Expand Down
6 changes: 6 additions & 0 deletions collector/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Exporter struct {
interfacesJumboPacketsRx *prometheus.GaugeVec
interfacesJumboPacketsTx *prometheus.GaugeVec
interfacesErrorPacketsRx *prometheus.GaugeVec
virtualServersState *prometheus.GaugeVec
virtualServersWaitingRequests *prometheus.GaugeVec
virtualServersHealth *prometheus.GaugeVec
virtualServersInactiveServices *prometheus.GaugeVec
Expand Down Expand Up @@ -80,6 +81,7 @@ type Exporter struct {
gslbServicesCurrentLoad *prometheus.GaugeVec
gslbServicesVirtualServerServiceHits *prometheus.CounterVec
gslbServicesEstablishedConnections *prometheus.GaugeVec
gslbVirtualServersState *prometheus.GaugeVec
gslbVirtualServersHealth *prometheus.GaugeVec
gslbVirtualServersInactiveServices *prometheus.GaugeVec
gslbVirtualServersActiveServices *prometheus.GaugeVec
Expand Down Expand Up @@ -157,6 +159,7 @@ func NewExporter(url string, username string, password string, ignoreCert bool,
interfacesJumboPacketsRx: interfacesJumboPacketsRx,
interfacesJumboPacketsTx: interfacesJumboPacketsTx,
interfacesErrorPacketsRx: interfacesErrorPacketsRx,
virtualServersState: virtualServersState,
virtualServersWaitingRequests: virtualServersWaitingRequests,
virtualServersHealth: virtualServersHealth,
virtualServersInactiveServices: virtualServersInactiveServices,
Expand Down Expand Up @@ -206,6 +209,7 @@ func NewExporter(url string, username string, password string, ignoreCert bool,
gslbServicesCurrentLoad: gslbServicesCurrentLoad,
gslbServicesVirtualServerServiceHits: gslbServicesVirtualServerServiceHits,
gslbServicesEstablishedConnections: gslbServicesEstablishedConnections,
gslbVirtualServersState: gslbVirtualServersState,
gslbVirtualServersHealth: gslbVirtualServersHealth,
gslbVirtualServersInactiveServices: gslbVirtualServersInactiveServices,
gslbVirtualServersActiveServices: gslbVirtualServersActiveServices,
Expand Down Expand Up @@ -273,6 +277,7 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
e.interfacesJumboPacketsTx.Describe(ch)
e.interfacesErrorPacketsRx.Describe(ch)

e.virtualServersState.Describe(ch)
e.virtualServersWaitingRequests.Describe(ch)
e.virtualServersHealth.Describe(ch)
e.virtualServersInactiveServices.Describe(ch)
Expand Down Expand Up @@ -326,6 +331,7 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
e.gslbServicesVirtualServerServiceHits.Describe(ch)
e.gslbServicesEstablishedConnections.Describe(ch)

e.gslbVirtualServersState.Describe(ch)
e.gslbVirtualServersHealth.Describe(ch)
e.gslbVirtualServersInactiveServices.Describe(ch)
e.gslbVirtualServersActiveServices.Describe(ch)
Expand Down
3 changes: 2 additions & 1 deletion collector/gslb_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package collector
import (
"strconv"

"citrix-netscaler-exporter/netscaler"

"github.com/prometheus/client_golang/prometheus"
"github.com/rokett/citrix-netscaler-exporter/netscaler"
)

var (
Expand Down
28 changes: 27 additions & 1 deletion collector/gslb_virtual_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ package collector
import (
"strconv"

"citrix-netscaler-exporter/netscaler"

"github.com/prometheus/client_golang/prometheus"
"github.com/rokett/citrix-netscaler-exporter/netscaler"
)

var (
gslbVirtualServersState = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gslb_virtual_servers_state",
Help: "Current state of the server",
},
[]string{
"ns_instance",
"virtual_server",
},
)

gslbVirtualServersHealth = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "gslb_virtual_servers_health",
Expand Down Expand Up @@ -119,6 +131,20 @@ var (
)
)

func (e *Exporter) collectGSLBVirtualServerState(ns netscaler.NSAPIResponse) {
e.gslbVirtualServersState.Reset()

for _, vs := range ns.GSLBVirtualServerStats {
state := 0.0

if vs.State == "UP" {
state = 1.0
}

e.gslbVirtualServersState.WithLabelValues(e.nsInstance, vs.Name).Set(state)
}
}

func (e *Exporter) collectGSLBVirtualServerHealth(ns netscaler.NSAPIResponse) {
e.gslbVirtualServersHealth.Reset()

Expand Down
3 changes: 2 additions & 1 deletion collector/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package collector
import (
"strconv"

"citrix-netscaler-exporter/netscaler"

"github.com/prometheus/client_golang/prometheus"
"github.com/rokett/citrix-netscaler-exporter/netscaler"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion collector/service_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package collector
import (
"strconv"

"citrix-netscaler-exporter/netscaler"

"github.com/prometheus/client_golang/prometheus"
"github.com/rokett/citrix-netscaler-exporter/netscaler"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion collector/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package collector
import (
"strconv"

"citrix-netscaler-exporter/netscaler"

"github.com/prometheus/client_golang/prometheus"
"github.com/rokett/citrix-netscaler-exporter/netscaler"
)

var (
Expand Down
28 changes: 27 additions & 1 deletion collector/virtual_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ package collector
import (
"strconv"

"citrix-netscaler-exporter/netscaler"

"github.com/prometheus/client_golang/prometheus"
"github.com/rokett/citrix-netscaler-exporter/netscaler"
)

var (
virtualServersState = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "virtual_servers_state",
Help: "Current state of the server",
},
[]string{
"ns_instance",
"virtual_server",
},
)

virtualServersWaitingRequests = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "virtual_servers_waiting_requests",
Expand Down Expand Up @@ -129,6 +141,20 @@ var (
)
)

func (e *Exporter) collectVirtualServerState(ns netscaler.NSAPIResponse) {
e.virtualServersState.Reset()

for _, vs := range ns.VirtualServerStats {
state := 0.0

if vs.State == "UP" {
state = 1.0
}

e.virtualServersState.WithLabelValues(e.nsInstance, vs.Name).Set(state)
}
}

func (e *Exporter) collectVirtualServerWaitingRequests(ns netscaler.NSAPIResponse) {
e.virtualServersWaitingRequests.Reset()

Expand Down
3 changes: 2 additions & 1 deletion collector/vpn_virtual_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package collector
import (
"strconv"

"citrix-netscaler-exporter/netscaler"

"github.com/prometheus/client_golang/prometheus"
"github.com/rokett/citrix-netscaler-exporter/netscaler"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"

"github.com/rokett/citrix-netscaler-exporter/collector"
"citrix-netscaler-exporter/collector"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SETLOCAL

set APP=Citrix-NetScaler-Exporter
set VERSION=4.3.1
set VERSION=4.4.0
set BINARY-WINDOWS-X64=%APP%_%VERSION%_Windows_amd64.exe
set BINARY-LINUX=%APP%_%VERSION%_Linux_amd64

Expand Down
1 change: 1 addition & 0 deletions netscaler/get_gslb_virtual_server_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// GSLBVirtualServerStats represents the data returned from the /stat/gslbvserver Nitro API endpoint
type GSLBVirtualServerStats struct {
Name string `json:"name"`
State string `json:"state"`
Health string `json:"vslbhealth"`
InactiveServices string `json:"inactsvcs"`
ActiveServices string `json:"actsvcs"`
Expand Down
1 change: 1 addition & 0 deletions netscaler/get_virtual_server_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// VirtualServerStats represents the data returned from the /stat/lbvserver Nitro API endpoint
type VirtualServerStats struct {
Name string `json:"name"`
State string `json:"state"`
WaitingRequests string `json:"vsvrsurgecount"`
Health string `json:"vslbhealth"`
InactiveServices string `json:"inactsvcs"`
Expand Down

0 comments on commit 0a70835

Please sign in to comment.