How to add/setup a group of servers Maintenance schedule

Document ID : KB000115699
Last Modified Date : 24/09/2018
Show Technical Document Details
UIM customers may need to place servers into maintenance mode en masse. There could be one or more options leveraged to accomplish this task, e.g., NAS LUA script that reads a list of servers to place in maintenance, from a file, probe utility commands/script, or REST API calls.
- UIM 8.5.1
-- NAS script to set all robots from a given file into maintenance mode –
-- Just put a maintenance.txt file in the nas installation directory (probes/service/nas) with a robot address on each line.
-- /domain/hub/robot
-- /domain/hub/robot2

local duration = 60 --edit per hub - note this is in seconds
local myBuffer ="NMS Scheduled Maintenance Script: \n"
local fts = timestamp.format (,"%d_%b_%Y_%H_%M_%S")
local ts = timestamp.format (,"%c")

-- see if the file exists
function file_exists(file)
local f =, "rb")
if f then f:close() end
return f ~= nil

-- get all lines from a file, returns an empty
-- list/table if the file does not exist
function lines_from(file)
if not file_exists(file) then return {} end
lines = {}
for line in io.lines(file) do
lines[#lines + 1] = line
return lines

-- tests the functions above
local file = "maintenance.txt"
local lines = lines_from(file)

myBuffer = myBuffer..ts.."\n"
myBuffer = myBuffer.."Maintenance Period Duration: "..tostring(duration).." seconds\n"

-- print all line numbers and their contents
for _,device in pairs(lines) do
local myArgs = pds.create ()
pds.putString (myArgs, "until", "")
pds.putInt (myArgs, "for", duration)
pds.putString(myArgs, "comment", "NMS Scheduled Maintenance Script")
local rc = nimbus.request(device.."/controller","maint_until", myArgs)
myBuffer = myBuffer..device..": In Maintenance\n"

print (myBuffer)
Additional Information:
Probe Utility commands

You can also run the pu command from the cmd line to see all of the available probe commands which could be used within a script. Most of them are self-explanatory. The _* commands are only available via checking Expert Mode. Click the cogwheel icon to enable Expert Mode.

User-added image

C:\Users\Administrator>"C:\Program Files (x86)\Nimsoft\bin\pu.exe" -u administra
tor -p xxxxxxxx maintenance_mode
Sep 24 15:11:15:309 pu: SSL - init: mode=0, cipher=DEFAULT, context=OK
Address: maintenance_mode            Request: _command

add_computer_systems_to_active_window PDS_PCH          17 scheduleId,csIds

probe_up        PDS_PCH           1

_restart        PDS_PCH           1

get_historical_maintenance_windows PDS_PCH          27 start_time,end_time,dev_id

register_maintenance_subscriber PDS_PCH          42 path,version,interval_start,interval_stop

new_duration_for_active_window PDS_PCH          20 scheduleId,duration

_status         PDS_PCH           9 detail%d

remove_computer_systems_from_schedule PDS_PCH          17 scheduleId,csIds

get_next_fire_time_for_schedules PDS_PCH           1

_stop           PDS_PCH           1

delete_schedule PDS_PCH          11 scheduleId

add_schedule    PDS_PCH         190 name,description,start_time,duration,account

_debug          PDS_PCH           8 level%d

_command        PDS_PCH           9 detail%d

unregister_maintenance_subscriber PDS_PCH           5 path

stop_maintenance PDS_PCH          17 scheduleId,csIds

add_computer_systems_to_schedule PDS_PCH          17 scheduleId,csIds

modify_schedule PDS_PCH         202 schedule_id,name,description,start_time,dura

REST API option:

Maintenance Mode via command line 2.5 (rest api)

The attached tool makes it possible to put servers in maintenance mode via a command line tool (via REST API calls)

- list defined calendars
- list servers/devices in maintenance
- add server(s) in existing calendar (with server name)
- define calendar and add servers, with the server name, directly in this new calendar
- put an USM group into maintenance
- list empty calendars
- delete empty calendars
- list expired calendars
- delete expired calendars
- remove servers from maintenance

Doc file is included.

Prereq: this tool uses the webservices_rest probe that must be deployed to your UMP server.

note: Perl source and compiled version are included

Version 2.2:
- add USM group in maintenance
- add regex selection of robots in maintenance
- delete empty and/or expired calendars (only for MSSQL, if anybody with MySQL skills could translate them?)
- tested and compiled on Centos7 & Windows 2012

Version 2.4:
- UMP/Rest http or https
- add with(nolock) in sql queries
- correct sql query to select USM groups

Version 2.5:
- remove servers from maintenance (in regex format)
- a server that has multiple entries in the discovery tab (mutiple cs_ids) will have all entries added in maintenance