Added CheckMk files

This commit is contained in:
2023-08-25 13:16:26 +02:00
parent 0058b5e483
commit 6770680e65
10 changed files with 1756 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
#!/bin/bash
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
# Reason for this no-op: shellcheck disable=... before the first command disables the error for the
# entire script.
:
# Disable unused variable error (needed to keep track of version)
# shellcheck disable=SC2034
CMK_VERSION="2.1.0p18"
# Check for APT updates (Debian, Ubuntu)
# TODO:
# Einstellungen:
# - upgrade oder dist-upgrade
# - vorher ein update machen
# Bakery:
# - Bakelet anlegen
# - Async-Zeit einstellbar machen und das Ding immer async laufen lassen
# Check programmieren:
# * Schwellwerte auf Anzahlen
# * Regexen auf Pakete, die zu CRIT/WARN führen
# - Graph malen mit zwei Kurven
# This variable can either be "upgrade" or "dist-upgrade"
UPGRADE=upgrade
DO_UPDATE=yes
check_apt_update() {
if [ "$DO_UPDATE" = yes ]; then
# NOTE: Even with -qq, apt-get update can output several lines to
# stderr, e.g.:
#
# W: There is no public key available for the following key IDs:
# 1397BC53640DB551
apt-get update -qq 2>/dev/null
fi
apt-get -o 'Debug::NoLocking=true' -o 'APT::Get::Show-User-Simulation-Note=false' -s -qq "$UPGRADE" | grep -v '^Conf'
}
if type apt-get >/dev/null; then
echo '<<<apt:sep(0)>>>'
out=$(check_apt_update)
if [ -z "$out" ]; then
echo "No updates pending for installation"
else
echo "$out"
fi
fi
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
# Reason for this no-op: shellcheck disable=... before the first command disables the error for the
# entire script.
:
# Disable unused variable error (needed to keep track of version)
# shellcheck disable=SC2034
CMK_VERSION="2.1.0p18"
if type who >/dev/null; then
echo "<<<logins>>>"
who | wc -l
fi
+1315
View File
File diff suppressed because it is too large Load Diff
+77
View File
@@ -0,0 +1,77 @@
#!/bin/bash
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
# Reason for this no-op: shellcheck disable=... before the first command disables the error for the
# entire script.
:
# Disable unused variable error (needed to keep track of version)
# shellcheck disable=SC2034
CMK_VERSION="2.1.0p18"
# gets optional socket as argument
do_query() {
# we use the sockets full name as instance name:
INSTANCE_HEADER="[[$2]]"
# Check if mysqld is running and root password setup
echo "<<<mysql_ping>>>"
echo "$INSTANCE_HEADER"
mysqladmin --defaults-extra-file="$MK_CONFDIR"/mysql.cfg ${1:+--socket="$1"} ping 2>&1 || return
echo "<<<mysql>>>"
echo "$INSTANCE_HEADER"
mysql --defaults-extra-file="$MK_CONFDIR"/mysql.cfg ${1:+--socket="$1"} -sN \
-e "show global status ; show global variables ;"
echo "<<<mysql_capacity>>>"
echo "$INSTANCE_HEADER"
mysql --defaults-extra-file="$MK_CONFDIR"/mysql.cfg ${1:+--socket="$1"} -sN \
-e "SELECT table_schema, sum(data_length + index_length), sum(data_free)
FROM information_schema.TABLES GROUP BY table_schema"
echo "<<<mysql_slave>>>"
echo "$INSTANCE_HEADER"
mysql --defaults-extra-file="$MK_CONFDIR"/mysql.cfg ${1:+--socket="$1"} -s \
-e "show slave status\G"
}
if [ ! -f "${MK_CONFDIR}/mysql.local.cfg" ]; then
cat <<EOF >"${MK_CONFDIR}/mysql.local.cfg"
# This file is created because some versions of mysqladmin
# issue a warning if there are missing includes.
EOF
fi
if type mysqladmin >/dev/null; then
mysql_socket_string=$(grep -F -h socket "$MK_CONFDIR"/mysql{.local,}.cfg | sed -ne 's/.*socket=\([^ ]*\).*/\1/p')
alias_string=$(grep -F -h alias "$MK_CONFDIR"/mysql{.local,}.cfg | sed -ne 's/.*aliases=\([^ ]*\).*/\1/p')
if [ -z "$mysql_socket_string" ]; then
mysql_socket_string=$(ps -fww -C mysqld | grep "socket" | sed -ne 's/.*socket=\([^ ]*\).*/\1/p')
fi
if [ -z "$mysql_socket_string" ]; then
do_query "" ""
else
IFS=" " mapfile -t mysql_sockets <<<"$mysql_socket_string"
IFS="," read -r -a aliases <<<"$alias_string"
for i in "${!mysql_sockets[@]}"; do
socket="${mysql_sockets[i]}"
alias="${aliases[i]}"
if [ -z "$alias" ]; then
do_query "$socket" "$socket"
else
do_query "$socket" "$alias"
fi
done
fi
# In async execution the cache file would be removed if the plugin exits with non-zero exit code.
# Avoid this from happening, just because the last mysql command failed (due to missing permissions).
exit 0
fi