Nagios Scripts in Solarwinds: The Best of Both Worlds

Whether you’re migrating from a Nagios-based platform to Solarwinds, or looking to expand existing Linux monitoring, the Nagios Script component of Solarwinds’ SAM module will easily make your month! It’s easy to overlook in the multitudes of checks but we’ve created a short tour for you – just a taste of its flexibility.

Imagine being able to simply paste your Nagios scripts into Solarwinds, assign it to nodes, and watch the perfdata roll in! It’s that easy.

In this high-level introduction, the we will introduce you to the Solarwinds’ Nagios Script plugin by implementing one of the excellent built-in checks on a Linux host.

Before You Begin

Don’t dive into the SAM component configuration just yet! There are a couple important tasks you need to complete first…

  1. You won’t get far adding components to SAM without valid credentials, so it’s a good idea to get those in place first. Head over to the SAM settings page and add any credentials needed to run Nagios Perl scripts on your hosts. 
    All Settings\SAM Settings\Credentials Library\Add New Credential

  2. Once the credentials are in place, head back over to Node Management and ensure the hosts to which you want to apply the Nagios checks are added to Solarwinds. It won’t matter how they’re polled, whether ping-only, SNMP, or the Solarwinds Linux Agent.

Once you’ve got your hosts and your credentials locked-in, you’re ready for your SAM Components! Head on over to the Application Monitor Templates editor, and we’ll get started. You’ll find it at:

All Settings\SAM Settings\Manage Templates

A Note On Using Your Own Script

In this demo, we’re duplicating and then deploying a built-in Nagios Perl Script. Once you’re comfortable with the configuration and have everything working, you’ll want to create  a *new* Solarwinds Nagios Template for your other Nagios scripts. The steps are just as we’ve described here, except you’ll ‘Create’ rather than ‘Copy,’ and you’ll be pasting in your own script body and command Line. 

Create a New Copy of the Application Monitor Template

From the list on the left, choose “Linux,” then find Nagios Linux File & Directory Count Script in the list on the right. Tick the box for that row to select it, then click Copy. Solarwinds doesn’t automatically open the new template, so you’ll have to scroll up to find it (Hint: it’s the same name, but with “Copy of” prepended), select it, and then click Edit.


  1. Be sure not to skip the essentials – before you configure the Component itself, be sure to name the template and give it a useful description! You can also optionally add tags and a custom view here. Lastly for the top section, be sure to set a reasonable polling frequency. For this check, we’ll leave the default period of 300 seconds in place.

2. Next, Click the + beside the Component Monitor (File & Directory Count Monitor) to expand it. Customize as appropriate.

3. In our example, we’ll choose Username and Password for our Authentication Type, and we assume you’ve added these as SAM credentials, as discussed earlier. From the Credential For Monitoring dropdown box, select the name of the credential you added for this check. You can also set this option to <None> and specify the credentials when you apply the Template to your Nodes. Note: If you’re using a private key, you’ll need to install a SAM certificate, instead.

4. We’re using the standard port, we’ll use /var/tmp as our working directory, and we’ll leave the option for Check type as Host. Ensure Count statistic as difference is unchecked, as this Nagios script will return whole data, rather than incremental.

5. You’ll notice the Command Line and Script Body have already been filled in for you, thanks to the built-in template component. However, you’ll need to replace /etc in the Command Line with the directory you want the script to count. We’re counting /opt/SolarWinds, which is where the Linux Agent lives. The -sub option used here tells the script to also count subdirectories. Take a look at the code, and for some further digging, examine how the script is actually returning three metrics as one result. 

Note: Be wary of permissions. If the user executing the script doesn’t have the ability to see files, they won’t be counted, and you may get unexpected results. In our demo, the user chosen does not have rights to some items, and we’ve demonstrated what that looks like towards the very end.

6. Below the Script Body, you’ll find three sections already in place for the script outputs, each with a namethresholds, and a conversion option. For now, we’ll leave the defaults in place for all three, as the Template has them named already, and the default null values for Warning and Critical thresholds will keep your monitoring environment peaceful while you experiment further. Eventually, as you add your own more-powerful scripts, you’ll want to set these thresholds for each output accordingly.

7. Make sure you Save & Continue Working – next, we’ll test the new component against one of your servers!

Testing & Deployment

It’s always good to test a new monitor template before applying it to nodes. Pick an appropriate linux host, and from the menu at the top of the Components section, first tick the checkbox beside the File & Directory Count Monitor component to select it, then click Set Test Node and select the host you picked – then press Test.

If the script is successful, you’ll see both a success message and the actual output of the script Solarwinds just ran on the host for you. If not, you’ll also be given the script output, if any – and a debug message identifying the underlying problem.

Once you’ve got a successful test, it’s time to Submit at the bottom of the page! You’ll be returned to the Management page for Application Monitor Templates, so find your new template name in the list, select it, and click Assign to Node.

You’ll be taken to the standard available/selected option page. Once you’ve added the nodes, click Next.

We’ll choose to Inherit credentials from template, since our template specifies the SAM credentials directly. It’s also a good idea to do one or more tests here, to ensure your settings are correct. Note the permissions denials, though the script still completes successfully! Here, the script is only counting files the user can actually see.

When you’re ready to finalize your settings and apply the Template to the nodes, click Assign Application Monitors to complete. Solarwinds will do a bunch of background work, and you should start seeing data roll in from the hosts very soon!

Solarwinds can now chart and report on the Nagios script perfdata with its powerful graphing engine!

Additional Resources

Shopping Cart