@@ -79,6 +79,7 @@ func (internalError *internalError) Wrap(err string) *internalError {
79
79
// Stats represents NGINX Plus stats fetched from the NGINX Plus API.
80
80
// https://nginx.org/en/docs/http/ngx_http_api_module.html
81
81
type Stats struct {
82
+ NginxInfo NginxInfo
82
83
Connections Connections
83
84
HTTPRequests HTTPRequests
84
85
SSL SSL
@@ -88,6 +89,18 @@ type Stats struct {
88
89
StreamUpstreams StreamUpstreams
89
90
}
90
91
92
+ // NginxInfo contains general information about NGINX Plus.
93
+ type NginxInfo struct {
94
+ Version string
95
+ Build string
96
+ Address string
97
+ Generation uint64
98
+ LoadTimestamp string `json:"load_timestamp"`
99
+ Timestamp string
100
+ ProcessID uint64 `json:"pid"`
101
+ ParentProcessID uint64 `json:"ppid"`
102
+ }
103
+
91
104
// Connections represents connection related stats.
92
105
type Connections struct {
93
106
Accepted uint64
@@ -658,6 +671,11 @@ func determineStreamUpdates(updatedServers []StreamUpstreamServer, nginxServers
658
671
659
672
// GetStats gets connection, request, ssl, zone, stream zone, upstream and stream upstream related stats from the NGINX Plus API.
660
673
func (client * NginxClient ) GetStats () (* Stats , error ) {
674
+ info , err := client .getNginxInfo ()
675
+ if err != nil {
676
+ return nil , fmt .Errorf ("failed to get stats %v" , err )
677
+ }
678
+
661
679
cons , err := client .getConnections ()
662
680
if err != nil {
663
681
return nil , fmt .Errorf ("failed to get stats: %v" , err )
@@ -694,6 +712,7 @@ func (client *NginxClient) GetStats() (*Stats, error) {
694
712
}
695
713
696
714
return & Stats {
715
+ NginxInfo : * info ,
697
716
Connections : * cons ,
698
717
HTTPRequests : * requests ,
699
718
SSL : * ssl ,
@@ -704,6 +723,15 @@ func (client *NginxClient) GetStats() (*Stats, error) {
704
723
}, nil
705
724
}
706
725
726
+ func (client * NginxClient ) getNginxInfo () (* NginxInfo , error ) {
727
+ var info NginxInfo
728
+ err := client .get ("nginx" , & info )
729
+ if err != nil {
730
+ return nil , fmt .Errorf ("failed to get info: %v" , err )
731
+ }
732
+ return & info , nil
733
+ }
734
+
707
735
func (client * NginxClient ) getConnections () (* Connections , error ) {
708
736
var cons Connections
709
737
err := client .get ("connections" , & cons )
0 commit comments