deploy_icinga2_agent_hw.sh
· 2.3 KiB · Bash
Исходник
#!/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
| 1 | #!/bin/bash |
| 2 | # wget https://gist.githubusercontent.com/waja/d0995072b54b4ab5cb2b5e9ab9962543/raw/deploy_icinga2_agent_hw.sh -O /tmp/b && bash /tmp/b |
| 3 | |
| 4 | . /etc/os-release |
| 5 | |
| 6 | if [ "$(systemd-detect-virt)" == "none" ]; then |
| 7 | modprobe ipmi_si && modprobe ipmi_devintf && \ |
| 8 | apt-get install -y --no-install-recommends -t ${VERSION_CODENAME}-backports freeipmi-tools libipc-run-perl pciutils && \ |
| 9 | 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 && \ |
| 10 | echo "nagios ALL=(root) NOPASSWD: /usr/sbin/smartctl" > /etc/sudoers.d/check_smart && \ |
| 11 | echo "nagios ALL = (root) NOPASSWD: /usr/lib/nagios/plugins/pmp-check-lvm-snapshots" > /etc/sudoers.d/check_lvm_snapshots && \ |
| 12 | echo "nagios ALL = NOPASSWD: /usr/lib/monitoring-plugins/check_vgfree" > /etc/sudoers.d/check_vgfree && \ |
| 13 | echo "ipmi_devintf" >> /etc/modules && echo "ipmi_si" >> /etc/modules |
| 14 | apt-get install -y --no-install-recommends -t ${VERSION_CODENAME}-backports nagios-plugins-contrib sudo && \ |
| 15 | if [ -f /proc/mdstat ]; then |
| 16 | cat > /etc/sudoers.d/check_raid <<EOF |
| 17 | User_Alias CHECK_RAID=nagios |
| 18 | Defaults:CHECK_RAID !requiretty |
| 19 | CHECK_RAID ALL=(root) NOPASSWD: /sbin/dmsetup status --noflush |
| 20 | EOF |
| 21 | elif [[ "$(lspci | grep MegaRAID)" == *"MegaRAID"* ]]; then |
| 22 | if [ ${VERSION_ID} -gt 11 ]; then |
| 23 | VERSION_CODENAME="bullseye" |
| 24 | fi |
| 25 | cat > /etc/apt/sources.list.d/${VERSION_CODENAME}-le-vert.net.list <<EOF |
| 26 | # Add key: wget -O - http://hwraid.le-vert.net/debian/hwraid.le-vert.net.gpg.key | sudo apt-key add - |
| 27 | # |
| 28 | |
| 29 | # |
| 30 | # Packages for RAID systems (http://hwraid.le-vert.net/wiki/DebianPackages) |
| 31 | # |
| 32 | |
| 33 | deb http://hwraid.le-vert.net/debian ${VERSION_CODENAME} main |
| 34 | EOF |
| 35 | wget -O - http://hwraid.le-vert.net/debian/hwraid.le-vert.net.gpg.key | sudo apt-key add - && \ |
| 36 | apt-get update && \ |
| 37 | apt-get install -y --no-install-recommends megacli sudo && \ |
| 38 | cat > /etc/sudoers.d/check_raid <<EOF |
| 39 | User_Alias CHECK_RAID=nagios, icinga, sensu |
| 40 | Defaults:CHECK_RAID !requiretty |
| 41 | CHECK_RAID ALL=(root) NOPASSWD: /sbin/dmsetup status --noflush |
| 42 | CHECK_RAID ALL=(root) NOPASSWD: /sbin/megacli -PDList -aALL -NoLog |
| 43 | CHECK_RAID ALL=(root) NOPASSWD: /sbin/megacli -LdInfo -Lall -aALL -NoLog |
| 44 | CHECK_RAID ALL=(root) NOPASSWD: /sbin/megacli -AdpBbuCmd -GetBbuStatus -aALL -NoLog |
| 45 | EOF |
| 46 | fi |
| 47 | fi |
| 48 |
deploy_icinga2_satellite.sh
· 2.5 KiB · Bash
Исходник
#!/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
| 1 | #!/bin/bash |
| 2 | # wget https://gist.githubusercontent.com/waja/d0995072b54b4ab5cb2b5e9ab9962543/raw/deploy_icinga2_satellite.sh -O /tmp/a && bash /tmp/a |
| 3 | DIST=$(awk -F"[)(]+" '/VERSION=/ {print $2}' /etc/os-release); \ |
| 4 | echo "deb http://packages.icinga.com/debian icinga-${DIST} main" > /etc/apt/sources.list.d/${DIST}-icinga.list && \ |
| 5 | 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 && \ |
| 6 | apt-get install -y --no-install-recommends gnupg apt-transport-https && \ |
| 7 | wget -qO - https://packages.icinga.com/icinga.key | apt-key add - && \ |
| 8 | apt-get update && apt-get install -y --no-install-recommends icinga2-bin icinga2-common monitoring-plugins-basic libmonitoring-plugin-perl && \ |
| 9 | 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 && \ |
| 10 | apt-get install -y --no-install-recommends python3-nagiosplugin dbus && \ |
| 11 | if [ ! $(apt-get install -qy --no-install-recommends -t $(lsb_release -sc)-backports monitoring-plugins-systemd>/dev/null) ]; then |
| 12 | /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 && \ |
| 13 | dpkg -i /tmp/monitoring-plugins-systemd_2.3.1-4_all.deb |
| 14 | fi && \ |
| 15 | apt-get install -y --no-install-recommends monitoring-plugins-cyconet sysstat binutils sudo && \ |
| 16 | echo "nagios ALL = NOPASSWD: /usr/lib/monitoring-plugins/check_oom" > /etc/sudoers.d/check_oom && \ |
| 17 | echo 'nagios ALL = NOPASSWD: /usr/lib/nagios/plugins/check_pressure' > /etc/sudoers.d/check_pressure && \ |
| 18 | sed -i 's#^include_recursive "conf.d"#//include_recursive "conf.d"#' /etc/icinga2/icinga2.conf && \ |
| 19 | service icinga2 restart && icinga2 node wizard && \ |
| 20 | sed -i 's#.*accept_config = false# accept_config = true#' /etc/icinga2/features-available/api.conf && \ |
| 21 | sed -i 's#.*accept_commands = false# accept_commands = true#' /etc/icinga2/features-available/api.conf && \ |
| 22 | sed -i '${/^$/d;}' /etc/icinga2/zones.conf && \ |
| 23 | cat >> /etc/icinga2/zones.conf <<EOF |
| 24 | object Zone "linux-commands" { |
| 25 | global = true |
| 26 | } |
| 27 | |
| 28 | object Zone "windows-commands" { |
| 29 | global = true |
| 30 | } |
| 31 | |
| 32 | object Zone "generic-commands" { |
| 33 | global = true |
| 34 | } |
| 35 | EOF |
| 36 | service icinga2 checkconfig && service icinga2 restart |
| 37 |
deploy_icinga2_systemd_check.sh
· 554 B · Bash
Исходник
#!/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
| 1 | #!/bin/bash |
| 2 | # wget https://gist.githubusercontent.com/waja/d0995072b54b4ab5cb2b5e9ab9962543/raw/deploy_icinga2_systemd_check.sh -P /tmp/ && bash /tmp/deploy_icinga2_systemd_check.sh |
| 3 | apt-get install -y --no-install-recommends python3-nagiosplugin dbus && |
| 4 | 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 |
| 5 |