DX Unified Infrastructure Management

 View Only
Expand all | Collapse all

Maintenance mode

  • 1.  Maintenance mode

    Posted May 13, 2010 12:45 PM

    Hi,
    we've this request:
    in this version on NimBUS, when we want set a robot in maintenance mode, we can only set ultil date. He need to set also start date.

    Regards,
    Paolo



  • 2.  Re: Maintenance mode

    Posted May 14, 2010 12:31 AM
    Hi,

    as I know it is not possible to set a start date for the maintenance mode. With a custom probe (coded by yourself) you can implement such a feature (like a scheduled list) by using the callback function of the controller.

    I hope this helps,
    Olaf


  • 3.  Re: Maintenance mode

    Posted May 14, 2010 01:03 AM

    You might also be able to achieve this by coding a NAS script and configuring a scheduled job in the auto-operator.

     

    -Keith



  • 4.  Re: Maintenance mode

    Posted May 14, 2010 06:06 PM
    I agree here with Keith. Using the NAS you'll have the ability to schedule your script as needed using the AO.


  • 5.  Re: Maintenance mode

    Posted May 16, 2010 03:54 AM

    Please proviede an example, or explanation of your suggestion. Thanks (new to NIM)



  • 6.  Re: Maintenance mode

    Posted May 16, 2010 11:52 PM

    The robot/controller has a callback named maint_until that you can use to set maintenance mode from a script. It is documented in the controller whitepaper, which you can find in the solutions in the Self-Service Center. The duration of the maintenance can be specified in one of two ways:

     

    • The until argument can specify the end time of the maintenance (as a numeric timestamp).
    • The for argument can specify the number of seconds the maintenance should last.

    You could send a request to the callback using any supported SDK language or the pu command. Here is a snippet of Lua that would set maintenance mode to last for five minutes:

     

    args = pds.create()
    pds.putInt(args, "for", 300)
    resp,rc = nimbus.request(robot_addr, "maint_until", args)

     

    You would have to specify the robot_addr variable, and it would be a good idea to make sure the rc variable is set to 0 after the callback returns. If you were running this in the NAS, that should be all there is to it. If you were running it in the NSA, you would have to call nimbus.login() before sending the request.

     

    -Keith



  • 7.  Re: Maintenance mode
    Best Answer

    Posted May 25, 2010 05:58 AM

    You can also do this with the Probe Utility against the robot . Use 'maint_until' and specify how long it should be in maintenance mode for, leave 'until' empty (this is an epoch number), and specify how many seconds in the 'for' parameter.


    For example:

    pu -u administrator -p xxxxxxxx /"full path to robot"/controller maint_until for 120 until ""

    Remember to always include all parameters and leave the "blank" ones in the end.

    The call back for the controller is:

    maint_until (until, for)

    To enter maintenance mode:

    Specify either the 'until' value, which is a time value representing the time in seconds since the Epoch (00:00:00 UTC, January 1, 1970) or the 'for' value which is the time in seconds you want the robot to stay in maintenance mode.

    To leave maintenance mode:

    Use the same call but do not specify neither 'until' nor 'for'.

    Another option (as previously suggested) is via Lua - all credit for the below goes to James Christensen:

     

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------

    You will need to edit the duration (it is in seconds), the hub name and the hub robot name. Please note that this script purposely skips putting the hub robot into maintenance for good reason. A timestamped log file is also created that will list the robots as they are put into maintenance or, in the case of the hub robot, skipped.


    -------------------------------- NAS script to place all robots reporting to specified hub into maintenance mode ---------------

     

    local duration = 60 --edit per hub - note this is in seconds local hubName = "jmc-lt-dev" --edit per hub local hubRobot = "jmc-w2k3" -- edit per hub local nmsDomain = "JMC_LT_DEV" --edit per hub local hubAddr = "/"..nmsDomain.."/"..hubName.."/"..hubRobot.."/"

    local myBuffer ="ITA Scheduled Maintenance Script for "..hubName.."\n"

    local fts = timestamp.format (timestamp.now(),"%d_%b_%Y_%H_%M_%S")

    local ts = timestamp.format (timestamp.now(),"%c")

     

    myBuffer = myBuffer..ts.."\n"

    myBuffer = myBuffer.."Maintenance Period Duration:

    "..tostring(duration).." seconds\n"

     

    local val,rc = nimbus.request( hubAddr.."hub","getrobots") print("return code:"..tostring(rc)) if val ~= nil then

       print("Val is not null and type is: "..type (val))

       for i,a in pairs(val) do

          print("a is not null and type is: "..type(a))

          if a ~= nil then

             if type(a) == "table" then

                for b,t in pairs(a) do

                   if t.name == hubRobot then

                      print("Found hub robot: "..t.name)

                      myBuffer = myBuffer.."Found hub robot....Skipping\n"

                   else

                      local myArgs = pds.create ()

                      pds.putString (myArgs, "until", "")

                      pds.putInt (myArgs, "for", duration)

                      pds.putString(myArgs, "comment", "ITA Scheduled Maintenance Script")

                      local rc = nimbus.request(t.addr.."/controller",

    "maint_until", puPds)

                      pds.delete(myArgs)

                      myBuffer = myBuffer..t.name..": "..t.addr.."\n"

                      print(t.name)

                      print(t.addr)

                   end

                end

             end

          end

       end

    end

     

    file.create ("C:\\ITA Scheduled Maintenance_"..fts..".log",myBuffer)


    ----------------------------------------------------------------------------------------------------------------------------------------------------------------

     

    Good luck!

     

    Dustin



  • 8.  Re: Maintenance mode

    Posted May 28, 2010 11:45 AM
    Thanks all!

    Paolo


  • 9.  Re: Maintenance mode

    Posted Jun 17, 2010 04:31 PM

    Hello,

    I have adapt the script to set multiple robots in maintenance for only one machine, when a executing the script from the nas my robot will be set in maintenance mode.It work fin with a alarm.

    I have then try to run it directly from a command line with nsa.exe scriptname but the robot go never in maintenance mode but a have well the alarm.

    Have somebody I idee  why it doesn't execute the maintenance mode ?

     

     

    Joel

     

    -------------------------------- NAS script to place a robot to specified hub into maintenance mode ---------------
    Alarmlev1="2"
    Alarmlev2="0"

    local duration = 120 --edit per hub - note this is in seconds
    local hubName = "NimBUSServer" --edit per hub
    local hubRobot = "monitor1" -- edit per hub
    local nmsDomain = "Enterprise" --edit per hub
    local hubAddr = "/"..nmsDomain.."/"..hubName.."/"..hubRobot.."/"
    print (hubAddr)
    local myBuffer ="Scheduled Maintenance\n"
    local fts = timestamp.format (timestamp.now(),"%d_%b_%Y_%H_%M_%S")
    local dts = "'"..timestamp.format ( timestamp.now(), "%Y-%m-%d %H:%M:%S").."'"

    --print (dts)
    local ts = timestamp.format (timestamp.now(),"%c")
    --print (ts)
    myBuffer = myBuffer..ts.."\n"
    myBuffer = myBuffer.."Period Duration:"..tostring(duration).." seconds\n"
    --print (myBuffer)
    local val,rc = nimbus.request( hubAddr.."hub","getrobots")
       print("return code:"..tostring(rc))
       if val ~= nil then
         --print("Val is not null and type is: "..type (val))
         for i,a in pairs(val) do
            --print("a is not null and type is: "..type(a))
            if a ~= nil then
               if type(a) == "table" then
                  for b,t in pairs(a) do
                     if t.name == hubRobot then
                         
                     else
                         if t.name=="st-bos_steria_be" then
                            local myArgs = pds.create ()
                            pds.putString (myArgs, "until", "")
                            pds.putInt (myArgs, "for", duration)
                            pds.putString(myArgs, "comment", "Scheduled Maintenance")
                            print (myArgs)
                            local rc = nimbus.request(t.addr.."/controller","maint_until", myArgs)
                            pds.delete(myArgs)
                            myBuffer = t.name..": "..myBuffer.."\n"
                            nimbus.alarm (Alarmlev1,myBuffer,"maintenance","",t.name)
                                                   
                         end --if
                     end --if
                  
                  end -- for

               end --if
            
              end --if
          
          end --for

       end --if

    print (myBuffer)
    file.create ("./Scheduled_Maintenance_"..fts..".log",myBuffer)



  • 10.  Re: Maintenance mode

    Posted Jun 17, 2010 07:05 PM

    Hi Joel,

    I have a quick look to your script and one thing is missing if you try to run this script from the commandline with nsa.exe:

    You need to login at NimBUS using the nimbus.login(....) function at the top of your script.

    I hope this helps...

    Olaf



  • 11.  Re: Maintenance mode

    Posted Jun 18, 2010 12:19 PM

    Thanks,

    I work now

     

     

    Joel



  • 12.  Re: Maintenance mode

    Posted Mar 17, 2011 07:25 PM

    kruepke wrote:

    Here is a snippet of Lua that would set maintenance mode to last for five minutes:

     

    args = pds.create()
    pds.putInt(args, "for", 300)
    resp,rc = nimbus.request(robot_addr, "maint_until", args)

     

    You would have to specify the robot_addr variable, and it would be a good idea to make sure the rc variable is set to 0 after the callback returns. If you were running this in the NAS, that should be all there is to it. If you were running it in the NSA, you would have to call nimbus.login() before sending the request.

     

    -Keith


     

     

    So it looks like it is not possible to call a script such as this with a pre-processing rule?

     

    When I try, I get the following error:

    nas: PREPROCESSOR ERROR: scripts/maintenance\maintenance_test:4: attempt to index global 'pds' (a nil value)

     

    I can run the script fine from the scripts tab in Auto-Operator, and schedule the script fine using the Auto-Operator scheduler, but no luck with a pre-processing rule.



  • 13.  Re: Maintenance mode

    Posted Mar 18, 2011 12:55 AM

    No, pre-processing scripts do not support external calls. Most (or maybe all) of the extra Lua libraries provided by the NAS are not available in pre-processing scripts. The reason is that the pre-processing scirpts are run as the NAS receives matching alarm messages from the hub. This slows down the processing of incoming alarm messages. If you were to call functions like nimbus.request() from a pre-processing script, that would add even more delay, which could be very dangerous.

     

    -Keith 



  • 14.  Re: Maintenance mode

    Posted Mar 24, 2011 01:02 AM

    Any opinions out there as to which method is "best" to use?

     

    Use the PU command in a script to set maintenence mode?

     

    Use nimbus.request in a script to set maintenance mode?

     

    Which method would be least taxing on the HUB?



  • 15.  Re: Maintenance mode

    Posted Mar 24, 2011 06:13 AM

    Those two options are equivalent from the perspective of the hub. The nimbus.request() function in Lua does exactly the same thing as the PU command. I would recommend choosing a scripting language with which you are comfortable. If that is a language that has a Nimsoft SDK, use the provided function/method/subroutine to make the request to the robot. (If you have any trouble locating the right function, just ask here on the fourm!) If you choose to work with a language that does not have a Nimsoft SDK, have your script call the PU command to send the request to the robot.

     

    Of course, you can definitely use this as an opportunity to learn a new language if you would prefer to do that!

     

    The funny thing about the PU command is that sending arguments to callbacks is a little strange. You have to figure out the order in which the arguments have to be specified. I usually do this by running the command with no arguments for the callback, which causes the command to prompt you for each argument. Then that is the order you can sepcify the arguments on the command line.

     

    Usually when you send a request to a callback using one of the SDKs, you get to be very explicit about the name and value of each argument rather than relying on order. It is a bit more work, but it is more straightforward.

     

    I hope this helps a bit...

     

    -Keith



  • 16.  Re: Maintenance mode

    Posted Mar 24, 2011 08:49 PM

    Keith,

     

    Thanks for all the info. We'll be using LUA for the scripts to put robots into Maintenance.

     

    Depending on what our customer wants, it will either be at the Pre-processing stage (Where we'll have to use the PU command), or it will be using an AO profile, in which case we'll probably use nimbus.request.

     

    Good to know what neither method should cause issues with the hub...



  • 17.  Re: Maintenance mode

    Posted Mar 24, 2011 09:14 PM

    Sorry, I might have misunderstood your question. I did not realize you were specifically talking about putting robots into maintenance mode from the NAS. I thought it was a more general question about SDKs and PU.

     

    When it comes to the NAS, I think using a Lua script is your only option--from an AO profile or from a sheduled job. I do not think you can call the PU command from a pre-processing rule at all.

     

    -Keith



  • 18.  Re: Maintenance mode

    Posted Mar 24, 2011 10:29 PM

    PU command can be called from pre-processing by using os.execute in a LUA script...



  • 19.  Re: Maintenance mode

    Posted Mar 24, 2011 11:41 PM

    Ah, so the libraries provided by Lua are not blocked even though the libraries provided by Nimsoft are! Very interesting. That makes sense for the string and table libraries, although arguably that may be a concern for the os library.

     

    Please use caution when making external calls from pre-processing scripts. Pre-procecessing scripts slow down the ability of the NAS to process incoming alarm messages from the hub. Making an external call would slow it down even more. You may find that there are times the NAS will be unable to keep up with incoming messages for extended periods of time, which would delay your ability to see alarms for new issues.

     

    -Keith