2023-04-21 23:54:18 -06:00
|
|
|
#!/bin/bash
|
2023-04-21 23:54:18 -06:00
|
|
|
|
|
|
|
# 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
|
2023-04-21 23:54:20 -06:00
|
|
|
|
|
|
|
ln_existing() {
|
|
|
|
src=$1
|
|
|
|
dest=$2
|
|
|
|
if [[ -e "$dest" ]] || [[ -L "$dest" ]]; then
|
|
|
|
rm "$dest"
|
|
|
|
fi
|
|
|
|
ln -s "$src" "$dest"
|
|
|
|
}
|
2023-04-21 23:54:18 -06:00
|
|
|
|
2023-04-21 23:54:18 -06:00
|
|
|
apt update
|
2023-04-21 23:54:20 -06:00
|
|
|
apt install -y python3-venv git sysstat bc smartmontools curl recode python3-pip
|
2023-04-21 23:54:20 -06:00
|
|
|
pip install -U pip wheel setuptools
|
2023-04-21 23:54:20 -06:00
|
|
|
pip install psutil check_systemd
|
2023-04-21 23:54:20 -06:00
|
|
|
|
|
|
|
mkdir -p /usr/lib64/nagios/plugins/
|
2023-04-21 23:54:18 -06:00
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
# Install global pip packages
|
|
|
|
#pip install psutil
|
2023-04-21 23:54:18 -06:00
|
|
|
|
2023-04-21 23:54:18 -06:00
|
|
|
git -C /opt/icinga2-checks pull || git clone https://git.dp15.us/dpanzer/icinga2-checks.git /opt/icinga2-checks
|
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
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
|
2023-04-21 23:54:20 -06:00
|
|
|
/opt/venvs/linuxfabrik/bin/pip install -U pip wheel setuptools
|
2023-04-21 23:54:20 -06:00
|
|
|
/opt/venvs/linuxfabrik/bin/pip install bs4 psutil smbprotocol vici pymysql
|
|
|
|
fi
|
2023-04-21 23:54:19 -06:00
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
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
|
2023-04-21 23:54:19 -06:00
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
setcap cap_net_raw+ep /usr/lib/nagios/plugins/check_icmp
|
2023-04-21 23:54:20 -06:00
|
|
|
setcap cap_net_raw+ep /usr/lib/nagios/plugins/check_ping
|
2023-04-21 23:54:20 -06:00
|
|
|
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
|