-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from rokett/dev
Added AAA stats
- Loading branch information
Showing
12 changed files
with
211 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package collector | ||
|
||
import ( | ||
"strconv" | ||
|
||
"citrix-netscaler-exporter/netscaler" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
var ( | ||
aaaAuthSuccess = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "aaa_auth_success", | ||
Help: "Count of authentication successes", | ||
}, | ||
[]string{ | ||
"ns_instance", | ||
}, | ||
) | ||
|
||
aaaAuthFail = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "aaa_auth_fail", | ||
Help: "Count of authentication failures", | ||
}, | ||
[]string{ | ||
"ns_instance", | ||
}, | ||
) | ||
|
||
aaaAuthOnlyHTTPSuccess = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "aaa_auth_only_http_success", | ||
Help: "Count of HTTP connections that succeeded authorisation", | ||
}, | ||
[]string{ | ||
"ns_instance", | ||
}, | ||
) | ||
|
||
aaaAuthOnlyHTTPFail = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "aaa_auth_only_http_fail", | ||
Help: "Count of HTTP connections that failed authorisation", | ||
}, | ||
[]string{ | ||
"ns_instance", | ||
}, | ||
) | ||
|
||
aaaCurIcaSessions = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "aaa_current_ica_sessions", | ||
Help: "Count of current Basic ICA only sessions", | ||
}, | ||
[]string{ | ||
"ns_instance", | ||
}, | ||
) | ||
|
||
aaaCurIcaOnlyConn = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "aaa_current_ica_only_connections", | ||
Help: "Count of current Basic ICA only connections", | ||
}, | ||
[]string{ | ||
"ns_instance", | ||
}, | ||
) | ||
) | ||
|
||
func (e *Exporter) collectAaaAuthSuccess(ns netscaler.NSAPIResponse) { | ||
e.aaaAuthSuccess.Reset() | ||
|
||
val, _ := strconv.ParseFloat(ns.AAAStats.AuthSuccess, 64) | ||
e.aaaAuthSuccess.WithLabelValues(e.nsInstance).Set(val) | ||
} | ||
|
||
func (e *Exporter) collectAaaAuthFail(ns netscaler.NSAPIResponse) { | ||
e.aaaAuthFail.Reset() | ||
|
||
val, _ := strconv.ParseFloat(ns.AAAStats.AuthFail, 64) | ||
e.aaaAuthFail.WithLabelValues(e.nsInstance).Set(val) | ||
} | ||
|
||
func (e *Exporter) collectAaaAuthOnlyHTTPSuccess(ns netscaler.NSAPIResponse) { | ||
e.aaaAuthOnlyHTTPSuccess.Reset() | ||
|
||
val, _ := strconv.ParseFloat(ns.AAAStats.AuthOnlyHTTPSuccess, 64) | ||
e.aaaAuthOnlyHTTPSuccess.WithLabelValues(e.nsInstance).Set(val) | ||
} | ||
|
||
func (e *Exporter) collectAaaAuthOnlyHTTPFail(ns netscaler.NSAPIResponse) { | ||
e.aaaAuthOnlyHTTPFail.Reset() | ||
|
||
val, _ := strconv.ParseFloat(ns.AAAStats.AuthOnlyHTTPFail, 64) | ||
e.aaaAuthOnlyHTTPFail.WithLabelValues(e.nsInstance).Set(val) | ||
} | ||
|
||
func (e *Exporter) collectAaaCurIcaSessions(ns netscaler.NSAPIResponse) { | ||
e.aaaCurIcaSessions.Reset() | ||
|
||
val, _ := strconv.ParseFloat(ns.AAAStats.CurrentIcaSessions, 64) | ||
e.aaaCurIcaSessions.WithLabelValues(e.nsInstance).Set(val) | ||
} | ||
|
||
func (e *Exporter) collectAaaCurIcaOnlyConn(ns netscaler.NSAPIResponse) { | ||
e.aaaCurIcaOnlyConn.Reset() | ||
|
||
val, _ := strconv.ParseFloat(ns.AAAStats.CurrentIcaOnlyConnections, 64) | ||
e.aaaCurIcaOnlyConn.WithLabelValues(e.nsInstance).Set(val) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package netscaler | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
// AAAStats represents the data returned from the /stat/aaa Nitro API endpoint | ||
type AAAStats struct { | ||
AuthSuccess string `json:"aaaauthsuccess"` | ||
AuthFail string `json:"aaaauthfail"` | ||
AuthOnlyHTTPSuccess string `json:"aaaauthonlyhttpsuccess"` | ||
AuthOnlyHTTPFail string `json:"aaaauthonlyhttpfail"` | ||
CurrentIcaSessions string `json:"aaacuricasessions"` | ||
CurrentIcaOnlyConnections string `json:"aaacuricaonlyconn"` | ||
} | ||
|
||
// GetAAAStats queries the Nitro API for AAA stats | ||
func GetAAAStats(c *NitroClient, querystring string) (NSAPIResponse, error) { | ||
stats, err := c.GetStats("aaa", querystring) | ||
if err != nil { | ||
return NSAPIResponse{}, err | ||
} | ||
|
||
var response = new(NSAPIResponse) | ||
|
||
err = json.Unmarshal(stats, &response) | ||
if err != nil { | ||
return NSAPIResponse{}, errors.Wrap(err, "error unmarshalling response body") | ||
} | ||
|
||
return *response, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters