Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Info

Invoking rrd4j/rrd4j Converter API to generate catalog of ds in RRD within a directory. Many tools produce RRD files with just 2 data sources, DS0 and DS1 however there is no limit to the number of entries, hence the code

RrdDb rrd = RrdDb.getBuilder()
   .setPath("test")
  .setRrdToolImporter(new URL(dataFileUri).getFile())
  .setBackendFactory(new RrdMemoryBackendFactory()).build();
for (int cnt = 0; cnt != rrd.getDsCount(); cnt++) {
  String ds = rrd.getDatasource(cnt).getName();
}

is iterated for every file matching *.rrd filemask

Usage

  • build
mvn -Dmaven.test.skip=true package
  • run via CLASSPATH:
java -cp target\example.rrd-cachedb.jar;target\lib\* example.App --path data --save

or just

java -cp target/example.rrd-cachedb.jar:target/lib/* example.App --path data --s

alternatively

export CLASSPATH=target/example.rrd-cachedb.jar:target/lib/\*
java example.App --path data --save

validate explcitly via

sqlite3 $HOME/cache.db "select count(*) from cache;"

returning the number of inserted rows

16

or to collect the subset of folders:

test -d data/web || cp -R data/* data/web
java -cp target\example.rrd-cachedb.jar;target\lib\* example.App --path data --save --collect web,app --reject util

followed with

sqlite3 $HOME/cache.db "select distinct(fname) from cache;"

where re the sample.rrd file was placed into data\web (additional folders used to test the collect and reject processing are not shown)

this outputs

Scanning path: /C:/developer/sergueik/selenium_java/rrd-cachedb/data/
Reading RRD file: web:sample
ds[0]= "ClientGlideIdle"
ds[1]= "ClientGlideRunning"
ds[2]= "ClientGlideTotal"
ds[3]= "ClientInfoAge"
ds[4]= "ClientJobsIdle"
ds[5]= "ClientJobsRunning"
ds[6]= "ReqIdle"
ds[7]= "ReqMaxRun"
ds[8]= "StatusHeld"
ds[9]= "StatusIdle"
ds[10]= "StatusIdleOther"
ds[11]= "StatusPending"
ds[12]= "StatusRunning"
ds[13]= "StatusStageIn"
ds[14]= "StatusStageOut"
ds[15]= "StatusWait"
fname = web:sample      ds = ClientGlideIdle
fname = web:sample      ds = ClientGlideRunning
fname = web:sample      ds = ClientGlideTotal
fname = web:sample      ds = ClientInfoAge
fname = web:sample      ds = ClientJobsIdle
fname = web:sample      ds = ClientJobsRunning
fname = web:sample      ds = ReqIdle
fname = web:sample      ds = ReqMaxRun
fname = web:sample      ds = StatusHeld
fname = web:sample      ds = StatusIdle
fname = web:sample      ds = StatusIdleOther
fname = web:sample      ds = StatusPending
fname = web:sample      ds = StatusRunning
fname = web:sample      ds = StatusStageIn
fname = web:sample      ds = StatusStageOut
fname = web:sample      ds = StatusWait
  • to specify alternative SQLite filename, use --file option
java -cp target/example.rrd-cachedb.jar:target/lib/* example.App --path data --save --file my.db

Saving on MySQL server

  • start mysql server which access credentials are known:
docker start mysql-server

Processing Symbolic Links

prepare

cd data/web/
ln -fs sample.rrd  link.rrd
touch none.rrd
ln -fs none.rrd  badlink.rrd
rm none.rrd

run

 java -cp target/example.rrd-cachedb.jar:target/lib/* example.App --path data --save

NOTE: even without any code changes the data/web/link.rrd willbe added and data/web/badlink.rrd will be not. However to try manual validation of the link target run as:

 java -cp target/example.rrd-cachedb.jar:target/lib/* example.App --path data --save --verifylinks

this will print among oher things,

Testing link link.rrd target path sample.rrd
Valid link link.rrd target path /home/sergueik/rrd-cachedb/data/web/sample.rrd
Testing link badlink.rrd target path none.rrd

illustrating the process

See Also

Author

Serguei Kouzmine