Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User session uptime #3

Closed
max-xface opened this issue Sep 21, 2023 · 3 comments
Closed

User session uptime #3

max-xface opened this issue Sep 21, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@max-xface
Copy link

Can you add an output of how long the user session has been active?

@max-xface max-xface added the enhancement New feature or request label Sep 21, 2023
@fdomain
Copy link
Contributor

fdomain commented Sep 22, 2023

Yes, this is something doable.

Output example from occtl --json show users:

    "Connected at":  "2023-09-22 04:28",
    "_Connected at":  " 9h:46m",

What should be done is to parse the duration of "_Connected at" value.
Don't hesitate to propose a PR if you're interested, otherwise I'll have a look soon.

@fdomain
Copy link
Contributor

fdomain commented Sep 22, 2023

After looking closer into this, the values returned in Connected at or _Connected at are not consistent enough (the format changes depending on the connection time).
I proposed a PR on ocserv project to display the raw value of the connection start time (unix timestamp).

Depending on its acceptance, I'll make the required change on ocserv-exporter.
The only thing you'll have to do on Prometheus is to compute the uptime by doing something like:

time() - vpn_user_start_time_seconds

@fdomain
Copy link
Contributor

fdomain commented Sep 26, 2023

The PR is accepted, so I added vpn_user_start_time_seconds metric (see 11796a5).

It relies on the presence of the raw_connected_at field in JSON output of occtl, which will be most likely available with version 1.2.3 of ocserv.

@fdomain fdomain closed this as completed Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants