Monitor Synology NAS with SNMP

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Monitor Synology NAS with SNMP

Post by papoo »

this script is not necessarily successful, do not hesitate to propose improvements, optimizations
2018-08-24 18_31_58-Domoticz.png
2018-08-24 18_31_58-Domoticz.png (24.57 KiB) Viewed 11153 times
For this script to work you need to enable SNMP on your synology NAS and install SNMP on your Raspberry Pi

Enable SNMP on your synology NAS

Go toMain Menu>Control Panel >SNMP to enable SNMP service, which allows users to monitor
Synology DiskStation network flow with the network management software.

You can use V1/V2
And set a password (Community)

Install SNMP on Raspberry Pi
Log in to you Raspberry Pi and issue:

sudo apt-get install snmpd
sudo apt-get install snmp

Reboot your Pi:
sudo reboot

Check if SNMP is up and running, issue:
snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.4.1.6574.1.5.1.0

Replace PASSWORD with the Community name you entered while setting up your NAS
Replace NASIPADDRESS with the ip address of your NAS
You should get something like this:
"DS218+" which corresponds to your Synology Model

test
snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.5.31
snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.5.38
snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.5.41
then modify OID_HDUnit, OID_HDTotal, OID_HDUsed variables (.38 on DSM 5.1, .41 on DSM 6.0+ or .31 on my new DS218)

if you have à DS2XX model, uncomment -- local OID_HDtemp2='1.3.6.1.4.1.6574.2.1.1.6.1' to show the hdd2 temperature

Then create:
1 device Switch
x temperature device
3 percent devices
1 meter device
all you have to do is create a Synology.lua file that you will put in /home/pi/domoticz/scripts/dzVents/scripts/Synology.lua
you will customize the following code

Code: Select all

--[[
name : synology2.lua
auteur : papoo
creation : 17/02/2019
mise à  jour : 05/04/2019

https://pon.fr/dzvents-supervision-dun-nas-synology-avec-snmp/
https://github.com/papo-o/domoticz_scripts/blob/master/dzVents/scripts/synology2.lua
https://easydomoticz.com/forum/viewtopic.php?f=17&t=7022
https://www.domoticz.com/forum/viewtopic.php?f=59&t=24618

For this script to work you need to enable SNMP on your synology NAS and install SNMP on your Raspberry Pi

Enable SNMP on your synology NAS
 
Go toMain Menu>Control Panel >SNMP to enable SNMP service, which allows users to monitor
Synology DiskStation network flow with the network management software.

You can use V1/V2
And set a password (Community)

Install SNMP on Raspberry Pi
Log in to you Raspberry Pi and issue:

sudo apt-get install snmpd
sudo apt-get install snmp

Reboot your Pi:
sudo reboot

Check if SNMP is up and running, issue:
snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.4.1.6574.1.5.1.0

Replace PASSWORD with the Community name you entered while setting up your NAS
Replace NASIPADDRESS with the ip address of your NAS
You should get something like this:
"DS218+" which corresponds to your Synology Model

how to choose disk capacity to monitor?

snmpwalk -v 2c -c PASSWORD NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.3
results of my DS218 :

HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Physical memory
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Virtual memory
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: Memory buffers
HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: Cached memory
HOST-RESOURCES-MIB::hrStorageDescr.8 = STRING: Shared memory
HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: Swap space
HOST-RESOURCES-MIB::hrStorageDescr.31 = STRING: /
HOST-RESOURCES-MIB::hrStorageDescr.36 = STRING: /tmp
HOST-RESOURCES-MIB::hrStorageDescr.37 = STRING: /run
HOST-RESOURCES-MIB::hrStorageDescr.38 = STRING: /dev/shm
HOST-RESOURCES-MIB::hrStorageDescr.39 = STRING: /sys/fs/cgroup
HOST-RESOURCES-MIB::hrStorageDescr.40 = STRING: /run/cgmanager/fs
HOST-RESOURCES-MIB::hrStorageDescr.51 = STRING: /volume1
HOST-RESOURCES-MIB::hrStorageDescr.54 = STRING: /volume1/@docker/btrfs


then modify     OID_HDUnit, OID_HDTotal, OID_HDUsed variables with your last number choice (.38 on DSM 5.1, .41 on DSM 6.0+ or .51 on my new DS218)

if you have à DS2XX model, uncomment     -- local OID_HDtemp2='1.3.6.1.4.1.6574.2.1.1.6.1'  to show the hdd2 temperature
Then create:
1 device Switch
1 temperature device
3 percent devices
x meter device   
--]]
--------------------------------------------
-------------Fonctions----------------------
-------------------------------------------- 
function format(str)
   if (str) then
      str = string.gsub (str, " Bytes", "")
      str = string.gsub (str, " kB", "")

   end
   return str   
end

-------------------------------------------
-------------Fin Fonctions-----------------
-------------------------------------------

    local NasIp = "diskstation2"                            -- NAS IP Address
    local CommunityPassword = "synology"                    -- SNMP Password
    local NAS = "Synology"                                  -- NAS Switch
    local NAS_TEMP = "Synology Temp"
    local NAS_CPU = "Synology Utilisation CPU"              -- NAS CPU 
    local NAS_MEM = "Synology Utilisation RAM"              -- NAS MEM 
    local NAS_HD_SPACE_PERC = "Synology Occupation Disque"  -- NAS HD Space  in %
    local NAS_HD_SPACE = "Synology Espace Disponible"       -- NAS HD Space  in Go (custom sensor)
    local NAS_HDD1_TEMP = "Synology HDD1 Temp"              -- NAS HD1 Temp, nil si inutilisé 
    local NAS_HDD2_TEMP = nil                               -- NAS HD2 Temp, nil si inutilisé
    local NAS_HDD3_TEMP = nil                               -- NAS HD3 Temp, nil si inutilisé
    local NAS_HDD4_TEMP = nil                               -- NAS HD4 Temp, nil si inutilisé
    local OID_NAS_TEMP = '1.3.6.1.4.1.6574.1.2.0'
    local OID_HDUnit = '1.3.6.1.2.1.25.2.3.1.4.51'          -- OID HD Unit Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .51 on my DS218
    local OID_HDTotal = '1.3.6.1.2.1.25.2.3.1.5.51'         -- OID Total space volume in Go Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .51 on my DS218
    local OID_HDUsed = '1.3.6.1.2.1.25.2.3.1.6.51'          -- OID Space used volume in Go Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+ or .51 on my DS218
    local OID_CpuUser = '1.3.6.1.4.1.2021.11.9.0'           -- OID CPU user
    local OID_CpuSystem = '1.3.6.1.4.1.2021.11.10.0'        -- OID CPU System
    local OID_MemAvailable = '1.3.6.1.4.1.2021.4.13.0'      -- OID Free Memory Available
    local OID_MemTotalSwap = '1.3.6.1.4.1.2021.4.3.0'       -- OID MemTotalSwap
    local OID_MemTotalReal = '1.3.6.1.4.1.2021.4.5.0'       -- OID MemTotalReal
    local OID_MemTotalFree = '1.3.6.1.4.1.2021.4.11.0'      -- OID MemTotalFree
    local OID_HDtemp1 = '1.3.6.1.4.1.6574.2.1.1.6.0'        -- OID Temperature HDD1   
    local OID_HDtemp2 = '1.3.6.1.4.1.6574.2.1.1.6.1'        -- OID Temperature HDD2 
    local OID_HDtemp3 = '1.3.6.1.4.1.6574.2.1.1.6.2'        -- OID Temperature HDD3
    local OID_HDtemp4 = '1.3.6.1.4.1.6574.2.1.1.6.3'        -- OID Temperature HDD4
    --local OID_Raid_Status = '1.3.6.1.4.1.6574.3.1.1.3.0'        -- OID Raid Status
    --local OID_Physical_Memory_Units = '1.3.6.1.2.1.25.2.3.1.4.1'
    --local OID_Physical_Memory_Size = '1.3.6.1.2.1.25.2.3.1.5.1'
    --local OID_Physical_Memory_Used = '1.3.6.1.2.1.25.2.3.1.6.1'
    --local OID_system_memory_total = '1.3.6.1.4.1.2021.4.5.0'
    --local OID_system_memory_free = '1.3.6.1.4.1.2021.4.6.0'
    --local OID_system_vsmemory_shared = '1.3.6.1.4.1.2021.4.13.0'
    --local OID_system_vsmemory_buffer = '1.3.6.1.4.1.2021.4.14.0'

   
return {
    active = true,
    on = {
    timer = {'every minute'}
    },    
   -- on = { devices = { "your trigger device" }},
        
  logging =   {   level    =   domoticz.LOG_DEBUG,                                             -- Seulement un niveau peut être actif; commenter les autres
                -- level    =   domoticz.LOG_INFO,                                            -- Only one level can be active; comment others
                -- level    =   domoticz.LOG_ERROR,
                -- level    =   domoticz.LOG_MODULE_EXEC_INFO,
                marker    =   "Synology Monitor v1.35 "      },
    
    execute = function(dz)
        local i = 0
        local results = {}
        local command = 'snmpget -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_NAS_TEMP..' '..OID_HDUnit..' '..OID_HDTotal..' '..OID_HDUsed..' '..OID_CpuUser..' '..OID_CpuSystem..' '..OID_MemAvailable ..' '.. OID_MemTotalSwap ..' '..OID_MemTotalReal..' '..OID_MemTotalFree..' '..OID_HDtemp1..' '..OID_HDtemp2..' '..OID_HDtemp3..' '..OID_HDtemp4--..' '..OID_Physical_Memory_Units ..' '..OID_Physical_Memory_Used..' '..OID_Physical_Memory_Size ..' '..OID_system_memory_total ..' '..OID_system_memory_free ..' '.. OID_system_vsmemory_shared ..' '.. OID_system_vsmemory_buffer 
        local handle = assert(io.popen(command))
        for line in handle:lines() do
            results[i] =  format(line)
            i = i + 1
        end
        handle:close()
        if results[0] then
            dz.log("NASTemp : "..results[0],dz.LOG_DEBUG)
            if NAS_TEMP then dz.devices(NAS_TEMP).update(0,results[0]) end
            end
        if results[1] then dz.log("HDUnit : "..results[1],dz.LOG_DEBUG) end
        if results[2] then dz.log("HDTotal : "..results[2],dz.LOG_DEBUG) end
        if results[3] then dz.log("HDUsed : "..results[3],dz.LOG_DEBUG) end
        if results[4] then dz.log("CpuUser : "..results[4],dz.LOG_DEBUG) end
        if results[5] then dz.log("CpuSystem : "..results[5],dz.LOG_DEBUG) end
        
        if results[1] and results[2] then

           HDTotalGo = dz.utils.round((results[2] *  results[1] / 1024 / 1024 / 1024/1024),2)
           dz.log("HDTotalGo : "..HDTotalGo,dz.LOG_DEBUG)
        end
         if results[1] and results[3] then
           HDUsedGo = dz.utils.round(((results[3]) *  results[1] / 1024 / 1024 / 1024/1024), 2)
        end       

        if results[1] and results[2] and results[3] then
            HDFreeGo = dz.utils.round(((results[2] - results[3]) *  results[1] / 1024 / 1024 / 1024/1024),2)
        end
        if HDFreeGo then 
            dz.log("HDFreeGo : "..HDFreeGo,dz.LOG_DEBUG) 
            dz.devices(NAS_HD_SPACE).update(0,HDFreeGo)
            end 
        if results[2] and results[3] then         
            HDFreePerc = dz.utils.round(((results[3] * 100) / results[2]), 0)
        end
        if HDFreePerc then 
            dz.log("HDFreePercent : "..HDFreePerc,dz.LOG_DEBUG)
            dz.devices(NAS_HD_SPACE_PERC).update(0,HDFreePerc)
            end
        if results[4] and results[5] then
            CpuUsed = (results[4] + results[5])
        end
        if CpuUsed then 
            dz.log("CpuUsed : "..CpuUsed,dz.LOG_DEBUG)
            dz.devices(NAS_CPU).update(0,CpuUsed)
            end

        if results[7] then
            dz.log("memTotalSwap: "..tostring(results[7]),dz.LOG_DEBUG)
        end
        if results[8] then
            dz.log("memTotalReal: "..tostring(results[8]),dz.LOG_DEBUG)
        end
        if results[9] then
            dz.log("memTotalFree: "..tostring(results[9]),dz.LOG_DEBUG)
        end

        if results[7] and results[8] and results[9] then
            MemUsedPerc = dz.utils.round(100-results[9]*100/(results[7]+results[8]), 0)
        end
        if MemUsedPerc then 
            dz.log("MemUsedPercent : "..MemUsedPerc,dz.LOG_DEBUG)
            dz.devices(NAS_MEM).update(0,MemUsedPerc)
        end

        if results[10] then 
            dz.log("HDTemp1 : "..tostring(results[10]),dz.LOG_DEBUG) 
            if NAS_HDD1_TEMP ~= nil then dz.devices(NAS_HDD1_TEMP).update(0,results[10]) end
        end
        if results[11] then 
            dz.log("HDTemp2 : "..tostring(results[11]),dz.LOG_DEBUG) 
            if NAS_HDD2_TEMP ~= nil then dz.devices(NAS_HDD2_TEMP).update(0,results[11]) end
        end
        if results[12] then 
            dz.log("HDTemp3 : "..tostring(results[12]),dz.LOG_DEBUG) 
            if NAS_HDD3_TEMP ~= nil then dz.devices(NAS_HDD3_TEMP).update(0,results[12]) end
        end
        if results[13] then 
            dz.log("HDTemp4 : "..tostring(results[13]),dz.LOG_DEBUG) 
            if NAS_HDD4_TEMP ~= nil then dz.devices(NAS_HDD4_TEMP).update(0,results[13]) end
        end

        if results[0] and results[5] and results[6] then
                dz.log("Requete SNMP correcte ",dz.LOG_DEBUG)
                dz.devices(NAS).switchOn().checkFirst()
            else
                dz.log("Requete SNMP incorrecte ",dz.LOG_DEBUG)
                dz.devices(NAS).switchOff().checkFirst()
            end

        --RAID Status :
        --OK(1), Repairing(2), Migrating(3), Expanding(4), Deleting(5), Creating(6), RaidSyncing(7), RaidParityChecking(8), RaidAssembling(9), Canceling(10), Degraded(11), Creashed(12)
    end
}
Here are the logs of my NAS when the level domoticz.LOG_DEBUG is activated:
2018-08-24 19_06_24-Domoticz.png
2018-08-24 19_06_24-Domoticz.png (17.33 KiB) Viewed 11153 times
Last edited by papoo on Friday 05 April 2019 13:28, edited 6 times in total.
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Monitor Synology NAS with SNMP

Post by sincze »

Tnx. Nice to see somebody managed to move the script towards dzvents. Maybe add it to the Domoticz general wiki as well under Monitor NAS ??
https://www.domoticz.com/wiki/NAS_Monitoring
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: Monitor Synology NAS with SNMP

Post by papoo »

script update
DomoRies
Posts: 14
Joined: Friday 25 November 2016 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Monitor Synology NAS with SNMP

Post by DomoRies »

Thanks for your script! It's easy to install but i get a error in the domoticz log:

Code: Select all

2018-09-03 12:22:00.594 Status: dzVents: Error (2.4.7): Synology Monitor v1.03 : An error occured when calling event handler synology
2018-09-03 12:22:00.594 Status: dzVents: Error (2.4.7): Synology Monitor v1.03 : /home/pi/domoticz/scripts/dzVents/scripts/synology.lua:118: attempt to perform arithmetic on field '?' (a string value)
Now it only updates NAS_HD1_TEMP
I'm using domoticz beta version: 4.9980 and Synology nas DS1513+ DSM 6.2-23739 Update 2
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: Monitor Synology NAS with SNMP

Post by freijn »

Very nice job, many thanks !
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Monitor Synology NAS with SNMP

Post by snellejellep »

it works for some things but i get this error message:

Code: Select all

2018-09-03 19:36:00.359 Status: dzVents: Error (2.4.7): Synology Monitor v1.03 : An error occured when calling event handler monitor NAS
2018-09-03 19:36:00.359 Status: dzVents: Error (2.4.7): Synology Monitor v1.03 : ...moticz/scripts/dzVents/generated_scripts/monitor NAS.lua:117: attempt to perform arithmetic on field '?' (a string value)
can someone help me?
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: Monitor Synology NAS with SNMP

Post by papoo »

comment line 86 level = domoticz.LOG_ERROR, -- Only one level can be active; comment others
uncomment line 87 -- level = domoticz.LOG_DEBUG,

what the result on your log?

OID HD Unit Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
OID Total space volume in Go Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
OID Space used volume in Go Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
if you have a new synology nas try .31
if you want to try in command line before install this script

Code: Select all

snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.5.31
snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.5.38
snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.5.41
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Monitor Synology NAS with SNMP

Post by snellejellep »

papoo wrote: Monday 03 September 2018 21:06 comment line 86 level = domoticz.LOG_ERROR, -- Only one level can be active; comment others
uncomment line 87 -- level = domoticz.LOG_DEBUG,

what the result on your log?

OID HD Unit Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
OID Total space volume in Go Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
OID Space used volume in Go Change OID to .38 on DSM 5.1 or .41 on DSM 6.0+
if you have a new synology nas try .31
if you want to try in command line before install this script

Code: Select all

snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.5.31
snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.5.38
snmpget -v 2c -c PASSWORD -O qv NASIPADDRESS 1.3.6.1.2.1.25.2.3.1.5.41
that fixed it for me, thanks!
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: Monitor Synology NAS with SNMP

Post by papoo »

script and help update
Tonio16
Posts: 45
Joined: Friday 23 February 2018 20:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: France
Contact:

Re: Monitor Synology NAS with SNMP

Post by Tonio16 »

Hello

Just one remark. On my DS216Play I am using .42 with the last DSM.

Regards

Antoine
SchulieBug
Posts: 4
Joined: Monday 25 March 2019 16:04
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Monitor Synology NAS with SNMP

Post by SchulieBug »

I'm getting these errors:

2019-03-26 16:10:00.204 Status: dzVents: Error (2.4.15): Synology Monitor v1.04 : An error occured when calling event handler SynologyNAS
2019-03-26 16:10:00.204 Status: dzVents: Error (2.4.15): Synology Monitor v1.04 : ...cz/var/scripts/dzVents/generated_scripts/SynologyNAS.lua:75: attempt to perform arithmetic on field '?' (a nil value)

Can someone point me in the right direction?
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: Monitor Synology NAS with SNMP

Post by papoo »

@SchulieBug
can you tell me what is your ligne 75?
the last version of this script is here https://github.com/papo-o/domoticz_scri ... ology2.lua
can you try it?
User avatar
papoo
Posts: 126
Joined: Friday 22 January 2016 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10
Location: France
Contact:

Re: Monitor Synology NAS with SNMP

Post by papoo »

new version 1.35.
Improvement calculation of the memory used and taking into account the temperature HDD up to 4 disks
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Monitor Synology NAS with SNMP

Post by FunFair »

With DSM7 my 2 disks are located at .1.3.6.1.2.1.25.2.3.1.5.47 and .1.3.6.1.2.1.25.2.3.1.5.48

This instead of .38 or .41
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Monitor Synology NAS with SNMP

Post by EddyG »

For those who connect a APC UPS to the Synology you could use:

Code: Select all

    local OID_UPS_STATUS = '1.3.6.1.4.1.6574.4.2.1.0'       -- OID Ups status
    local OID_UPS_RUNTIME = '1.3.6.1.4.1.6574.4.3.6.1.0'    -- OID Ups runtime
    local OID_UPS_CHARGE = '1.3.6.1.4.1.6574.4.3.1.1.0'     -- OID Ups status
    local UPS_Status = ""
...    
                ..OID_UPS_STATUS..' '..OID_UPS_RUNTIME..' '..OID_UPS_CHARGE..' '
...
        if results[17] then
            if results[17] == '"OL"' then UPS_Status = 'ONLINE'
            elseif results[17] == '"OB"' then UPS_Status = 'ON BATTERY'
            elseif results[17] == '"LB"' then UPS_Status = 'LOW BATTERY'
            elseif results[17] == '"HB"' then UPS_Status = 'HIGH BATTERY'
            elseif results[17] == '"RB"' then UPS_Status = 'REPLACE BATTERY'
            elseif results[17] == '"OL CHRG"' then UPS_Status = 'CHARGING'
            elseif results[17] == '"OB DISCHRG"' then UPS_Status = 'DISCHARGING'
            elseif results[17] == '"BYPASS"' then UPS_Status = 'BYPASS'
            elseif results[17] == '"CAL"' then UPS_Status = 'CALIBRATION'
            elseif results[17] == '"OFF"' then UPS_Status = 'OFF'
            elseif results[17] == '"OVER"' then UPS_Status = 'OVERLOAD'
            elseif results[17] == '"TRIM"' then UPS_Status = 'SMART TRIM'
            elseif results[17] == '"BOOST"' then UPS_Status = 'BOOST'
            elseif results[17] == '"FSD"' then UPS_Status = 'FORCE SHUTDOWN'
            else UPS_Status = 'UNKNOWN'
            end
            dz.log("NAS UPS status : "..tostring(UPS_Status),dz.LOG_DEBUG)
            if NAS_UPS_STATUS ~= nil then dz.devices(NAS_UPS_STATUS).updateText(UPS_Status) end
        end

        if results[18] then
            dz.log("NAS UPS runtime : "..tostring(dz.utils.round(results[18]/60,0)),dz.LOG_DEBUG)
            if NAS_UPS_RUNTIME ~= nil then dz.devices(NAS_UPS_RUNTIME).update(0,dz.utils.round(results[18]/60,0)) end
        end

        if results[19] then
            dz.log("NAS UPS charge : "..tostring(dz.utils.round(results[19],0)),dz.LOG_DEBUG)
            if NAS_UPS_CHARGE ~= nil then dz.devices(NAS_UPS_CHARGE).update(0,dz.utils.round(results[19],0)) end
        end
Change the index (17,18,19) to the real index.
Status is a Text device, Runtime a custom sensor with axis -> mins and Charge is a percentage device.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Monitor Synology NAS with SNMP

Post by EddyG »

The OID_CpuUser and OID_CpuSystem are momentary values, and vary a lot.
Beter use the one (or more) of the load values:

Code: Select all

    local OID_Cpu_1min = '1.3.6.1.4.1.2021.10.1.3.1'
    local OID_Cpu_5min = '1.3.6.1.4.1.2021.10.1.3.2' 
    local OID_Cpu_15min = '1.3.6.1.4.1.2021.10.1.3.3' 
jeroenkl
Posts: 113
Joined: Sunday 14 July 2013 22:00
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: NL
Contact:

Re: Monitor Synology NAS with SNMP

Post by jeroenkl »

FunFair wrote: Tuesday 29 June 2021 22:01 With DSM7 my 2 disks are located at .1.3.6.1.2.1.25.2.3.1.5.47 and .1.3.6.1.2.1.25.2.3.1.5.48

This instead of .38 or .41
On DS920+ with DSM7 it is .57
Last edited by jeroenkl on Friday 17 September 2021 20:53, edited 1 time in total.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Monitor Synology NAS with SNMP

Post by EddyG »

On DSM 7.0 you can walk 1.3.6.1.2.1.25.2.3.1 and starting 1.3.6.1.2.1.25.2.3.1.31 you will see textual description of the different mounts.
This is part of mine:

Code: Select all

01/09/2021 15:30:20 (178 ms) : 1.3.6.1.2.1.25.2.3.1.3.31 = "/" [ASN_OCTET_STR]
01/09/2021 15:30:20 (197 ms) : 1.3.6.1.2.1.25.2.3.1.3.56 = "/volume1" [ASN_OCTET_STR]

Here you can find that my volume1 is on 1.3.6.1.2.1.25.2.3.1.3.56 Yours might differ on the last digits.
The corresponding data for calculating free space is on:

Code: Select all

1.3.6.1.2.1.25.2.3.1.4.56  -> Unit
1.3.6.1.2.1.25.2.3.1.5.56  -> Total space
1.3.6.1.2.1.25.2.3.1.6.56  -> Used space
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest