Hi Chet,

I was fiddling with the XML-RPC for PHP inc file from
http://phpxmlrpc.sourceforge.net, and I might have come to a more systematic
alternative.

I leave here an example function that gets the in and out bps interface
usage on a single call:

<?php

include("xmlrpc.inc");

function ifInOutBps($host, $port, $user, $pass, $device, $interface)
{
  $ifInOctets = 'ifInOctets_ifInOctets';
  $ifOutOctets = 'ifOutOctets_ifOutOctets';

  # base url
  $url = '/zport/dmd/Devices';

  # message
  $msg = new xmlrpcmsg(
    $device.'.os.interfaces.'.$interface.'.getRRDValues', array());
  $xifInOctets = new xmlrpcVal($ifInOctets);
  $xifOutOctets = new xmlrpcVal($ifOutOctets);
  $xifOctets = new xmlrpcVal(array($xifInOctets, $xifOutOctets), 'array');
  $msg->addParam($xifOctets);

  # client
  $clt = new xmlrpc_client($url, $host, $port);
  $clt->setCredentials($user, $pass);

  # get response
  $rsp = $clt->send($msg);

  # any error?
  if ($rsp->faultCode()) {
    die('ifInOutBps - Send error: '.$rsp->faultString().'\n'); }

  # convert to data structure
  $dst = xmlrpc_decode($rsp->serialize());

  return(array('in'=>$dst[$ifInOctets]*8, 'out'=>$dst[$ifOutOctets]*8));
}

?>

Although I've included the credentials to access the data, they are not
needed for some reason. I wonder if this is because I'm using
'localhost:8080' or because there's no authentication at all on the XML-RPC
interface...


Any comments?
antonio


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chet Luther
Sent: Wednesday, January 17, 2007 11:30 PM
To: General discussion of using zenoss system
Subject: [zenoss-users] Re: Get RRD values from Zenoss

On 1/17/07, Antonio Paneiro <[EMAIL PROTECTED]> wrote:
>
> Sorry to get back off list on this matter but I've been struggling to 
> find out how to extract that type of data from Zenoss on a Perl or PHP 
> script. I understand the fix Eric provided to correct the problem that 
> you raised, and the way to get that from the zendmd console.. but how 
> do you get that from a script? XML-RPC?

Antonio,

I feel your pain. The Zenoss developers are Python snobs (I think I may be
next) and don't like to talk about things like Perl or PHP.

There are almost too many ways to do this so I'll just explain the concept
and let you apply it using your favorite method. Zenoss's web interface will
let you run any method of any object using a simple URL. The following
example will give me the most recent load average of a Linux server I call
angel:

http://username:[EMAIL PROTECTED]:8080/zport/dmd/Devices/Server/Linu
x/devices/angel/getRRDValue?dsname=laLoadInt5_laLoadInt5

Notice the following things about this URL:
    1. username:password would be a user with the rights to view this
information.
    2. /Devices/Server/Linux/devices/angel is the object.
    3. getRRDValue is the method.
    4. dsname is the parameter to the getRRDValue method.
    5. laLoadInt5_laLoadInt5 is the name of the data source I'm interested
in.

Another example of getting the maximum interface output over the last 24
hours.

http://username:[EMAIL PROTECTED]:8080/zport/dmd/Devices/Server/Linu
x/devices/angel/os/interfaces/eth0/getRRDValue?dsname=ifOutOctets_ifOutOctet
s&drange=86400&function=MAXIMUM

I hope this makes things clearer to you. Unfortunately you still need to dig
around in the source to see what method it is you might like to use.
Watching the URLs as you browser the web interface can sometimes give you a
place to start searching.

--
Chet Luther
[EMAIL PROTECTED]
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to