From a6e9b97b2af0546aa2dfe2a6f6e2e1e54709b503 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Wed, 11 Aug 2021 15:54:41 +0200 Subject: [PATCH] port checker, coredumpchecker --- bot.sh | 20 ++++++++++++++++++++ coredumps.sh | 12 ++++++++++++ hdd.sh | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 coredumps.sh diff --git a/bot.sh b/bot.sh index 9bd9a4a..e9bf327 100755 --- a/bot.sh +++ b/bot.sh @@ -67,6 +67,26 @@ if [ "$?" -gt "0" ]; then fi unset -f checkCert + +#check availablitiy of "forbidden" ports +curl 'http://mrbesen.de:9999' --output - -s > /dev/null +if [ "$?" -eq "0" ]; then + echo "9999 public!" + printf -v msg '%b\n\nport 9999 public iptable reules broken?' "${msg}" + ident="$ident:firewall" +fi + + +# check for new coredumps +. coredumps.sh +checkCoreDump +if [ "$?" -ne "0" ]; then + echo "new coredump" + printf -v msg '%b\n\nnew coredump' "${msg}" + ident="$ident:coredump" +fi +unset -f checkCoreDump + . func.sh if [[ "${#msg}" -gt "1" ]]; then #remove prepend diff --git a/coredumps.sh b/coredumps.sh new file mode 100755 index 0000000..0a614d7 --- /dev/null +++ b/coredumps.sh @@ -0,0 +1,12 @@ + +#!/bin/bash +function checkCoreDump { + SAVEFILE="coredumpcount" + coredumpcount=$(ls "/var/lib/systemd/coredump/" | wc -l) + lastcount=$(cat "${SAVEFILE}") + echo "${coredumpcount}" > "${SAVEFILE}" + if [ "$coredumpcount" -gt "${lastcount}" ]; then + return 1 + fi + return 0 +} diff --git a/hdd.sh b/hdd.sh index 84a02ed..8068f74 100755 --- a/hdd.sh +++ b/hdd.sh @@ -4,5 +4,5 @@ function hddUsage { } function hddTop { - du -hd 3 / --exclude="/proc" | sort -hr | grep -E "/.*/.*/" | head -n 3 | sed -e 's/\t/%20/g; s:/:%2F:g; a%0A' | sed -e '1i \%0A' | tr -d '\n' + du -hd 3 / --exclude="/proc" --exclude="/media" --exclude="/mnt" --exclude="/usr/local/bin/dchub/share" | sort -hr | grep -E "/.*/.*/" | head -n 3 | sed -e 's/\t/%20/g; s:/:%2F:g; a%0A' | sed -e '1i \%0A' | tr -d '\n' }