Writing a collector for OpenTSDB is quite simple, if you have cloned from git repository the tcollector
script you will see the startstop
executable, this daemon once being launched will execute all files that are stored inside ./tcollector/collectors/NUMBER
where NUMBER
is the periodicity in minutes.
Said that, what you need to do is coding those scripts that will be stored inside collectors
folder. When OpenTSDB executes those scripts it expects the following output:
<METRIC> <UNIX_TIMESTAMP> <VALUE>
So, in your case. Imaging you want to report the temperature of your PC (call each 5 minutes, you will have to follow the next steps:
- Write your script, for example in Java, that gets the temperature of your PC (using SNMP, from the OS, or using any other method). Then when you run your script manually it will output:
pc.temperature 1371075574 40
- Put the script under
./tcollector/collectors/5/
so OpenTSDB will launch it each 5 minutes - Launch the collector by invoking
startstop
(OpenTSDB must be running)
A more detailed explanation here.