banshee is under active development: collectors will keep changing, and a version you publish will likely need adjustments. For stable use, wait for version 1.0.0.

Windows

banshee/windows-collection/windows/ssh/

sessions

The sessions open on a Windows, in use and disconnected, by SSH and PowerShell

  • windows
  • ssh
  • powershell
  • sessions
  • users

by banshee1 installation2 versions

Keen 1.0.0 · 26 lines
// The sessions open on a Windows, by SSH: those in use, at the console as by Remote Desktop, and those
// left disconnected, which keep their programs and their memory.
// Runs one PowerShell command that only reads the counters of the Terminal Services object,
// Win32_PerfRawData_LocalSessionManager_TerminalServices: ActiveSessions and InactiveSessions. Their names
// are English whatever the language of Windows, where the output of quser is translated.
need('protocol:ssh');

output('sessions', 'number', array('label' => 'Open sessions'));
output('active', 'number', array('label' => 'Sessions in use'));
output('disconnected', 'number', array('label' => 'Disconnected sessions'));

// No threshold by default: what is normal depends on the server, a jump host or a server without sessions.
watch.above('too-many', 'Too many open sessions', 'sessions', array('enabled' => false));
watch.above('disconnected', 'Disconnected sessions left open', 'disconnected', array('enabled' => false));

$read = ssh.run("powershell -NoProfile -NonInteractive -Command \""
    . "Get-CimInstance Win32_PerfRawData_LocalSessionManager_TerminalServices"
    . " | Select-Object ActiveSessions, InactiveSessions | ConvertTo-Json -Compress\"");
$answer = text.trim($read['output']);
if (list.count(text.match($answer, '^\{')) == 0) {
    fail('misconfigured', 'PowerShell did not return the Terminal Services counters', $answer . $read['errors']);
}
$counters = json.read($answer);
value('active', $counters['ActiveSessions']);
value('disconnected', $counters['InactiveSessions']);
value('sessions', $counters['ActiveSessions'] + $counters['InactiveSessions']);