Aspersa User's Manual
The stalk tool
Aspersa Manual › The stalk tool

The stalk tool watches for a condition to become true, and when it does, executes a script. By default it executes the collect tool, but that can be customized. This tool is useful for gathering diagnostic data when an infrequent event occurs, so an expert person can review the data later.

Command-Line Options and Environment Variables

The tool accepts no command-line arguments or environment variables, and can be configured by editing the source code or by creating a file of the same name with an extension of '.conf' that it will source to set variables.

How it Works

Although it comes pre-configured to do a specific thing, in general this tool is just a skeleton script for the following flow of actions:

  1. Loop infinitely, sleeping between iterations.
  2. In each iteration, run some command and get the output.
  3. If the command fails or the output is larger than the threshold, execute the collection script; but do not execute if the destination disk is too full.

By default, the tool is configured to execute mysqladmin extended-status and extract the value of the Threads_connected variable; if this is greater than 100, it runs the collection script. This is really just placeholder code, and almost certainly needs to be customized!

If the tool does execute the collection script, it will wait for a while before checking and executing again. This is to prevent a continuous condition from causing a huge number of executions to fire off.

Example Usage

Perhaps the best way to use this tool is to run it inside of a screen session, so that you can disconnect from the server you're watching and the tool will continue to run.

See this blog post for an example usage scenario.