I managed to traverse the trunk groups but still can't get the name.
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Alberto |
Posted: |
2022-03-02 07:23 |
Hi Kevork,
Unfortunately, from what I can gather you can't model a component with multiple indexes. When modelling a component, the snmpindex (single value) is stored on the component properties and used for fetching snmp data using the component template. Since only a single snmpindex can be stored when modelling a component, you won't be able to fetch the data within the table using the component template.
Your best option here would be to create a Python collector plugin. You can model the components storing each index on a specific property within the component and then use a Python datasource, which would then make use of these indexes to fetch the data using SNMP (instead of relying on the snmpindex property from SNMP modelling). Python component modelling is a bit more convoluted, but much easier to get around these limitations. For more information on Python component modelling and Python datasources, you can check
this tutorial on zenpack sdk documentation. You will need to create functions to fetch the SNMP data within your Python collector, using the AgentProxy module on pynetsnmp.twistedsnmp.
If you choose to go this way, let me know so I can share a sanitised version of my code for doing that.
------------------------------
Alberto
------------------------------
- The ZenPack SDK docs have a pretty good section on component modeling. It includes an example of using the GetTableMaps function of CollectorPlugin to pull attributes from several tables.
- The public ZenPacks in the Zenoss github should contain several more examples that can serve as inspiration. For example, the CheckPoint ZenPack VsxMultiDisk modeler also uses the GetTableMaps function, and may actually be a better example than something like the SNMP IpInterface modeler. (The IpInterface modeler needs to do some more complex IP address and network relationship building).
I hope this helps!
------------------------------
Michael J. Rogers
Senior Instructor - Zenoss
Austin TX
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Alberto |
Posted: |
2022-03-02 07:26 |
Using the PythonCollector modeller, you could also get all indexes, manipulate to your liking (i.e. converting them to strings and concatenating them) and add the result and the component title, or as a different component property.
------------------------------
Alberto
------------------------------
- The ZenPack SDK docs have a pretty good section on component modeling. It includes an example of using the GetTableMaps function of CollectorPlugin to pull attributes from several tables.
- The public ZenPacks in the Zenoss github should contain several more examples that can serve as inspiration. For example, the CheckPoint ZenPack VsxMultiDisk modeler also uses the GetTableMaps function, and may actually be a better example than something like the SNMP IpInterface modeler. (The IpInterface modeler needs to do some more complex IP address and network relationship building).
I hope this helps!
------------------------------
Michael J. Rogers
Senior Instructor - Zenoss
Austin TX
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Kevork Belian |
Posted: |
2022-03-02 07:47 |
thanks Alberto,
unfortunately I am stuck with Zenoss version 3.1 for now. I can't use higher version.
The indices are hierarchical so by concatenating them I was able to get the individual trunk group OIDs.
I am not sure how efficient this method is. I have to see it once I can display the components on the GUI.
Now I am getting this warning in zenhub.log:
WARNING zen.ApplyDataMap: no relationship: found on:10.100.160.11 (<class 'Products.ZenModel.Device.Device'> ZenPacks.community.SonusSBC.SBCDevice)
regards
Kevork
------------------------------
Kevork Belian
------------------------------
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Alberto |
Posted: |
2022-03-02 07:58 |
Hi Kevork,
The error you're getting is on modelling. The Python class of your device seems to be the default one, which would not contain the relationship for your component (the relationship would be specified by the "relname" variable on your SnmpPlugin class). If you are following the normal ZenPack development practice, you will have created a device with a relationship to this component. Another option would be to monkeypatch the default device class
'Products.ZenModel.Device.Device' to add the relationship to your component (although this is generally not the best option - you would do that only if you have multiple device types that require such relationship, which doesn't seem to be your case).
Regards,
------------------------------
Alberto
------------------------------
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Kevork Belian |
Posted: |
2022-03-02 08:05 |
I created the Device class and added it to the Zenpack.
I added the device 10.100.160.11 and specified the path to be the class for the SBC.
But I can't make it accept the SBC class. On zendmd here is what I get:
Welcome to the Zenoss dmd command shell!
'dmd' is bound to the DataRoot. 'zhelp()' to get a list of commands.
Use TAB-TAB to see a list of zendmd related commands.
Tab completion also works for objects -- hit tab after an object name and '.'
(eg dmd. + tab-key).
>>> dev=find('10.100.160.11')
>>> print dev.__class__
<class 'Products.ZenModel.Device.Device'>
I deleted and re-added the device many times from GUI and command line but no use.
It is really frustrating.
------------------------------
Kevork Belian
------------------------------
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Alberto |
Posted: |
2022-03-02 08:25 |
Have you changed the "zPythonClass" property of your device class so that it matches the python device class you've created on the ZenPack?
If so, check your ZenPack folder and see if Zenoss compiled your device class python code (you should find a .pyc file with the same name as your .py file if so). If you can't find the compiled file, either there's an error on the code or Zenoss didn't even try to use it (which would point to an error on the property config above).
Cheers,
------------------------------
Alberto
------------------------------
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Kevork Belian |
Posted: |
2022-03-02 08:37 |
yes the zPythonClass points to the device class that I have created.
the .pyc files are being generated.
I will delete the zenpack, device class and device and redo everything from scratch I guess.
I can't think of anything else.
thanks for the help.
regards
Kevork
------------------------------
Kevork Belian
------------------------------
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Alberto |
Posted: |
2022-03-02 09:12 |
Try restarting zopectl and zenhub for good measure. Apart from that, can't help much.
Cheers,
------------------------------
Alberto
------------------------------
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Michael Rogers |
Posted: |
2022-03-02 10:27 |
Was the zPythonClass set on the new device class before the new device was created inside it? Or was it changed after the device was added to the system?
------------------------------
Michael J. Rogers
Senior Instructor - Zenoss
Austin TX
------------------------------
Subject: |
RE: SNMP Plugin with multiple indexes |
Author: |
Kevork Belian |
Posted: |
2022-03-02 11:04 |
hi Michael,
I added the device after setting the zPythonClass property.
I restarted the zenoss and added the device again. now zendmd is showing the class but the device is shown twice:
>>> print d.__class__
<class 'ZenPacks.community.SonusSBC.SBCDevice.SBCDevice'>
Anyhow thanks. I have to redo the zenpack and class from scratch. Probably there are mistakes in the code.
------------------------------
Kevork Belian
------------------------------