Monday, August 18, 2014

PATROL Agent 9.5 - Part 7: How to configure a PATROL recovery action to run as a different user?

The information included in this post applies to all versions of PATROL agent, not just version 9.5. 

By default, if you configure a PATROL recovery action to run when a parameter is in ALARM or WARNING state, the recovery action script will be executed by PATROL default account.  What if you want to execute some commands within the recovery action script as a different account?  For example, what if you want to start SQL*Net listener within your recovery action as account 'oracle' instead of 'patrol'?

There is a PSL built-in function called execute.  Its format looks like this:

execute(type, text, [instance], [username], [password]);

For example, you can add the following PSL statement in your recovery action to start the SQL*Net listener automatically when the SQL*Net listener status parameter is in ALARM state:

execute("OS", "lsnrctl start", "", "oracle", "password");

where "password" can be either a clear text or an encrypted password.

To protect the password, you can encrypt it offline.  Then save the encrypted password in a pconfig variable.  Prior to call execute() command, you simply use command get ([variable_name]) to read the password out.

For example, if you have saved your oracle encrypted password in a pconfig variable called "/ORACLE/Encrypted_Password", you can include the following commands in your recovery action PSL script to automatically start SQL*Net when it is down.

pass = get("/ORACLE/Encrypted_Password");
execute("OS", "lsnrctl start", "", "oracle", pass); 

The reason you can use get("/ORACLE/Encrypted_Password") instead pconfig(GET,  "/ORACLE/Encrypted_Password") is because all pconfig variables are loaded into agent name space during PATROL agent start-up.

No comments:

Post a Comment