#!/bin/bash
ALL_SESSIONS=$(ps auxwww | grep sshd: | grep -v 'grep\|listen' -c)
ROOT_SESSIONS=$(ps auxwww | grep sshd: | grep -v 'grep\|listen' | grep 'root\|priv' -c)
echo "# HELP node_active_sessions active sessions by type."
echo "# TYPE node_active_sessions gauge"
echo "node_active_sessions{type=\"all\"} $ALL_SESSIONS"
echo "node_active_sessions{type=\"root\"} $ROOT_SESSIONS"