fixed active-sessions.sh
This commit is contained in:
parent
afc5dd6c7a
commit
9bd3a90acd
3 changed files with 5 additions and 17 deletions
|
@ -10,7 +10,6 @@ Some useful bash scripts.
|
||||||
|[login-notify.sh](login-notify.sh)|Script to send an alert on ssh login|
|
|[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|
|
|[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-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|
|
|[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|
|
|[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:
|
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 healthcheck.sh login-notify.sh validate-remote-backup.sh docker-compose-up-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
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
@ -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
|
|
|
@ -1,9 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ALL_SESSIONS=$(ps auxwww | grep sshd: | grep -v 'grep\|listen' -c)
|
ALL_SESSIONS=$(netstat -tnp | grep sshd -c)
|
||||||
ROOT_SESSIONS=$(ps auxwww | grep sshd: | grep -v 'grep\|listen' | grep 'root\|priv' -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 "# HELP node_active_sessions active sessions by type."
|
||||||
echo "# TYPE node_active_sessions gauge"
|
echo "# TYPE node_active_sessions gauge"
|
||||||
echo "node_active_sessions{type=\"all\"} $ALL_SESSIONS"
|
echo "node_active_sessions{type=\"all\"} $ALL_SESSIONS"
|
||||||
|
echo "node_active_sessions{type=\"su\"} $SU_SESSIONS"
|
||||||
echo "node_active_sessions{type=\"root\"} $ROOT_SESSIONS"
|
echo "node_active_sessions{type=\"root\"} $ROOT_SESSIONS"
|
||||||
|
|
Reference in a new issue