2023-06-07 14:31:09 -06:00
|
|
|
#!/usr/bin/env bash
|
2023-04-21 23:54:18 -06:00
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
# apt-get update && apt-get 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:20 -06:00
|
|
|
if [[ $UID != 0 ]]; then
|
|
|
|
echo "Please run this script with sudo:"
|
|
|
|
echo "sudo $0 $*"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
apt-get update
|
|
|
|
apt-get install -y python3-venv git sysstat bc smartmontools curl recode python3-pip
|
2023-04-21 23:54:20 -06:00
|
|
|
curl https://bootstrap.pypa.io/get-pip.py | python3
|
|
|
|
# sudo synogear install
|
2023-04-21 23:54:20 -06:00
|
|
|
pip install --disable-pip-version-check --root-user-action=ignore -U pip wheel setuptools
|
|
|
|
pip install --disable-pip-version-check --root-user-action=ignore 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
|
2023-04-21 23:54:20 -06:00
|
|
|
#pip install --disable-pip-version-check --root-user-action=ignore psutil
|
2023-04-21 23:54:18 -06:00
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
# git -C /opt/icinga2-checks pull || git clone https://git.evulid.cc/cyberes/icinga2-checks.git /opt/icinga2-checks
|
2023-04-21 23:54:18 -06:00
|
|
|
|
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
|
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
/opt/venvs/icinga2_checks/bin/pip install --disable-pip-version-check --root-user-action=ignore -U pip wheel setuptools
|
|
|
|
/opt/venvs/icinga2_checks/bin/pip install --disable-pip-version-check --root-user-action=ignore -r /opt/icinga2-checks/requirements.txt
|
2023-04-21 23:54:20 -06:00
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
/opt/venvs/check_pve/bin/pip install --disable-pip-version-check --root-user-action=ignore -U pip wheel setuptools
|
|
|
|
/opt/venvs/check_pve/bin/pip install --disable-pip-version-check --root-user-action=ignore -r /opt/icinga2-checks/check_pve/requirements.txt
|
2023-04-21 23:54:20 -06:00
|
|
|
|
|
|
|
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 --disable-pip-version-check --root-user-action=ignore -U pip wheel setuptools
|
|
|
|
/opt/venvs/linuxfabrik/bin/pip install --disable-pip-version-check --root-user-action=ignore bs4 psutil smbprotocol vici pymysql
|
2023-04-21 23:54:20 -06:00
|
|
|
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)"
|
|
|
|
|
2023-04-21 23:54:20 -06:00
|
|
|
mkdir -p /opt/venvs/icinga2_checks/lib/python3.10/site-packages/certifi/
|
2023-04-21 23:54:20 -06:00
|
|
|
ln_existing /etc/ssl/certs/ca-certificates.crt /opt/venvs/icinga2_checks/lib/python3.10/site-packages/certifi/cacert.pem
|