J’aimerais récupérer les d’informations de mon imprimante réseau depuis Jeedom.
Pour ce faire, j’ai testé un peu les possibilités avec SNMP Tool qui m’a permis de récupérer les OIDs dont j’avais besoin.
Un peu de VBScript le résultat me convient.
J’ai vu que le plugin Monitoring2 pouvait éventuellement convenir, mais avant de ma lancer j’aimerais avoir votre avis et voir sur ce qui a déjà pu être fait (plugin plus approprié? widget?)
J’espère trouver de bons conseils.
Bien cordialement
Je partage le code VBS si ça peut intéresser quel qu’un:
on error resume next
err.clear
strOutput = ""
strDeviceIP =Inputbox("Enter IP: ", "SNMP - find Printer info")
If IsEmpty(strDeviceIP) Then
wscript.echo "L'opération a été annulée"
Wscript.Quit
End If
If strDeviceIP = "" Then
wscript.echo "Attention: ce champ ne peut étre vide!"
Wscript.Quit
End If
Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("ping -n 2 -w 1000 " & strDeviceIP)
strPingResults = LCase(objScriptExec.StdOut.ReadAll)
If InStr(strPingResults, "perdus = 0") Then
strOutput = "SNMP - find Printer info" & vbCrLf & vbCrLf
strCommunity = "public"
set objSNMP = CreateObject("OlePrn.OleSNMP")
objSNMP.Open strDeviceIP, strCommunity, 2, 1000
Else
msgbox (strDeviceIP & " na pas repondu au ping!")
Wscript.Quit
End If
if err.number = 0 Then
'# OID : 1.3.6.1.2.1.1.3.0
'# 1 (iso).
'# 3 (org).
'# 6 (dod).
'# 1 (internet).
'# 2 (mgmt).
'# 1 (mib-2).
'# 1 (system).
'# 3 (sysUpTime).
'# 0 (sysUpTimeInstance)
uptime = objSNMP.Get(".1.3.6.1.2.1.1.3.0")
'# OID : 1.3.6.1.2.1.1.5.0
'# 1 (iso).
'# 3 (org).
'# 6 (dod).
'# 1 (internet).
'# 2 (mgmt).
'# 1 (mib-2).
'# 1 (SYSTEM).
'# 5 (SYSnAME).
'# 0 access mode of RFC ASN.1 is "R/W" (read/write)
model = objSNMP.Get(".1.3.6.1.2.1.1.5.0")
'# OID MIB SNMP récupérés avec Visual SNMP.
'# http://cdn3.sysaid.com/VisualSNMPSetup.exe
'# 1.3.6.1.4.1.1602.1.3.3.1.1.2.1.1.(adresse IP)
hostname = objSNMP.Get(".1.3.6.1.4.1.1602.1.3.3.1.1.2.1.1."& strDeviceIP)
'# OID : 1.3.6.1.2.1.43.5.1.1.17.1
'# 1 (iso).
'# 3 (org).
'# 6 (dod).
'# 1 (internet).
'# 2 (mgmt).
'# 1 (mib-2).
'# 43 (printmib).
'# 5 (prtGeneral).
'# 1 (prtGeneralTable).
'# 1 (prtGeneralEntry.
'# 17 (prtGeneralSerialNumber).
'# 1 access mode of "public" community is "RO" (read only)
serialnumber = objSNMP.Get(".1.3.6.1.2.1.43.5.1.1.17.1")
tps = 100
tpm = tps * 60
tph = tpm * 60
tpd = tph * 24
ticks = Uptime
seconds = int(ticks/tps) mod 60
minutes = int(ticks/tpm) mod 60
hours = int(ticks/tph) mod 24
days = int(ticks/tpd)
uptime = "En activitée depuis: "& days & " jours," & hours & " heures," & minutes & " minutes," & seconds & " secondes."
strOutput = strOutput & "IP Adresse: "& strDeviceIP & vbcrlf
strOutput = strOutput & "HostName: "& hostname & vbCrLf
strOutput = strOutput & "Model: "& model & vbCrLf
strOutput = strOutput & "N° de série: "& serialnumber & vbcrlf
stroutput = strOutput & uptime
wscript.echo strOutput
end if
Bonjour, je reviens sur le plugin monitoring2 et le protocole SNMP.
Je l’utilise pour monitorer mon switch NetGear 8 ports, en plaçant les OID correctement il fait bien le job, sans soucis.
Oula tout le monde a été tagué là-dessus… La réponse est on ne peut plus simple, le plugin n’a pas encore les bons tags de compatibilité matérielle en stable mais c’est OK en beta. ça va donc arriver.
Bonjour,
Les soucis sont du a un probleme de compatibilité déclaré je regarde pourquoi.
Pour le traitement sur un oid ce n’est pas possible (par contre si tu lis la doc on a des fonctions internet pour le temps d’uptime par exemple ca pourrait correspondre a ce que tu cherches a faire).