tcollector doesn't care whether the collector you write is in Python or a shell script or what. As long as you put the collector in tcollector/collectors/0
it should be picked up automatically. If it is not, then check that your shell script is executable (chmod a+x
) and that it starts with a shebang (#!/bin/sh
for example).
How to add data in openTSDB through java using tCollector
Question
My goal is to insert data into TSDB directly through java code, for which, I tried creating the executable jar which was printing data to STDOUT. Then I wrote collector to run this jar and put it inside tcollector/collectors/0
. Finally, I tried executing the collector in two ways, one in shell script and the other in python.
Python Collector:
def main():
while True:
os.system("java -jar ./TCollectorTSDB.jar")
sys.stdout.flush()
time.sleep(COLLECTION_INTERVAL)
if __name__ == "__main__":
sys.stdin.close()
sys.exit(main())
The above collector was working perfectly fine, but when I tried to run the same jar from shell script the Collector was not picking the shell script.
Shell script collector:
java -jar "./TCollectorTSDB.jar"
Do I have to configure something, to register this collector? If we have to insert data through Java which is the best way to do the same with Collector?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow