Server Management - Systems Insight Manager
1748122 Members
3497 Online
108758 Solutions
New Discussion юеВ

Re: Clean up old servers in SIM

 
Matt Ronsman
Advisor

Clean up old servers in SIM

I am looking for a way to delete old items out of HP SIM that have not been heard from in a while. We will retire servers but unless we go into SIM to delete them they will be there forever. If there was a cleanup job we could run periodically to delete systems out that haven't been heard from in like 90 days that would be ideal. Not sure why there isn't something like that built in? Please let me know if anyone has any ideas on this.

Thanx,
Matt
11 REPLIES 11
Matt Ronsman
Advisor

Re: Clean up old servers in SIM

Awesome! I will give it a try. Thanks so much!!

Thanx,
Matt
fred Passeron
HPE Pro

Re: Clean up old servers in SIM

Hi
Nice Job indeed but I have a few questions :

1/The query you described is an event query : this means that the result is a list of event, therefore if you select those for deletion, you will delete the events not the systems that generated them ? correct ?

I think you made it closely but what is missing is a combination of a system and an event query that HP SIM can do !

So from the UI, one can create a new collection by using the customize button in the collection panel. Then click on new for a new collection and select Choose members from the existing system and event collections. Now Use the all system collection for the system and the newly created event collection Unreachable for the last 90 days. The result should show you a system list that could use later for a delete task.

2/Delete Task:
now the funny part : using simple CLI.

A\ custom command tools creation and scheduling :
on the cms, create a batch to list systems to be deleted and to delete them when done :

autodelete.bat:

echo off
cd C:\HP-SIM-custom\Autodeletion-of-old-systems
REM delete old files
del C:\HP-SIM-custom\Autodeletion-of-old-systems\nodes.txt
REM Create list of systems to be deleted and delete each of them sequentially
mxquery -e "Fred Test" |find "DeviceName" >nodes.txt
for /f "tokens=2" %%f in (nodes.txt) do @mxnode -r %%f -x force


Fred Test is the collection you created in the step 1

adapt path for your environment...

B\Create now a custom tool that will launch this script and schedule through HP SIM periodically.

I need now to do some more testing with a proper collection that includes systems and events.

I 'll tell you tomorrow about it.

regards

Fred
тАЬLife is pleasant. Death is peaceful. It's the transition that's troublesome.тАЭ Isaac Asimov
Matt Ronsman
Advisor

Re: Clean up old servers in SIM

You guys are blowing me away! Thanks so very much for the ideas!! I really appreciate it. Let me know how the testing goes Fred.

Thanx,
Matt
Matt Ronsman
Advisor

Re: Clean up old servers in SIM

Trying this out now and thinking about the query. So lets say a production server was unreachable during a down time over 90 days ago but was started up again an hour later and has since been running fine. If I don't clear out the unreachable event it would register on my query and would then be deleted with the batch file, correct? We are not real good about clearing old events here...

Is there some other identifier like a failed hardware status poll or something that would ensure that this entity has not been around for longer than a certain amount of time? Ideally it would be good to know that the thing I am deleting has been off the map fully for a while. Please let me know your thoughts.

Thanx,
Matt
BPE
Esteemed Contributor

Re: Clean up old servers in SIM

Hello Matt

The system not reachable event is by default automatically cleared by the system reachable event. Those events are generated by the internal system polling code as far as I know. Clear is not Delete !!!

The only concern I have at the moment is that if you have a bug with a new release/update and your task will be executed you could lose some history information.

Do you have special devices which are not originally supported by HP SIM (customer extensions) or special plug-ins which could
influence the HP SIM basic behavior?


As a background information:
- Thanks for triggering the discussion
- I got some inspiration from a scheduled task "Delete Events older than 90 days" which is not enabled by default.
- We have an IP range with important server but also some DHCP devices in the same range which leads to a similar problem if you want to use auto discovery but shorter unreachable time.
- I hoped this will motivate other to join the discussion (thanks to Fred). It seems to work)
- A good simple solutions needs some thinking time
Matt Ronsman
Advisor

Re: Clean up old servers in SIM

bpe,

I guess I was unaware that a System Reachable event actually clears the preceeding Unreachable event. That does help. We do not have any super custom entities in SIM that will not be rediscovered anyway and losing some history on the item is not the worst thing that could happen in the world.

So it is totally a workable solution and I thank you and Fred for the valuable input and help!

Thanx,
Matt
Matt Ronsman
Advisor

Re: Clean up old servers in SIM

Fred,

Did you get a chance to test this out? The problem I am having is with the mxquery -e command in the batch file. It does not see the collection that I created that includes All Systems and the custom Event query. It sees everything else including the custom Event query when I just type mxquery alone. Please let me know if I am doing something wrong.

Thanx,
Matt
fred Passeron
HPE Pro

Re: Clean up old servers in SIM

hi there,

sorry it took so long to answer.
I actually faced the same issue as you did but didn't have time till now to look at it again...
Finally found a solution though :-)

Situation is the following :
1/either you stick to the first event query and you get a list of all devices that have been unreachable for X days then you delete them all...Some admins might use it...

2/you try to work more intelligently...I do sometimes, at least I try :-)
My first solution was a good idea but I mixed collection and queries..that is why it cannot work..
My workaround is the following :(still using some scriptings and the windows based grep command (available here : http://gnuwin32.sourceforge.net/packages/grep.htm)
4 steps:
1/gather the list of systems that are unreachable
2/gather the list of systems to compare against
3/generate the final list of systems to be deleted.
4/delete these systems

in this example I work with servers therefore my second query is using the "All Servers" collection to find the servers to be deleted.
1st script :
echo on
Rem Move to the script directory
cd C:\test-fred\script\
REM delete old files
del C:\test-fred\script\nodes*.txt
REM Create list of systems
mxquery -e "Not Reachable for the last x days" |find "DeviceName" >nodes1.txt
mxquery -e "All Servers" |find "DeviceName" >nodes2.txt
REM Parse them to extract the proper list of system to delete
"c:\Program Files (x86)\GnuWin32\bin\grep.exe" -f nodes2.txt nodes1.txt >nodestodelete.txt
REM Transform lines in columns
for /f "delims=" %%a in ('type "nodestodelete.txt"') do call :commande "%%a"
goto :eof
:commande
set ligne=%1
set ligne=%ligne:"=%
@echo %ligne% >>nodestodelete2.txt

2nd script:

echo off
REM Delete now devices
for /F "tokens=2" %%f in (nodestodelete2.txt) do @mxnode -r %%f -x force


I create a final script to call these two one after the other.This script will then be used in a custom command in HP SIM that will be scheduled as explained higher in this thread.

I am not that good at scripting, that is why I came up with this solution. I am pretty sure sone others can improve it, please do.

So better late than never...
hope it helps !

fred
тАЬLife is pleasant. Death is peaceful. It's the transition that's troublesome.тАЭ Isaac Asimov
Matt Ronsman
Advisor

Re: Clean up old servers in SIM

Thanks for remembering! I really appreciate it. I will give it a shot.

Thanx,
Matt