AnsweredAssumed Answered

pdsGet_F not working in perl API and multiple instances of perl probe file listing in infrastructure manager

Question asked by amit_saxena on Nov 25, 2011
Latest reply on Nov 30, 2011 by amit_saxena

Hi all,

 

I am working for a perl program to read QoS data from bus by subscribing with "QOS_MESSAGE" subject. I am somewhat successful however I am facing two issues.

 

The perl program along with the screenshots are attached with this post. The perl program is also pasted below.

 

1) I am unable to fetch the data for "samplevalue" and "sampledev" by using "pdsGet_F" on userdata. "pdsGet_INT" is also not working.

 

2) Whenever I deploy the probe, apart from regular probe entry, there is an additional entry created by the name of perl program in the listing of probes. To remove the same, I have to delete it and then restart Nimsoft controller service.

 

Please help and suggest.

 

#!perl.exe  use strict; use warnings;  my $UNABLE_TO_CREATE_SERVER_SESSION = 2; my $COULD_NOT_ATTACH_SUBSCRIBE      = 3;  use lib "C:\\Program Files\\Nimsoft\\perllib";  use Nimbus::API; use Nimbus::smileyfrustrated:ession;  my $program_name_without_extension; $program_name_without_extension = $0; $program_name_without_extension =~ s/\.[^\.]*$//g;  ############################################################## # Service functions ############################################################## sub program_restart { }  sub program_timeout { }  sub hubpost {      my $message_handle;      my $user_data;      my $full_message;       ( $message_handle, $user_data, $full_message ) = @_;       #my $subject = pdsGet_PCH ($full,"subject");      #my $string = pdsGet_PCH ($udata,"message");      #my $number = pdsGet_INT ($udata,"level");  ###      my $subject; ###      $subject = pdsGet_PCH ( $full_message, "subject" ); ###  ###      my $message; ###      $message = pdsGet_PCH ( $user_data, "message" ); ###  ###      my $severity; ###      $severity = pdsGet_INT ($user_data, "level" ); ###  ###      nimLog ( 0, "Received a \"$severity\" severity alarm having \"$subject\" as a subject. The full alarm message is \"$message\" ." );  ###      my $alarm_nimid; ###      my $alarm_nimts; ###      my $alarm_tz_offset; ###      my $alarm_source; ###      my $alarm_robot; ###      my $alarm_domain; ###      my $alarm_origin; ###      my $alarm_pri; ###      my $alarm_subject; ###      my $alarm_prid; ###  ###      $alarm_nimid     = pdsGet_PCH ( $full_message, "nimid"     ); ###      $alarm_nimts     = pdsGet_INT ( $full_message, "nimts"     ); ###      $alarm_tz_offset = pdsGet_INT ( $full_message, "tz_offset" ); ###      $alarm_source    = pdsGet_PCH ( $full_message, "source"    ); ###      $alarm_robot     = pdsGet_PCH ( $full_message, "robot"     ); ###      $alarm_domain    = pdsGet_PCH ( $full_message, "domain"    ); ###      $alarm_origin    = pdsGet_PCH ( $full_message, "origin"    ); ###      $alarm_pri       = pdsGet_INT ( $full_message, "pri"       ); ###      $alarm_subject   = pdsGet_PCH ( $full_message, "subject"   ); ###      $alarm_prid      = pdsGet_PCH ( $full_message, "prid"      ); ###  ###  ###      nimLog ( 0, "alarm_nimid=[$alarm_nimid]"         ); ###      nimLog ( 0, "alarm_nimts=[$alarm_nimts]"         ); ###      nimLog ( 0, "alarm_tz_offset=[$alarm_tz_offset]" ); ###      nimLog ( 0, "alarm_source=[$alarm_source]"       ); ###      nimLog ( 0, "alarm_robot=[$alarm_robot]"         ); ###      nimLog ( 0, "alarm_domain=[$alarm_domain]"       ); ###      nimLog ( 0, "alarm_origin=[$alarm_origin]"       ); ###      nimLog ( 0, "alarm_pri=[$alarm_pri]"             ); ###      nimLog ( 0, "alarm_subject=[$alarm_subject]"     ); ###      nimLog ( 0, "alarm_prid=[$alarm_prid]"           ); ###  ###      my $alarm_level; ###      my $alarm_subsys; ###      my $alarm_message; ###      my $alarm_token; ###  ###      $alarm_level   = pdsGet_INT ( $user_data, "level"   ); ###      $alarm_subsys  = pdsGet_PCH ( $user_data, "subsys"  ); ###      $alarm_message = pdsGet_PCH ( $user_data, "message" ); ###      $alarm_token   = pdsGet_PCH ( $user_data, "token"   ); ###  ###      nimLog ( 0, "alarm_level=[$alarm_level]"     ); ###      nimLog ( 0, "alarm_subsys=[$alarm_subsys]"   ); ###      nimLog ( 0, "alarm_message=[$alarm_message]" ); ###      nimLog ( 0, "alarm_token=[$alarm_token]"     );       my $alarm_nimid;      my $alarm_qos;      my $alarm_source;      my $alarm_target;      my $alarm_sampletime;      my $alarm_sampletype;      my $alarm_samplevalue;      my $alarm_sampledev;      my $alarm_samplerate;       $alarm_nimid       = pdsGet_PCH ( $full_message, "nimid"       );      $alarm_qos         = pdsGet_PCH ( $user_data,    "qos"         );      $alarm_source      = pdsGet_PCH ( $user_data,    "source"      );      $alarm_target      = pdsGet_PCH ( $user_data,    "target"      );      $alarm_sampletime  = pdsGet_INT ( $user_data,    "sampletime"  );      $alarm_sampletype  = pdsGet_INT ( $user_data,    "sampletype"  );      $alarm_samplevalue = pdsGet_F   ( $user_data,    "samplevalue" );      $alarm_sampledev   = pdsGet_F   ( $user_data,    "sampledev"   );      $alarm_samplerate  = pdsGet_INT ( $user_data,    "samplerate"  );       nimLog ( 0, "alarm_nimid=[$alarm_nimid]"             );      nimLog ( 0, "alarm_qos=[$alarm_qos]"                 );      nimLog ( 0, "alarm_source=[$alarm_source]"           );      nimLog ( 0, "alarm_target=[$alarm_target]"           );      nimLog ( 0, "alarm_sampletime=[$alarm_sampletime]"   );      nimLog ( 0, "alarm_sampletype=[$alarm_sampletype]"   );      nimLog ( 0, "alarm_samplevalue=[$alarm_samplevalue]" );      nimLog ( 0, "alarm_sampledev=[$alarm_sampledev]"     );      nimLog ( 0, "alarm_samplerate=[$alarm_samplerate]"   );             nimSendReply ( $message_handle ); }  my ( $program_log_file, $program_name, $program_log_level, $version, $program_execution_interval ); $program_log_file           = $program_name_without_extension . ".log"; $program_name               = $0; $program_log_level          = 0; $version                    = 0.1; $program_execution_interval = 60;  print "program_log_file=[$program_log_file]\n"; print "program_name=[$program_name]\n"; print "program_log_level=[$program_log_level]\n";  nimLogSet ( $program_log_file, $program_name, $program_log_level, 0 ); nimLog ( 0, "------------------- Starting ( PID : $$ ) ------------------- " );  my $session1; $session1 = Nimbus::smileyfrustrated:ession->new ( $program_name ); $session1->setInfo ( $version, "Nimbus Software AS" );  #Attach / Subscribe if ( $session1->attach("$program_name_without_extension") ) {      if ( $session1->subscribe("QOS_MESSAGE") )      {           nimLog ( 0, "Could not attach / subscribe" );           nimAlarm ( 5, "Could not attach / subscribe" );            exit ( $COULD_NOT_ATTACH_SUBSCRIBE );      } }    if ( $session1->server ( NIMPORT_ANY, \&program_timeout, \&program_restart ) == 0 ) {      #Do nothing      #$session1->addCallback ( "custom_function", "arg1,arg2_str,arg3_num%d" ); } else {      nimLog ( 0, "Unable to create server session." );      exit ( $UNABLE_TO_CREATE_SERVER_SESSION ); }  #nimLog ( 0, "Going to dispatch the probe" );  $session1->dispatch ();  exit ( 0 );  

 

 

Regards,

Amit Saxena

Outcomes