DX Unified Infrastructure Management

  • 1.  getting all alarms from NAS

    Posted Dec 16, 2013 02:49 PM

    Hi,

     

    I'm trying to get all alarms from nas with get_alarms callback. Apparently this callback only returns max. 500 alarms at a time and needs to be repeated until the callback returns NIME_NOENT, which is also return code 4.

     

    With the probe utility I can replicate this behaviour, but seem to be missing something when trying the same through APIs.

     

    I've tried with Perl, .NET and nsa but couldn't  figure it out. I've tried opening session explicitly and by letting the API do it.

     

    Here's an example Perl script that I tried:

     

    #!/opt/nimsoft/perl/bin/perl  use strict; use Nimbus::API; use Nimbus::smileyfrustrated:ession; use Nimbus::CFG; use Data::smileyvery-happy:umper;  my ($rc, $pds);  nimLogin("administrator", "password");  while ($rc != NIME_NOENT) {         ($rc, $pds) = nimNamedRequest("/Dev/Main/fihkinim01/nas", "get_alarms");         print "$rc\n"; }

     

    I have around 17 alerts in this environment and it just gives me output:

     

    [root@fihkicen02 scripts]# ./get_alarms.pl 0 0 0 0 0 0 0

     etc.

     

    Would be a big help if someone knows how to do this.

     

    -jon



  • 2.  Re: getting all alarms from NAS

    Posted Dec 16, 2013 03:07 PM

    OK, So I tried establishing session in .NET and it didn't work.. now I tried in Perl as well and it seems to work. Now I only need to figure out what's going wrong with .NET :smileytongue:

     

    Here's Perl code

    #!/opt/nimsoft/perl/bin/perl
    
    use strict;
    use Nimbus::API;
    use Nimbus::smileyfrustrated:ession;
    use Nimbus::CFG;
    use Data::smileyvery-happy:umper;
    
    nimLogin("administrator", "password");
    my $a = pdsCreate();
    
    my ($nims) = nimNamedSession("/domain/hub/robot/nas");
    
    my ($rc, $pds);
    
    while ($rc != NIME_NOENT) {
            ($rc, $pds) = nimSessionRequest ($nims, "get_alarms", $a);
            print "$rc\n";
    }
    
    nimSessionFree($nims);
    

     -jon



  • 3.  Re: getting all alarms from NAS

    Posted Dec 16, 2013 03:12 PM

    Yeah okay got .net running as well.. In case someone's interested, here's corresponding .NET code:

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using Nimsoft.NimBUS;
    using Nimsoft.NimBUS.Messaging;
    using Nimsoft.NimBUS.Security;
    
    namespace getAlarms
    {
        class Program
        {
            static void Main(string[] args)
            {
                string sid = Login.UserLogin("user", "pass");
    
                using (NimbusSession s = new NimbusSession("/domain/hub/robot/nas", sid))
                {
                    s.Connect(100);
                    int alarms = 500;
                    PDS param = new PDS();
                    param.PutInt("show_all", 1);
                    Request getAlarms = new Request("get_alarms", param);
    
                    while (alarms == 500)
                    {
                        PDS reply = s.SendMessage(getAlarms);
                        alarms = reply.GetTablePDSs("alarms").Length;
                        Console.WriteLine(alarms.ToString());
                        //System.Threading.Thread.Sleep(100);
                    }
         
                }
    
            }
        }
    }
    

     -jon



  • 4.  Re: getting all alarms from NAS

    Posted Mar 21, 2016 02:14 PM

    Hi John,

    Were you able to write the perl script to list down all alarms? Powershell script is working but I need perl script. If you managed to complete perl script can you please post the code to fetch message strings of all alarms.

    thanks in advance