getSessions Function
The getSessions function allows retrieving all the active sessions for the systems of interest.
Syntax
var result = getSessions(<system>);
Parameters Usage
Parameter  | Type  | Default  | Use  | Annotation  | 
system  | Integer String  | null  | Optional  | The identifier (ID), name, or SystemObject of the system of interest. The null default value means all the systems.  | 
Result
The getSessions function returns:
- A SessionObjects object containing the active sessions.
 - null, if there are no active sessions for the requested system, or the specified system is offline or invalid.
 
Error Handling
Errors can occur in case:
- The specified <system> is not a positive integer, a string, or a SystemObject.
 
Examples of Use
How to get the active sessions of the current system
var system = getCurrentSystem();
var sessions = getSessions(system);
if (sessions != null) {
console("Sessions active on {0}:", system.systemName);
for (var i = 0; i < sessions.length; i ++) {
console("- {0}: {1}", sessions[i].sessionType, sessions[i].count);
}
}
How to get the active sessions in all systems
var sessions = getSessions();
if (sessions != null) {
for (var i = 0; i < sessions.length; i ++){
console("Sessions active on {0}:", sessions[i].system.systemName);
console("- {0}: {1}", sessions[i].sessionType, sessions[i].count);
}
}
