Last active
April 24, 2024 12:46
-
-
Save waja/d0995072b54b4ab5cb2b5e9ab9962543 to your computer and use it in GitHub Desktop.
Deploying icinga2 satellite or agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# wget https://gist.githubusercontent.com/waja/d0995072b54b4ab5cb2b5e9ab9962543/raw/deploy_icinga2_agent_hw.sh -O /tmp/b && bash /tmp/b | |
. /etc/os-release | |
if [ "$(systemd-detect-virt)" == "none" ]; then | |
modprobe ipmi_si && modprobe ipmi_devintf && \ | |
apt-get install -y --no-install-recommends -t ${VERSION_CODENAME}-backports freeipmi-tools libipc-run-perl pciutils && \ | |
echo "nagios ALL=(root) NOPASSWD: /usr/sbin/ipmi-sensors, /usr/sbin/ipmi-sel, /usr/sbin/ipmi-fru, /usr/sbin/ipmi-dcmi" > /etc/sudoers.d/check_ipmi_sensor && \ | |
echo "nagios ALL=(root) NOPASSWD: /usr/sbin/smartctl" > /etc/sudoers.d/check_smart && \ | |
echo "nagios ALL = (root) NOPASSWD: /usr/lib/nagios/plugins/pmp-check-lvm-snapshots" > /etc/sudoers.d/check_lvm_snapshots && \ | |
echo "nagios ALL = NOPASSWD: /usr/lib/monitoring-plugins/check_vgfree" > /etc/sudoers.d/check_vgfree && \ | |
echo "ipmi_devintf" >> /etc/modules && echo "ipmi_si" >> /etc/modules | |
apt-get install -y --no-install-recommends -t ${VERSION_CODENAME}-backports nagios-plugins-contrib sudo && \ | |
if [ -f /proc/mdstat ]; then | |
cat > /etc/sudoers.d/check_raid <<EOF | |
User_Alias CHECK_RAID=nagios | |
Defaults:CHECK_RAID !requiretty | |
CHECK_RAID ALL=(root) NOPASSWD: /sbin/dmsetup status --noflush | |
EOF | |
elif [[ "$(lspci | grep MegaRAID)" == *"MegaRAID"* ]]; then | |
if [ ${VERSION_ID} -gt 11 ]; then | |
VERSION_CODENAME="bullseye" | |
fi | |
cat > /etc/apt/sources.list.d/${VERSION_CODENAME}-le-vert.net.list <<EOF | |
# Add key: wget -O - http://hwraid.le-vert.net/debian/hwraid.le-vert.net.gpg.key | sudo apt-key add - | |
# | |
# | |
# Packages for RAID systems (http://hwraid.le-vert.net/wiki/DebianPackages) | |
# | |
deb http://hwraid.le-vert.net/debian ${VERSION_CODENAME} main | |
EOF | |
wget -O - http://hwraid.le-vert.net/debian/hwraid.le-vert.net.gpg.key | sudo apt-key add - && \ | |
apt-get update && \ | |
apt-get install -y --no-install-recommends megacli sudo && \ | |
cat > /etc/sudoers.d/check_raid <<EOF | |
User_Alias CHECK_RAID=nagios, icinga, sensu | |
Defaults:CHECK_RAID !requiretty | |
CHECK_RAID ALL=(root) NOPASSWD: /sbin/dmsetup status --noflush | |
CHECK_RAID ALL=(root) NOPASSWD: /sbin/megacli -PDList -aALL -NoLog | |
CHECK_RAID ALL=(root) NOPASSWD: /sbin/megacli -LdInfo -Lall -aALL -NoLog | |
CHECK_RAID ALL=(root) NOPASSWD: /sbin/megacli -AdpBbuCmd -GetBbuStatus -aALL -NoLog | |
EOF | |
fi | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# wget https://gist.githubusercontent.com/waja/d0995072b54b4ab5cb2b5e9ab9962543/raw/deploy_icinga2_satellite.sh -O /tmp/a && bash /tmp/a | |
DIST=$(awk -F"[)(]+" '/VERSION=/ {print $2}' /etc/os-release); \ | |
echo "deb http://packages.icinga.com/debian icinga-${DIST} main" > /etc/apt/sources.list.d/${DIST}-icinga.list && \ | |
if [ "${DIST}" == "stretch" -a ! -f /etc/apt/sources.list.d/stretch-backports.list ]; then wget -qP /etc/apt/sources.list.d/ http://ftp.cyconet.org/debian/sources.list.d/stretch-backports.list; fi && \ | |
apt-get install -y --no-install-recommends gnupg apt-transport-https && \ | |
wget -qO - https://packages.icinga.com/icinga.key | apt-key add - && \ | |
apt-get update && apt-get install -y --no-install-recommends icinga2-bin icinga2-common monitoring-plugins-basic libmonitoring-plugin-perl && \ | |
if [ "$(awk -F"[\"]+" '/VERSION_ID=/ {print $2}' /etc/os-release)" -ge "10" ]; then apt-get install -y --no-install-recommends -t ${DIST}-backports monitoring-plugins-contrib xz-utils lzop lz4; else apt-get install -y --no-install-recommends nagios-plugins-contrib xz-utils lzop; fi && \ | |
apt-get install -y --no-install-recommends python3-nagiosplugin dbus && \ | |
if [ ! $(apt-get install -qy --no-install-recommends -t $(lsb_release -sc)-backports monitoring-plugins-systemd>/dev/null) ]; then | |
/usr/bin/wget -qP /tmp http://ftp.de.debian.org/debian/pool/main/m/monitoring-plugins-systemd/monitoring-plugins-systemd_2.3.1-4_all.deb && \ | |
dpkg -i /tmp/monitoring-plugins-systemd_2.3.1-4_all.deb | |
fi && \ | |
apt-get install -y --no-install-recommends monitoring-plugins-cyconet sysstat binutils sudo && \ | |
echo "nagios ALL = NOPASSWD: /usr/lib/monitoring-plugins/check_oom" > /etc/sudoers.d/check_oom && \ | |
echo 'nagios ALL = NOPASSWD: /usr/lib/nagios/plugins/check_pressure' > /etc/sudoers.d/check_pressure && \ | |
sed -i 's#^include_recursive "conf.d"#//include_recursive "conf.d"#' /etc/icinga2/icinga2.conf && \ | |
service icinga2 restart && icinga2 node wizard && \ | |
sed -i 's#.*accept_config = false# accept_config = true#' /etc/icinga2/features-available/api.conf && \ | |
sed -i 's#.*accept_commands = false# accept_commands = true#' /etc/icinga2/features-available/api.conf && \ | |
sed -i '${/^$/d;}' /etc/icinga2/zones.conf && \ | |
cat >> /etc/icinga2/zones.conf <<EOF | |
object Zone "linux-commands" { | |
global = true | |
} | |
object Zone "windows-commands" { | |
global = true | |
} | |
object Zone "generic-commands" { | |
global = true | |
} | |
EOF | |
service icinga2 checkconfig && service icinga2 restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# wget https://gist.githubusercontent.com/waja/d0995072b54b4ab5cb2b5e9ab9962543/raw/deploy_icinga2_systemd_check.sh -P /tmp/ && bash /tmp/deploy_icinga2_systemd_check.sh | |
apt-get install -y --no-install-recommends python3-nagiosplugin dbus && | |
apt-get install -y --no-install-recommends -t $(lsb_release -sc)-backports monitoring-plugins-systemd || /usr/bin/wget -P /tmp http://ftp.de.debian.org/debian/pool/main/m/monitoring-plugins-systemd/monitoring-plugins-systemd_2.3.1-2_all.deb && dpkg -i /tmp/monitoring-plugins-systemd_2.3.1-2_all.deb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment