icinga2-checks/install.sh

77 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# apt update && apt install -y git && cd /opt && git -C /opt/icinga2-checks pull || git clone https://git.dp15.us/dpanzer/icinga2-checks.git /opt/icinga2-checks && bash /opt/icinga2-checks/install.sh
ln_existing() {
src=$1
dest=$2
if [[ -e "$dest" ]] || [[ -L "$dest" ]]; then
rm "$dest"
fi
ln -s "$src" "$dest"
}
apt update
apt install -y python3-venv git sysstat bc smartmontools curl recode python3-pip
pip install -U pip wheel setuptools
pip install psutil check_systemd
mkdir -p /usr/lib64/nagios/plugins/
# Install global pip packages
#pip install psutil
git -C /opt/icinga2-checks pull || git clone https://git.dp15.us/dpanzer/icinga2-checks.git /opt/icinga2-checks
mkdir -p /opt/venvs
if [[ ! -d /opt/venvs/icinga2_checks ]]; then
echo "Creating venv in /opt/venvs/icinga2_checks"
python3 -m venv /opt/venvs/icinga2_checks
fi
if [[ ! -d /opt/venvs/check_pve ]]; then
echo "Creating venv in /opt/venvs/check_pve"
python3 -m venv /opt/venvs/check_pve
fi
/opt/venvs/icinga2_checks/bin/pip install -U pip wheel setuptools
/opt/venvs/icinga2_checks/bin/pip install -r /opt/icinga2-checks/requirements.txt
/opt/venvs/check_pve/bin/pip install -U pip wheel setuptools
/opt/venvs/check_pve/bin/pip install -r /opt/icinga2-checks/check_pve/requirements.txt
ln_existing /opt/icinga2-checks/check_iowait.sh /usr/lib64/nagios/plugins/check_iowait
ln_existing /opt/icinga2-checks/check_bandwidth.py /usr/lib64/nagios/plugins/check_bandwidth
ln_existing /opt/icinga2-checks/check_curl.sh /usr/lib64/nagios/plugins/check_curl
# ==============================================================================
# Install the Linuxfabrik checks
if [[ ! -d /opt/linuxfabrik-monitoring-plugins ]]; then
git clone https://github.com/Linuxfabrik/monitoring-plugins.git /opt/linuxfabrik-monitoring-plugins
if [[ ! -d /opt/venvs/linuxfabrik ]]; then
echo "Creating venv in /opt/venvs/linuxfabrik"
python3 -m venv /opt/venvs/linuxfabrik
fi
cd /opt/linuxfabrik-monitoring-plugins
rm -rf lib
git clone https://github.com/Linuxfabrik/lib.git
/opt/venvs/linuxfabrik/bin/pip install -U pip wheel setuptools
/opt/venvs/linuxfabrik/bin/pip install bs4 psutil smbprotocol vici pymysql
fi
ln_existing /opt/linuxfabrik-monitoring-plugins/check-plugins/disk-io/disk-io3 /usr/lib64/nagios/plugins/disk-io
ln_existing /opt/linuxfabrik-monitoring-plugins/check-plugins/cpu-usage/cpu-usage3 /usr/lib64/nagios/plugins/cpu-usage
ln_existing /opt/linuxfabrik-monitoring-plugins/check-plugins/disk-usage/disk-usage3 /usr/lib64/nagios/plugins/disk-usage
ln_existing /opt/linuxfabrik-monitoring-plugins/check-plugins/memory-usage/memory-usage3 /usr/lib64/nagios/plugins/memory-usage
ln_existing /opt/linuxfabrik-monitoring-plugins/check-plugins/ping/ping3 /usr/lib64/nagios/plugins/ping
ln_existing /opt/linuxfabrik-monitoring-plugins/check-plugins/disk-smart/disk-smart3 /usr/lib64/nagios/plugins/disk-smart
setcap cap_net_raw+ep /usr/lib/nagios/plugins/check_icmp
setcap cap_net_raw+ep /usr/lib/nagios/plugins/check_ping
setcap 'cap_net_raw+ep' "$(which ping)"
ln_existing /etc/ssl/certs/ca-certificates.crt /opt/venvs/icinga2_checks/lib/python3.10/site-packages/certifi/cacert.pem