Skip to content

Commit 89fe503

Browse files
committed
feat: add vpn_start_time_seconds metric
* added metric giving the ocserv start time in seconds since unix epoch
1 parent 6848671 commit 89fe503

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

cmd/ocserv-exporter/exporter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func (e *Exporter) updateStatus() {
6565
vpnIPsBanned.Reset()
6666
return
6767
}
68+
vpnStartTime.WithLabelValues().Set(float64(status.RawUpSince))
6869
vpnActiveSessions.WithLabelValues().Set(float64(status.ActiveSessions))
6970
vpnHandledSessions.WithLabelValues().Set(float64(status.HandledSessions))
7071
vpnIPsBanned.WithLabelValues().Set(float64(status.IPsBanned))

cmd/ocserv-exporter/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ var (
1818
Name: "occtl_users_scrape_error_total",
1919
Help: "Total number of errors that occurred when calling occtl show users.",
2020
}, []string{})
21+
vpnStartTime = prometheus.NewGaugeVec(prometheus.GaugeOpts{
22+
Name: "vpn_start_time_seconds",
23+
Help: "Start time of ocserv since unix epoch in seconds.",
24+
}, []string{})
2125
vpnActiveSessions = prometheus.NewGaugeVec(prometheus.GaugeOpts{
2226
Name: "vpn_active_sessions",
2327
Help: "Current number of users connected.",
@@ -98,6 +102,7 @@ func main() {
98102
prometheus.MustRegister(
99103
occtlStatusScrapeError,
100104
occtlUsersScrapeError,
105+
vpnStartTime,
101106
vpnActiveSessions,
102107
vpnHandledSessions,
103108
vpnIPsBanned,

0 commit comments

Comments
 (0)