Getting gaps in metric data for data from an EP Agent plugin
book
Article ID: 122851
calendar_today
Updated On:
Products
CA Application Performance Management Agent (APM / Wily / Introscope)INTROSCOPE
Issue/Introduction
We are running a python script as a stateful plugin to report data back to the EP agent every 15 seconds. As far as we can tell the plugin runs correctly but we find that in the data recorded in APM there are gaps (zero values) in the data
Cause
This is not a APM issue. The plugin is running as a stateful plugin and the 15 second interval is controlled in the plugin code itself not by the EP agent via the delayinseconds setting as would be the case for stateless plugins. The problem is not the way that the script is run but in the way python outputs data. It maintains it’s data in a buffer and for performance reasons will only flush the buffer to stdout when it is full. Therefore if the buffer is not filled every 15 seconds the data may not be sent.
Environment
EPA agent – any platform any release
Resolution
To ensure the data is sent for each cycle you need to flush the output buffers using sys.stdout.flush() as shown in the below artificial example
#!/usr/bin/python
import sys import re import time
def main(): while True: print "<metric type=\"IntAverage\" name=\"MYSCRIPTPY1|VirtualMachine|Process|ME:Cpu Usage %\" value=\"55\" />" sys.stdout.flush() time.sleep(15) if __name__ == "__main__": main()