From 9bd3a90acd660b5a444132e64c986b05440ffe32 Mon Sep 17 00:00:00 2001 From: samuel-p Date: Thu, 20 May 2021 21:44:58 +0200 Subject: [PATCH] fixed active-sessions.sh --- README.md | 4 +--- docker-stack-deploy-all.sh | 12 ------------ node_exporter/active-sessions.sh | 6 ++++-- 3 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 docker-stack-deploy-all.sh diff --git a/README.md b/README.md index 7ec2b49..093cd73 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ Some useful bash scripts. |[login-notify.sh](login-notify.sh)|Script to send an alert on ssh login| |[validate-remote-backup.sh](validate-remote-backup.sh)|Script to validate server side rsync command to use ssh force command| |[docker-compose-up-all.sh](docker-compose-up-all.sh)|Script to call `docker-compose up -d` on all subdirectories| -|[docker-stack-deploy-all.sh](docker-stack-deploy-all.sh)|Script to call `docker stack deploy` on all subdirectories| |[node_dir_size_exporter.sh](node_exporter/directory-size.sh)|Script to call `du` on a given directory to export the size to prometheus| |[update-notify.sh](update-notify.sh)|Script to call `apt` to check the host for new updates and notify in gotify| @@ -27,8 +26,7 @@ __node_exporter__ To set up all scripts in the current directory run this: ``` -curl https://git.sp-codes.de/samuel-p/awesome-scripts/raw/branch/master/setup.sh | bash -s healthcheck.sh login-notify.sh validate-remote-backup.sh docker-compose-up-all.sh docker-stack-deploy-all.sh update-notify.sh -curl https://git.sp-codes.de/samuel-p/awesome-scripts/raw/branch/master/setup.sh | bash -s active-sessions.sh directory-size.sh +curl https://git.sp-codes.de/samuel-p/awesome-scripts/raw/branch/master/setup.sh | bash -s healthcheck.sh login-notify.sh validate-remote-backup.sh docker-compose-up-all.sh update-notify.sh ``` ## Usage diff --git a/docker-stack-deploy-all.sh b/docker-stack-deploy-all.sh deleted file mode 100644 index b757683..0000000 --- a/docker-stack-deploy-all.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -for dir in */; do - service="${dir/\//}" - if [ -f "$service/docker-compose.yml" ]; then - echo "deploy $service" - docker stack deploy -c "$service/docker-compose.yml" "$service" - fi -done - -echo "cleanup docker" -docker system prune --all --volumes --force diff --git a/node_exporter/active-sessions.sh b/node_exporter/active-sessions.sh index c77910f..ce846e9 100644 --- a/node_exporter/active-sessions.sh +++ b/node_exporter/active-sessions.sh @@ -1,9 +1,11 @@ #!/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) +ALL_SESSIONS=$(netstat -tnp | grep sshd -c) +SU_SESSIONS=$(ps aux | grep ' [s]u' -c) +ROOT_SESSIONS=$(netstat -tnp | grep sshd | grep root -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=\"su\"} $SU_SESSIONS" echo "node_active_sessions{type=\"root\"} $ROOT_SESSIONS"