| Subject: |
RE: Zenoss 4.2.5 - updating component property from a trap event class mapping transform |
| Author: |
Pheripheral Pheripheral |
| Posted: |
2019-01-29 05:58 |
Update
I've made this work (amazing what a nights sleep can do ...)
I'm now grabbing the list of components from the device object and looping through to match a component against the one the trap is raised on and then updating that component.
# set component from trap event attributeevt.component=evt.mibSpecificEventFieldSensorNameSENSOR_ACTIVE = 1# find matching sensor from device sensorsfor sensor in device.sensors(): if sensor.title == evt.component: # if the status changed then update sensor Component if sensor.sensorValue != SENSOR_ACTIVE: @transact def updateDb(): sensor.sensorValue=SENSOR_ACTIVE updateDb()This works and sets my property on the component.
If anyone knows of a way to grab this without looping the components do let me know, but in the meantime this works and as i'm only expecting around 4 or 5 components on the device it shouldn't east computing resources.
------------------------------
Pheripheral Pheripheral
------------------------------
| Subject: |
RE: Zenoss 4.2.5 - updating component property from a trap event class mapping transform |
| Author: |
Ryan Matte |
| Posted: |
2019-02-21 11:21 |
The reason you were running in to the error you were seeing is because an event without a component was hitting your transform and you weren't checking for the existence of component before proceeding with the rest of your code. A simple "if component:" at the top of that code would have fixed that.
------------------------------
Ryan Matte
------------------------------