Moved to a new, package based installation method. Also added a few more support files.

This commit is contained in:
Fabian Schlenz 2020-07-17 06:01:19 +02:00
parent 7be58113d8
commit 6519037034
16 changed files with 897 additions and 423 deletions

14
build.sh Executable file
View File

@ -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"

0
rc.zabbix_agentd → files/etc/rc.d/rc.zabbix_agentd Normal file → Executable file
View File

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

View File

@ -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."

Binary file not shown.

View File

@ -4,11 +4,12 @@
<!ENTITY name "zabbix_agent"> <!ENTITY name "zabbix_agent">
<!ENTITY author "fabianonline"> <!ENTITY author "fabianonline">
<!ENTITY plgauthor "fabianonline"> <!ENTITY plgauthor "fabianonline">
<!ENTITY agent_version "5.0.2">
<!ENTITY baseURL "https://git.schle.nz/fabian/unraid-zabbix_agent/raw/branch/main"> <!ENTITY baseURL "https://git.schle.nz/fabian/unraid-zabbix_agent/raw/branch/main">
<!ENTITY pluginURL "&baseURL;/zabbix_agent.plg"> <!ENTITY pluginURL "&baseURL;/zabbix_agent.plg">
<!ENTITY agentURL "&baseURL;/zabbix_agentd-&agent_version;"> <!ENTITY version "2020.07.16">
<!ENTITY version "2020-07-14"> <!ENTITY packageName "zabbix_agent-&version;.package.tgz">
<!ENTITY packageURL "&baseURL;/&packageName;">
<!ENTITY packageMD5 "2740e36b05204d8f9be5be853cc105cd">
]> ]>
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;"> <PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;">
@ -16,305 +17,41 @@
<CHANGES> <CHANGES>
##&name; ##&name;
### 2020-07-16
- Package based installation process.
- Added a zabbix template file.
### 2020-07-15
- More metrics
### 2020-07-14 ### 2020-07-14
- Initial commit - Initial commit
</CHANGES> </CHANGES>
<FILE Run="/bin/bash"><INLINE> <FILE Run="/bin/bash"><INLINE>
echo "Installation of zabbix_agent plugin started." echo "Installation of zabbix_agent plugin started."
mkdir -p /boot/config/plugins/zabbix_agent/scripts if [ -e /boot/config/plugins/zabbix_agent/&packageName; ]; then
if [ -e /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version; ]; then echo "Package already exists."
echo "Agent already exists. Using local file."
else else
echo "zabbix_agent version &agent_version; not found." echo "Current &packageName; not found; removing old packages (if existing)."
echo "Removing old agents..." rm /boot/config/plugins/zabbix_agent/*.package.tgz
rm /boot/config/plugins/zabbix_agent/zabbix_agentd-* echo "Downloading current package..."
echo "Downloading &agentURL;..."
wget "&agentURL;" -O /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version;
fi 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..."
</INLINE></FILE> </INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/rc.zabbix_agentd"><INLINE> <FILE Name="/boot/config/plugins/zabbix_agent/&packageName;">
<![CDATA[ <URL>&packageURL;</URL>
#!/bin/sh <MD5>&packageMD5;</MD5>
# </FILE>
# rc.zabbix_agentd This shell script takes care of starting and stopping
# the Zabbix agent
OPTIONS="-c /boot/config/plugins/zabbix_agent/zabbix_agentd.conf"
start() {
if [ -x /usr/sbin/zabbix_agentd ]; then
echo -n "Starting zabbix_agentd: "
/usr/sbin/zabbix_agentd $OPTIONS
echo " /usr/sbin/zabbix_agentd $OPTIONS"
fi
}
stop() {
# Stop daemons.
COUNT=0
echo -n "Shutting down zabbix_agentd: "
while `killall zabbix_agentd 2>/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
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/zabbix_agentd.conf"><INLINE>
<![CDATA[
Server=0.0.0.0/0
LogType=system
AllowRoot=1
StartAgents=1
DenyKey=system.run[*]
AllowKey=agent.*
AllowKey=net.if.*
AllowKey=net.if.*[*]
AllowKey=proc.*
AllowKey=proc.*[*]
AllowKey=sensor[*]
AllowKey=system.*
AllowKey=system.*[*]
AllowKey=vfs.dev.*
AllowKey=vfs.dev.*[*]
AllowKey=vfs.fs.*
AllowKey=vfs.fs.*[*]
AllowKey=vm.memory.size[*]
AllowKey=unraid.*
AllowKey=unraid.*[*]
DenyKey=*
UserParameter=unraid.disks.discovery,/usr/local/emhttp/plugins/zabbix_agent/scripts/disks.discovery.sh
UserParameter=unraid.disk[*],/usr/local/emhttp/plugins/zabbix_agent/scripts/disk.sh "$1"
UserParameter=unraid.disks.totals,/usr/local/emhttp/plugins/zabbix_agent/scripts/disks.totals.sh
UserParameter=unraid.qemu.discovery,/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.discovery.sh
UserParameter=unraid.qemu[*],/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.sh "$1"
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/disks.discovery.sh"><INLINE>
<![CDATA[
#!/bin/bash
id='""'
device='""'
first=1
echo -n '['
while IFS="=" read key value; do
if [ "$key" = "id" ] && [ -n "$value" ] && [ "$value" != '""' ]; then
[ $first = 0 ] && echo -n ","
first=0
echo -n '{"{#ID}":'$value'}'
fi
done < /var/local/emhttp/disks.ini
echo ']'
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/disk.sh"><INLINE>
<![CDATA[
#!/bin/bash
id="$1"
found=0
device=""
while read line; do
if [[ $line == "["* ]]; then
if [ $found = 1 ]; then
[ $fsFree -ge 0 ] && [ $fsSize -ge 0 ] && fsUsed=$(( $fsSize - $fsFree ))
echo -n '{"device":"'$device'", "name":"'$name'", "status":"'$status'", "temp":'$temp', "size":'$size', "num_reads":'$num_reads', '
echo -n '"num_writes":'$num_writes', "num_errors":'$num_errors', "type":"'$type'", "fs_size":'$fsSize', "fs_free":'$fsFree', "fs_used":'$fsUsed', '
break
else
device=''
name=''
status=''
temp=-1
size=-1
num_reads=-1
num_writes=-1
num_errors=-1
type=""
fsSize=-1
fsFree=-1
fsUsed=-1
fi
else
while IFS="=" read key value; do
value="${value%\"}"
value="${value#\"}"
[ $key = "id" ] && [ "$value" = "$id" ] && found=1
[ $key = "device" ] && device="$value"
[ $key = "name" ] && name="$value"
[ $key = "status" ] && status="$value"
[ $key = "temp" ] && [ "$value" != "*" ] && temp="$value"
[ $key = "size" ] && size=$(( $value * 1024 ))
[ $key = "numReads" ] && num_reads="$value"
[ $key = "numWrites" ] && num_writes="$value"
[ $key = "numErrors" ] && num_errors="$value"
[ $key = "type" ] && type="$value"
[ $key = "fsSize" ] && fsSize=$(( $value * 1024 ))
[ $key = "fsFree" ] && fsFree=$(( $value * 1024 ))
done <<< "$line"
fi
done < <(cat /var/local/emhttp/disks.ini ; echo "[empty]")
if [ $found = 0 ]; then
echo "UNSUPPORTED"
exit 1
fi
read bytes_read bytes_written _ < <(grep $device"=" /var/local/emhttp/diskload.ini | cut -d"=" -f2)
echo '"bytes_reading":'$bytes_read', "bytes_writing":'$bytes_written'}'
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/disks.totals.sh"><INLINE>
<![CDATA[
#!/bin/bash
id="$1"
found=0
device=""
data_size=0
data_free=0
data_used=0
cache_size=0
cache_free=0
cache_used=0
while read line; do
if [[ $line == "["* ]]; then
if [ "$type" = "Cache" ]; then
cache_size=$(( $cache_size + $size ))
cache_free=$(( $cache_free + $free ))
elif [ "$type" = "Data" ]; then
data_size=$(( $data_size + $size ))
data_free=$(( $data_free + $free ))
fi
type=""
size=0
free=0
else
IFS="=" read key value <<< "$line"
value="${value%\"}"
value="${value#\"}"
[ $key = "type" ] && type="$value"
[ $key = "fsSize" ] && size=$(( $value * 1024 ))
[ $key = "fsFree" ] && free=$(( $value * 1024 ))
fi
done < <(cat /var/local/emhttp/disks.ini ; echo "[empty]")
echo -n '{"data": {"size":'$data_size ', "free":'$data_free ', "used":'$(( $data_size - $data_free ))'},'
echo ' "cache":{"size":'$cache_size', "free":'$cache_free', "used":'$(( $cache_size - $cache_free ))'}}'
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/qemu.discovery.sh"><INLINE>
<![CDATA[
#!/bin/bash
first=1
echo -n "["
while read name; do
[ "$name" = "" ] && continue
[ $first = 0 ] && echo -n ","
first=0
echo -n '{"{#VM}":"'$name'"}'
done < <(virsh list --name --all)
echo "]"
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/qemu.sh"><INLINE>
<![CDATA[
#!/bin/bash
VM="$1"
echo -n '{'
state=`virsh domstate "$VM"`
echo -n '"state":"'$state'"'
if [ "$state" != "running" ]; then
echo -n '}'
exit
fi
while IFS=":" read key value; do
[ "$key" = "CPU(s)" ] && echo -n ', "cpus":'$value
[ "$key" = "CPU time" ] && echo -n ', "cpu_time":'${value%s}
[ "$key" = "Max memory" ] && echo -n ', "memory_max":'$((${value%KiB} * 1024))
[ "$key" = "Used memory" ] && echo -n ', "memory_used":'$((${value%KiB} * 1024))
done < <(virsh dominfo "$VM")
while read if key value; do
[ "$key" = "rx_bytes" ] && echo -n ', "network_bytes_in":'$value
[ "$key" = "tx_bytes" ] && echo -n ', "network_bytes_out":'$value
done < <(virsh domifstat "$VM" vnet0)
echo "}"
]]>
</INLINE></FILE>
<FILE Run="/bin/bash"><INLINE> <FILE Run="/bin/bash"><INLINE>
cp /boot/config/plugins/zabbix_agent/rc.zabbix_agentd /etc/rc.d/rc.zabbix_agentd if [ -x /etc/rc.d/rc.zabbix_agentd ]; then
chmod +x /etc/rc.d/rc.zabbix_agentd echo "Stopping old zabbix agent..."
/etc/rc.d/rc.zabbix_agentd stop
fi
mkdir -p /usr/local/emhttp/plugins/zabbix_agent/scripts echo "Extracting support files..."
cp -R /boot/config/plugins/zabbix_agent/scripts/* /usr/local/emhttp/plugins/zabbix_agent/scripts/ tar -xzvf /boot/config/plugins/zabbix_agent/&packageName; --strip=1 -C /
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 /etc/rc.d/rc.zabbix_agentd start
</INLINE></FILE> </INLINE></FILE>
@ -328,10 +65,12 @@ echo "Stopping zabbix_agentd..."
/etc/rc.d/rc.zabbix_agentd stop /etc/rc.d/rc.zabbix_agentd stop
echo "Deleting /usr/sbin/zabbix_agentd..." echo "Deleting /usr/sbin/zabbix_agentd..."
rm /usr/sbin/zabbix_agentd rm /usr/sbin/zabbix_agentd
echo "Deleting /boot/config/plugins/zabbix_agent..." echo "Deleting /etc/rc.d/rc.zabbix_agentd..."
rm -rf /boot/config/plugins/zabbix_agent rm /etc/rc.d/rc.zabbix_agentd
echo "Deleting /usr/local/emhttp/plugins/zabbix_agent..." echo "Deleting /boot/config/plugins/zabbix_agent/..."
rm -rf /usr/local/emhttp/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." echo "Removal of zabbix_agent plugin completed."
</INLINE></FILE> </INLINE></FILE>

View File

@ -1,118 +0,0 @@
<?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN [
<!ENTITY name "zabbix_agent">
<!ENTITY author "fabianonline">
<!ENTITY plgauthor "fabianonline">
<!ENTITY agent_version "5.0.2">
<!ENTITY baseURL "https://git.schle.nz/fabian/unraid-zabbix_agent/raw/branch/main">
<!ENTITY pluginURL "&baseURL;/zabbix_agent.plg">
<!ENTITY agentURL "&baseURL;/zabbix_agentd-&agent_version;">
<!ENTITY version "2020-07-14">
]>
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;">
<CHANGES>
##&name;
### 2020-07-14
- Initial commit
</CHANGES>
<FILE Run="/bin/bash"><INLINE>
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..."
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/rc.zabbix_agentd"><INLINE>
<![CDATA[
{{{ rc.zabbix_agentd }}}
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/zabbix_agentd.conf"><INLINE>
<![CDATA[
{{{ zabbix_agentd.conf }}}
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/disks.discovery.sh"><INLINE>
<![CDATA[
{{{ scripts/disks.discovery.sh }}}
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/disk.sh"><INLINE>
<![CDATA[
{{{ scripts/disk.sh }}}
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/disks.totals.sh"><INLINE>
<![CDATA[
{{{ scripts/disks.totals.sh }}}
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/qemu.discovery.sh"><INLINE>
<![CDATA[
{{{ scripts/qemu.discovery.sh }}}
]]>
</INLINE></FILE>
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/qemu.sh"><INLINE>
<![CDATA[
{{{ scripts/qemu.sh }}}
]]>
</INLINE></FILE>
<FILE Run="/bin/bash"><INLINE>
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
</INLINE></FILE>
<!--- Uninstall -->
<FILE Run="/bin/bash" Method="remove"><INLINE>
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."
</INLINE></FILE>
</PLUGIN>

846
zabbix_template.xml Normal file
View File

@ -0,0 +1,846 @@
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>5.0</version>
<date>2020-07-17T03:56:57Z</date>
<groups>
<group>
<name>Servers</name>
</group>
</groups>
<templates>
<template>
<template>Unraid server</template>
<name>Unraid server</name>
<groups>
<group>
<name>Servers</name>
</group>
</groups>
<applications>
<application>
<name>CPUs</name>
</application>
<application>
<name>Disks</name>
</application>
<application>
<name>Memory</name>
</application>
<application>
<name>VMs</name>
</application>
</applications>
<items>
<item>
<name>Zabbix agent ping</name>
<key>agent.ping</key>
<triggers>
<trigger>
<expression>{nodata(10m)}=1</expression>
<name>Zabbix agent is offline</name>
<priority>HIGH</priority>
</trigger>
</triggers>
</item>
<item>
<name>CPU total utilisation guest</name>
<key>system.cpu.util[all,guest,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item>
<item>
<name>CPU total utilisation idle</name>
<key>system.cpu.util[all,idle,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item>
<item>
<name>CPU total utilisation iowait</name>
<key>system.cpu.util[all,iowait,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item>
<item>
<name>CPU total utilisation system</name>
<key>system.cpu.util[all,system,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item>
<item>
<name>CPU total utilisation user</name>
<key>system.cpu.util[all,user,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item>
<item>
<name>Disk totals</name>
<key>unraid.disks.totals</key>
<history>0</history>
<trends>0</trends>
<value_type>TEXT</value_type>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
</item>
<item>
<name>Total cache free</name>
<type>DEPENDENT</type>
<key>unraid.disks.totals[cache,free]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.cache.free</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disks.totals</key>
</master_item>
</item>
<item>
<name>Total cache size</name>
<type>DEPENDENT</type>
<key>unraid.disks.totals[cache,size]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.cache.size</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disks.totals</key>
</master_item>
</item>
<item>
<name>Total cache used</name>
<type>DEPENDENT</type>
<key>unraid.disks.totals[cache,used]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.cache.used</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disks.totals</key>
</master_item>
</item>
<item>
<name>Total data free</name>
<type>DEPENDENT</type>
<key>unraid.disks.totals[data,free]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.data.free</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disks.totals</key>
</master_item>
</item>
<item>
<name>Total data size</name>
<type>DEPENDENT</type>
<key>unraid.disks.totals[data,size]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.data.size</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disks.totals</key>
</master_item>
</item>
<item>
<name>Total data used</name>
<type>DEPENDENT</type>
<key>unraid.disks.totals[data,used]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.data.used</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disks.totals</key>
</master_item>
</item>
<item>
<name>Memory available</name>
<key>vm.memory.size[available]</key>
<units>B</units>
<applications>
<application>
<name>Memory</name>
</application>
</applications>
</item>
<item>
<name>Memory used</name>
<key>vm.memory.size[used]</key>
<units>B</units>
<applications>
<application>
<name>Memory</name>
</application>
</applications>
</item>
</items>
<discovery_rules>
<discovery_rule>
<name>CPUs</name>
<key>system.cpu.discovery</key>
<delay>1h</delay>
<item_prototypes>
<item_prototype>
<name>CPU #{#CPU.NUMBER} utilisation guest</name>
<key>system.cpu.util[{#CPU.NUMBER},guest,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item_prototype>
<item_prototype>
<name>CPU #{#CPU.NUMBER} utilisation idle</name>
<key>system.cpu.util[{#CPU.NUMBER},idle,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item_prototype>
<item_prototype>
<name>CPU #{#CPU.NUMBER} utilisation iowait</name>
<key>system.cpu.util[{#CPU.NUMBER},iowait,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item_prototype>
<item_prototype>
<name>CPU #{#CPU.NUMBER} utilisation system</name>
<key>system.cpu.util[{#CPU.NUMBER},system,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item_prototype>
<item_prototype>
<name>CPU #{#CPU.NUMBER} utilisation user</name>
<key>system.cpu.util[{#CPU.NUMBER},user,avg1]</key>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>CPUs</name>
</application>
</applications>
</item_prototype>
</item_prototypes>
</discovery_rule>
<discovery_rule>
<name>Disks</name>
<key>unraid.disks.discovery</key>
<delay>10m</delay>
<item_prototypes>
<item_prototype>
<name>Disk {#ID} current reading</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},bytes_reading]</key>
<delay>0</delay>
<units>B/s</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.bytes_reading</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} current writing</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},bytes_writing]</key>
<delay>0</delay>
<units>B/s</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.bytes_writing</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} device</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},device]</key>
<delay>0</delay>
<trends>0</trends>
<value_type>TEXT</value_type>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.device</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} FS free</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},fs_free]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.fs_free</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} FS size</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},fs_size]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.fs_size</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} FS used</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},fs_used]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.fs_used</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} name</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},name]</key>
<delay>0</delay>
<trends>0</trends>
<value_type>TEXT</value_type>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.name</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} errors</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},num_errors]</key>
<delay>0</delay>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.num_errors</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
<trigger_prototypes>
<trigger_prototype>
<expression>{change()}&gt;0</expression>
<recovery_mode>NONE</recovery_mode>
<name>Disk {#ID} errored</name>
<priority>HIGH</priority>
<manual_close>YES</manual_close>
</trigger_prototype>
</trigger_prototypes>
</item_prototype>
<item_prototype>
<name>Disk {#ID} reads</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},num_reads]</key>
<delay>0</delay>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.num_reads</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} writes</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},num_writes]</key>
<delay>0</delay>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.num_writes</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} size</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},size]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.size</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} status</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},status]</key>
<delay>0</delay>
<trends>0</trends>
<value_type>TEXT</value_type>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.status</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
<trigger_prototypes>
<trigger_prototype>
<expression>{str(DISK_OK)}=0</expression>
<name>Disk {#ID} state is $1</name>
<priority>HIGH</priority>
</trigger_prototype>
</trigger_prototypes>
</item_prototype>
<item_prototype>
<name>Disk {#ID} temp</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},temp]</key>
<delay>0</delay>
<units>°C</units>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.temp</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} type</name>
<type>DEPENDENT</type>
<key>unraid.disk[{#ID},type]</key>
<delay>0</delay>
<trends>0</trends>
<value_type>TEXT</value_type>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.type</params>
</step>
</preprocessing>
<master_item>
<key>unraid.disk[{#ID}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>Disk {#ID} data</name>
<key>unraid.disk[{#ID}]</key>
<history>0</history>
<trends>0</trends>
<value_type>TEXT</value_type>
<applications>
<application>
<name>Disks</name>
</application>
</applications>
</item_prototype>
</item_prototypes>
</discovery_rule>
<discovery_rule>
<name>VMs</name>
<key>unraid.qemu.discovery</key>
<delay>10m</delay>
<item_prototypes>
<item_prototype>
<name>VM {#VM} CPUs</name>
<type>DEPENDENT</type>
<key>unraid.qemu[{#VM},cpus]</key>
<delay>0</delay>
<applications>
<application>
<name>VMs</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.cpus</params>
</step>
</preprocessing>
<master_item>
<key>unraid.qemu[{#VM}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>VM {#VM} CPU percentage</name>
<type>DEPENDENT</type>
<key>unraid.qemu[{#VM},cpu_percentage]</key>
<delay>0</delay>
<value_type>FLOAT</value_type>
<applications>
<application>
<name>VMs</name>
</application>
</applications>
<preprocessing>
<step>
<type>JAVASCRIPT</type>
<params>j=JSON.parse(value);
return j.cpu_time / j.cpus * 100;</params>
</step>
<step>
<type>CHANGE_PER_SECOND</type>
<params/>
</step>
</preprocessing>
<master_item>
<key>unraid.qemu[{#VM}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>VM {#VM} CPU time</name>
<type>DEPENDENT</type>
<key>unraid.qemu[{#VM},cpu_time]</key>
<delay>0</delay>
<value_type>FLOAT</value_type>
<units>s</units>
<applications>
<application>
<name>VMs</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.cpu_time</params>
</step>
</preprocessing>
<master_item>
<key>unraid.qemu[{#VM}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>VM {#VM} Memory max</name>
<type>DEPENDENT</type>
<key>unraid.qemu[{#VM},memory_max]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>VMs</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.memory_max</params>
</step>
</preprocessing>
<master_item>
<key>unraid.qemu[{#VM}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>VM {#VM} Memory used</name>
<type>DEPENDENT</type>
<key>unraid.qemu[{#VM},memory_used]</key>
<delay>0</delay>
<units>B</units>
<applications>
<application>
<name>VMs</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.memory_used</params>
</step>
</preprocessing>
<master_item>
<key>unraid.qemu[{#VM}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>VM {#VM} Network In</name>
<type>DEPENDENT</type>
<key>unraid.qemu[{#VM},network_in]</key>
<delay>0</delay>
<units>B/s</units>
<applications>
<application>
<name>VMs</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.network_bytes_in</params>
</step>
<step>
<type>CHANGE_PER_SECOND</type>
<params/>
</step>
</preprocessing>
<master_item>
<key>unraid.qemu[{#VM}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>VM {#VM} Network Out</name>
<type>DEPENDENT</type>
<key>unraid.qemu[{#VM},network_out]</key>
<delay>0</delay>
<units>B/s</units>
<applications>
<application>
<name>VMs</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.network_bytes_out</params>
</step>
<step>
<type>CHANGE_PER_SECOND</type>
<params/>
</step>
</preprocessing>
<master_item>
<key>unraid.qemu[{#VM}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>VM {#VM} state</name>
<type>DEPENDENT</type>
<key>unraid.qemu[{#VM},state]</key>
<delay>0</delay>
<trends>0</trends>
<value_type>TEXT</value_type>
<applications>
<application>
<name>VMs</name>
</application>
</applications>
<preprocessing>
<step>
<type>JSONPATH</type>
<params>$.state</params>
</step>
</preprocessing>
<master_item>
<key>unraid.qemu[{#VM}]</key>
</master_item>
</item_prototype>
<item_prototype>
<name>VM {#VM} data</name>
<key>unraid.qemu[{#VM}]</key>
<history>0</history>
<trends>0</trends>
<value_type>TEXT</value_type>
<applications>
<application>
<name>VMs</name>
</application>
</applications>
</item_prototype>
</item_prototypes>
</discovery_rule>
</discovery_rules>
</template>
</templates>
</zabbix_export>