Quantcast
Channel: windows – Monitis Blog
Viewing all articles
Browse latest Browse all 68

Automating Data Collection for Your Custom Monitors

$
0
0

Once you have learned how easy is to create Monitis custom monitor using simple Windows scripts, you may be ready to deploy those scripts in your productions server. Windows makes it very easy to run a program periodically so that you can feed your custom monitor with fresh data at the most suitable time for your environment.

In the following examples, we assume that you have already created and tested the scripts that creates and uploads data to your custom monitors, as explained in this series of articles: Start Exploring Monitis API with cURL and How to Monitor Windows Servers with VBScript, WMI and Monitis.

So, as an example, you may have one script for each custom monitor, named pushData1.vbs, pushData2.vbs, etc. We also assume that all necessary scripts are stored on a local folder, such as c:\monitis.

All versions of Windows includes the Task Scheduler, but it appears slightly different between the operating system versions.

Windows 2008

Let’s begin with the current version of Windows; the screenshots below apply to Windows 2008, Windows Vista, Windows 7 and Windows 2008 R2. You can find the Task Scheduler in several ways:

– In your Start menu start typing Task Scheduler and it will appear as the first icon in the search result;

– In Server Manager, inside the Configuration subtree

– In Computer Manager, inside the System Tools subtree

Once you get to the Task Scheduler, right click on the Task Scheduler Library node and then click Create Task:

Another window will pop up, and in the General Tab choose and enter a Task Name and select the option “Run wether the user is logged on or not”:

In the Trigger tab click New and configure the way your script execution will be triggered.

You will probably execute your script daily, starting at midnight and repeating frequently, such as every five minutes, for a duration of one day.

In the Actions tab, click New and keep the default action “Start a program”.

In “Program/Script,” type or browse to C:\Windows\System32\cscript.exe. In “Add arguments,” type the full path name of the script to be run, such as C:\monitis\pushDataConn.vbs.

Next, when you click OK in the Task properties you will be asked for the credentials that will be used to run the script. Use an account with administrative rights on the computer (local or remote) from where the script will gather data.

 

Windows 2003

The following instructions applies to the older versions Windows, such as Windows 2003 and Windows XP.

You can find the Task Scheduler in Start, Control Panel, and Scheduled tasks.

Once there click on the File menu and then choose New and Scheduled task:


In the newly created object assign a task name.

Double click on the new task, and a window will pop up with all the configuration details:

In “Run” type c:\WINDOWS\system32\cscript.exe <your script path and file name>.

In the Schedule tab chose the frequency and the start time:


For example, daily at 0:00

Click Advanced and configure the task to repeat at the frequency you need…


for example, every five minutes for 24 hours

Click OK; close the Advanced Schedule Options window and then go back to the Task tab.

In “Run as” enter the name of an account with administrative rights on the computer (local or remote) — from where the script will gather data. Then click Set password and type the password for that account.

Click OK to confirm the task configuration.

After a while, when you refresh the web page of your Monitis account dashboard, you will see the newly collected data showing up in your Custom monitor widget.

Scheduling multiple scripts

If you have multiple scripts to schedule, you have a couple of options. First, you have to determine if all scripts will run with the same frequency. In this case, you may want to group all scripts inside a batch file and then schedule the batch file itself.

For example, your batch file may be c:\monitis\runall.bat and contain the following lines:

cscript pushData1.vbs

cscript pushData2.vbs

cscript pushData3.vbs

In order to schedule the batch file directly just replace the commands explained above with the full path name of the batch file itself. In Windows 2008 clear the “Add arguments” textbox.

If the frequencies for which you want to run the scripts are different, you may have to schedule each script with different parameters. Or, as a mixed case, you may want to schedule several batch files each containing different scripts.

Creating scheduled tasks from the command line

Instead of using the Graphical User Interface for creating the scheduled task, you can also do that from command line.

This is less common but it may be convenient if you have a set of well established scripts and you need to schedule them on multiple servers. In this scenario you can log in on each server, copy the necessary file, run a command and you are done.

The command schtasks.exe automates the scheduled task creation. For example, the following command will create a task as explained in the steps above on Windows 2008:

schtasks /create /TN “pushData” /SC DAILY /TR “c:\WINDOWS\system32\cscript.exe c:\monitis\pushDataConn.vbs” /ST 00:00 /RI 5 /DU 24:00 /RU username /RP password

The syntax for Windows 2003 is just slightly different:

schtasks /create /TN “pushData” /SC DAILY /TR “c:\WINDOWS\system32\cscript.exe c:\monitis\pushDataConn.vbs” /ST 00:00 /RI 5 /DU:0024:00 /RU username /RP password

It’s fairly easy to set up your custom monitor using simple Windows scripts — the everyday language of the computer. And it’s just as easy to automate the process of data collection to keep the monitoring process relevant. We at Monitis hope that this modest tutorial will help you see the common sense behind continually monitoring your servers.

If you have more questions, please leave them here in the comments section. Or contact us; we’ll be glad to chat with you.

Monitis is an on-demand IT monitoring platform which consolidates server monitoring, application monitoring, website monitoring, end user experience and cloud monitoring in all-in-one monitoring software as a server.

The post Automating Data Collection for Your Custom Monitors appeared first on Monitis Blog.


Viewing all articles
Browse latest Browse all 68

Trending Articles