简体   繁体   中英

how to remove a data source from rrd db programatically?

I'm trying to remove a data source from a rrd db.

I found I can do something like "rrdtool tune mydb.rrd DEL:source_name" and it works, but I want to do it from C/C++ code. I could use the system function in Linux, but I don't like the overhead.

I looked in https://oss.oetiker.ch/rrdtool/doc/librrd.en.html to see if there is something I could use, but I didn't find anything.

I also looked in the rrd source code from https://github.com/oetiker/rrdtool-1.x/tree/master/src and I found they call rrd_modify_r2() to remove sources, but this function is static, so it's not exported (as opposed to rrdc_create_r2)

So, how can I remove a source from C/C++ code?

thanks, Catalin

You use of course rrdtool tune filename.rrd DEL:ds-name to do this from the commandline, as you note.

However the RRDTool C bindings in librrd are not as comprehensive, and do not appear to expose this functionality. Not sure why - the modify functions is clearly useful - but thats how it seems to be.

One option you have would be to simply call the external rrdtool binary with fork/exec, passing the appropriate commandline. This is not a particularly pretty way to do it, but is more portable and compatible with the published interface.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM