DX Infrastructure Management

Maintenance Mode via command line 2.6 (rest api) 

01-07-2016 07:31 AM

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.

 

All remarks or ideas are very  welcome

 

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

tested on UIM 9.0.2 windows

Version 2.6:

- option -ir"regex" makes it possible to set devices in maintenance based on the cm_computer_system table.  So you can put devices in maintenance that are not a robot.

Statistics
0 Favorited
5 Views
1 Files
0 Shares
3 Downloads
Attachment(s)
zip file
nimsoft_rest_maintenance_2.6.zip   26.15MB   1 version
Uploaded - 05-29-2019

Tags and Keywords

Comments

06-15-2018 01:07 PM

Hi,

 

I checked the maintanance mode logs and see that this is happening due to foreign key violation. 

 

Jun 14 13:23:03:457 ERROR [attach_socket, com.nimsoft.monitor.probe.util.MaintenanceScheduleUtil] Error adding CS 8519 to scheduleId 4 PreparedStatementCallback; SQL [INSERT INTO MAINTENANCE_SCHEDULE_MEMBERS (schedule_id, cs_id) VALUES(?, ?)]; The INSERT statement conflicted with the FOREIGN KEY constraint "FK__MAINTENAN__SCHED__6A50C1DA". The conflict occurred in database "CA_UIM", table "dbo.MAINTENANCE_SCHEDULE", column 'SCHEDULE_ID'.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK__MAINTENAN__SCHED__6A50C1DA". The conflict occurred in database "CA_UIM", table "dbo.MAINTENANCE_SCHEDULE", column 'SCHEDULE_ID'.
Jun 14 13:23:03:458 ERROR [attach_socket, com.nimsoft.monitor.probe.util.MaintenanceScheduleUtil] Error adding CS 8508 to scheduleId 4 PreparedStatementCallback; SQL [INSERT INTO MAINTENANCE_SCHEDULE_MEMBERS (schedule_id, cs_id) VALUES(?, ?)]; The INSERT statement conflicted with the FOREIGN KEY constraint "FK__MAINTENAN__SCHED__6A50C1DA". The conflict occurred in database "CA_UIM", table "dbo.MAINTENANCE_SCHEDULE", column 'SCHEDULE_ID'.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK__MAINTENAN__SCHED__6A50C1DA". The conflict occurred in database "CA_UIM", table "dbo.MAINTENANCE_SCHEDULE", column 'SCHEDULE_ID'.

06-15-2018 04:42 AM

When looking in the maintenance_mode log: (and looking for the command with the input file that returned the internal error)

   Added csIds 2,29886,56069,56173,56174 to scheduleId 5402

   An exception occurred while processing a message from Socket[addr=/192.168.0.153,port=51561,localport=48060].

   (2) communication error, I/O error on nim session (S) com.nimsoft.nimbus.NimServerSession(Socket[addr=/192.168.0.153,port=51561,localport=48060]): Software caused connection abort: recv failed

First he confirms that the calendar definition is correct, than he confirms that the 4 devices are added in the calendar and than something exceptional happens (in some cases)

But; when looking in USM to all maintenance definitions I can see the calendar with schedule id: 5402 and I can see the 4 devices defined in the calendar. (if you execute: nimsoft_rest_maintenance -lm"y")

---

I re-executed the same command 10 minutes later, and at that moment it ended successful.

Perhaps this is a known problem? (I dont have access anymore to these)

06-14-2018 04:09 PM

Hi Team,

 

I am testing nimsoft_rest_maintanace_v2.5 version to add servers to maintanance mode via command line. It is working perfectly fine when I add 1 server by using option - ih

 

nimsoft_rest_maintenance.exe -ac"a" -ci"3" -ih"tfewrwepdbd0535" -sim"n"

 

But when I try to add multiple servers by placing the servers in file it is throwing below error.

step 4b: HTTP POST error code: 500
step 4b: HTTP POST error message: Internal Server Error

 

I placed one server per line and also command was able to find cs_id for all servers. It is failing while posting the API step. 

 

Can you please let me know if someone is facing this issue or any resolution for the same? 

 

Just to let you know that I used -if option while using file to add multiple servers into maintenance window.

 

Thanks,

Ganesh Sambandan

05-22-2018 07:26 AM

updated to 2.5

05-18-2018 12:39 PM

A 2.5 is almost ready, with the option to remove a device from maintenance (also implemented in the probe_main_on where you can add/remove from maintenance via nimalarm)

What are your suggestions?

05-18-2018 09:01 AM

Is this still valid and working?  Is there a newer update?  Just asking as this post is a year old and I'm just seeing it.  I have a use for this and as I dig into the files I may have a couple suggested changes/additions if not already incorporated.

04-10-2018 06:52 AM

Can you send me a list of queries that would need to be ported?  I will see if I can get one of our Oracle guys to port them.

04-10-2018 02:48 AM

No, but if somebody has the knowledge to translate the sql queries into oracle queries I will be happy to add the oracle support

04-09-2018 03:53 PM

Is there an Oracle version of this yet?

01-08-2016 01:31 AM

Like Jason indicated is this command line tool using the "new" maintenance mode that:

- has no need of additional NAS rules

- uses the REST API calls to add devices/hosts (or a list of devices) into an existing maintenance schedule

01-07-2016 10:12 AM

??So, the method you describe using the "computer state monitor" is actually semi-deprecated.   (The reason being, you can no longer set machines in USM to 'maintenance' or 'managed' state, unless you are still using the (also deprecated) SOC (Service-Oriented Configuration.)  It will still technically work if you set the status in the database (CM_COMPUTER_SYSTEM) but it's been replaced by the new USM-based Maintenance Mode.

 

 

This new method of maintenance mode involves creating Maintenance Schedules in USM, and adding members to those schedules.  No additional configuration in NAS is necessary - the NAS automaticallly communicates with the maintenance_mode probe every few minutes to get a list of current/upcoming maintenance windows.

 

 

If I am not mistaken the REST API calls (and therefore this command line tool) are designed to use this "new" maintenance mode.

 

 

-Jason

01-07-2016 08:44 AM

Just to be clear, if I understand correctly the above puts a device into 'maintenance mode' and it would still be necessary to configure nas accordingly to have alarms suppressed.

 

open the nas Configure GUI > Auto-Operator > Properties tab > check the box to 'Activate Auto-Operator' > Computer State Monitor tab > check the box to 'Activate' > under 'Action On Maintenance State' check the box for 'Filter Message' or 'Make Invisible' > click the box for Apply.

 

Setting the computer state monitor in the NAS forces the NAS to look at CM_COMPUTER_SYSTEM when alarms come in, and check if a machine is in "managed", "unmanaged" or "maintenance" state, and then act accordingly based on the settings you have set for that particular state. There should be no impact except that which is configured by the customer (i.e. alarms from 'maintenance' machines will be set invisible if they have that option selected...)

Related Entries and Links

No Related Resource entered.