Data Infrastructure Management Software Discussions

perf-threshold-template-attach-objects syntax?

Hi Chris,

apitest tool also works for DFM API. I tested "perf-threshold-template-attach-objects" ZAPI using apitest and it is working fine.

[root@lnx186-58 ~]# dfm perf template list

Id      Name             Status    Description

------- ---------------- --------- ----------------------------------------

2       tmp1             Enabled

[root@lnx186-58 ~]# vi file.txt

[root@lnx186-58 ~]# /u/agireesh/apitest -t dfm -h XX.XX.XX.XX -p ******* -f file.txt

Testing: perf-threshold-template-attach-objects(template-name-or-id=2, new-objects=

                  ) Success

{

}

[root@lnx186-58 ~]# cat file.txt

<perf-threshold-template-attach-objects>

                 <template-name-or-id>2</template-name-or-id>

                 <new-objects>

                              <object-info>

                                          <object-id>198</object-id>

                               </object-info>

                  </new-objects>

</perf-threshold-template-attach-objects>

[root@lnx186-58 ~]#

There might be other reason due to that your API is failing. Could you check below things

1. Did you add  threshold to template before attaching the objects to template..? If there is no threshold added for template then you cannot add the template to object.

2. You are trying to attach the threshold template to incompatible  objects. could you please send the output of "dfm perf threshold list -x" command.

Regards,

Gireesh

perf-threshold-template-attach-objects syntax?

Hi Chris,

Could you test that script?

my $api = new NaElement('perf-threshold-template-attach-objects');

# Name or id of a performance template

$api->child_add_string('template-name-or-id','2');

# The list of objects to be attached to the template. At least one object should be specified.

my $xi = new NaElement('new-objects');

$api->child_add($xi);

my $xi1 = new NaElement('object-info');

$xi->child_add($xi1);

# The object that is associated with the view

my $xi2 = new NaElement('object-id');

$xi1->child_add($xi2);

# Identification number (ID) for a DFM object.

$xi2->child_add_string('obj-id','12974');

# Type of the DFM object. "resource_group" "data_set" "resource_pool" "filer" "vfiler" "volume" "qtree" "lun" "aggregate" "interface"

$xi1->child_add_string('object-type','volume');

print 'Calling:\n';

print $api->sprintf();

my $r = $s->invoke_elem($api);

if ($r->results_status() eq 'failed') {

    print 'Error:\n';

    print $r->sprintf();

    exit 1;

}

print 'Received:\n';

print $r->sprintf();

Regards,

perf-threshold-template-attach-objects syntax?

I think

# The object that is associated with the view

my $xi2 = new NaElement('object-id');

$xi1->child_add($xi2);

# Identification number (ID) for a DFM object.

$xi2->child_add_string('obj-id','12974');

has to replaced by

# The object that is associated with the view

# Identification number (ID) for a DFM object.

$xi1->child_add_string('object-id','12974');

perf-threshold-template-attach-objects syntax?

So this moved me past the initial error - Thanks. My initial mistake was $cmd->invoke($cmd) where $cmd was an NaElement, should have been invoke_elem ! I won't do that again.

Now I get a good return code, but the outcome is not as expected with your code or mine. When I try to add a volume to the template the object that is actualy added is "Global", obj-id 1.

volume is a valid object type for the template, and the equivalent dfm cli command does the right thing (adds the volume).

./dfm perf template attach 3 13002

Template Id: 3

Template Name: test_template

Template Status: Enabled

Template Description: test_template

Threshold Information:

     Threshold Id: 7

     Threshold Event Name: test_threshold

     Thershold Interval: 300 seconds

     Counter Information:

             Counter Name: nfs_write_ops:volume

             Counter Tyoe: upper

             Counter Unit: per_sec

             Counter Value: 1000

Applied objects:

     lnn30oznp1:/lnn30f1v2 (13002)

However, using the sample code the output is the same other than:

Applied objects:

            Global

The sprintf output shows the command to be:

Calling:

<perf-threshold-template-attach-objects>

     <template-name-or-id>3</template-name-or-id>

     <new-objects>

           <object-info>

                       <object-id>

                                   <obj-id>13002</obj-id.

                        </object-id>

                        <object-type?volume</object-type>

            </object-info>

     </new-objects>

</perf-threshold-tempalte-attach-objects>

Received:\n<results status="passed"></results>

and running it again tries to add Global again:

Error:\n<result reason="1 (1) is already attatched." status="failed" errno"13115"></results>

Any ideas?

perf-threshold-template-attach-objects syntax?

There was one layer of NeElement nesting too deep in both code versions. In your example script $xi2 is not needed. $xi1 are array elements of $x1. I now have a version that works.

Thanks for the help.

Forums