Documentation forServer & Application Monitor
Monitoring your applications and environment is a key capability of Hybrid Cloud Observability and is also available in a standalone module, Server & Application Monitor (SAM). Hybrid Cloud Observability and SAM are built on the self-hosted SolarWinds Platform.

Nagios scripting in SAM component monitors

The Nagios Script Monitor in SAM supports custom Nagios scripting on Linux-based systems. You can create multiple instances of this component monitor per template to run custom Nagios scripts. This section describes how to use Nagios scripts with SAM, including script arguments and output formats. To learn about the Nagios programming language, see the Nagios website (© 2019, Nagios Enterprises, LLC, available at https://www.nagios.org, obtained on June 25, 2019).

This SAM feature does not currently support polling via SolarWinds Platform Remote Collectors.

Want to see how other SolarWinds customers use script monitors? See SAM Discussions in THWACK.

Nagios support in SAM

SAM supports using Nagios scripting with Nagios installed and configured on target servers, as well as Nagios plugins and compiled binary Executable and Linkable Format (ELF) files for Linux-based computers.

For a list of templates that support Nagios scripts and use the Nagios Script Monitor, navigate to the Manage Templates page.

  1. Click Settings > All Settings > SAM Settings.
  2. Under Application Monitor Templates, click Manage Templates.
  3. In the search field, enter Nagios to filter the list.

Credentials

To process scripts, include credentials with permission to run scripts on Linux target systems.

Nagios polled by SolarWinds Platform agent for Linux

To use this component monitor with Nagios, as polled by the SolarWinds Platform agent for Linux, enter a script as follows. For the script argument, use python $(SCRIPT).

from random import randint
STAT_PAIRS_COUNT = 10
 
for stat_id in range(STAT_PAIRS_COUNT):
	print 'Statistic.random%d: %d\nMessage.random%d: %s' % (stat_id, randint(1,100), stat_id, 'random number: ' + str(randint(1,100)))

How the Nagios script works

The Nagios Script Monitor executes the script remotely using the target server you provide then reports the metrics:

  1. Connects to the target server using SSH.
  2. Executes the script using the command line value.

    The script executes on the target system, not the SolarWinds Platform server. You may need to enter additional parameters to satisfy the hostname and credentials needed to execute.

  3. Captures metrics and returns the data to the monitor.
  4. Closes the SSH connection.
  5. SAM parses the text output, saves data, and reports the values using the output formats from the component monitor.

Elements of a Nagios script

SolarWinds recommends writing scripts in the Nagios Script Monitor to verify access between the Main Polling Engine (usually the SolarWinds Platform server) and target server(s). You can write and test scripts in your preferred ISE, connecting and testing against the target server to verify if the code functions. You must test the script through the Nagios Script Monitor to ensure entered credentials and target server access, and to generate metrics output.

The script in the monitor should include:

  • Nagios parameters to run the script in the Command Line field.
  • Nagios script code added in the Script Body field with credentials.
  • Exit codes to report status in the script.
  • Formatted output after running the script.

Test the component monitor and script before using it in a template and assigning the template to nodes. Check database tables for metric output, along with any output processes.

Script Working Directory field

Enter the working directory where the script will run on the target system. A popular directory is /tmp.

If using an ELF script, leave this field blank.

Script Body field

Enter your Nagios script code. You can write and compile the script in your preferred language (such as Perl or Python), and then copy and paste the code into this field. Depending on the language, you may need to take additional steps for the script and command line to execute.

If you used compiled Nagios plugins, leave this field empty.

For an ELF script, enter a character in the field. It will not be used when executed.

Scripts must report their status by exiting with the appropriate exit code. The exit code is used to report the status of the monitor, as displayed in the SolarWinds Platform Web Console. See Report status through exit codes in SAM script monitors.

Command Line field

Enter your Nagios parameters used to run the script.

The data you enter may also require additional information depending on the code compiler:

  • For Perl and Python, enter the command line required to run the script including all parameters. Start the command with perl for Perl and bash for Python.
  • For an ELF file, enter the full path to the script and all parameters.

Use Nagios Plugins and ELF files

SAM supports using compiled Nagios Plugins from the Nagios site and ELF files on Linux-based computers.

For Nagios Plugins:

  • Install plugins on the target system. SAM does not transfer the plugins to the server.
  • When configuring the Nagios Script Monitor, leave the Script Body field empty.
  • For the Command Line field, enter a path location on the remote file system for the plugin location and any required parameters.
  • Nagios plugins typically require the hostname. You may need to enter a parameter -H with the hostname. You can assign and use a variable to provide the hostname by using ${IP} or %{Node.DNS} in the script.

For ELF files:

  • Transfer the script to the target system.
  • Leave the Script Working Directory blank.
  • Enter any character in the Script Body. The field cannot be empty but is not used when executing the script.
  • For the Command Line field, enter the full path to the script located on the target system and all Nagios parameters.