DX Unified Infrastructure Management

Expand all | Collapse all

Finding all robots in Maintenance Mode

Anon Anon

Anon AnonJan 30, 2013 10:45 PM

  • 1.  Finding all robots in Maintenance Mode

    Posted Jan 30, 2013 10:08 PM

    I want to develop a procedure for listing all robots currently in maintenance (aside from looking on the UMP portlet).

     

    I did a sql query against CM_COMPUTER_SYSTEM (select * from CM_COMPUTER_SYSTEM), and I see a 'Maintenance' column, but the values in that column for all robots always shows as '0', even for robots that are in maintenance.

     

    Is anyone familiar with why this field doesn't seem to update, or another method for generating a list of maintenance mode robots?

     

     

    thanks!



  • 2.  Re: Finding all robots in Maintenance Mode

    Posted Jan 30, 2013 10:45 PM
    I'm looking for a way to check this too.


  • 3.  Re: Finding all robots in Maintenance Mode

    Posted Jan 31, 2013 10:14 PM

    A LUA Script can do that. You need to do the following:

     

    1. Queries the Primary hub to obtain a list of all hubs

    -- Obtain a list of all hubs
    hublist = nimbus.request("hub","gethubs");
    hubs = hublist.hublist

    2. Queries each hub to obtain a list of all the robots under it.

    for hubkey,hubtable in pairs(hubs) do
       hub = hubs[hubkey]

    3. Queries each robot to retrieve information to be used to create the Maintenance Report
       robotinfo = nimbus.request(hub.addr,"getrobots")
       robot_list = robotinfo.robotlist
       for robotkey,robottable in pairs(robot_list) do
          robot = robot_list[robotkey]

    The maintenance value can be found at "robot.maint_until".

     

     

     

     

     



  • 4.  Re: Finding all robots in Maintenance Mode

    Posted Jan 31, 2013 10:23 PM

    I think you can do it without querying each robot. The robot list from the hub should include the status of each robot. Maintenance mode is a specific status value (maybe 4?). If you avoid querying each robot, the script will be significantly faster, especially if it runs when any robots are down.



  • 5.  Re: Finding all robots in Maintenance Mode

    Posted Feb 01, 2013 08:15 PM

    I agree with Keith, querying each robot is probably not necesary. I mentioned that because in our environment we do have to perform that query in order to obtain information that can only be obtained at the robot level, and produce a weekly report via UR about robots being under maintenance, discriminated based on their respective OS.



  • 6.  Re: Finding all robots in Maintenance Mode

    Posted Feb 04, 2013 11:17 PM
    Have you tried a SQL query similar to this?

    "select robot, hub, status, alive_time, ip, maint_until FROM CM_NIMBUS_ROBOT where status = 4"

    Status = 4 appears to mean in maintenance mode


  • 7.  Re: Finding all robots in Maintenance Mode
    Best Answer

    Posted Feb 05, 2013 09:25 AM

    To me, the most reliable way is to use a lua script

     

    nimbus.login("", "")
    hubs = nimbus.request("hub", "gethubs")
    
    for i,_ in pairs(hubs.hublist) do
         robots,rc  = nimbus.request(hubs.hublist[i].addr, "getrobots")
         
         if rc == 0 then
              for _,robot in pairs(robots.robotlist) do
                   if robot.status ~= 0 then
                        print(robot.name..": "..robot.status)
                   end
              end
         else
              print("skipping "..hubs.hublist[i].addr)
         end
    end

     



  • 8.  Re: Finding all robots in Maintenance Mode

    Posted Feb 06, 2013 01:54 AM

    thanks, John!

     

    the only change I made was replaced print(robot.name..": "..robot.status) with nimbus.alarm(3, robot.name..":  robot is in the wrong state")



  • 9.  Re: Finding all robots in Maintenance Mode

    Posted Feb 06, 2013 10:50 PM

    Good to hear it helped! If you're having NAS run this on schedule, I would also suggest you add error check to getting the hublist and also raise an alarm when the "skipping" is executed :smileyhappy:



  • 10.  Re: Finding all robots in Maintenance Mode

    Posted Feb 08, 2013 11:11 AM

    Edit:

    I want to automatize the maintenance mode for defined robots.


    Here the answer and some scrips to start looking at it : http://forum.nimsoft.com/t5/General/Maintenance-mode-via-the-command-line/m-p/17383#M6518

     

    Only one question: How to deactivate robots? Delete maint_until only and restart robot?

     

    Thanks



  • 11.  Re: Finding all robots in Maintenance Mode

    Posted Feb 08, 2013 05:41 PM

    If you are asking how to take a robot out of maintenance mode, you can use the same callback (maint_until) and set the for argument to 0. It might also work with setting the until argument to 0, but I did not try that.



  • 12.  Re: Finding all robots in Maintenance Mode

    Posted Mar 02, 2013 01:09 AM
    Hi John,

    After scheduling it in NAS, how do we get an output?


  • 13.  Re: Finding all robots in Maintenance Mode

    Posted Mar 02, 2013 01:55 AM

    If you run it as a scheduled job in the NAS, the print() statements will print to nas.log. If you want them somewhere else, you need to code that in the script. You could collect the info into an email to send via action.email() or open up and write the info to a separate file.



  • 14.  Re: Finding all robots in Maintenance Mode

    Posted Mar 06, 2015 08:00 PM

    Where do I set this script to run from, please?



  • 15.  Re: Finding all robots in Maintenance Mode

    Posted Mar 06, 2015 08:50 PM

    You can run it from the NAS GUI or make it a scheduled job in the NAS. Otherwise I think you can run it anywhere you have the NSA installed.



  • 16.  Re: Finding all robots in Maintenance Mode

    Posted Mar 06, 2015 11:33 PM

    If you are using the newest versions of UIM/Nimsoft you can also query the database 

     

    select distinct cs.name, cs.ip, cs.origin, ms.SCHEDULE_NAME, ms.DESCRIPTION, CONVERT(VARCHAR(50), mw.START_TIME,100) as 'Start Time', CONVERT(VARCHAR(50), mw.END_TIME, 100) as 'End Time' from CM_COMPUTER_SYSTEM cs  
    INNER JOIN MAINTENANCE_SCHEDULE_MEMBERS msm  
    ON cs.cs_id=msm.CS_ID  
    INNER JOIN MAINTENANCE_WINDOW mw  
    ON msm.SCHEDULE_ID=mw.SCHEDULE_ID  
    INNER JOIN MAINTENANCE_SCHEDULE ms  
    ON msm.SCHEDULE_ID=ms.SCHEDULE_ID  
    WHERE mw.END_TIME >=GETDATE()