You are on page 1of 5

Nagios XI Checking Program Loadtime With

autoIT in Nagios XI

The Industry
Standard in IT Infrastructure Monitoring

Purpose
This document describes how to time program start times in Windows with autoIT.

Target Audience
This document is intended for use by Nagios XI Administrators who want to monitor how long Windows takes to fully start a program or
application. A basic knowledge of autoIT is recommended.

Prerequisites
It is required that you have AutoIT installed, as well as it's script editor. A guide this can be found at:
http://assets.nagios.com/downloads/nagiosxi/docs/Integrating_autoIT_With_Nagios.pdf
You must also have NSClient++ installed on the Windows machine you intend to use for this task. Information on NSClient++ can be
found at:

http://www.nsclient.org/nscp/wiki/Documentation

Editing the Script


Once the applications have been installed on the Windows system open SciTE Editor and paste in the following script:
http://pastebin.com/8GANh1dR

This script bahaves much like the autoIT timer script, as can be seen
a timer funtion is initiated and Mozilla Firefox's executable is ran. After
the program loads the timer is stopped and the time is saved to a text
document named ProgramLoadingTime.txt. The time is then printed by
a shell script to the Nagios server's command line.

Inorder to check a different program change line 19 to the directory


where the program's main executable may be found, then change line
20 to the title of the program's window when it opens and fully loads.
Line 23 must also be changed to the title of the window as well.

Defining A Check
The next step is to create a batch file and define an NSClient++ check that can be used by Nagios to launch the autoIT script you

Nagios Enterprises, LLC US: 1-888-NAGIOS-1


P.O. Box 8154
Int'l: +1 651-204-9102
Saint Paul, MN 55108
Fax: +1 651-204-9103
USA

Web: www.nagios.com
Email: sales@nagios.com

Page 1
Copyright 2010-2011 Nagios Enterprises, LLC
Revision 1.0 June, 2012

Nagios XI Checking Program Loadtime With


autoIT in Nagios XI

create.
You can do this by opening your favorite text editor and pasting in the batch script below, which can be found at
http://www.pastebin.com/54kKBSwb.
@echo off
cd C:\Users\Administrator\Desktop

# The directory where your .au3 file may be found

programloadtime.au3

# The name of your script

type ProgramLoadingTime.txt

# This tells the batch file to print our text file

@exit 0
Once the script is pasted into notepad save the file as a batch file (.bat)
named check_programloadingtime.bat to the directory where your
NSClient++ scripts are located.

The check must now be added to the nsclient.ini file, or NSC.ini depending on which version of NSClient++ the windows host is
operating under. Open the .ini which will be located in the base NSClient++ directoy and find the external scripts section. Here below
the other defined checks add this string:
check_plt =scripts\check_programloadingtime.bat $ARG1$
Note: Be sure to use the directory where your checks are located if you
have altered it from the default.
After nsclient.ini/NSC.ini has been edited restart NSClient++ in windows
cmd with the commands:
net stop nscp
net start nscp
OR if you are using an older version of NSClient++
net stop nsclientpp
net start nsclientpp
You can now test the check which has been added, enter
nscp test
into the Windows command line, in order to locally check your new batch file and see if it prints out the time in milliceconds it took to
load the program use the following
command:
check_plt

As you can see 1094.23076117216 was the load time of the program saved as text and printed back to us. Don't worry! The plugin that
has been written turns this is to a much more manageable format.

Nagios Enterprises, LLC US: 1-888-NAGIOS-1


P.O. Box 8154
Int'l: +1 651-204-9102
Saint Paul, MN 55108
Fax: +1 651-204-9103
USA

Web: www.nagios.com
Email: sales@nagios.com

Page 2
Copyright 2010-2011 Nagios Enterprises, LLC
Revision 1.0 June, 2012

Nagios XI Checking Program Loadtime With


autoIT in Nagios XI

So there it is, the check has


been written and added to nsclient.ini. Next we will combine this check on the windows side with a plugin
called check_autoit_timer. This plug In will not play nice with everything you script in Autoit it was designed specifically for the purpose
of checking loading times of webpages, programs, and actions in a Windows environment.

Add A Plugin To Nagios


In order to automate the autoIT script and monitor its output with Nagios, you will first need to upload a plugin in Nagios XI.
The check_autoit_timer.sh plugin that can work with the example autoIT script in this document can be downloaded from Nagios
Exchange (http://exchange.nagios.org/directory/Plugins/Operating-Systems/Windows-NRPE/autoIT-Program-TimerPlugin/details).
Documentation on installing plugins in Nagios XI can be found in the following document:
http://assets.nagios.com/downloads/nagiosxi/docs/Managing_Plugins_in_Nagios_XI.pdf

Define A Command In Nagios


After you have installed the plugin you will need to create a
command in Nagios that can be referenced by service
checks that you create later.
To create a new command click configure on the top of
your Nagios web interface, then click Enter Nagios Core
Configuration Manager and log in. Once you are in the
Core Config Manager, select Commands from the list on
the left, and then click the Add New button.
Use the following title for your command:

check_autoit_timer
In the Command Line box enter the following:

$USER1$/check_autoit_timer.sh -H $HOSTADDRESS$ -p 5666 -c "$ARG1$" -w $ARG2$ -c $ARG3$


The Command Type should be:

check command

After this has all been entered click Save.


Once the command is saved you will be brought back to the Command Management screen. From there click Apply Configuration.
Once the configuration is applied click continue.

Create A Service In Nagios


The final step in monitoring an autoIT script with
Nagios is to create a new service definition that
should associated with the check.

Nagios Enterprises, LLC US: 1-888-NAGIOS-1


P.O. Box 8154
Int'l: +1 651-204-9102
Saint Paul, MN 55108
Fax: +1 651-204-9103
USA

Web: www.nagios.com
Email: sales@nagios.com

Page 3
Copyright 2010-2011 Nagios Enterprises, LLC
Revision 1.0 June, 2012

Nagios XI Checking Program Loadtime With


autoIT in Nagios XI
To do this....
To create a new service we will go to the Services section under Monitoring in Nagios Core Config Manager, and click Add New.

In the Common Settings Config Name will be:

check_autoit_timer
Under Hosts we will select our windows machine which we will be running the command on.
The Service Description:

autoIT Program Load Time


Under the Check Command drop down we will select the
plugin:

check_autoit_timer
Now the arguments which corresponds with the plugin check
must be added.

$ARG1$ = check_plt
$ARG2$ = Warning Threshold
;The amount
(In milliseconds that the check will
create a warning from)
$ARG3$ = Critical Threshold ;The amount
of time required to trigger the critical
threshold, once again in milliseconds
And finally the template we will choose will be:

generic-service

The last step required to enable monitoring of your newly


configured service is to apply the configuration to Nagios.
To do this, click the Apply Configuration link from the CCM
menu, and click the Apply Configuration button that appears
on the screen.

Nagios Enterprises, LLC US: 1-888-NAGIOS-1


P.O. Box 8154
Int'l: +1 651-204-9102
Saint Paul, MN 55108
Fax: +1 651-204-9103
USA

Web: www.nagios.com
Email: sales@nagios.com

Page 4
Copyright 2010-2011 Nagios Enterprises, LLC
Revision 1.0 June, 2012

Nagios XI Checking Program Loadtime With


autoIT in Nagios XI
Finishing Up
This is intended to be an introductory guide to monitoring automated Windows tasks using Nagios. If you questions about using autoIT
with Nagios, please visit our support forums at http://support.nagios.com/forum/index.php.

Nagios Enterprises, LLC US: 1-888-NAGIOS-1


P.O. Box 8154
Int'l: +1 651-204-9102
Saint Paul, MN 55108
Fax: +1 651-204-9103
USA

Web: www.nagios.com
Email: sales@nagios.com

Page 5
Copyright 2010-2011 Nagios Enterprises, LLC
Revision 1.0 June, 2012

You might also like