#!/bin/bash function help { echo -e "Synology Plugin for Pandora FMS Plugin server. http://pandorafms.com" echo " " echo "This plugin is used to monitor a Synology device via SNMP checks" echo -e "Syntax:" echo -e "\t\tparameter 1 must be the IP address of the device" echo -e "\t\tparameter 2 must be the SNMP Community (only v2c)" echo -e "\t\tparameter 3 must be the Pandora FMS agent name" echo -e "Sample:" echo " ./synology.sh 10.113.7.220 frcpass PPAMSSV020" echo "" exit } if [ $# -ne 3 ] then help fi ip=$1 community=$2 agent=$3 temp="/tmp" filename="synology$agent.123456.data" file="$temp/$filename" pandoradir="/var/spool/pandora/data_in/" snmp=$(snmpwalk -v2c -c"$community" "$ip" 1.3.6.1.4.1.6574.1 2>&1) if [[ "$snmp" == *"Timeout"* ]] then echo "0" exit 0 else echo "1" fi echo "" > $file systemstatus=$(snmpwalk -v2c -c"$community" "$ip" -Ovq .1.3.6.1.4.1.6574.1.1.0) systemtemp=$(snmpwalk -v2c -c"$community" "$ip" -Ovq .1.3.6.1.4.1.6574.1.2.0) systempower=$(snmpwalk -v2c -c"$community" "$ip" -Ovq .1.3.6.1.4.1.6574.1.3.0) systemfan=$(snmpwalk -v2c -c"$community" "$ip" -Ovq .1.3.6.1.4.1.6574.1.4.1.0) cpufan=$(snmpwalk -v2c -c"$community" "$ip" -Ovq .1.3.6.1.4.1.6574.1.4.2.0) model=$(snmpwalk -v2c -c"$community" "$ip" -Ovq .1.3.6.1.4.1.6574.1.5.1.0) version=$(snmpwalk -v2c -c"$community" "$ip" -Ovq .1.3.6.1.4.1.6574.1.5.3.0) echo "" >> $file echo "" >> $file echo "generic_data" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "generic_data" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "generic_data" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "generic_data" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "generic_data" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "generic_data_string" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "generic_data_string" >> $file echo "" >> $file echo "" >> $file echo "" >> $file for i in $(snmpwalk -v2c -c"$community" "$ip" -Ovq SNMPv2-SMI::enterprises.6574.2.1.1.1) do disk_id=$(snmpget -v2c -c"$community" "$ip" -Ovq SNMPv2-SMI::enterprises.6574.2.1.1.2.$i | sed 's/"//g') disk_name=$(snmpget -v2c -c"$community" "$ip" -Ovq SNMPv2-SMI::enterprises.6574.2.1.1.3.$i| sed 's/"//g') disk_status=$(snmpget -v2c -c"$community" "$ip" -Ovq SNMPv2-SMI::enterprises.6574.2.1.1.5.$i) disk_temp=$(snmpget -v2c -c"$community" "$ip" -Ovq SNMPv2-SMI::enterprises.6574.2.1.1.6.$i) echo "" >> $file echo "" >> $file echo "generic_data" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "generic_data" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file done for i in $(snmpwalk -v2c -c"$community" "$ip" -Ovq SNMPv2-SMI::enterprises.6574.3.1.1.1) do raid_name=$(snmpget -v2c -c"$community" "$ip" -Ovq 1.3.6.1.4.1.6574.3.1.1.2.$i| sed 's/"//g') raid_status=$(snmpget -v2c -c"$community" "$ip" -Ovq 1.3.6.1.4.1.6574.3.1.1.3.$i) raid_free=$(snmpget -v2c -c"$community" "$ip" -Ovq 1.3.6.1.4.1.6574.3.1.1.4.$i) raid_total=$(snmpget -v2c -c"$community" "$ip" -Ovq 1.3.6.1.4.1.6574.3.1.1.5.$i) perc_total=$(echo "scale=2; $raid_free * 100 / $raid_total" | bc) echo "" >> $file echo "" >> $file echo "generic_data" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "generic_data" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file echo "" >> $file done echo "" >> $file mv $file $pandoradir