diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..be6c909 --- /dev/null +++ b/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash +VERSION=`xpath -q -e 'string(//PLUGIN/@version)' zabbix_agent.plg` +FILE="zabbix_agent-$VERSION.package.tgz" +echo "Version in plugin file: $VERSION" +echo "Generated file will be: $FILE" +echo "Is this correct? If yes, press Enter. If not, press Ctrl-C." +read + +echo "Creating $FILE..." +echo +tar -czvf "$FILE" files +echo +read md5 _ < <(md5sum "$FILE") +echo "MD5 of the resulting file for the plugin file: $md5" diff --git a/zabbix_agentd.conf b/files/boot/config/plugins/zabbix_agent/zabbix_agentd.conf similarity index 100% rename from zabbix_agentd.conf rename to files/boot/config/plugins/zabbix_agent/zabbix_agentd.conf diff --git a/rc.zabbix_agentd b/files/etc/rc.d/rc.zabbix_agentd old mode 100644 new mode 100755 similarity index 100% rename from rc.zabbix_agentd rename to files/etc/rc.d/rc.zabbix_agentd diff --git a/files/usr/local/emhttp/plugins/zabbix_agent/README.md b/files/usr/local/emhttp/plugins/zabbix_agent/README.md new file mode 100644 index 0000000..037a4e7 --- /dev/null +++ b/files/usr/local/emhttp/plugins/zabbix_agent/README.md @@ -0,0 +1,5 @@ +**zabbix_agent** + +This plugin installs and configures zabbix_agentd which can be used to monitor this Unraid server using a central Zabbix server. + +You can download a matching zabbix template at https://git.schle.nz/fabian/unraid-zabbix_agent/raw/branch/main/zabbix_template.xml diff --git a/files/usr/local/emhttp/plugins/zabbix_agent/images/zabbix_agent.png b/files/usr/local/emhttp/plugins/zabbix_agent/images/zabbix_agent.png new file mode 100644 index 0000000..d9c2003 Binary files /dev/null and b/files/usr/local/emhttp/plugins/zabbix_agent/images/zabbix_agent.png differ diff --git a/scripts/disk.sh b/files/usr/local/emhttp/plugins/zabbix_agent/scripts/disk.sh similarity index 100% rename from scripts/disk.sh rename to files/usr/local/emhttp/plugins/zabbix_agent/scripts/disk.sh diff --git a/scripts/disks.discovery.sh b/files/usr/local/emhttp/plugins/zabbix_agent/scripts/disks.discovery.sh similarity index 100% rename from scripts/disks.discovery.sh rename to files/usr/local/emhttp/plugins/zabbix_agent/scripts/disks.discovery.sh diff --git a/scripts/disks.totals.sh b/files/usr/local/emhttp/plugins/zabbix_agent/scripts/disks.totals.sh similarity index 100% rename from scripts/disks.totals.sh rename to files/usr/local/emhttp/plugins/zabbix_agent/scripts/disks.totals.sh diff --git a/scripts/qemu.discovery.sh b/files/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.discovery.sh similarity index 100% rename from scripts/qemu.discovery.sh rename to files/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.discovery.sh diff --git a/scripts/qemu.sh b/files/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.sh similarity index 100% rename from scripts/qemu.sh rename to files/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.sh diff --git a/zabbix_agentd-5.0.2 b/files/usr/sbin/zabbix_agentd similarity index 100% rename from zabbix_agentd-5.0.2 rename to files/usr/sbin/zabbix_agentd diff --git a/generate.rb b/generate.rb deleted file mode 100755 index a81259b..0000000 --- a/generate.rb +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env ruby - -puts "Reading zabbix_agent.template.plg..." -input = File.read("./zabbix_agent.template.plg") - -output = input.gsub(/{{{ (.+) }}}/) do - puts "Including #{$1}..." - File.read($1) -end -puts "Writing zabbix_agent.plg..." -File.write("./zabbix_agent.plg", output) -puts "Done." diff --git a/zabbix_agent-2020.07.16.package.tgz b/zabbix_agent-2020.07.16.package.tgz new file mode 100644 index 0000000..2dca9e7 Binary files /dev/null and b/zabbix_agent-2020.07.16.package.tgz differ diff --git a/zabbix_agent.plg b/zabbix_agent.plg index 80a0b5f..8fc7bb7 100644 --- a/zabbix_agent.plg +++ b/zabbix_agent.plg @@ -4,11 +4,12 @@ - - - + + + + ]> @@ -16,305 +17,41 @@ ##&name; +### 2020-07-16 +- Package based installation process. +- Added a zabbix template file. + +### 2020-07-15 +- More metrics + ### 2020-07-14 - Initial commit echo "Installation of zabbix_agent plugin started." -mkdir -p /boot/config/plugins/zabbix_agent/scripts -if [ -e /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version; ]; then - echo "Agent already exists. Using local file." +if [ -e /boot/config/plugins/zabbix_agent/&packageName; ]; then + echo "Package already exists." else - echo "zabbix_agent version &agent_version; not found." - echo "Removing old agents..." - rm /boot/config/plugins/zabbix_agent/zabbix_agentd-* - echo "Downloading &agentURL;..." - wget "&agentURL;" -O /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version; + echo "Current &packageName; not found; removing old packages (if existing)." + rm /boot/config/plugins/zabbix_agent/*.package.tgz + echo "Downloading current package..." fi - -echo "Removing old support files..." -rm /boot/config/plugins/zabbix_agent/rc.zabbix_agentd -rm /boot/config/plugins/zabbix_agent/zabbix_agentd.conf -rm /boot/config/plugins/zabbix_agent/scripts/* - -echo "Installing new support files..." - -/dev/null`; do - echo -n "." - sleep 1 - COUNT=$((COUNT+1)) - if [ $COUNT -ge 30 ]; then - killall -9 zabbix_agentd - sleep 1 - break - fi - done - echo " DONE" -} - -# See how we were called. -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart|reload) - stop - start - ;; - *) - echo $"Usage: $0 {start|stop|restart}" - ;; -esac - -]]> - - - - - - - - - - - - - - - - - - - - - - - - - + +&packageURL; +&packageMD5; + -cp /boot/config/plugins/zabbix_agent/rc.zabbix_agentd /etc/rc.d/rc.zabbix_agentd -chmod +x /etc/rc.d/rc.zabbix_agentd +if [ -x /etc/rc.d/rc.zabbix_agentd ]; then + echo "Stopping old zabbix agent..." + /etc/rc.d/rc.zabbix_agentd stop +fi -mkdir -p /usr/local/emhttp/plugins/zabbix_agent/scripts -cp -R /boot/config/plugins/zabbix_agent/scripts/* /usr/local/emhttp/plugins/zabbix_agent/scripts/ -chmod +x /usr/local/emhttp/plugins/zabbix_agent/scripts/* - -/etc/rc.d/rc.zabbix_agentd stop - -cp /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version; /usr/sbin/zabbix_agentd -chmod +x /usr/sbin/zabbix_agentd +echo "Extracting support files..." +tar -xzvf /boot/config/plugins/zabbix_agent/&packageName; --strip=1 -C / /etc/rc.d/rc.zabbix_agentd start @@ -328,10 +65,12 @@ echo "Stopping zabbix_agentd..." /etc/rc.d/rc.zabbix_agentd stop echo "Deleting /usr/sbin/zabbix_agentd..." rm /usr/sbin/zabbix_agentd -echo "Deleting /boot/config/plugins/zabbix_agent..." -rm -rf /boot/config/plugins/zabbix_agent -echo "Deleting /usr/local/emhttp/plugins/zabbix_agent..." -rm -rf /usr/local/emhttp/plugins/zabbix_agent +echo "Deleting /etc/rc.d/rc.zabbix_agentd..." +rm /etc/rc.d/rc.zabbix_agentd +echo "Deleting /boot/config/plugins/zabbix_agent/..." +rm -rf /boot/config/plugins/zabbix_agent/ +echo "Deleting /usr/local/emhttp/plugins/zabbix_agent/..." +rm -rf /usr/local/emhttp/plugins/zabbix_agent/ echo "Removal of zabbix_agent plugin completed." diff --git a/zabbix_agent.template.plg b/zabbix_agent.template.plg deleted file mode 100644 index a94f91b..0000000 --- a/zabbix_agent.template.plg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - -]> - - - - -##&name; - -### 2020-07-14 -- Initial commit - - - -echo "Installation of zabbix_agent plugin started." -mkdir -p /boot/config/plugins/zabbix_agent/scripts -if [ -e /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version; ]; then - echo "Agent already exists. Using local file." -else - echo "zabbix_agent version &agent_version; not found." - echo "Removing old agents..." - rm /boot/config/plugins/zabbix_agent/zabbix_agentd-* - echo "Downloading &agentURL;..." - wget "&agentURL;" -O /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version; -fi - -echo "Removing old support files..." -rm /boot/config/plugins/zabbix_agent/rc.zabbix_agentd -rm /boot/config/plugins/zabbix_agent/zabbix_agentd.conf -rm /boot/config/plugins/zabbix_agent/scripts/* - -echo "Installing new support files..." - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -cp /boot/config/plugins/zabbix_agent/rc.zabbix_agentd /etc/rc.d/rc.zabbix_agentd -chmod +x /etc/rc.d/rc.zabbix_agentd - -mkdir -p /usr/local/emhttp/plugins/zabbix_agent/scripts -cp -R /boot/config/plugins/zabbix_agent/scripts/* /usr/local/emhttp/plugins/zabbix_agent/scripts/ -chmod +x /usr/local/emhttp/plugins/zabbix_agent/scripts/* - -/etc/rc.d/rc.zabbix_agentd stop - -cp /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version; /usr/sbin/zabbix_agentd -chmod +x /usr/sbin/zabbix_agentd - -/etc/rc.d/rc.zabbix_agentd start - - - - - - -echo "Removal of zabbix_agent plugin started." -echo "Stopping zabbix_agentd..." -/etc/rc.d/rc.zabbix_agentd stop -echo "Deleting /usr/sbin/zabbix_agentd..." -rm /usr/sbin/zabbix_agentd -echo "Deleting /boot/config/plugins/zabbix_agent..." -rm -rf /boot/config/plugins/zabbix_agent -echo "Deleting /usr/local/emhttp/plugins/zabbix_agent..." -rm -rf /usr/local/emhttp/plugins/zabbix_agent -echo "Removal of zabbix_agent plugin completed." - - - diff --git a/zabbix_template.xml b/zabbix_template.xml new file mode 100644 index 0000000..d1c8dd2 --- /dev/null +++ b/zabbix_template.xml @@ -0,0 +1,846 @@ + + + 5.0 + 2020-07-17T03:56:57Z + + + Servers + + + + + +