DX Infrastructure Management

Expand all | Collapse all

Perl SDK - list probes

Jump to Best Answer
  • 1.  Perl SDK - list probes

    Posted 11-17-2014 05:53 PM

    I'm trying to list the probes on a robot using nimNamedRequest but I can't find the data type returned by the command.

     

    I have tried the same method as with the getrobots:

     

    $cmd = "getrobots"; my($iRet,$retdata) = nimNamedRequest($row->get("addr"),$cmd,$args,10); my $retPDS = Nimbus::smileytongue:DS->new($retdata); for ( my $y=0; my $row2 = $retPDS->getTable("robotlist", PDS_PDS, $y); $y=$y+1 )  {     print "+-" . $row2->get("addr") . "\n"; }

     but i'm not sure what the table name is for the 'probelist' command

     

    nimLogSet ("stdout","",5,1);  my $args=Nimbus::smileytongue:DS->new();  $cmd = "probe_list"; my($iRet,$retdata) = nimNamedRequest($robot . "/controller",$cmd,$args,10);  if ( $iRet ) {     print "Error: " . nimError2Txt($iRet) . "\n"; } else {      my $retPDS = Nimbus::smileytongue:DS->new($retdata);       $retPDS->dump();       for ( my $x=0; my $row = $retPDS->getTable("probelist", PDS_PDS, $x); $x=$x+1 )      {           print "+" . $row->get("name") . "\n";      } }

     Any advice? Is there any more documentation where these things are detailed?

     

    Thanks



  • 2.  Re: Perl SDK - list probes
    Best Answer

    Posted 11-17-2014 07:49 PM

    The reply to the probe_list callback is not in table format. It just contains nested PDSes. (I found this by using the Probe Utility - Ctrl+P.) I think the easiest way to handle that in Perl is to use the asHash() function to convert it to a nested hash.



  • 3.  Re: Perl SDK - list probes

    Posted 11-18-2014 01:08 PM

    Hi Keith,

     

    thanks that worked fine, on a related note it seems that calling 'probe_config_get' is failing:

     

    my $args=Nimbus::smileytongue:DS->new();
    $args->string ("name", "cdm");
    $args->string ("robot", "dcslovtfs02");
    $cmd = "probe_config_get";
    my($iRet,$retdata) = nimNamedRequest($robot."/controller",$cmd,$args,60);
    if ( $iRet ) 
    {
    print "Error: " . nimError2Txt($iRet) . "\n";
    } else 
    {

     all I get back is error but from the controller log I see I'm getting the error

    Nov 18 10:04:22:085 [2108] Controller: (probe_config_get) - called from 192.168.122.118/61210 
    Nov 18 10:04:22:085 [2108] Controller: nimSessionWait: 4 sessions, 1000 ms timeout, 1 rounds 
    Nov 18 10:04:22:086 [5348] Controller: handle_probe_config_get: missing data (probe name) 
    Nov 18 10:04:22:086 [5348] Controller: sockWrite: first 20 bytes of buf = <nimbus/1.0 37 0
     
    Nov 18 10:04:22:086 Controller:  10.249.34.189/48000->192.168.122.118/61210 (54): 
    Nov 18 10:04:22:086 [5348] Controller: SREPLY: status = 1(error) ->192.168.122.118/61210 

     so I can't work out why my PDS args isn't working

     

    Thanks

     



  • 4.  Re: Perl SDK - list probes

    Posted 11-18-2014 03:44 PM

    Hi,

     

    If you wish to use the PDS object like that, you need to get the PDS datastructure out of it when calling nimNamedRequest.

     

    Try it with this fix:

     

    my($iRet,$retdata) = nimNamedRequest($robot."/controller",$cmd,$args->data(),60);

     

    Another alternative would be to do

    my $args_pds = pdsCreate();
    pdsPut_PCH($args_pds, "name", "cdm");
    pdsPut_PCH("$args_pds, "robot, "dcslovtfs02");
    
    my($iRet,$retdata) = nimNamedRequest($robot."/controller",$cmd,$pds_args,60);
    
    pdsDelete($pds_args); 

     

    -jon



  • 5.  Re: Perl SDK - list probes

    Posted 11-18-2014 05:36 PM

    Thanks Jon,

     

    the second one worked, the first still didn't but as long as it works I'll go with that.

     



  • 6.  Re: Perl SDK - list probes

    Posted 01-28-2016 01:04 PM

    Hi,

     

    I have the same problems on my code (i'm pretty new with perl langage). How could i use asHash() function without PDS object (i dont find in the SDK Perl pdsCreate(), pdsDump() etc..)

     

    foreach(@monitoredProbes) {

        my $PDS = pdsCreate();

        pdsPut_PCH($PDS, "name", "$_");

        my ($PROBESLIST_INT_RC,$PROBESLIST_PDS) = nimNamedRequest("${ROBOT_STR_ADDR}/controller","probe_list",$PDS);

        pdsDelete($PDS);

     

     

        if($PROBESLIST_INT_RC == 0) {

            # pdsDump($PROBESLIST_PDS);

     

     

            my %PROBE_CONFIGURATION = $PROBESLIST_PDS->asHash();

            my $PROBE_STR_Name = $PROBE_CONFIGURATION{'name'};

            print "name $PROBE_STR_Name ! \n";

            # my $pdsPROBES = Nimbus::PDS->new($PROBESLIST_PDS);

        }

        else {

            print "probe dont have $_ ! \n";

        }

    }

     

    Thank you !



  • 7.  Re: Perl SDK - list probes

    Posted 01-29-2016 01:35 AM

    Hi,

     

    I think you need a step to convert the returned data from the call to a PDS so:

     

     

    foreach(@monitoredProbes) {

        my $PDS = pdsCreate();

        pdsPut_PCH($PDS, "name", "$_");

        my ($PROBESLIST_INT_RC,$PROBESLIST_DATA) = nimNamedRequest("${ROBOT_STR_ADDR}/controller","probe_list",$PDS);

        pdsDelete($PDS);

     

     

        if($PROBESLIST_INT_RC == 0) {

            # pdsDump($PROBESLIST_PDS);

     

            my $PROBESLIST_PDS = Nimbus::PDS->new($PROBESLIST_DATA);

            my %PROBE_CONFIGURATION = $PROBESLIST_PDS->asHash();

            my $PROBE_STR_Name = $PROBE_CONFIGURATION{'name'};

            print "name $PROBE_STR_Name ! \n";

            # my $pdsPROBES = Nimbus::PDS->new($PROBESLIST_PDS);

        }

        else {

            print "probe dont have $_ ! \n";

        }

    }

     

    Arron



  • 8.  Re: Perl SDK - list probes

    Posted 01-29-2016 06:01 AM

    Hmm i can not recover my data... I have try many things but nothing works ! However when i write this code :

     

    my $PROBESLIST_PDS = Nimbus::PDS->new($PROBESLIST_DATA);

    pdsDump($PROBESLIST_PDS->data());

     

    I see my probe data... And when i try to get data with asHash() or getTable("$_",PDS_PDS) he return a undef VAR.

     

    This is an example of my pdsDump return ( callback probe_list )

    tdump_return.png



  • 9.  Re: Perl SDK - list probes

    Posted 01-29-2016 09:08 AM

    OH ! I have found the solution :

     

    my $PROBESLIST_PDS = Nimbus::PDS->new($PROBESLIST_DATA);

    my $PROBES_ARR_INFO = $PROBESLIST_PDS->asHash();

    my $PROBE_STR_Description = $PROBES_ARR_INFO->{"$_"}{"description"};

     

    I dont understand totally HASH structure on perl...

     

    Thanks anyway !



  • 10.  Re: Perl SDK - list probes

    Posted 01-29-2016 02:46 PM

    It sounds like you're actually getting a reference to the variable, so you'll need to dereference it to get the actual data.

     

    edit: seems like i replied to a wrong post and you already got it.

     

    -jon



  • 11.  Re: Perl SDK - list probes

    Posted 02-04-2016 03:58 PM
      |   view attached

    Better late than never, here is a probe_list perl script with some explanations:

    Attachment(s)

    zip
    probe_list.pl.zip   1K 1 version