2

I'm currently fiddling with a project using the ONTAPI (perf stats monitoring sort of thing).

What I'm wanting to do is reproduce the information from 'df' and 'df -s'.

Doing well so far, because the api 'volume-list-info' seems to have most of the information I want. There's just one thing missing - how much of the 'snap reserve' I'm actually using.

I can't seem to find it in either that, or the 'snapshot' counters. I would ideally be able to do this without having to do a per-volume calculation, because one of the things I'm hoping to do is support a lightweight proxy client that 'just' fetches source XML for processing on a server.

Or is there a way I can calculate this from the size/used/available in the volume-list-info?

2 Answers 2

2

Having been chipping away at this problem, and with thanks to the excellent "toasters" mailing list (Archive) - my eventual solution was to make use of the system-cli API call.

#!/usr/bin/env perl
use strict;
use warnings;

use XML::Twig;
use LWP;

my $twig = XML::Twig->new( 'pretty_print' => 'indented' );
$twig->set_root(
    XML::Twig::Elt->new(
        'netapp',
        {   version => 1.7,
            vfiler  => "somevfiler",
            xmlns   => "http://www.netapp.com/filer/admin",
        },
    )
);
my $api_req = $twig->root->insert_new_elt('system-cli');
my $args    = $api_req->insert_new_elt('args');
$args->insert_new_elt( 'last_child', 'arg', 'df' );
$args->insert_new_elt( 'last_child', 'arg', '-k' );

$twig->set_doctype('netapp SYSTEM "file:/etc/netapp_filer.dtd"');
$twig->set_xml_version("1.0");
$twig->set_encoding('utf-8');

$twig->print;

exit;

my $user_agent = LWP::UserAgent->new(
    'ssl_opts' => {
        'verify_hostname' => 0,
        'SSL_version'     => 'SSLv3',
    }
);

my $request =
    HTTP::Request->new( 'POST' =>
        'https://myfilername/servlets/netapp.servlets.admin.XMLrequest_filer'
    );
$request->authorization_basic( 'username_here', 'password_here' );
$request->content( $twig->sprint );

my $results = $user_agent->request($request);
if ( not $results->is_success ) {
    print "Error: ", $results->status_line;
    exit;
}

my $results_xml = XML::Twig->new( 'pretty_print' => 'indented_a' );
$results_xml->parse( $results->content );
$results_xml->print;

This works to capture the results of a df -k via an API call. But there's just one drawback - you only get a plain text 'command output' blob, which you then have to parse yourself anyway, so you don't really gain much over ssh hostname df -k - just a different authentication and fetch method, but that's really what I was after.

Also of note - this does't use the NetApp SDK. You might consider that an advantage or not. Personally I find XML::Twig and LWP quite good to work with - YMMV.

Anyway - other suggestions include:

  • ssh hostname df -k
  • use SNMP to query it
  • to a two pass API call, first to enumerate, second to query.
2
  • 1
    Glad you sorted the problem, thanks for the kind words, and I hope you'll forgive me editing in a link to the actual list (I don't mind those aggregation engines, but I can't guarantee they'll stay available as I don't control them).
    – MadHatter
    Jul 3, 2015 at 14:51
  • Not at all. Should have thought of it.
    – Sobrique
    Jul 3, 2015 at 15:01
1

as you found, system-cli may be the only way to get 'df' output.

because 'space used for snapshots' can exceed the snap reserve, i prefer a different measure. the snapshot-volume-info API returns size-available (how much more space you can use in the volume, before you lose the ability to make more snapshots).

to collect other space stats for a flexvol i'd use volume-space-get-iter (volume-space-list-info-iter in 7m) or volume-footprint-get-iter (vol-footprint-info in 7m) APIs.

the NetApp Manageability SDK download includes documentation; the calls i mentioned are under, for example :

doc/ontapi/ontapi_1.20/Vserver/snapshot/index.html#snapshot-volume-info doc/ontapi/ontapi_1.20/Vserver/volume/index.html#volume-space-get-iter doc/ontapi/ontapi_1.20/Vserver/volume/index.html#volume-footprint-get-iter

(an older doc download is available at http://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Broken-link-for-SDK-API-Doc/m-p/97275 )

1
  • That works nicely, yes. My goal is an offline and cut down collector of stuff with as few dependencies as possible. So password and api call to build the XML and collect and forward whatever response.
    – Sobrique
    Jul 4, 2015 at 10:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .