diff --git a/scripts/disk.sh b/scripts/disk.sh
index 8d5148c..f2516a6 100755
--- a/scripts/disk.sh
+++ b/scripts/disk.sh
@@ -7,8 +7,9 @@ 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', '
+ echo -n '"num_writes":'$num_writes', "num_errors":'$num_errors', "type":"'$type'", "fs_size":'$fsSize', "fs_free":'$fsFree', "fs_used":'$fsUsed', '
break
else
device=''
@@ -22,6 +23,7 @@ while read line; do
type=""
fsSize=-1
fsFree=-1
+ fsUsed=-1
fi
else
while IFS="=" read key value; do
diff --git a/scripts/disks.totals.sh b/scripts/disks.totals.sh
new file mode 100755
index 0000000..c085500
--- /dev/null
+++ b/scripts/disks.totals.sh
@@ -0,0 +1,38 @@
+#!/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 ))'}}'
diff --git a/zabbix_agent.plg b/zabbix_agent.plg
index 0a169e5..80a0b5f 100644
--- a/zabbix_agent.plg
+++ b/zabbix_agent.plg
@@ -24,17 +24,21 @@
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 files."
+ echo "Agent already exists. Using local file."
else
echo "zabbix_agent version &agent_version; not found."
- echo "Removing old files..."
+ echo "Removing old agents..."
rm /boot/config/plugins/zabbix_agent/zabbix_agentd-*
- 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 "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..."
@@ -119,6 +123,7 @@ 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"
@@ -158,8 +163,9 @@ 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', '
+ echo -n '"num_writes":'$num_writes', "num_errors":'$num_errors', "type":"'$type'", "fs_size":'$fsSize', "fs_free":'$fsFree', "fs_used":'$fsUsed', '
break
else
device=''
@@ -173,6 +179,7 @@ while read line; do
type=""
fsSize=-1
fsFree=-1
+ fsUsed=-1
fi
else
while IFS="=" read key value; do
@@ -205,6 +212,50 @@ echo '"bytes_reading":'$bytes_read', "bytes_writing":'$bytes_written'}'
]]>
+
+
+
+
@@ -61,6 +65,12 @@ fi
]]>
+
+
+
+