Page 11 sur 15
Re: DZVents : Supervision d'un nas Synology avec SNMP
Publié : 09 févr. 2021, 19:28
par denis_brasseur
La ligne de commande récupéré et saisie dans le terminal valide bien les OID.
C'est donc bien snmpget qu'il te faut utiliser.
Depuis les logs :
Code : Tout sélectionner
Status: dzVents: snmpget -v 2c -c password -O qv adresseip 1.3.6.1.4.1.2021.11.9.0
Debug: Synology Monitor v1.41 : Requete SNMP incorrecte
Il te faut maintenant comprendre pourquoi la requete est tronqué, et pourquoi un et un seul OID est affiché dans la requete et depuis le script alors que pris en compte dans le terminal.
Re: DZVents : Supervision d'un nas Synology avec SNMP
Publié : 10 févr. 2021, 18:17
par Tontonpat
Bonjour,
Tu dis que chez toi çà fonctionne. Tu supervises ton NAS depuis ce même NAS?
Le « Requete SNMP incorrecte » est lié au script:
Code : Tout sélectionner
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
As tu une idée pour m'aider?
Re: DZVents : Supervision d'un nas Synology avec SNMP
Publié : 11 févr. 2021, 11:56
par Tontonpat
Bonjour,
En testant ça :
J'ai bien la 1ère valeur remontée.
Code : Tout sélectionner
2021-02-11 11:51:00.661 Status: dzVents: Info: Synology Monitor v1.41 : ------ Start internal script: ZZ Temp NAS:, trigger: "every minute"
2021-02-11 11:51:00.663 Status: dzVents: Debug: Synology Monitor v1.41 : last ifHCOutOctets : 0 at 60 seconds ago
2021-02-11 11:51:00.663 Status: dzVents: Debug: Synology Monitor v1.41 : last ifHCInOctets : 0 at 60 seconds ago
2021-02-11 11:51:00.705 Status: dzVents: 39
2021-02-11 11:51:00.705 Status: dzVents: Debug: Synology Monitor v1.41 : NASTemp : 39
2021-02-11 11:51:00.705 Status: dzVents: Debug: Synology Monitor v1.41 : Processing device-adapter for NAS Temp: Temperature device adapter
2021-02-11 11:51:00.706 Status: dzVents: Debug: Synology Monitor v1.41 : Upload : 0ko/s, Download : 0ko/s
2021-02-11 11:51:00.706 Status: dzVents: Debug: Synology Monitor v1.41 : Requete SNMP incorrecte
2021-02-11 11:51:00.706 Status: dzVents: Debug: Synology Monitor v1.41 : Constructed timed-command: Off
2021-02-11 11:51:00.706 Status: dzVents: Info: Synology Monitor v1.41 : ------ Finished ZZ Temp NAS
Si je test avec 1 au lieu de 0 :
Rien ne s'affiche
Cela veut bien dire que results ne s'incrémente pas, non?
Re: DZVents : Supervision d'un nas Synology avec SNMP
Publié : 14 févr. 2021, 11:55
par Tontonpat
Bonjour,
Je tourne en rond...
Est ce que quelqu’un supervise son NAS depuis son NAS?
snmpwalk n’affiche que la première valeur, et snmpget n’affiche rien du tout.
Du coup j’ai fait plusieurs dzvents sur lesquels je change le premier oid.
Est ce possible de combiner tous les dzvents en un seul?
Re: DZVents : Supervision d'un nas Synology avec SNMP
Publié : 17 févr. 2021, 05:22
par denis_brasseur
Tu dois pouvoir faire une boucle afin de n'avoir qu'un seul script.
Je n'ai pas testé, il y aura certainement du debug a faire
L'idée est de faire un tableau (les_oid) et de boucler sur les éléments de ce tableau.
Je ne connais pas la performance de ce script.
Code : Tout sélectionner
local les_oid = {
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_ifHCOutOctets,
OID_ifHCInOctets
} -- Liste des oid séparées par une virgule
local i = 0
local results = {}
for _, name in ipairs(les_oid) do
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..name
local handle = assert(io.popen(command))
for line in handle:lines() do
--dz.log(format(line).." "..i, dz.LOG_info)
results[i] = format(line)
end
handle:close()
i = i + 1
end
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
Re: DZVents : Supervision d'un nas Synology avec SNMP
Publié : 17 févr. 2021, 08:59
par Tontonpat
Merci,
Je vais étudier ça et je te dirai
Re: DZVents : Supervision d'un nas Synology avec SNMP
Publié : 20 févr. 2021, 11:06
par Tontonpat
Bonjour,
J'ai tout regroupé dans un seul script, en tâtonnant :
Code : Tout sélectionner
--[[
name : synology2.lua
auteur : papoo
creation : 17/02/2019
mise à jour : 18/12/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 = '192.168.*.*' -- NAS IP Address
local CommunityPassword = '****' -- SNMP Password
local NAS = 'Synology' -- NAS Switch
local NAS_TEMP = 'NAS Temp'
local NAS_CPU = 'NAS Utilisation CPU' -- NAS CPU
local NAS_MEM = 'NAS Utilisation RAM' -- NAS MEM
local NAS_HD_SPACE_PERC = 'NAS Occupation Disque' -- NAS HD Space in %
local NAS_HD_SPACE = 'NAS Espace Disponible' -- NAS HD Space in Go (custom sensor)
local NAS_HDD1_TEMP = 'NAS HDD1 Temp' -- NAS HD1 Temp, nil if unused
local NAS_HDD2_TEMP = 'NAS HDD2 Temp' -- NAS HD2 Temp, nil if unused
local NAS_HDD3_TEMP = nil -- NAS HD3 Temp, nil if unused
local NAS_HDD4_TEMP = nil -- NAS HD4 Temp, nil if unused
local NAS_UPLOAD = nil -- NAS upload in ko/s, nil if unused
local NAS_DOWNLOAD = nil -- NAS download in ko/s, nil if unused
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_memAvailReal = '1.3.6.1.4.1.2021.4.6.0'
local OID_MemTotalFree = '1.3.6.1.4.1.2021.4.11.0' -- OID MemTotalFree
local OID_Memtampon = '1.3.6.1.4.1.2021.4.14.0' -- OID Memtampon
local OID_Memcache = '1.3.6.1.4.1.2021.4.15.0' -- OID Memcache
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_ifHCOutOctets = '1.3.6.1.2.1.2.2.1.16.3' -- OID ifHCOutOctets if not work try 1.3.6.1.2.1.2.2.1.16.1 or 1.3.6.1.2.1.2.2.1.16.2
--local OID_ifHCInOctets = '1.3.6.1.2.1.2.2.1.10.3' -- OID ifHCInOctets if not work try 1.3.6.1.2.1.2.2.1.10.1 or 1.3.6.1.2.1.2.2.1.10.2
--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_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'}},
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.41 '
},
execute = function(dz)
local i, results = 0, {}
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_NAS_TEMP
local handle = assert(io.popen(command))
for line in handle:lines() do
results[i] = format(line)
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
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDtemp1
local handle = assert(io.popen(command))
for line in handle:lines() do
results[1] = format(line)
end
handle:close()
if results[1] then
dz.log('HDD1_TEMP : '..results[1],dz.LOG_DEBUG)
if NAS_HDD1_TEMP then dz.devices(NAS_HDD1_TEMP).update(0,results[1]) end
end
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDtemp2
local handle = assert(io.popen(command))
for line in handle:lines() do
results[2] = format(line)
end
handle:close()
if results[2] then
dz.log('HDD2_TEMP : '..results[2],dz.LOG_DEBUG)
if NAS_HDD2_TEMP then dz.devices(NAS_HDD2_TEMP).update(0,results[2]) end
end
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_CpuUser
local handle = assert(io.popen(command))
for line in handle:lines() do
results[3] = format(line)
end
handle:close()
--if results[3] then dz.log('CpuUser : '..results[3],dz.LOG_DEBUG) end
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_CpuSystem
local handle = assert(io.popen(command))
for line in handle:lines() do
results[4] = format(line)
end
handle:close()
--if results[4] then dz.log('CpuSystem : '..results[4],dz.LOG_DEBUG) end
if results[3] and results[4] then
CpuUsed = (results[3] + results[4])
end
if CpuUsed then
dz.log('CpuUsed : '..CpuUsed,dz.LOG_DEBUG)
dz.devices(NAS_CPU).update(0,CpuUsed)
end
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDUnit
local handle = assert(io.popen(command))
for line in handle:lines() do
results[5] = format(line)
end
handle:close()
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDTotal
local handle = assert(io.popen(command))
for line in handle:lines() do
results[6] = format(line)
end
handle:close()
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDUsed
local handle = assert(io.popen(command))
for line in handle:lines() do
results[7] = format(line)
end
handle:close()
if results[5] and results[6] then
HDTotalGo = dz.utils.round((results[6] * results[5] / 1024 / 1024 / 1024/1024),2)
dz.log('HDTotalGo : '..HDTotalGo,dz.LOG_DEBUG)
end
if results[5] and results[7] then
HDUsedGo = dz.utils.round(((results[7]) * results[5] / 1024 / 1024 / 1024/1024), 2)
end
if results[5] and results[6] and results[7] then
HDFreeGo = dz.utils.round(((results[6] - results[7]) * results[5] / 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[6] and results[7] then
HDFreePerc = dz.utils.round(((results[7] * 100) / results[6]), 0)
end
if HDFreePerc then
dz.log('HDFreePercent : '..HDFreePerc,dz.LOG_DEBUG)
dz.devices(NAS_HD_SPACE_PERC).update(0,HDFreePerc)
end
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_memAvailReal
local handle = assert(io.popen(command))
for line in handle:lines() do
results[8] = format(line)
end
handle:close()
if results[8] then
dz.log('memAvailReal: '..tostring(results[8]),dz.LOG_DEBUG)
end
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_MemTotalReal
local handle = assert(io.popen(command))
for line in handle:lines() do
results[9] = format(line)
end
handle:close()
if results[9] then
dz.log('memTotalReal: '..tostring(results[9]),dz.LOG_DEBUG)
end
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_Memcache
local handle = assert(io.popen(command))
for line in handle:lines() do
results[10] = format(line)
end
handle:close()
if results[10] then
dz.log('memcache: '..tostring(results[10]),dz.LOG_DEBUG)
end
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_Memtampon
local handle = assert(io.popen(command))
for line in handle:lines() do
results[11] = format(line)
end
handle:close()
if results[11] then
dz.log('memtampon: '..tostring(results[11]),dz.LOG_DEBUG)
end
if results[8] and results[9] then
MemUsedPerc = dz.utils.round(100-(results[8]+results[10]+results[11])*100/results[9], 0)
end
if MemUsedPerc then
dz.log('MemUsedPercent : '..MemUsedPerc,dz.LOG_DEBUG)
dz.devices(NAS_MEM).update(0,MemUsedPerc)
end
end
}
J'ai trouvé que le calcul de la RAM n'était pas vraiment juste, et en fouillant sur le net, j'ai trouvé d'autres OID concernant la RAM.
Code : Tout sélectionner
local OID_Memtampon = '1.3.6.1.4.1.2021.4.14.0' -- OID Memtampon
local OID_Memcache = '1.3.6.1.4.1.2021.4.15.0' -- OID Memcache
On peut le voir sur la fin du script, ou je prends en compte, la mémoire cache, le tampon et la dispo. Je ne trouve pas l'OID de la mémoire réservé (pour être vraiment précis

)
Tout fonctionne, même si je penses qu'il y a moyen de l'alleger
Re: DZVents : Supervision d'un nas Synology avec SNMP
Publié : 20 févr. 2021, 17:29
par denis_brasseur
Tontonpat a écrit : 20 févr. 2021, 11:06
Bonjour,
J'ai tout regroupé dans un seul script, en tâtonnant :
--------------------
Tout fonctionne, même si je penses qu'il y a moyen de l'alleger
Je ne comprend pas. Tu demandes de l'aide, par MP également, je prend le temps de te proposer une solution propre qui te permet d'alléger ton script. As tu essayé la boucle que je t'ai proposé ?
A l'issue de cette boucle, tu récupères directement les valeurs de cette facon,
sans avoir besoin de faire un nouveau local command = 'snmpwalk -v 2c -c ' :
Code : Tout sélectionner
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[10] then
dz.log('HDD1_TEMP : '..results[10],dz.LOG_DEBUG)
if NAS_HDD1_TEMP then dz.devices(NAS_HDD1_TEMP).update(0,results[10]) end
end
Code : Tout sélectionner
--------------------------------------------
-------------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 = '192.168.*.*' -- NAS IP Address
local CommunityPassword = '****' -- SNMP Password
local NAS = 'Synology' -- NAS Switch
local NAS_TEMP = 'NAS Temp'
local NAS_CPU = 'NAS Utilisation CPU' -- NAS CPU
local NAS_MEM = 'NAS Utilisation RAM' -- NAS MEM
local NAS_HD_SPACE_PERC = 'NAS Occupation Disque' -- NAS HD Space in %
local NAS_HD_SPACE = 'NAS Espace Disponible' -- NAS HD Space in Go (custom sensor)
local NAS_HDD1_TEMP = 'NAS HDD1 Temp' -- NAS HD1 Temp, nil if unused
local NAS_HDD2_TEMP = 'NAS HDD2 Temp' -- NAS HD2 Temp, nil if unused
local NAS_HDD3_TEMP = nil -- NAS HD3 Temp, nil if unused
local NAS_HDD4_TEMP = nil -- NAS HD4 Temp, nil if unused
local NAS_UPLOAD = nil -- NAS upload in ko/s, nil if unused
local NAS_DOWNLOAD = nil -- NAS download in ko/s, nil if unused
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_memAvailReal = '1.3.6.1.4.1.2021.4.6.0'
local OID_MemTotalFree = '1.3.6.1.4.1.2021.4.11.0' -- OID MemTotalFree
local OID_Memtampon = '1.3.6.1.4.1.2021.4.14.0' -- OID Memtampon
local OID_Memcache = '1.3.6.1.4.1.2021.4.15.0' -- OID Memcache
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_ifHCOutOctets = '1.3.6.1.2.1.2.2.1.16.3' -- OID ifHCOutOctets if not work try 1.3.6.1.2.1.2.2.1.16.1 or 1.3.6.1.2.1.2.2.1.16.2
--local OID_ifHCInOctets = '1.3.6.1.2.1.2.2.1.10.3' -- OID ifHCInOctets if not work try 1.3.6.1.2.1.2.2.1.10.1 or 1.3.6.1.2.1.2.2.1.10.2
--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_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'
local les_oid = {
OID_NAS_TEMP,
OID_HDtemp1,
OID_HDtemp2,
OID_CpuUser,
OID_CpuSystem,
OID_HDUnit,
OID_HDTotal,
OID_HDUsed,
OID_memAvailReal,
OID_MemTotalReal,
OID_Memcache,
OID_Memtampon
} -- Liste des oid séparées par une virgule
return {
active = true,
on = {timer = {'every minute'}},
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.41 '
},
execute = function(dz)
local i = 0
local results = {}
for _, name in ipairs(les_oid) do
local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..name
local handle = assert(io.popen(command))
for line in handle:lines() do
results[i] = format(line)
end
handle:close()
i = i + 1
end
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_NAS_TEMP
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
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDtemp1
if results[1] then
dz.log('HDD1_TEMP : '..results[1],dz.LOG_DEBUG)
if NAS_HDD1_TEMP then dz.devices(NAS_HDD1_TEMP).update(0,results[1]) end
end
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDtemp2
if results[2] then
dz.log('HDD2_TEMP : '..results[2],dz.LOG_DEBUG)
if NAS_HDD2_TEMP then dz.devices(NAS_HDD2_TEMP).update(0,results[2]) end
end
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_CpuUser
--if results[3] then dz.log('CpuUser : '..results[3],dz.LOG_DEBUG) end
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_CpuSystem
--if results[4] then dz.log('CpuSystem : '..results[4],dz.LOG_DEBUG) end
if results[3] and results[4] then
CpuUsed = (results[3] + results[4])
end
if CpuUsed then
dz.log('CpuUsed : '..CpuUsed,dz.LOG_DEBUG)
dz.devices(NAS_CPU).update(0,CpuUsed)
end
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDUnit
--results[5]
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDTotal
--results[6]
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_HDUsed
--results[7] = format(line)
if results[5] and results[6] then
HDTotalGo = dz.utils.round((results[6] * results[5] / 1024 / 1024 / 1024/1024),2)
dz.log('HDTotalGo : '..HDTotalGo,dz.LOG_DEBUG)
end
if results[5] and results[7] then
HDUsedGo = dz.utils.round(((results[7]) * results[5] / 1024 / 1024 / 1024/1024), 2)
end
if results[5] and results[6] and results[7] then
HDFreeGo = dz.utils.round(((results[6] - results[7]) * results[5] / 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[6] and results[7] then
HDFreePerc = dz.utils.round(((results[7] * 100) / results[6]), 0)
end
if HDFreePerc then
dz.log('HDFreePercent : '..HDFreePerc,dz.LOG_DEBUG)
dz.devices(NAS_HD_SPACE_PERC).update(0,HDFreePerc)
end
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_memAvailReal
if results[8] then
dz.log('memAvailReal: '..tostring(results[8]),dz.LOG_DEBUG)
end
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_MemTotalReal
if results[9] then
dz.log('memTotalReal: '..tostring(results[9]),dz.LOG_DEBUG)
end
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_Memcache
if results[10] then
dz.log('memcache: '..tostring(results[10]),dz.LOG_DEBUG)
end
--local command = 'snmpwalk -v 2c -c '..CommunityPassword..' -O qv '..NasIp..' '..OID_Memtampon
if results[11] then
dz.log('memtampon: '..tostring(results[11]),dz.LOG_DEBUG)
end
if results[8] and results[9] then
MemUsedPerc = dz.utils.round(100-(results[8]+results[10]+results[11])*100/results[9], 0)
end
if MemUsedPerc then
dz.log('MemUsedPercent : '..MemUsedPerc,dz.LOG_DEBUG)
dz.devices(NAS_MEM).update(0,MemUsedPerc)
end
end
}
Re: DZVents : Supervision d'un nas Synology avec SNMP
Publié : 20 févr. 2021, 17:59
par Tontonpat
Désolé de t’avoir contrarié.
J’avais commencé de bidouiller avant que tu me propose ton script.
Je ne l’ai pas encore essayé, mais je vais le faire et je te dirai.
Le but de mon message précédent était de proposer des OID complémentaires concernant la RAM
Re: [DzVents] Supervision d'un nas Synology avec SNMP
Publié : 05 juil. 2021, 21:11
par rito
Bonjour
Je viens de mettre à jour mon Synology en DSM 7 et j ai depuis cette erreur ( alors que tout fonctionnait avant )
Code : Tout sélectionner
2021-07-05 21:10:00.599 Error: dzVents: Error: (3.1.7) Synology Monitor v1.41 : An error occurred when calling event handler synology
2021-07-05 21:10:00.599 Error: dzVents: Error: (3.1.7) Synology Monitor v1.41 : .../domoticz/scripts/dzVents/generated_scripts/synology.lua:165: attempt to perform arithmetic on a string value (field '?')
Des idées de l origine de cette erreur ?
Merci pour votre retour
EDIT :
apres test, il apparait que ce soit cette partie de code qui ne fonctionne plus ...
Code : Tout sélectionner
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
j ai un DS920+, les OID ont changé ?