DX Infrastructure Manager

Expand all | Collapse all

Maintenance Mode at the endpoint

Jump to Best Answer
  • 1.  Maintenance Mode at the endpoint

    Posted 04-26-2013 08:22 PM

    Need to see if there is a way we can place a robot in Maintenance Mode from the Robot Endpoint. Essentially, the thought is to place a scripted icon on the desktop that can be launched locally and it would place that particular robot in Maintenance Mode.


    Any ideas are appreciated.

  • 2.  Re: Maintenance Mode at the endpoint

    Posted 04-26-2013 11:20 PM



    I can think of a few ways to do this:


    You could do this with PU command line utility, the downside being that you'd need to give it nimbus credentials. If you're on linux and logged as root, that shouldn't be a problem.


    Another way would be to have the icon run a script that modifies the configuration file directly and then restarts the service.


    I've done something similar in a case where a 3rd party needed to be able to disable some tests and place some robots in maintenance mode. I created a logmon watcher that runs a perl script, that looks for existance of certain files and send and informative alarm based on the occurrence of those files. Then a NAS AO script checks the files and sends the callbacks to either disable a set of tests or to place the entire robot in maintenance mode. The perl script keeps track on the last modifed timestamp of the file, and when it exceeds a certain amount of time, it then sends an alert that tells the NAS to enable the tests again, or to remove or to leave maintenance mode.


    I hope that was clearly enough explained :smileyhappy:



  • 3.  Re: Maintenance Mode at the endpoint

    Posted 04-26-2013 11:26 PM

    Johncw is right in every manner, however I might add a couple of points if I may.


    While perl is very effective I find the distribution of active/strawberry perl a bit of a bind on windows OS. I prefer LUA for simple tasks such as this purley as the NSA probe can be deployed from the archive with ease.


    A call back to the controller using "main_until" should do the job.


    Happy to help you with the LUA code should you need it.

  • 4.  Re: Maintenance Mode at the endpoint

    Posted 04-26-2013 11:45 PM

    I agree, LUA is better if you're on a windows host. Then again, if available I'd argue that powershell is even handier :smileyhappy:

  • 5.  Re: Maintenance Mode at the endpoint

    Posted 04-27-2013 12:09 AM

    Thanks tons for the great suggestions. Admittedly, I've never done any LUA scripting, but have a better than average knowledge of Powershell. Yes, these are all Windows servers.


    If anyone has any PS or LUA scripts that will work, I am most interested in trying them out.

  • 6.  Re: Maintenance Mode at the endpoint
    Best Answer

    Posted 04-27-2013 12:40 PM

    With PU, if you wanted to provide credentials, you'd do something like this:

    <nimdir>\bin\pu.exe -u user -p password controller maint_until 'until' 'for' 'comment' 'from'

     where time fields are ticks, and one of them is required.


    With powershell, you'd need to modify robot.cfg <controller> section to contain key "maint_until" with the value as ticks. You could get it with something like this:


    $epoch = get-date -date "01/01/1970"
    (new-timespan -start $epoch -end (get-date)).totalseconds -match "\d*"
    $until = $matches[0] + time in seconds you want to have the robot in maintenance mode

    and then restart the nimbus service.


    Here's also my LUA that NAS runs to disable profiles and put  robots in maintence mode. It's not the final version but it should how I intend it to work. You'd need to modify it a bit if you wanted to have several remote tests for a server in the same probe


    Message is in format "server name;activate" or ";deactivate"

    arguments provided by AO profile are: $domain,$origin,$hostname,$message, $nimid


    here's the script:

    args = split(SCRIPT_ARGUMENT, ",")
    info = split(args[4], ";")
    target = "/"..args[1].."/"..args[2].."/"..info[1].."/controller"
    printf("TARGET: "..target)
    maint = pds.create()
    pds.putInt(maint, "for", 900)
    leave = pds.create()
    pds.putInt(leave, "for", 0)
    remote_net_args = pds.create()
    pds.putString(remote_net_args, "name", "net_connect")
    remote_maint_net = pds.create()
    if info[2] == "deactivate" then
       _, rc = nimbus.request(target, "maint_until", maint)
       printf("MAINT MODE RETURN CODE: "..rc)
         if info[1] == "profile_name" then
              pds.putString(remote_maint_net, "/profiles/profile_name/active", "no")
       pds.putPDS(remote_net_args, "as_pds", remote_maint_net)
       _, rc = nimbus.request("/domain/hub/robot/controller", "probe_config_set", remote_net_args)
        printf("DEACTIVATE RC: "..rc)
    elseif info[2] == "activate" then
       _, rc = nimbus.request(target, "maint_until", leave)
       printf("LEAVE MAINT MODE RETURN CODE: "..rc)
        if info[1] == "profile_name" then
              pds.putString(remote_maint_net, "/profiles/profile_name/active", "yes")
       pds.putPDS(remote_net_args, "as_pds", remote_maint_net)
       _, rc = nimbus.request("/domain/hub/robot/controller", "probe_config_set", remote_net_args)
       printf("ACTIVATE RC: "..rc)