You could use the JSR-223 feature of the shell. I whipped up the javascript, 
has not been tested, but something like it should work. You can run it using 
the command:


script -e js -f /<script_location> -a table=<tableName>


Here is a script that counts files for a table. You could easily modify this to 
fetch a unique colf from the metadata table for any given tablet and if you 
count based on that, then you have the number of tablets.


importPackage(java.lang);
importPackage(java.util);
importPackage(org.apache.hadoop.io);
importPackage(org.apache.accumulo.core.data);
importPackage(org.apache.accumulo.core.security);


var tableId = connection.tableOperations().tableIdMap().get(table);
var auths = new Authorizations();
var scanner = connection.createScanner("accumulo.metadata", auths);
scanner.setRange(new Range(tableId+;", tableId+"<");
scanner.fetchColumnFamily(new Text("file"));

var iter = scanner.iterator();

var files = 0;
while (iter.hasNext()) {
   files = files + 1;
}

println(files);

> On January 24, 2017 at 9:34 AM Michael Wall <[email protected]> wrote:
> 
>     Matt,
> 
>     I typically run the following to see all the online tablets
> 
>     scan -t accumulo.metadata -c loc
> 
>     and the following to find all tablets, online and offline
> 
>     scan -t accumulo.metadata -c ~tab
> 
> 
> 
>     On Mon, Jan 23, 2017 at 11:35 PM Josh Elser <[email protected] 
> mailto:[email protected] > wrote:
> 
>         > > I believe this would be the number of unique rows in the Accumulo
> >         metadata table (that don't fall in the "~del" prefix).
> > 
> >         Not sure if we have a class you could just invoke, but this would be
> >         pretty easy to script just using the Accumulo shell.
> > 
> >         Dickson, Matt MR wrote:
> >         > *UNOFFICIAL*
> >         >
> >         > Is there a way to query to the metadata table to quickly get a 
> > list of
> >         > the number of tablets for all tables in an Accumulo instance?
> >         > I'd like to do this to integrate into existing monitoring tools 
> > rather
> >         > than go to the Accumulo gui.
> >         > Thanks in advance
> > 
> >     > 

Reply via email to