The SAM Nagios Script monitor 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 information details the format and usage of Nagios scripts for SAM, including script arguments and output formats. This information does not provide information on coding in Nagios. For resources to learn or use the Nagios programming language, see Nagios resources. SAM does support using Nagios plugins.
After configuring Nagios and reviewing the components of a script, create Nagios scripts using the component monitor per template.
SAM supports using Nagios scripting with Nagios installed and configured on target servers.
To locate a list of out-of-the-box Nagios script supporting templates, navigate to the Manage Templates page. Click Settings > All Settings > SAM Settings and click Manage Templates. In the search field, enter Nagios to filter the list. These templates use customized instances of the Nagios Script Monitor.
To process scripts, you must include credentials with permissions to run scripts on the monitored Linux-based computer.
Nagios polled by Orion agent for Linux
If you are using this component monitor with Nagios and polled by Orion agent for Linux, you need to enter a script as follows. The argument would be
python $(SCRIPT) with a body of:
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)))
The Nagios script monitor executes the script remotely using the target server you provide then reports the metrics:
Executes the script using the command line value.
The script executes on the target system, not the Orion server. You may need to enter additional parameters to satisfy the hostname and credentials needed to execute.
SolarWinds recommends writing scripts in the Nagios Script monitor to verify correct access between the main polling engine, SAM, and the target server(s). You can write and test Nagios 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:
You must test the component monitor and script before assigning and using the component monitor within a template as is. Testing the script generates the required database tables for metrics output and verifies output processes.
Script Working Directory field
Enter a working directory where the script processes when executed. This is a directory located on the target system. A popular directory is /tmp.
If using a compiled binary file (ELF) script, leave this field blank.
Script Body field
Use the Script Body field to enter your Nagios script code. You can write and compile the script in a language you prefer then copy and paste the code into this field. For example, customers have used Perl, Python, and compiled binary file (ELF). 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.
If using a compiled binary file (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, displayed in the Orion Web Console.
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:
SAM supports using compiled Nagios Plugins found through the Nagios site and compiled binary files (ELF) used on Linux-based computers.
For Nagios plugins:
For compiled binary files: