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/README.md

66 lines
2.3 KiB
Markdown
Raw Normal View History

2020-05-20 23:46:30 +00:00
# awesome-scripts
2020-05-20 23:57:45 +00:00
Some useful bash scripts.
## Content
|Script|Description|
|---|---|
|[healthcheck.sh](healthcheck.sh)|Script to use as cron wrap to monitor the job with health.sp-codes.de|
2020-12-30 01:01:43 +00:00
|[login-notify.sh](login-notify.sh)|Script to send an alert on ssh login|
2020-05-20 23:57:45 +00:00
|[validate-remote-backup.sh](validate-remote-backup.sh)|Script to validate server side rsync command to use ssh force command|
2020-06-15 16:00:27 +00:00
|[docker-compose-up-all.sh](docker-compose-up-all.sh)|Script to call `docker-compose up -d` on all subdirectories|
2021-05-15 22:27:56 +00:00
|[node_dir_size_exporter.sh](node_exporter/directory-size.sh)|Script to call `du` on a given directory to export the size to prometheus|
2020-12-30 01:01:43 +00:00
|[update-notify.sh](update-notify.sh)|Script to call `apt` to check the host for new updates and notify in gotify|
2020-05-20 23:57:45 +00:00
2021-05-15 22:27:56 +00:00
__node_exporter__
|Script|Description|
|---|---|
|[active-sessions.sh](node_exporter/active-sessions.sh)|Script to export all active sessions to prometheus|
|[directory-size.sh](node_exporter/directory-size.sh)|Script to export directory sizes to prometheus|
2020-05-20 23:57:45 +00:00
## Setup
2020-06-15 16:00:27 +00:00
To set up all scripts in the current directory run this:
2020-05-20 23:57:45 +00:00
```
2021-05-20 19:44:58 +00:00
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
2020-05-20 23:57:45 +00:00
```
2020-12-31 13:00:23 +00:00
## Usage
### healthcheck.sh
Just use it like this in a cronjob:
```
0 0 * * * /root/healthcheck.sh 333a77a4-a63e-4885-a045-d52a4f6a3d2f /root/backup.sh > /root/log/last-backup.log 2>&1
```
The first parameter is the healthcheck uuid instead of the script file you can als pass the command to execute directly after the uuid. The pipe to put all output to a log file is also optional.
### login-notify.sh
Place a `.gotify` file in the same direction as the script and put the application token in. Append the following line to `/etc/pam.d/sshd`:
```
session optional pam_exec.so seteuid /path/to/login-notify.sh
```
2021-05-15 22:27:56 +00:00
### node_exporter
Add the following in crontab:
```
*/5 * * * * /root/exporter/directory-size.sh "<your_dir_pattern>" "<your_key>" | sponge /path/to/textfiles/directory-size.prom
* * * * * /root/exporter/active-sessions.sh | sponge /path/to/textfiles/active-sessions.prom
```
Add the `textfiles` dir as param to `node_exporter`:
```
node_exporter --collector.textfile.directory /path/to/textfiles ...
```