Currently, the number of clients logged on Spectrum (using Webapp or Java console) is displayed in the Oneclick "Client Details" web page:
The Spectrum code pulls the data contained in the $SPECROOT/OCLogs/client.log and display the info in this readable web page.
However, there can be a situation where customers would like to get this info in a programmatical way (i.e, using REST or a custom script).
Spectrum 22.x, 23.x
Currently, there is no REST available to retrieve the number of user active sessions from Oneclick.
However, there is a simple solution that consists on using CURL + grep + sed + awk commands against the Oneclick "Client Details" web page:
------------------------
HTTP:
[xxx@xxx]$ curl -u spectrum:spectrum http://xxxxxx:8080/spectrum/console/do/clientDetails 2>&1 | grep -Eo '([0-9]+Client\(s\) Logged On|<td>[a-zA-Z0-9]+</td>)' | sed -E 's/<td>([a-zA-Z0-9]+)<\/td>/\1/' | awk 'BEGIN {print ""; ORS="\n\n"} /Client\(s\) Logged On/ {print; getline; print ""} !/Client\(s\) Logged On/ {print}'
HTTPS:
[xxx@xxx]$ curl -u spectrum:spectrum --insecure https://xxxxxx:8080/spectrum/console/do/clientDetails 2>&1 | grep -Eo '([0-9]+Client\(s\) Logged On|<td>[a-zA-Z0-9]+</td>)' | sed -E 's/<td>([a-zA-Z0-9]+)<\/td>/\1/' | awk 'BEGIN {print ""; ORS="\n\n"} /Client\(s\) Logged On/ {print; getline; print ""} !/Client\(s\) Logged On/ {print}'
The result displayed will be like that:
---------------------------------
2Client(s) Logged On -> number of users logged
banana -> user name
true -> If logged using Webapp console. If "false", logged using OC java console.
Operator -> user role
spectrum -> username
true -> If logged using Webapp console. If "false", logged using OC java console.
Administrator -> user role
------------------------
NOTES:
Here, we are considering the Oneclick user/password as "spectrum" ( -u ).
Also, you must replace the "xxxxxx" in the curl command by the name/ip of the oneclick machine where the users are logged.