This repository has been archived on 2023-09-23. You can view files and clone it, but cannot push or open issues or pull requests.
awesome-scripts/node_exporter/active-sessions.sh

12 lines
427 B
Bash
Raw Normal View History

2021-05-15 22:27:56 +00:00
#!/bin/bash
2021-05-20 19:44:58 +00:00
ALL_SESSIONS=$(netstat -tnp | grep sshd -c)
2021-05-21 17:07:42 +00:00
SU_SESSIONS=$(ps aux | grep ' [s][u] ' -c)
2021-05-20 19:44:58 +00:00
ROOT_SESSIONS=$(netstat -tnp | grep sshd | grep root -c)
2021-05-15 22:27:56 +00:00
echo "# HELP node_active_sessions active sessions by type."
echo "# TYPE node_active_sessions gauge"
echo "node_active_sessions{type=\"all\"} $ALL_SESSIONS"
2021-05-20 19:44:58 +00:00
echo "node_active_sessions{type=\"su\"} $SU_SESSIONS"
2021-05-15 22:27:56 +00:00
echo "node_active_sessions{type=\"root\"} $ROOT_SESSIONS"