DX Infrastructure Management

 View Only

Delete server/device in UIM via command line tool (v3.3) 

Jul 04, 2016 07:23 AM

A question that I receive with (almost) every client is: How do we delete device(s) in UIM/Nimsoft (in an user friendlly way)?

The latest available doc/discussion explained that this is a multi step procedure, certainly if you want also to delete the related QoS data.

 

Attached zip contains a tool: nimsoft_delete_device that will remove the device in

- via discovery_server probe callback (remove from usm)

- via hub probe callback (remove from IM)

- all related QoS data

- all related MCS\SSR QoS data

- all related alarms in nas_transaction_log and nas_transaction_summary

- via the nas probe callback (nameservice_delete)

 

Selection parameters:

  -h: device(s) to delete

  -f:  path/file with devices to delete, 1 device per line, example: -f"c:/temp/delete.txt"

  -o: filter on origin

  -c: filter on dedicated

      (Device, VirtualMachine, Host, HostSystem)

  -r: enable regex expressions on flags -h,-o,-c (y,n) default: n

Delete parameters:

  -p: prevent rediscovery (y,n) default: n

  -q: delete QoS (y,n) default: y

      (QoS will not be deleted if -c is used)

  -i: delete in hub/IM (y,n) default: y

  -a: delete alarm (y,n) default: y

  -m: delete MCS/SSR QoS entries (y,n) default: y

  -n: delete in NAS address table (y,n) default: n

Display parameters

  -l: list detailed list of selected QoS to delete (y,n) default: n

  -v: verbose (y,n) default: y

  -t: verbose on sql delete (y,n) default: n

Execution parameters

  -s: simulate run (y,n) default: y

Debug Parameters:

  -d: when using -d"p" you will receive in simulation mode the PU command needed to use the callback: remove_master_device_by_cskey

 

Example1: nimsoft_delete_device.exe -h"servername"

This will simulate the delete of the server "servername".  If the simulation is ok for you, you can add: -s"n"

Example2: nimsoft_delete_device.exe -f"c:/temp/delete_servers.txt"

This will simulate the delete of all devices in file: c:/temp/delete_servers.txt. (Note: use a "/" to specify the path)

 

The script is written for Windows and MSSQL/mySQL and compiled via the pp option in Strawberry Perl. The package contains the .exe and .pl versions)

The zip contains also a CentOS compiled version (.bin)

In the zip file there is also a doc file that contains more info (you will need to change a file: nimsoft_generic.dat with server & user settings)

 

Version 1.2:

- parameter -o makes it possible to filter on origin in regex format

- mssql trusted connection can be used

Version 2.0:

- mysql added

- delete alarms in nas_transaction_log and nas_transaction_summary

- delete mcs/ssr qos and definitions

- regex is now an option

Version 2.1:

- in the search of all robotnames the tool will only search the domain specified in the nimsoft_generic.dat file

Version 2.2:

- works now with MSSQL and MySQL

- Works now on Windows and Linux (tested on Centos7)

- included compiled version for Linux (.bin) and Windows (.exe) that should work on standalone servers (but with a robot installed)

Version 2.3:

- The step to delete the device in the robot table of the hub is now based on a simple SQL query instead of (time consuming) callbacks

Version 2.4:

- the -m option is modified to be compatible with UIM 8.51.

- delete device NAS addess table with the option -n

Version 2.5:

- add with(nolock) in the sql queries

- add debug option -d"p"

Version 2.6:

- add option -f, so that you can use a file, 1 server per line, to define the servers/devices to delete

Version 2.9:

- minor debug/message changes

- option -i"y", delete in hub/IM via removerobot callback, had a wrong callback address if the robot was on a remote hub

Version 3.0:

- if multiple cs_id's are found for a device, all will be deleted

- work together with a probe version of "delete device" so that you can delete a device via a nimalarm

Version 3.1:

- tested with version 9.0.2

- add option -p to activate "prevent_rediscovery" (y,n) default: n

Version 3.3:

- callback removerobot needed to be case sensitive (added lookup to find the correct case)

- reworked/retested the Perl setup environment chapter 3

- revised all print statements to make debugging easier

- when working with the Perl source, you will need 3 extra Perl packages installed (see chapter 3, last 3 cpan install statements)

- MCS code reworked, thanks to Swat team, to remove MVS profiles of the deleted device

- tested with 9.1 (or 9.0.2 sp1)

- prepared to work with probe_decom (probe that will accept remove devices commands via a simple NimAlarm)

 

Comments and ideas are very welcome.

(this is , like all other user written tools, only an example tool that I tested as good as possible)

 

Note1: this version was fully tested on 8.5.1, 9.0.2 and 9.0.2 sp1

If you want to run it on older 8.x versions you must use the -m"n" parameter so that the tool will not try to use the MCS/SSR tables from 8.4

(tested with -m"n" on 8.1 and 8.31)

Note2: if you run the tool in non-simulation mode and receive an error like: "rc=2 err=communication error from nimNamedRequest " this is probably due to an error in defining the correct variable values (specially Case is important) for uim_domain, uim_hub or uim_robot in the file nimsoft_generic.dat.  Try to use your values in the command:

pu -u administrator -p ?? /your_domain/your_hub/your_robot/discovery_server get_snmp_devices

The debug option -d"p" can help you to generate this PU command.

Pre-requisite: this tool does require a robot installed locally on the device where you want to run this tool (to be able to login to UIM)

 

 

Statistics
0 Favorited
44 Views
1 Files
0 Shares
6 Downloads
Attachment(s)
zip file
nimsoft_delete_device_v3.3.zip   18.83 MB   1 version
Uploaded - May 29, 2019

Tags and Keywords

Comments

Jun 26, 2018 05:05 AM

Currently this is the working link to documentation: Delete Devices in USM

Oct 13, 2017 09:28 AM

You can run the tool on any machine that has an UIM robot installed + nimsoft_generic.dat/pm

If you run: nimsoft_delete_device.exe/pl -h"your_devname" -d"p"

you will receive a PU command generated for the discovery_server callback..

If you replace the callback: remove_master_device_by_cskey + id by the callback: get_discovery_status, you can test if your connection to UIM works fine with the userid and password combination

Common problems are that the uim domain/hub/robot is not in the correct case or that the password is not encrypted via nimsoft_crypt.exe (both in nimsoft_generic.dat)

Oct 13, 2017 02:44 AM

I am trying to run it in my server but I get SSL Security error(SQL-08001). Any idea why this happened?

I'm pretty sure the information in nimsoft_generic.dat is correct because I can run it in my desktop up until I get 'Could not login to nimbus with username administrator!'. By the way is it only supposed to run in the UIM server?

Sep 18, 2017 09:47 AM

OK I will try to re-enter the user name and password again to make sure its accurate. If still not working I will email you for assistance. I have tried using the UIM administrator account and my own account with no luck already.

Sep 18, 2017 09:40 AM

Hi, like you can see at docops: "Delete Devices in USM - CA Unified Infrastructure Management - 8.5.1 - CA Technologies Documentation", the delete is not the same, qos data is not deleted, only the reference to the data is removed.

Sep 18, 2017 09:29 AM

Whether UIM version 8.5.1 have this feature of deleting all entries from DB too?

Sep 18, 2017 09:21 AM

Thank you for the reply. The user name and password were entered correctly and I got the password from the nimsoft crypt tool's output as outlined in the doc.

 

I have a question - does deleting servers from USM inventory screen and checking the 3 options (Delete Measurements, Ack Alarms, and Prevent Rediscovery) do the same thing as the nimsoft delete tool? If it doesnt delete all the qos data and various other leftover stuff I will email you to get this tool working.

 

Thanks again

Sep 16, 2017 01:45 AM

During simulation mode the tool doesn't need a login to UIM, only to SQL.

This means probably that the combiniation of uim_user and uim_password is:

- invalid

- password perhaps not encrypted with the nimsoft_crypt tool like described in the doc file

- you have a user/password combination for another environment (test/prod?)

Else send me an email (luc.christiaens@ca.com) and I can provide you with a version that creates the manual PU command to execute the callback.

Sep 15, 2017 01:42 PM

I am trying to get this utility working in our environment. In simulation mode it runs all the way through and bypasses all deletes which seems correct. When setting sim to no it stops at step 2 and says "Could not login to nimbus with username" then terminates. I have verified all the entires in the nimsoft_generic.dat file are correct. Any suggestions will be very helpful...

Jul 26, 2017 03:42 AM

We did talk offline, and the reason was that the tool was pointing to a test UIM installation.

May 16, 2017 03:10 AM

Ok, thanks, but how can I troubleshoot why the device is not found? I know it exists in cm_computer_system but still the script can't find it and stops.

May 16, 2017 02:39 AM

Thanks for the remark, this is clearly an error in my "print "statements.

The SQL queries are correctly using cm_computer_system but in the print statementsonly  I'm using in error cm_computer_table.

I made the correction in teh source so that the next version will include this. Thanks, Luc

May 16, 2017 02:07 AM

Hi,

I'm trying to run the script on Windows, UIM 8.5.1, but getting error:

 

nimsoft_delete_device -s"n" -h"dummyapp1"

 

 

the output I get indicates the device can't be found in cm_computer_table:

 

 

step 1: We added device string: dummyapp1
step 2: We found 0 matching devices in cm_computer_table (matching: ) (csids: )
step 2: Like no match was found in cm_computer_table we stop here

 

Obviously nimsoft_generic.dat is correct and the script is able to connect to the db but looking for cm_computer_table? Is there a cm_computer_table table? The device exists in cm_computer_system...

Mar 14, 2017 05:04 AM

Indeed, version 8.51 has removed the logic/requirement of a "model device" in MCS.

I'm testing the new version of the tool and will post it asap.

In the meantime you can use -m"n" to bypass this problem.

Note: like Yu mentioned, there is now in 8.51 a standard option under USM to remove a device (that works very good)

Mar 13, 2017 08:00 PM

Hello.

You are now able to remove devices through USM in UIM 8.5.1.

This is new feature in UIM 8.5.1.

Please have a minute to take a look at the below doc.

Remove Devices in USM - CA Unified Infrastructure Management - 8.5.1 - CA Technologies Documentation 

 

Regards,

Yu

Mar 13, 2017 05:08 PM

Hi Luc ~ Wondering if you can remark on any utility use against 8.5.1 GA. Upon execution against upgraded 8.5.1 GA environment received error shown below and appears that with 8.5.1 column [model_device] was removed from [SSRV2DeviceGroup] table. Adding -m"n" moves past the error but wondering if you have any other knowledge related to this table change.

 

Error output:

nimsoft_delete_device_v2.3\nimsoft_delete_device.exe -h "removednode" -q"y" -l"y" -I"n" -v"y" -s"n"
Unknown option: I
Unknown option: n
step 1: We added device string: removednode
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'model_device'. (SQL-42S22) [state was 42S22 now 42000]
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared. (SQL-42000)at script/nimsoft_delete_device.pl line 195.
SQL Error: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'model_device'.(SQL-42S22) [state was 42S22 now 42000]
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared. (SQL-42000)

Sep 23, 2016 05:23 AM

Hi Marek,

You can perhaps start a new discussion with your question?

I never reviewed these tables for possible relationships and for possible deletes in these entries.

Regards, Luc

Sep 23, 2016 04:39 AM

Luc,

thank you for very useful document and script, but I'm facing little bit different issue - due to wrong setup, ntperf probe created tens of thousands metrics instead of few metrics with thousands pieces of data. So my tables s_qos_data, cm_configuration_item and cm_configuration_item_metric contain huge number of rows with useless data. If I've read well your script will delete data from s_qos_data and *_qos_data_* tables according to table_id. Is there a way to delete data from cm_configuration_item and cm_configuration_item_metric? I don't know if there are some other relations ...

Kind regards,

Marek

Sep 01, 2016 03:35 AM

Perhaps that you need to change:

#!/usr/bin/perl

into:
#!/opt/nimbus/bin/perl

(I have also $PERL5LIB set to point to my perl env)

BUT: this Perl was written to access an UIM manager on Windows environment, I don't know if it will work if your UIM manager/DB is on Linux.

Aug 31, 2016 11:11 AM

Trying to run the command, but getting an error stating I'm missing something:

 

[root@nimsoft-prod-noc01 tools]# perl nimsoft_delete_device.pl -h"nos-hub01"
perl: symbol lookup error: ./auto/Nimbus/API/API.so: undefined symbol: Perl_xs_apiversion_bootcheck

Aug 10, 2016 03:14 AM

It's normal that during simulation this error rc=2 is not appearing because we don't create the callback to the discovery server.

I reproduced the second problem "not staying in domain", and will correct it.

Can you send me a direct email (luc.christiaens@ca.com) so I can post you a special version of the tool that will display more info.

Aug 09, 2016 04:30 PM

Confirmed nimsoft_generic.dat entries are accurate. Have attempted lower and upper case with no change. discovery_server is operational and deployed into the primary robot. When executed with simulation the script moves past step 2 where without simulation mode fails with the "rc=2 err". While executing with simulation mode observed the script not remaining with domain_lock. It is discovering another UIM domain on the subnet. This appears to be issue with the script API discovering the other UIM domain broadcast?

Aug 06, 2016 03:20 AM

I assume that all parameters in the nimsoft_generic.dat are correctly modified?

Specially: uim_domain, uim_hub and uim_robot because they are used to construct the address to the main hub to execute the callback. I assume that the discovery_server probe is also running on that server?

Because the error message you receive could indicate that the created address is incorrect.

Aug 05, 2016 04:03 PM

Thank you for confirming perl dependency. Error remains the same when using compiled executable or perl with "rc=2 err=communication". Running directly on primary hub as well.

UIM v8.4 SP1

     discovery_server v8.41 (yes, remove_master_devices_by_cskeys is available as have executed said tasks manually previously)

Aug 05, 2016 03:26 AM

- for Perl it's the same requirement as the UIM Perl requirement: only version 5.14.2 (the Perl source was created with Strawberry Perl 5.14.2 + the SDK Perl copied into these Strawberry libraries)

- what version of UIM are you running? The Perl uses the discovery_server probe callback: remove_master_devices_by_cskeys. Is this callback available in your discovery probe?

Aug 04, 2016 05:23 PM

Thanks! Was those settings but setting did not seem to take but looks better now when invoked as simulation. Can you confirm few additional items?

  • Any specific perl version dependency? When execute the script itself receive error that could not be started due to "perl514.dll" missing. Library content has been copied into lib folder. Currently have Strawberry Perl v5.24.
  • Receive this error when execute the compiled exe.
    • rc=2 err=communication error from nimNamedRequest for remove_master_devices_by_cskeys

Aug 04, 2016 03:41 AM

This depends what you define in the nimsoft_generic.dat file.

1 - if you enter sql_user and sql_password (password in crypted format) we will use SQL auth.

2 - if you use "sql_user=trusted" and use also "sql_password=" we will connect to MSSQL via a trusted connection. (=your logged on userid) (see also doc file page 12)

Aug 03, 2016 02:09 PM

What authentication methods are permitted for this utility to run against SQL servers? Mixed mode, Windows Authentication or is this utility SQL Server authentication only?

Jul 04, 2016 10:04 AM

I tested on 8.1 and 8.31; you need to use the parameter -m"n" so that the tool will not use the MCS/SSR sql tables

Jul 04, 2016 08:29 AM

I am running on 8.1.

Jul 04, 2016 08:10 AM

This version was tested on UIM 8.4

Probably this will work on other 8.x versions if you add the option: -m"n" to exclude MCS/SSR records that are new in 8.4.

( I will try to start a 8.31 image to test this out. What version are you running?)

Jul 04, 2016 08:05 AM

Luc -Whether it supports all versions of UIM.

Related Entries and Links

No Related Resource entered.