Deleting alerts from the command line

Tools and several solutions to manage Control-M products
User avatar
Deano
Nouveau
Nouveau
Posts: 42
Joined: 03 Jul 2006 12:00
Location: London´

Deleting alerts from the command line

Post by Deano » 28 Aug 2009 10:58

Hi Guys,

Rather than use the CCM, Tools, Remove Old Alerts

I would like to know what underlying script is ececuted by this option, so that I can set-up a job to perform this task regularly.

I'm guessing that once the alerts have been deleted, GAS will still need to be bounced/refreshed?!?

Any ideas?

thanks
Deano

User avatar
Walty
Nouveau
Nouveau
Posts: 473
Joined: 20 Jan 2006 12:00

Post by Walty » 28 Aug 2009 11:41

Hi,

the <erase_alerts> EM utility invoked in command line will erase Alerts, regardless of their current Status, up until the ending date and hour as specified

Erase Alerts Usage
This utility deletes all alerts posted prior to the specific hour and date from the CONTROLM/EM database.

Use one of the two options:
1. erase_alerts -U <user> -P <password> [-D <date> ] [-H <hour> ] [-F]
where
date : YYYYMMDD or YYMMDD format
hour : 0 - 23
Note: If date or hour are missing, then the current date/hour will be used.
-F: Forces the deletion without confirmation.
2. erase_alerts -I
A prompts is displayed requesting the date, hour and password.

You can schedule a job to execute this:

- Step 1 Erase old alerts
erase_alerts -U <user> -P <password> [-D <date> ] [-H <hour> ] [-F]

- Step 2 Refresh the GAS
ecs ctl -U emuser -P <Password> -C GAS -all -cmdstr "REFRESH"

- Step 3 Check the GAS
ecs ctl -U emuser -P <Password> -C GAS -all -cmd life_check
Best regards
Walty

User avatar
Walty
Nouveau
Nouveau
Posts: 473
Joined: 20 Jan 2006 12:00

Post by Walty » 28 Aug 2009 12:15

Hi,

You can also see the <ccmcli> utility to perform basic administrative tasks on CONTROL-M/EM components.
For more information, refer to the CONTROL-M/Enterprise Manager Utility Guide.
Best regards
Walty

User avatar
Deano
Nouveau
Nouveau
Posts: 42
Joined: 03 Jul 2006 12:00
Location: London´

Post by Deano » 28 Aug 2009 1:38

Thanks Walty,

We are running 6.4.01 and I cannot find that file (erase_alerts)!

Do you know where it is?

thanks
Deano

User avatar
Walty
Nouveau
Nouveau
Posts: 473
Joined: 20 Jan 2006 12:00

Post by Walty » 28 Aug 2009 2:55

Hi,

the <erase_aletrs> utility exist on Unix platform an is located on:

$HOME/scripts directory of <emuser>

Other solution is to execute this delete directly in your Control-M/EM DB by SQL query. The name of this table in Control-M/EM DB is <ALARM>

Don't forget to refresh the GAS after.
Best regards
Walty

User avatar
philmalmaison
Nouveau
Nouveau
Posts: 1148
Joined: 08 Jun 2007 12:00
Location: Ile de France

Post by philmalmaison » 31 Aug 2009 3:48

here is my solution :
erase_alerts -U ${user} -P ${pass} -D ${prior} -F
sleep 5
ecs ctl -U ${user} -P ${pass} -C GAS -M `uname -n` -name `GAS_name` -cmdstr "REFRESH"

in the following script
#!/bin/ksh
user=`cat ~/scripts/.psfile | awk '{print $1}'`
pass=`cat ~/scripts/.psfile | awk '{print $2}'`
prior=${1}
#
usage () {
echo
echo "usage : `basename $0` <date>"
echo "date = delete alerts prior to the date"
echo
exit 999
}
#
GAS_name () {
SQL -U${user} -P${pass} -b <<EOF>> ${gasname}
}

verif_config () {
orbix_state=`orbadmin ns status | awk '{print $4}'`
case "${orbix_state}" in
"Running")
echo "Noeud actif poursuite du traitement ..."
continue
;;
*)
echo "Noeud passif arret du traitement"
exit 0
;;
esac
}

#
# Main
#
if [ $# -ne 1 ]
then
usage ;
fi

verif_config;

erase_alerts -U ${user} -P ${pass} -D ${prior} -F
sleep 5
ecs ctl -U ${user} -P ${pass} -C GAS -M `uname -n` -name `GAS_name` -cmdstr "REFRESH"



regards
philmalmaison

User avatar
YOWAL
Nouveau
Nouveau
Posts: 18
Joined: 07 Jan 2009 12:00
Location: Argentina, Buenos Aires

Post by YOWAL » 02 Sep 2009 9:01

hi

try....

my_erasealerts.sh

erase_alerts -U [user] -P [pass] -D [AAMMDD] -H 00 -F

ecs ctl -U [user] -P [pass] -C GAS -M [server] -cmd stop
sleep 10
ecs gasrv

User avatar
philmalmaison
Nouveau
Nouveau
Posts: 1148
Joined: 08 Jun 2007 12:00
Location: Ile de France

Post by philmalmaison » 03 Sep 2009 4:57

but in your case as you stop/start the GAS, if a shout arrive during stop/start it should be ignore with an error message in xalert CCM.

you must just do a refresh for the GAS ...

regards
philmalmaison

User avatar
YOWAL
Nouveau
Nouveau
Posts: 18
Joined: 07 Jan 2009 12:00
Location: Argentina, Buenos Aires

Post by YOWAL » 03 Sep 2009 6:32

it's running everyday!
Job executed successfully. exiting.

+ sh /ecs63/scripts/Erase_Alerts_.sh 090902
Deleting all alerts prior to 20090902 at 00:00


424 alerts deleted.
Stop command been issued to GAS "suabaecs1" on suabaecs1
See output at /ecs63/log/wrapper_output/ecs.gasrv..090902.120020.std.log

User avatar
philmalmaison
Nouveau
Nouveau
Posts: 1148
Joined: 08 Jun 2007 12:00
Location: Ile de France

Post by philmalmaison » 04 Sep 2009 11:19

i didn't said anythink it works but you can miss some alerts during the GAS is stop, a REFRESH is taking care about it

regards
philmalmaison

User avatar
Deano
Nouveau
Nouveau
Posts: 42
Joined: 03 Jul 2006 12:00
Location: London´

Post by Deano » 11 Sep 2009 12:00

Thanks for the replies.

I am however running in a windows environment.

Is there an equivilent script?

User avatar
philmalmaison
Nouveau
Nouveau
Posts: 1148
Joined: 08 Jun 2007 12:00
Location: Ile de France

Post by philmalmaison » 11 Sep 2009 3:16

you can do the same using CCM in Windows

regards
philmalmaison

User avatar
Deano
Nouveau
Nouveau
Posts: 42
Joined: 03 Jul 2006 12:00
Location: London´

Post by Deano » 11 Sep 2009 3:25

erase_alerts.sh does not exist in windows (that I can find) !!

User avatar
Walty
Nouveau
Nouveau
Posts: 473
Joined: 20 Jan 2006 12:00

Post by Walty » 14 Sep 2009 8:14

Hi,

This script does not exist in Windows.
In the Windows environment i implemented one script like this (it works directly with the ALARM table in Control-M/EM db)

SET ServerInst=<MSSQL instance>
SET User=<emuser>
SET Pswd=<password>
SET MyServer=<your serveur>
SET MyDate=%1 (pass by AUTOEDIT variables)

ECHO Number of Alerts before delete
ECHO -------------------------------------
OSQL -U %User% -P %Pswd% -S %ServerInst% -h-1 -Q "select count(*) from ALARM"
ECHO .
ECHO Delete Alerts before date %1
ECHO ---------------------------------------------
OSQL -U %User% -P %Pswd% -S %ServerInst% -h-1 -Q " delete from ALARM where HOST_TIME < convert(datetime,'%MyDate%')"
ECHO .
ECHO Number of Alerts after delete
ECHO ----------------------------------
OSQL -U %User% -P %Pswd% -S %ServerInst% -h-1 -Q "select count(*) from ALARM"
ECHO .
ECHO Refresh GAS
ECHO ---------------
ctl -U %User% -P %Pswd% -M %MyServer% -C GAS -cmdstr "refresh"
ECHO .
_sleep 3
ECHO Check GAS
ECHO --------------
ctl -U %User% -P %Pswd% -M %MyServer% -C GAS -cmd life_check


Example of sysout:

Number of Alerts before delete
--------------------------------------
476
(1 row affected)
.
Delete Alerts before date 2009-09-11
-------------------------------------------
(46 rows affected)
.
Number of Alerts after delete
----------------------------------
430
(1 row affected)
.
Refresh GAS
---------------
The command string: "refresh"
have been sent to: GAS on testctlm, the Response is:
true
.
Check GAS
--------------
GAS on testctlm is alive!
Best regards
Walty

User avatar
Deano
Nouveau
Nouveau
Posts: 42
Joined: 03 Jul 2006 12:00
Location: London´

Post by Deano » 14 Sep 2009 11:52

Thanks Walty, That is exactly what I need.

Post Reply