This page applies to an earlier version of the AppDynamics App IQ Platform.
For the latest documentation, see the 4.5 Documentation.


Skip to end of metadata
Go to start of metadata

 

A remediation action runs a remediation script in a node. The script executes on the machine from which it was invoked or on the node specified by the remediation action configuration. You can use this type of action to automate your runbook procedures. For example, when a specific event occurs such as a JVM crash or a code problem and triggers a policy that calls the script, you could have the remediation script restart the JVM or increase the size of the connection pool on the JVM respectively.

Prerequisites for Local Script Actions

  • The Standalone Machine Agent must be installed running on the host on which the script executes. To see a list of installed machine agents for your application, click View machines with machine-agent installed in the bottom left corner of the remediation script configuration window.
  • To be able to run remediation scripts, the machine agent must be connected to an on-premise Controller or to a SaaS Controller via SSL. Remediation script execution is disabled if the machine agent connects to a SaaS Controller on an unsecured (i.e., non-SSL) HTTP connection.
  • The Machine Agent OS user must have full permissions to the script file and the log files generated by the script and/or its associated child processes.
  • The script must be placed in <agent install directory>\local-scripts.
  • The script must be available on the host on which it executes.
  • Processes spawned from the scripts must be daemon processes

Remediation Scripts

A remediation script is run on the machines that you specify in the remediation script configuration. You can run the script from the machine affected by the violation that triggered the action or from a central management server. It is not necessary for an app agent to be running on the machine on which the script executes, just a Machine Agent.

Guidelines for Remediation Scripts

By default the script is a shell script in /bin/sh invoked with the -ex option, unless the script has a header, in which case the interpreter in the header is used. For example, if the script header is "#!/bin/perl", the PERL interpreter is invoked.

A process exit code of zero indicates that the script execution succeeded. A non-zero exit code indicates that it failed.

The script should be written as generically as possible to allow it run on any of the nodes for which is it invoked. AppDynamics exports the following environment variables to the script runtime to provide context regarding the environment and the event that triggered the action.

Environment Variable

Cardinality (1 or N)

Notes

APP_ID

1

Name of the Application

EVENT_TIME

1

Timestamp of the event

EVENT_ID

1

Event Id

EVENT_TYPE

1

type of event, such as: ERROR, APPLICATION_ERROR, APPLICATION_INFO, STALL, BT_SLA_VIOLATION, DEADLOCK, MEMORY_LEAK, MEMORY_LEAK_DIAGNOSTICS, LOW_HEAP_MEMORY, ALERT, CUSTOM, APP_SERVER_RESTART, BT_SLOW, SYSTEM_LOG, INFO_INSTRUMENTATION_VISIBILITY, AGENT_EVENT, INFO_BT_SNAPSHOT, AGENT_STATUS, SERIES_SLOW, SERIES_ERROR, ACTIVITY_TRACE, OBJECT_CONTENT_SUMMARY, DIAGNOSTIC_SESSION, HIGH_END_TO_END_LATENCY, APPLICATION_CONFIG_CHANGE, APPLICATION_DEPLOYMENT, AGENT_DIAGNOSTICS, MEMORY, LICENSE

ENV_STARTUP_ARGS

1

Process args

ENV_SYSTEM_PROPERTIES

1

JVM System Props (When Java)

AFFECTED_ENTITY

1

Affected Entity that triggered the event

 

Remediation scripts must be stored in a sub-directory of the machine agent installation. The sub-directory must be named "local-scripts". The following paths are all valid:
 

${machine.agent.home}/local-scripts/runMe.sh
${machine.agent.home}/local-scripts/johns_scripts/runMe.sh
${machine.agent.home}/local-scripts/ops/johns_scripts/runMe.sh

Troubleshooting Remediation Scripts

To troubleshoot your remediation script, look for the process in the machine agent log. The log is located at

<machine_agent_home>/logs/machine-agent.log

The snippet below from the machine agent log shows both error and success messages from running a local script named "script.sh".