JobMonitors

Examples of JobMonitor Monitoring

Example 1: Monitor Linux Cron Job

Assume the monitored device in LogicMonitor is “app1″, and the collector monitoring “app1″ runs on the device “agenthost”.  There is a cron job “cleanlogs” running at 8:30, 12:30, and 16:30 everyday on app1.  Now, we want LogicMonitor to monitor:

  1. whether or not the task cleanlogs is started on time at 8:30, 12:30, and 16:30 everyday.
  2. whether or not the task finished successfully.

Step 1: Create the JobMonitor definition

The first step of monitoring a Linux cron task is to create a batch job definition via LogicMonitor.

  1. Log on to your LogicMonitor account.
  2. Go to Settings | LogicModules | JobMonitors
  3. Click Add -> JobMonitor
  4. Edit the JobMonitor definition (see the figure below)
  5. Click Submit to save the JobMonitor definition
Step 1: Create the Batchjob definition

The JobMonitor definition displayed above is associated with device app1, will trigger an alert if the JobMonitor isn't finished in 10 minutes and will trigger a warning alert if the job starts more than 15 minutes after its scheduled run times of 8:30, 12:30 and 16:30.  You should see the JobMonitor associated with the device app1 from the Devices page of your account.

Step 2: Wrap up the cron job

Our cron job cleanlogs currently executes a script “/usr/local/cleanlog.pl” at 8:30, 12:30, and 16:30 everyday:

Step 2: Wrap up the cron job

Copy lmbatchjobwrapper.pl (this file is stored in /usr/local/logicmonitor/agent/lib of collectorhost by default ) to app1 (you can store it anywhere you like).

Run "crontab -e" (or equivalent) and update the command line to 30 8,12,16 * * * /usr/local/lmcollectorlmbatchjobwrapper.pl agenthost:7214 app1 “Clean log monitoring” /usr/local/cleanlog.pl

“agenthost:7214″ is the name of the device on which the collector is running and the port on which the collector listen to accept batch job execution notification sent from lmJobMonitorwrapper.js.

“app1″ is the name of the monitored device on which the batch job is running.

“Clean log monitoring” is the name we gave this scheduled task in LogicMonitor (see step 1)

/usr/local/cleanlog.pl tells the wrapper how to start the real program to clean the logs.

 

Step 3: Check job executions

You can check every execution of the scheduled task from the Devices Page.  Executions that didn't start on time or finished abnormally will be displayed with an error.  

 

Example 2: Monitor Windows Scheduler Task

Assume the monitored device is "app1", and the collector monitoring "app1" runs on the device "agenthost".  There is a Windows scheduler task "cleanlogs" running at 8:30, 12:30, and 16:30 everyday on app1.  Now, we want LogicMonitor to monitor:

  1. whether or not the task cleanlogs is started on time at 8:30, 12:30, and 16:30 everyday.
  2. whether or not the task finished successfully.

Step 1: Create the JobMonitor definition

The first step of monitoring a Windows scheduler task is to create a batch job definition via LogicMonitor.

  1. Log on to your LogicMonitor account.
  2. Go to Settings | LogicModules | JobMonitors
  3. Click Add -> JobMonitor.
  4. Edit the JobMonitor definition (see the figure below)
  5. Click Submit to save the JobMonitor definition
Step 1: Create the Batchjob definition

The JobMonitor definition displayed above is associated with device app1, will trigger an alert if the JobMonitor isn't finished in 10 minutes and will trigger a warning alert if the job starts more than 15 minutes after its scheduled run times of 8:30, 12:30 and 16:30.  You should see the JobMonitor associated with the device app1 from the Devices page of your account.

Step 2: Wrap up the Windows scheduled task

Our scheduled task cleanlogs executes a script "C:\scripts\cleanlogs.bat" at 8:30, 12:30, and 16:30 everyday:

Step 2: Wrap up the Windows scheduled task

Copy lmbatchjobwrapper.js (The file is stored in <collectorInstallationDir>\Agent\lib of collectorhost - see figure below)to app1 (you can store it anywhere you like)

Open properties dialog of the scheduled task Cleanlogs, and update the command line to - cscript.exe C:\lmcollector\lmbatchjobwrapper.js agenthost:7214 app1 "Clean log monitoring" "cmd.exe /C C:\script\cleanlogs.bat"

"agenthost:7214" is the name of the device on which the collector is running and the port on which the collector listen to accept batch job execution notification sent from lmbatchjobwrapper.js.

"app1" is the name of the monitored device on which the batch job is running.

"Clean log monitoring" is the name we gave this scheduled task in LogicMonitor (see step 1)

"cmd.exe /C C:\script\cleanlogs.bat" tells the wrapper how to start the real program to clean the logs.

Step 3: Check job executions

You can check every execution of the scheduled task from the Devices Page.  Executions that didn't start on time or finished abnormally will be displayed with an error.