Accepted Solution

sdk -perl - getting snap_used ontapi 1.9

[ Edited ]

Hello folks,

we are trying to automate quota assignment on qtrees and to do so, we need to get first some figures about volume occupancy (newbie - very first program).
We are ontapi 1.9 7-mode and I managed to get almost all data that we need except snapshot occupancy.

This is the output of df in the column used for a volume


cdcsx077:~ # ssh user@nat002 df /vol/<volumename>/.snapshot

Filesystem kbytes used avail capacity Mounted on
/vol/<volumename>/ 145920 31424 114496 22% /vol/<volumename>/
/vol/<volumename>/.snapshot 7680 27940 0 364% /vol/<volumename>/.snapshot

I basically would like to get 27940 or at least (27940 - 7680)

And this is important not to offer this amount of space to the end user.

Please, could you point me out how to get it? I got blind looking at the API, I also installed Zexlorer and parse many xmls, with no success.

I'd be a pitty if we had to revert sdk to rsh to solve this. I'd appreciate any suggestion.

Re: sdk -perl - getting snap_used ontapi 1.9


There are a number of gaps in the SDK coverage. This has been the case for years and contunies to be frustrating. I've never managed to get a comittment from NetApp to fix the gaps.


To avoid falling back to an alternate conneciton method you can send CLI commands over the existing HTTP(S) connection using a NaElelemt type 'system-cli'. I have no idea if this is supported or not, but I use it extensively to plug gaps in the SDK.


this is an exmple method from my OO API. I don't know your coding style (and this page will kill my indentation, so ignore that) but you should get the idea.


sub get_snapshot_used {

# Workaround API gap

my $self = shift;

$self->debug( { Passed => \@_ } );

my $serv = $self->get_classic->get_naserver;

  || croak ( "No naserver object bound" );

my $name = $self->get_name();

my $cmd = NetAppApi::NaElement->new("system-cli");
my $cmd_args = NetAppApi::NaElement->new("args");

$cmd_args->child_add(NetAppApi::NaElement->new ("arg", "df"));
$cmd_args->child_add(NetAppApi::NaElement->new ("arg", "$name"));


my $output = $serv->invoke_elem( $cmd );

$self->debug( { Response => $output } );

if ( $output->results_status() eq "failed" ) {
croak (
"Unable to run system-cli $cmd,\n",
$output->results_reason() . "\n"

my @lines = split /\n/,$output->child_get_string("cli-output");;

my $used;

for my $line (@lines){

#/vol/<name>/.snapshot 7680 27940 0 364% /vol/<volumename>/.snapshot

if ($line =~ m/$name\/.snapshot/){

my @parts = split /\s+/,$line;

$used = $parts[2];
last LINE;



return $used;

Re: sdk -perl - getting snap_used ontapi 1.9

If you don't want to use the, for all intents and purposes, hidden, system-cli element, you can get what you are looking for with a little bit of collection and math.


snapshot-list-info returns 'total', the total number of 1024 byte blocks in a snapshot.

volume-list-info returns 'size-total', the total useable size in bytes of the volume (not including WAFL reserve or snapshot reserve). If you are using snap reserve, you'll have to take into accout the 'snapshot-blocks-reserve' value.

Re: sdk -perl - getting snap_used ontapi 1.9

Thanks for your reply Chris!

Yesterday I tested with Zexplorer and it worked, but wanted to create a function before replying, now I tested it and it works too. Perhaps it helps others.





Re: sdk -perl - getting snap_used ontapi 1.9

[ Edited ]

Thanks Liesc

Perhaps I am missing how to get the information, I tried to collect it from snapshot-list-info and getting the info not with total but wiht cumulative-total  .
It just gives me a value that it does not match with df output:

<!-- last snapshot -->
while df gives me:

/vol/<volname>/.snapshot 7680 28528 0 371% /vol/<volname>/.snapshot


I'd appreciate if you could explain me a bit more how to do the math with the data, I'd indeed prefer to use the sdk methods instead of the ssh backdoor.
Basically I want to get 28528 to substract to the volume reserved space, and this becomes the snap_delta, which cannot be shown as free to the end user. (Final goal is that this advanced users handle quotas themselfs, and this is to create proper limits)
I am not a Netapp admin, but my colleagues have also told me that perhaps this snapshot-list-info is based on snap list and if so, it can cause performance problems on big systems.