UNSOLVED

scottboss1

updated

15 years ago

0

4260

April 13th, 2012 10:00

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

  • JasonCwik

    1 Rookie

    •

    281 Posts

    892

    0

    Posted April 13th, 2012 12:00

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

  • JasonCwik

    1 Rookie

    •

    281 Posts

    892

    0

    Posted April 13th, 2012 12:00

    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

      89887

      976849960

      2148734312

      264518268

      2413252580

  • ShaiNair

    11 Posts

    892

    0

    Posted February 13th, 2014 07:00

    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

  • JasonCwik

    1 Rookie

    •

    281 Posts

    892

    0

    Posted February 13th, 2014 09:00

    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).

  • ShaiNair

    11 Posts

    892

    0

    Posted February 14th, 2014 01:00

    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 ....

  • ShaiNair

    11 Posts

    892

    0

    Posted February 14th, 2014 02:00

    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 ....

  • ShaiNair

    11 Posts

    892

    0

    Posted February 20th, 2014 02:00

    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