08-23-2010 03:48 AM
08-25-2010 01:19 AM
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.
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 :
REM delete old files
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.
08-25-2010 10:58 AM
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.
08-25-2010 11:56 AM
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
08-25-2010 12:02 PM
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!
08-26-2010 11:42 AM
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.
10-25-2010 06:32 AM
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)
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 :
Rem Move to the script directory
REM delete old files
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"
@echo %ligne% >>nodestodelete2.txt
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 !
10-26-2011 09:16 AM
Just like to bump this up. I like the idea of using the fact that system reachable will clear the previous system is unreachable but i have found this to be unreliable with system unreachable not neccessarily followed by a system reachable. I wonder is there any clever query we could run against the DB?