Created
October 21, 2014 14:25
-
-
Save cluther/4ba4debaab5bdb72147d to your computer and use it in GitHub Desktop.
Forking Zenoss metrics.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code goes into the __init__.py of a ZenPack. It patches the | |
# Products.ZenRRD.RRDUtil.RRDUtil.put() method. This allows for | |
# executing custom code for every RRD update that's made. | |
from Products.ZenUtils.Utils import monkeypatch | |
@monkeypatch('Products.ZenRRD.RRDUtil.RRDUtil') | |
def put(self, *args, **kwargs): | |
value = original(self, *args, **kwargs) | |
# args (example) | |
# ('Devices/c240-sim/faultInst_count', 0.0, 'GAUGE', '', 60, None, None) | |
# kwargs (example) | |
# {'allowStaleDatapoint': False, 'timestamp': 'N'} | |
# Do whatever you want with value, args and kwargs here. Don't do | |
# anything that takes a long time as this will block writing each | |
# RRD update. Ideally you'd publish to some in-memory queue like | |
# redis or memcached and have some other process reading from that | |
# queue. | |
# Don't forget to return value. | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment