Argument 1 = A number (0, 1, 2, 3) that will be used as the exit code the script will exit with (this is how Nagios determines the status)

Similar documents
Article Number: 722 Rating: Unrated Last Updated: Thu, Jul 20, 2017 at 12:31 AM

Article Number: 513 Rating: 5/5 from 1 votes Last Updated: Tue, Jul 19, 2016 at 10:09 PM

It is important to remember that an external worker needs all of the plugins installed on it so it can execute the checks that are handed to it.

This is sometimes necessary to free up disk space on a volume that cannot have extra disk space easily added.

OK: {C: 68% free / 99.51GB total} 'C: free'= g; ; ;0; 'C: free %'=68%;20;10;0;100

Article Number: 602 Rating: Unrated Last Updated: Tue, Jan 2, 2018 at 5:13 PM

This guide is broken up into several sections and covers different Linux distributions and non- Linux operating systems.

Article Number: 549 Rating: Unrated Last Updated: Tue, May 30, 2017 at 11:02 AM

How To Monitor Apache Cassandra Distributed Databases

PROGRAMATICALLY STARTING AND STOPPING AN SAP XMII UDS EXECUTABLE INSTANCE

Article Number: 38 Rating: Unrated Last Updated: Thu, Apr 28, 2016 at 9:49 PM

There are separate firewall daemons for for IPv4 and IPv6 and hence there are separate commands which are provided below.

How to change the Volume Licensing product key on a computer that is running Windows XP Service Pack 1 and later versions of Windows XP

This document is intended for use by Nagios XI Administrators who wish to monitor JMX applications.

As an A+ Certified Professional, you will want to use the full range of

These instructions cover how to install and use pre-compiled binaries to monitor AIX 5.3 using NRPE.

Interface Software for Alternator Control ICs

Manual Internet Explorer 9 Xp Windows 7 32 Bit

Purpose. Target Audience. Prerequisites. What Is An Event Handler? Nagios XI. Introduction to Event Handlers

Manual Internet Explorer 9 Xp 32 Bit Windows 7

Nagios Snmp External Command Error With No Output (return Code 3)

Debugging Runtime Scripts in Operations Manager and Essentials 2007 The third installment in the System Center Forum Scripting Series

COPYRIGHTED MATERIAL. Getting Started with Windows PowerShell. Installing Windows PowerShell

LCC Default Environtment Menu (lccdemenu) Manual

Manual Script Windows Batch If Condition. Syntax >>>CLICK HERE<<<

Linux Command Line Interface. December 27, 2017

Manual Internet Explorer 9 Xp 32 Bit Window 7

Purpose. Target Audience. Solution Overview NCPA. Using NCPA For Passive Checks

Monitoring Simplified.

Command Line Windows 7

Manual Script Windows Batch If Statement. Example >>>CLICK HERE<<<

Writing Perl Programs using Control Structures Worked Examples

@ECHO OFF c: cd \ msiexec /qn /i \\ \apps\SBACSecureBrowser6.3-Win.msi REBOOT=ReallySuppress exit

Dell OpenManage Essentials v1.1 Supporting Dell Client Devices

Backing Up And Restoring Your Nagios XI System

Overview of Windows PowerShell 5.0

Remove Windows Service Manually Command Line Net Start

Qlik Sense Cmdlet for PowerShell. Sokkorn CHEAV

Manual Script Windows Batch If Condition. Statement Example >>>CLICK HERE<<<

This guide will walk you through the steps for installing and using wget on Windows.

RAP as a Service for Dynamics AX

Upgrade EZ-Pay V6 Guide

Dell OpenManage Essentials v2.0 Support for Dell Client Devices

UPDATING YOUR SCS.1 FIRMWARE

McAfee Exploit Prevention Content Release Notes New Windows Signatures

Print Audit 6. Print Audit 6 Documentation Apr :07. Version: Date:

Book IX is designed to help both AutoCAD and AutoCAD LT users

Manual Script Windows Batch For Loop Files In A Directory

When Microsoft releases new updates to firmware and drivers, the firmware and driver pack is updated for all Surface models.

The Risks Associated with (unmanaged) PowerShell. Casting a hidden.net HITRUST Alliance

Adevice driver is a tiny chunk of programming code that

First data FDMS North / Datawire Integration using Cardnet

SETTING UP THE CLUB PC FOR OPTIMUM EASE OF USE

How to set up SQL Source Control The short guide for evaluators

Bash Tutorial. ASL Fall 2017 Week 2

Deploying Adobe Acrobat or Reader using SyAM Management Utilities

Coin Miner Product Countermeasures

Useful Unix Commands Cheat Sheet

Red Hat Ceph Storage 3

Shell programming. Introduction to Operating Systems

Questions & Answers. How Can I Restore the Familiar Explorer File View in Windows 10?

Open a command prompt window and change to the directory containing the file just downloaded. Run this command:

Lession #5: Adding a New Salary Using Batch Uploads

Windows Batch file to Easily Convert MagicLantern.RAW files into CinemaDNG Posted by idealsceneprod - 09 Nov :17

You will be prompted to log in (with your SFU id and password) and then redirected to the correct page:

Manual Internet Explorer 9 Xp 32 Bit Win 7 >>>CLICK HERE<<<

PowerShell-Module Documentation. Release docs

Offloading MySQL to Remote Server

Unix Scripts and Job Scheduling. Overview. Running a Shell Script

Getting Started with the HCA Plugin for Homebridge Updated 12-Nov-17

Manage Multiple SQL Server Installations and Databases with OSQL

Table of Contents. Installing the AD FS Running the PowerShell Script 16. Troubleshooting log in issues 19

Shell Programming (ch 10)

CS Unix Tools. Lecture 3 Making Bash Work For You Fall Hussam Abu-Libdeh based on slides by David Slater. September 13, 2010

Manual Internet Explorer 9 Xp Windows 7 64 Bit

Manual Internet Explorer 9 Xp Windows 7 64 Bit Offline Installer

Monitoring Apache Tomcat Servers With Nagios XI

DOS based Control Center to monitor, start and stop sessions needed for OmniFind Enterprise Edition 9.1, IBM Content Analytics 2.

Lecture 4. Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?

Powershell: Introduction and Practical Uses. Presentation URL:

Shell Programming (Part 2)

Suspicious Object List Exporter and Importer User Guide. Using Suspicious Object List Exporter

Manual Script Windows Batch If Condition. Statement Examples >>>CLICK HERE<<<

UiPath Orchestrator Azure Installation

Release Notes. LabVIEW Application Builder for Windows. Contents

How to Configure Impersonation for OneDrive for Business Data Sources

SHELL SCRIPT BASIC. UNIX Programming 2014 Fall by Euiseong Seo

PostMaster Enterprise v8.xx Setup Guide Windows

Windows Command-Line: The Personal Trainer. Windows 8.1, Windows Server 2012 & Windows Server 2012 R2. William Stanek

Submitting your Work using GIT

FIMS V You will need to know all of the following items before customizing the script and setting up the schedule.

24 DECEMBER 2018 / TECHNICAL How To Exploit PHP Remotely To Bypass Filters & WAF Rules

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Installing Nagios Log Server with VMware Workstation Player

What happens when a user opens a file locked with the SPIAgent File Locking Add-on?

Maintaining Concordance Andy Kass

Windows 7 And Vista Guide To Scripting, Automation, And Command Line Tools By Brian Knittel READ ONLINE

SHELL SCRIPT BASIC. UNIX Programming 2015 Fall by Euiseong Seo

Command Line Interface UNIX & DOS. Command Line Interface. Terminology. General Format. Part 3. You don't need a mouse or icons

4 Working with WSH objects

Transcription:

Nagios XI - Using Scripts / Plugins With NSClient++ Article Number: 58 Rating: Unrated Last Updated: Wed, Jul 19, 017 at 11:59 PM O ve r vie w This KB article explains how to use external scripts / plugins with NSClient++. NSClient++ has a lot of built in functionality however you will likely run into a situation where you need to use a script to provide additional monitoring capabilities. NSClient++ is capable of executing scripts such as: Batch Script =.bat Visual Basic Script =.vbs PowerShell Script =.ps1 This KB article will provide examples for these three types of scripts as each method is slightly different. Re quir e me nt s This KB article uses NSClient++ version 0.4.x (and future versions) which requires the NRPE module to be enabled (scripts are not possible with check_nt). Please ensure NSClient has been configured correctly as per these KB articles: Documentation - Configuring NSClient++ In addition to these settings, execute the follow commands on your windows server (in a command prompt) to ensure the External Scripts module is correctly loaded: cd "\Program Files\NSClient++\" nscp settings --activate-module CheckExternalScripts --add-defaults nscp settings --path "/settings/external scripts" --key "allow arguments" --set true Ba t c h S c r ipt This example demonstrates how to add a batch script to NSClient++. For this example you are going to create a basic script that takes two arguments. Argument 1 = A number (0, 1,, 3) that will be used as the exit code the script will exit with (this is how Nagios determines the status) Argument = A message that the script will display C re at e Bat c h Sc ript @echo off if [%1] == [] echo No exit code was supplied, aborting! & exit /B 3 if [%] == [] echo No dummy message was supplied, aborting! & exit /B 3 echo %~ exit /B %1% Save the file into C:\Program Files\NSClient++\scripts with the name check_dummy.bat Open a command prompt on your Windows machine and execute the following commands: check_dummy.bat "Something is CRITCAL" C:\Program Files\NSClient++\scripts>check_dummy.bat ""

C:\Program Files\NSClient++\scripts> The output from the second command, the number, is how Nagios will determine that this plugin is reporting a CRITICAL state. check_dummy_bat = scripts\\check_dummy.bat $ARG1$ "$ARG$" Te s t Sc ript Fro m Nagio s /usr/local/nagios/libexec/check_nrpe -H your_windows_server_ip_address -c check_dummy_bat -a "" /usr/local/nagios/libexec/check_nrpe -H your_windows_server_ip_address -c check_dummy_bat -a "" The output from the second command, the number, is how Nagios will determine that this plugin is reporting a CRITICAL state. This completes the example of configuring NSClient++ to use a batch script. You will now need to go and create a service in Nagios XI (this falls outside the scope of this KB article). Vis ua l Ba s ic S c r ipt This example demonstrates how to add a visual basic script (vbs) to NSClient++. For this example you are going to create a script that takes two arguments. Argument 1 = A number (0, 1,, 3) that will be used as the exit code the script will exit with (this is how Nagios determines the status) Argument = A message that the script will display C re at e Vis ual Bas ic Sc ript on error resume next If wscript.arguments.count < 1 Then wscript.echo "No exit code was supplied, aborting!" wscript.quit(3) ElseIf Wscript.Arguments.Count < Then wscript.echo "No dummy message was supplied, aborting!"

wscript.quit(3) End If wscript.echo wscript.arguments.item(1) wscript.quit(wscript.arguments.item(0)) Save the file into C:\Program Files\NSClient++\scripts with the name check_dummy.vbs Open a command prompt on your Windows machine and execute the following commands: cscript.exe //T:30 //NoLogo check_dummy.vbs "Something is CRITCAL" C:\Program Files\NSClient++\scripts>cscript.exe //T:30 //NoLogo check_dummy.vbs "Something is CRITCAL" C:\Program Files\NSClient++\scripts> The output from the second command, the number, is how Nagios will determine that this plugin is reporting a CRITICAL state. You need to execute the check_dummy.vbs script using cscript.exe as if forces the command to run in a command prompt and all output is passed to the command prompt. //T:30 is a timeout of 30 seconds //NoLogo suppresses the Microsoft banner from being displayed check_dummy_vbs = cscript.exe //T:30 //NoLogo scripts\\check_dummy.vbs $ARG1$ "$ARG$" Te s t Sc ript Fro m Nagio s /usr/local/nagios/libexec/check_nrpe -H your_windows_server_ip_address -c check_dummy_vbs -a "" /usr/local/nagios/libexec/check_nrpe -H your_windows_server_ip_address -c check_dummy_vbs -a ""

The output from the second command, the number, is how Nagios will determine that this plugin is reporting a CRITICAL state. This completes the example of configuring NSClient++ to use a visual basic script. You will now need to go and create a service in Nagios XI (this falls outside the scope of this KB article). Po we r S he ll S c r ipt This example demonstrates how to add a PowerShell script to NSClient++. For this example you are going to create a basic script that takes two arguments. Argument 1 = A number (0, 1,, 3) that will be used as the exit code the script will exit with (this is how Nagios determines the status) Argument = A message that the script will display C re at e Powe rshe ll Sc ript if ($args.count -lt 1) { write-host "No exit code was supplied, aborting!"; exit 3 } if ($args.count -lt ) { write-host "No dummy message was supplied, aborting!"; exit 3 } write-host $args[1] exit $args[0] Save the file into C:\Program Files\NSClient++\scripts with the name check_dummy.ps1 Open a command prompt as an a d minis tra to r on your Windows machine and execute the following command: powershell.exe Set-ExecutionPolicy Bypass That command configured PowerShell to run scripts and is re q uire d. Now execute the following commands: powershell.exe -File check_dummy.ps1 "" C:\Program Files\NSClient++\scripts>powershell.exe -File check_dummy.ps1 "" C:\Program Files\NSClient++\scripts> The output from the second command, the number, is how Nagios will determine that this plugin is reporting a CRITICAL state. check_dummy_ps1 = cmd /c echo scripts\\check_dummy.ps1 $ARG1$ "$ARG$"; exit($lastexitcode) powershell.exe -command -

check_dummy_ps1 = cmd /c echo scripts\\check_dummy.ps1 $ARG1$ "$ARG$"; exit($lastexitcode) powershell.exe -command - Te s t Powe rshe ll Sc ript Fro m Nagio s /usr/local/nagios/libexec/check_nrpe -H your_windows_server_ip_address -c check_dummy_ps1 -a "" /usr/local/nagios/libexec/check_nrpe -H your_windows_server_ip_address -c check_dummy_ps1 -a "" The output from the second command, the number, is how Nagios will determine that this plugin is reporting a CRITICAL state. This completes the example of configuring NSClient++ to use a PowerShell script. You will now need to go and create a service in Nagios XI (this falls outside the scope of this KB article). Fina l Tho ught s For any support related questions please visit the Nagios Support Forums at: http://support.nagios.com/forum/ Posted by: tle a - Wed, Jul 7, 016 at 11:15 PM. This article has been viewed 6998 times. Online URL: https://support.nagios.com/kb/article/nagios-xi-using-scripts-plugins-with-nsclient-58.html