I was wrestling with the NetApp Management SDK and Perl, and having lots of problems finding documentation and examples in one place. Since I did all the work, I thought I'd share what I found.
I am a competent Perl programmer, and I learned object-oriented programming (C++) in school, but I was having a lot of problems with the NetApp Manageability SDK. I was able to find a list of APIs and ONTAP APIs on the web site, but didn't have a good starting point.
I wanted to get specific NFS version 3 statistics, but not have the filer return all the information and be forced to parse through all the data. I wanted only the following statistics:
From the ONTAP API documentation, I found that perf-objects-get-instances took the following arguments:
List of counters whose values will be retrieved. This element can be used to limit data collection to a specified subset of the counters of instances of the object. If this element is absent, values of all counters will be retrieved.
List of the instance names for which to get counter values. This element can be used to limit data collection to a specific subject of the instances of the object. In Data ONTAP 7-Mode, counter values of all instances of the object will be retrieved when this element is absent. In Data ONTAP Cluster-Mode, either instances or instance-uuids input must be provided. The API errors out if both of these inputs are provided or neither of these inputs is provided, or if more than 500 instances are requested.
Name of the object to get counter values for.
I was able to get all the data using the invoke() method:
my $filer = NaServer -> new ($server, $majorversion, $minorversion);
When I searched online, I found a lot of people had the same problem. Instead of limiting the results they were receiving, they were iterating through the results and only taking the data that they needed. That's not what I wanted to do. I thought it was too inefficient, especially if my script was going to be called frequently. It also didn't feel right.
The problem was that I couldn't figure out how to pass the arguments for the counter array or the instance array. (I didn't need the instance array in this case, but I assumed that the mechanics were the same.) I was looking for Perl-ish ways to pass the variables.
Basically, what you are doing is building a $command object that will run the perf-object-get-instances command.
After the main object was created, I created another object, $counters. I started adding the data I wanted to the $counters object. Each statistic I wanted was added to the $counters object, as a type/statistic pair. After the $counters object was complete, I added it as a child to the $command object.
Since I didn't have any instances that I wanted to add, I didn't have to create an $instances object. If I did want one, I would have created another NaElement object and configured it in the same way.
Finally, I needed to add the object name at the end. In this case, I'm not adding another NaElement object. This time, it's just a string. I added a string of type objectname with the value nfsv3.
When I actually run the command, I need to use the invoke_elem() method instead of the invoke() method that was in the previous script.
Anyway, I took the time to write this up in the hopes that it will help someone else. (I suspect that I'll probably forget how to do this, and I'll be the one that's going online to look for this solution. )
Do you know if there is a description of what each of the NFS counters mean ? I.e when we poll the nfsv3_ops counter, it is increasing until no NFS clients are connected. Is it sufficient to assume then that nfsv3_ops is a count of total ops done until the point in time when that call was made to read the counter ?