Highlighted
scottboss1
1 Nickel

using Perl or Ruby can you show how much space is used by a (sub)tenant?

I prefer Perl but Ruby is acceptable. I need a script to look at all tenants/subnants and give me a report on how much space they are using.  I might assign the subtenant "Alpha App" 2 TB of space.  I need to know how much space they are using so I can actively talk to them about them using up all their space and they might need more.  or for some reporting/dashboards.

thanks

Labels (1)
0 Kudos
7 Replies
8 Krypton

Re: using Perl or Ruby can you show how much space is used by a (sub)tenant?

Here you go:

#!/usr/bin/perl -w

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;

my $req = HTTP::Request->new(GET => "https://$ARGV[0]/sysmgmt/tenants/$ARGV[1]/$ARGV[2]/scMetrics");

$req->header('x-atmos-tenantadmin' => $ARGV[3],

          'x-atmos-tenantadminpassword' => $ARGV[4],

          'Host' => 'localhost',

          'Accept' => 'application/xml');

# Execute the request

my $res = $ua->request($req);

if($res->is_success) {

          print $res->content;

} else {

          print $res->status_line, "\n";

}

Args are: IP, Tenant Name, Subtenant Name, tenant admin, tenant admin password.

Execution will output XML like this:

~ $ ./usage.pl 10.242.26.242 Tenant1 subtenant1 TenantAdmin password

<?xml version="1.0" encoding="UTF-8"?>

<scMetrics>

  <objCount>89887</objCount>

  <size>976849960</size>

  <realsize>2148734312</realsize>

  <metadatasize>264518268</metadatasize>

  <totalSize>2413252580</totalSize>

</scMetrics>

0 Kudos
8 Krypton

Re: using Perl or Ruby can you show how much space is used by a (sub)tenant?

I should mention that you can get more information in the System Management API guide, page 124.

0 Kudos
ShaiNair
6 Indium

Re: using Perl or Ruby can you show how much space is used by a (sub)tenant?

Hi Jason,

I am trying to write a script using perl to report on the free space on an RMG.

I have got the basic script working to get details from the Atmos but.

The api RMG Info (Sys Management API guide page 27 to 29) is only returning the following.

rmg, name, local time etc etc no space information

The Node Info is returning the total space on the node but not the used space.

When you login to the managemetn gui and look at the system dashboard you get the information.

Is there an API i can use to get the info in the system dashboard?

Regards

Shaji

0 Kudos
8 Krypton

Re: using Perl or Ruby can you show how much space is used by a (sub)tenant?

If you do a POX login (per the sysmgmt API guide) and then GET:

/maui_admin/list_rmg?from=datatables

You'll get the chunk of HTML from the GUI and you can parse the usage from there.  Note that this is undocumented and subject to change between versions.  I will file an enhancement request to make this available and documented through the POX API (if you remove ?from=datatables, you'll get an XML response but it does not include used capacity).

0 Kudos
ShaiNair
6 Indium

Re: using Perl or Ruby can you show how much space is used by a (sub)tenant?

Thanks Jason, I will give it a go.

May be asking too much while trying to save me from reinventing the wheel.

Have you got a sample script using the POX API, like the one you posted above for REST.

Once again, it has given me a lot to go on with ....

0 Kudos
ShaiNair
6 Indium

Re: using Perl or Ruby can you show how much space is used by a (sub)tenant?

I got what i need usign the following.

#!/usr/bin/perl

use strict;

use WWW::Mechanize;

use HTTP::Cookies;

my $url = "https://atmos/mgmt_login/login";

my $username = "sysadmin";

my $password = "passwd";

my $mech = WWW::Mechanize->new();

$mech->cookie_jar(HTTP::Cookies->new());

$mech->get($url);

$mech->form_name('login_form');

$mech->field(username => $username);

$mech->field(password => $password);

$mech->click();

my $output_page = $mech->content();

my $url = "https://atmos/maui_admin/maui_dashboard";

$mech->get($url);

my $output_page = $mech->content();

A bunch of search and repalce and if statements to get what i want ....

0 Kudos
ShaiNair
6 Indium

Re: using Perl or Ruby can you show how much space is used by a (sub)tenant?

Hi,

I have used perl and use WWW::Mechanize module to browse /maui_admin/maui_dashboard.

Then used a lot of search and replace and split commands to get what i need.

I managed to get the total and used capacity.

Regards

Shaji

0 Kudos