More and better scripts.
This commit is contained in:
parent
90166ba51f
commit
7be58113d8
@ -7,8 +7,9 @@ device=""
|
|||||||
while read line; do
|
while read line; do
|
||||||
if [[ $line == "["* ]]; then
|
if [[ $line == "["* ]]; then
|
||||||
if [ $found = 1 ]; 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 '{"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
|
break
|
||||||
else
|
else
|
||||||
device=''
|
device=''
|
||||||
@ -22,6 +23,7 @@ while read line; do
|
|||||||
type=""
|
type=""
|
||||||
fsSize=-1
|
fsSize=-1
|
||||||
fsFree=-1
|
fsFree=-1
|
||||||
|
fsUsed=-1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
while IFS="=" read key value; do
|
while IFS="=" read key value; do
|
||||||
|
38
scripts/disks.totals.sh
Executable file
38
scripts/disks.totals.sh
Executable file
@ -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 ))'}}'
|
@ -24,17 +24,21 @@
|
|||||||
echo "Installation of zabbix_agent plugin started."
|
echo "Installation of zabbix_agent plugin started."
|
||||||
mkdir -p /boot/config/plugins/zabbix_agent/scripts
|
mkdir -p /boot/config/plugins/zabbix_agent/scripts
|
||||||
if [ -e /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version; ]; then
|
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
|
else
|
||||||
echo "zabbix_agent version &agent_version; not found."
|
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/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;..."
|
echo "Downloading &agentURL;..."
|
||||||
wget "&agentURL;" -O /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version;
|
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/rc.zabbix_agentd"><INLINE>
|
||||||
@ -119,6 +123,7 @@ DenyKey=*
|
|||||||
|
|
||||||
UserParameter=unraid.disks.discovery,/usr/local/emhttp/plugins/zabbix_agent/scripts/disks.discovery.sh
|
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.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.discovery,/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.discovery.sh
|
||||||
UserParameter=unraid.qemu[*],/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.sh "$1"
|
UserParameter=unraid.qemu[*],/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.sh "$1"
|
||||||
|
|
||||||
@ -158,8 +163,9 @@ device=""
|
|||||||
while read line; do
|
while read line; do
|
||||||
if [[ $line == "["* ]]; then
|
if [[ $line == "["* ]]; then
|
||||||
if [ $found = 1 ]; 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 '{"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
|
break
|
||||||
else
|
else
|
||||||
device=''
|
device=''
|
||||||
@ -173,6 +179,7 @@ while read line; do
|
|||||||
type=""
|
type=""
|
||||||
fsSize=-1
|
fsSize=-1
|
||||||
fsFree=-1
|
fsFree=-1
|
||||||
|
fsUsed=-1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
while IFS="=" read key value; do
|
while IFS="=" read key value; do
|
||||||
@ -205,6 +212,50 @@ echo '"bytes_reading":'$bytes_read', "bytes_writing":'$bytes_written'}'
|
|||||||
]]>
|
]]>
|
||||||
</INLINE></FILE>
|
</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>
|
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/qemu.discovery.sh"><INLINE>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
@ -24,17 +24,21 @@
|
|||||||
echo "Installation of zabbix_agent plugin started."
|
echo "Installation of zabbix_agent plugin started."
|
||||||
mkdir -p /boot/config/plugins/zabbix_agent/scripts
|
mkdir -p /boot/config/plugins/zabbix_agent/scripts
|
||||||
if [ -e /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version; ]; then
|
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
|
else
|
||||||
echo "zabbix_agent version &agent_version; not found."
|
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/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;..."
|
echo "Downloading &agentURL;..."
|
||||||
wget "&agentURL;" -O /boot/config/plugins/zabbix_agent/zabbix_agentd-&agent_version;
|
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/rc.zabbix_agentd"><INLINE>
|
||||||
@ -61,6 +65,12 @@ fi
|
|||||||
]]>
|
]]>
|
||||||
</INLINE></FILE>
|
</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>
|
<FILE Name="/boot/config/plugins/zabbix_agent/scripts/qemu.discovery.sh"><INLINE>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{{{ scripts/qemu.discovery.sh }}}
|
{{{ scripts/qemu.discovery.sh }}}
|
||||||
|
@ -24,5 +24,6 @@ DenyKey=*
|
|||||||
|
|
||||||
UserParameter=unraid.disks.discovery,/usr/local/emhttp/plugins/zabbix_agent/scripts/disks.discovery.sh
|
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.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.discovery,/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.discovery.sh
|
||||||
UserParameter=unraid.qemu[*],/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.sh "$1"
|
UserParameter=unraid.qemu[*],/usr/local/emhttp/plugins/zabbix_agent/scripts/qemu.sh "$1"
|
||||||
|
Loading…
Reference in New Issue
Block a user