DX Unified Infrastructure Management

 View Only
  • 1.  Trying create an alarm using Perl PDS

    Posted Jul 22, 2010 03:40 PM

    Hello,

    i'm trying to build a Perlscript which sends an alarm into the NimBUS.
    I need to build the head myself, using PDS or something similar.

    The Problem is, my PDS will not create a header. I tried to give a value
    for "pri", the log said "could not get 'pri' from head PDS".

    Anybody knows how to build the header in a correct way?

    Tim


    ########################   Perl   ########################

    #!/opt/nimbus/bin/perl

    use Nimbus::API;
    use Nimbus::CFG;
    use Nimbus::smileytongue:DS;
    use Nimbus::smileyfrustrated:ession;

    my $username="USER";
    my $password="xxxPASSxxx";

    nimLogin($username, $password);

      my $pds_snd = pdsCreate();
       pdsPut_PCH($pds_snd, "subject", "alarm");
       pdsPut_INT($pds_snd, "pri", 5);
       pdsPut_PCH($pds_snd, "prid", "perlscript");
       pdsPut_PCH($pds_snd, "nimid", "MM93135124-35191");

    nimNamedRequest("spooler", "post", $pds_snd, 10);


    ########################   LOG   ########################

     spooler: got MSG on session 0x7ff314002590
     spooler: RREQUEST: post <-172.19.60.27/49832  h=256 d=80
     spooler:  head   mtype=100 cmd=post seq=0 ts=1279801208 frm=172.19.60.27/49832
     spooler:  head   tout=10 addr=spooler sid=GhboozMJ/BASe7I5ED61VgADMTI3OTgyMjgwNQFob25pbXFzLWJlZmUwMQEyMTg2
     spooler:  data   subject=alarm pri=5 prid=perlscript nimid=MM93135124-35191
     spooler: DISPATCHING post           , user-data (80 bytes)
     spooler: post - could not get 'pri' from head PDS



  • 2.  Re: Trying create an alarm using Perl PDS

    Posted Jul 22, 2010 03:59 PM

    Hello Tim,

     

    This subject came up recently, though in Lua rather than Perl (try searching for "impersonating an alarm"). This has a good example of creating a custom alarm.

     

    Looking at the code from that post, you seem to be missing several items from your PDS (domain, robot, source, origin etc).

     

    Also, you use the spooler "post" method, whereas the example from that thread uses"hubpost".

     

    Richard



  • 3.  Re: Trying create an alarm using Perl PDS

    Posted Jul 22, 2010 04:12 PM

    Thanks for your reply. I've already read this lua-script and tried to translate it into perl.

     

    If i try to assign the command "hubpost" i'm getting "Command 'hubpost' not in command-list".

     spooler: DISPATCHING hubpost        , user-data (77 bytes)
     spooler: Command 'hubpost' not in command-list



    I completed my script using

    pdsPut_PCH($pds_snd, "domain", "xxxDOMAINxxx");
    pdsPut_PCH($pds_snd, "robot", "xxxROBOTNAMExxx");
    pdsPut_PCH($pds_snd, "source", "perlscript");
    pdsPut_PCH($pds_snd, "origin", "hub");
    ....


    but it's the same issue. All contents will be submitted as "data" instead of "head".



  • 4.  Re: Trying create an alarm using Perl PDS

    Posted Jul 22, 2010 04:44 PM

    Hi Tim,

     

    I used the following code and got an alarm in NMS. As you can see, my code uses "hubpost". Just checking, and this command does not require authentication, so the login should not be required.

     

    Richard

     

     

    use Nimbus::API;
    use strict;

    my $username = "administrator";
    my $password = "nimsoft";

    nimLogin($username, $password);

    my $pds_snd = pdsCreate();
    pdsPut_PCH($pds_snd, "subject", "alarm");
    pdsPut_INT($pds_snd, "pri", 5);
    pdsPut_PCH($pds_snd, "prid", "perlscript");
    pdsPut_PCH($pds_snd, "nimid", "MM93135124-35191");
    pdsPut_INT($pds_snd, "nimts", time());
    pdsPut_PCH($pds_snd, "domain", "nmsdemo");
    pdsPut_PCH($pds_snd, "origin", "nimsoft-vm1");
    pdsPut_PCH($pds_snd, "robot", "nimsoft-vm1");
    pdsPut_PCH($pds_snd, "source", "192.168.120.100");

    my $udata = pdsCreate();
    pdsPut_PCH($udata,"message","test");
    pdsPut_PCH($udata,"subsys","test");
    pdsPut_INT($udata,"level",2);

    pdsPut_PDS($pds_snd,"udata",$udata);


    nimNamedRequest("spooler", "hubpost", $pds_snd, 10);



  • 5.  Re: Trying create an alarm using Perl PDS

    Posted Jul 22, 2010 05:42 PM

    Richard,

     

    The difference is probably that Tim's spooler is on a robot, while yours in on a Hub. The hub has an internal spooler that supports all the "normal" spooler commands in addition to the hub specific ones. If you look closely in the NMS the Hub's spooler probe does not have a separate PID because the hub is handling everything.

     

    -Stian



  • 6.  Re: Trying create an alarm using Perl PDS

    Posted Jul 22, 2010 05:38 PM

    Tim,

     

    Out of curiosity exactly *why* are you creating a raw alarm PDS instead of using the nimAlarm function?

     

    Also please keep in mind that the nimid has to be unique! The system does NOT like duplicates of those :smileywink:

     

    -Stian



  • 7.  Re: Trying create an alarm using Perl PDS

    Posted Jul 22, 2010 05:55 PM

    Hi,

     

    now it works. The command "hubpost" for the spooler is only available when a hub is installed.

     

    @stian

    I know, that ID was just for testing. I need to build customalarms. For example i need to define it's own messagequeue etc.

     

    Thanks a lot!