Sysedge Actions Restart Service Restart Process

Document ID : KB000028447
Last Modified Date : 14/02/2018
Show Technical Document Details

 

What is a Sysedge Watcher Action, and How does it work?

A systemEDGE action is introducing programmability for ANY trap that occurs.

The first important thing is actions are not allowed because of the default sysedge.cf (and Virtual Assurance Policy parameter under configuration section) no actions or sysedge.cf no_actions. For actions to work this MUST be removed.

What ANY trap means is IF you specify an action or program with a watcher. And a trap occurs ANY state change trap NOT READY, UP, DOWN, etc… That action gets run.

The most common use An action for a process watcher when that process (or Service) goes down you want to restart the failed process.

SystemEDGE contains 2 default ways to do this but you can make your own customization to do this as well.

 

  restartproc.exe/restartsvc.exe (Windows)

  restartproc.sh (UNIX/Linux)

 

When executing the files from <installdir>/systemedge/bin

A sample watcher for windows would be,

watch process procAlive 'testapp|TESTAPP' 1000 0x0 30 'testapp restart' 'C:\sysedge\bin\restartproc.exe c:\testapp.exe'

Above stated this restartproc.exe is going to execute though for each state change trap sent. So how do you program your shell script or batch file to only restart a process when its down?

This can be done by evaluating the parameters passed to the custom script/executable created,

When the action is run the sysedge process passes values,

arg  1 = Program binary to restart

arg  2 = Empire trap type

arg  3 = Process monitoring entry index

arg  4 = Process monitoring entry description

arg  5 = Process monitoring entry attribute

arg  6 = Process monitoring entry operator

arg  7 = Process monitoring entry current value

arg  8 = Process monitoring entry threshold value

arg  9 = Process monitoring entry flags

arg 10 = Process monitoring entry regular expression

arg 11 = Process monitoring entry current process id

So when Sysedge runs your file the run parameter looks like,

 

 c:\sysedge\bin\restartproc.exe c:\testapp.exe 10 1000 "testapp restart" 1 3 6 4 0x0 "testapp|TESTAPP" 3024

 

So by evaluating %2% or $2 (argument 2) you can run this at only specific state change trap types like 10 DOWN.

·         Caveat if you add additional parameters into the run line,

Like 'C:\sysedge\bin\restartproc.exe c:\testapp.exe restart'

This will shift all passed arguments / args because restart is now arg1 %1% so the trap type will now be arg3 instead of arg2.

Trap types,

 The trap type can be seen from the octet under the mib trap table,

1.3.6.1.4.1.546.9

When the action is executed the sysedge data directory containing the sysedge.log should contain an entry like,

 (): Executing action command: '/opt/CA/SystemEDGE/bin/restartproc.sh /etc/init.d/crond 10 15 cron process 1 4 6 4 0x0 cron 27877 Process //./crond Alive 6'

Any of the above execution items can be evaluated by evaluating the correct arg in your script/bat.

With conditional logic such as, (Below Sample *nix SH Shell script)

 if [ "$2" -eq 10 ]; then

    echo Restarting $1  >> /tmp/procstart.log

    $1

fi

 

 Or if you wanted to do an action only when the process comes up like log a

message to syslog etc... Evaluate on 11 the UP TRAP String.

if [ "$2" -eq 11 ]

Do my action here

fi