View previous topic :: View next topic |
Author |
Message |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Tue Apr 22, 2008 6:14 pm Post subject: Scheduled Tasks check |
|
|
Utility that may check status of scheduled tasks available at
www.ks-soft.net/download/utils/schtaskcheck.zip
This is command line utility that can be used with Shell Script test method
http://www.ks-soft.net/hostmon.eng/mframe.htm#tests.htm#chkShell
Usage: schtaskcheck.exe -task:<task_name> -timeframe:<time_interval> [-host:<hostname>] [-user:<username>] [-pswd:<password>] [-ignoreres]
There are 2 mandatory command line parameters:
-task: Scheduled task name
-timeframe: Specifies time interval when the task was expected to be excuted. Interval specified in minutes. E.g. -timeframe:60 means scheduled task had to be executed within last hour.
Also there are several predefined constants you may use: today, yesterday, this_week, last_week, this_month and last_month
3 optional parameters:
-host: Specifies the name or IP address of a remote computer, with or without backslash characters. If omitted, utility checks the local computer
-user: Run the utility with the permission of the specified user account
-pswd: Specifies the password of the user account that is specified in the -user parameter
-ignoreres: This option suppresses additional check for last exit code. If omitted, utility checks task exit code and returns Bad status when exitcode<>0
Examples:
schtaskcheck -task:"Daily Backup" -timeframe:120
schtaskcheck -task:check_log -timeframe:today -host:Second_Server
schtaskcheck -task:check_log -timeframe:today -host:ftp.corp.com -user:admin
schtaskcheck -task:AV_update -timeframe:yesterday -host:192.168.1.100 -user:dsma -pswd:secretphrase -ignoreres
Regards
Alex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
vpavel
Joined: 30 Oct 2007 Posts: 12
|
Posted: Tue Jul 15, 2008 9:41 am Post subject: |
|
|
When i am trying to monitor schedule tasks execution in different time zone , i receive BAD result becouse of time difference.It doesn't work even after upgrade to last 7.24 version.I use custom folder GMT setting.But shell script execute test with local time
[11:40:06 AM] Script executed, correct result received:
----------
- Status: Bad
- Reply: 15.07.2008 19:38:00 Last Result : 1
Can you fix it please ? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Tue Jul 15, 2008 1:33 pm Post subject: |
|
|
Folder-level "GMT offset" option has nothing to do with external utilities like schtaskcheck.exe. This option affects GUI, reports, schedules.
In many cases you can adjust "timeframe" parameter of the test to make it work. However we added new option "-remotegmt" that allows you to specify GMT offset on target server (minutes).
E.g.
-remotegmt:-300 specified Easter Time zone (GMT -05:00)
-remotegmt:+540 specified Tokyo/Seoul time (GMT +09:00)
New version of the utility available at www.ks-soft.net/download/utils/schtaskcheck.zip
Regards
Alex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
vpavel
Joined: 30 Oct 2007 Posts: 12
|
Posted: Tue Jul 15, 2008 1:56 pm Post subject: |
|
|
thank you ![](images/smiles/icon_razz.gif) |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
greyhat64
![](images/avatars/13145101248a46568d995b.jpg)
Joined: 14 Mar 2008 Posts: 246 Location: USA
|
Posted: Thu Aug 14, 2008 10:02 am Post subject: |
|
|
Alex,
Thanks! I had written a script to do this via WMI, but I think I like this better.
Though, if you keep this up, I'm gonna need to occupy my time doing something other that script writing. ![](images/smiles/icon_lol.gif) |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Marcel_vrinds
Joined: 13 Jan 2010 Posts: 2
|
Posted: Wed Jan 13, 2010 2:03 pm Post subject: |
|
|
Hi,
I am using this tool, but i get "error: script returns no results"
Started schtaskcheck on the active rma side. If i start a cmd screen on the rma side, i get; ScriptRes:Bad:13-1-2010 19:50:28. So that is good! but why don't i get the info in the hostmonitor.
Can someone help me.
Cheers! |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Wed Jan 13, 2010 2:08 pm Post subject: |
|
|
What version of HostMonitor do you use? RMA?
Windows version on system where RMA is running? Service Pack?
Can this agent perform any other Shell Script test without problem?
Regards
Aex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Marcel_vrinds
Joined: 13 Jan 2010 Posts: 2
|
Posted: Wed Jan 13, 2010 3:46 pm Post subject: |
|
|
Hi
Thanks for the quick reaction
Hostmonitor 8.14 and RMA 3.35
Hostmonitor is running on sbs2003 with all sp's and updates
RMA is running on server 2003 r2 with all updates
This is the first shell script that i am using.
Thanks,
Marcel |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Fri Jan 15, 2010 12:41 pm Post subject: |
|
|
Sorry, I missed your answer.
Could you please try to setup some other Shell Script test? HostMonitor provides several samples, you may use simply VB or Java script, even BAT file.
This way we will know is problem related to schtaskcheck.exe utility or there is some problem related to external program execution.
What account do you use to run agent?
Regards
Alex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
YG
Joined: 03 Sep 2010 Posts: 4
|
Posted: Fri Sep 03, 2010 1:05 pm Post subject: If it's not to much to ask |
|
|
I am a newbie admin and I am in need of some help on the Scheduled task check test.
Would somebody be so kind to give me an example of the script to check if the scheduled task with the name “File Transfer to AOD“ completed by a certain time ( for example: it starts at 12AM Eastern Standard Time and has to be completed by 5AM ). No matter what I do I can’t make it work.
Your help is greatly appreciated. Thank you in advance. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Fri Sep 03, 2010 6:11 pm Post subject: |
|
|
Have you setup Shell Script test to be executed every day at 5:01AM using command for the script like
schtaskcheck.exe "-task:File Transfer to AOD“ -timeframe:today -host:hostname -user:username -pswd:password
Quote: | I can’t make it work. |
Could you please be more specific? What exactly parameters for the script do you use and what exactly is test result (status and reply)?
Regards
Alex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
YG
Joined: 03 Sep 2010 Posts: 4
|
Posted: Sat Sep 04, 2010 10:59 am Post subject: |
|
|
Thank you for your help. I will try that.
The problem was after I clicked on the "let's try" it was not recognizing the scheduled task name.
I can see now that you put the " before -task, I had it after -task like this:
-task "File transfer to AOD" because that's how it was shown in the example in the beginning of the forum. I will try it your way let you know what happened. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
YG
Joined: 03 Sep 2010 Posts: 4
|
Posted: Tue Sep 07, 2010 11:46 am Post subject: |
|
|
It appears to be a Windows Server 2008 R2 issue. The script runs fine against Server 2003 Scheduled tasks but fails to recognize then on 2008. Any ideas how to use them on 2008 R2 scheduled task? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Wed Sep 08, 2010 12:05 pm Post subject: |
|
|
I am afraid we need to create different utility for Windows 2008.
On the other hand, if you need to check local system or you can install RMA on target system, then you may use script like the following
Code: |
Option Explicit
const statusAlive = "scriptRes:Host is alive:"
const statusDead = "scriptRes:No answer:"
const statusUnknown = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"
Dim objArgs, fnd
fnd = 0
Set objArgs = WScript.Arguments
if objArgs.count <> 2 then
WScript.StdOut.Write statusUnknown & "2 arguments expected <TaskName> <timeframe>"
End if
Dim service
' Create the TaskService object.
Set service = CreateObject("Schedule.Service")
call service.Connect()
' Get the task folder that contains the tasks.
Dim rootFolder
Set rootFolder = service.GetFolder("\")
Dim taskCollection
Set taskCollection = rootFolder.GetTasks(0)
If taskCollection.Count = 0 Then
WScript.StdOut.Write statusUnknown & "No tasks are registered."
Else
Dim registeredTask
Dim D1, D1D, Dif
For Each registeredTask In taskCollection
if registeredTask.Name = objArgs(0) then
fnd = fnd + 1
D1 = registeredTask.LastRunTime
D1D = CDate(D1)
Dif = DateDiff("n", D1D, Now())
if Dif > Int(objArgs(1)) then
WScript.StdOut.Write statusBad & "Last Run: " & Dif & " min"
Else
WScript.StdOut.Write statusOk & "Last Run: " & Dif & " min"
End If
End If
Next
if fnd = 0 then
WScript.StdOut.Write statusUnknown & "Task " & objArgs(0) & " NOT found."
End If
End If
|
Script requires 2 parameters: taskname and timeframe (specified in minutes). E.g. "File Transfer to AOD" 300
Command line to start script: cmd /c cscript /B /E:VBScript %Script% %Params%
Regards
Alex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
KS-Soft
Joined: 03 Apr 2002 Posts: 12795 Location: USA
|
Posted: Thu Sep 09, 2010 12:17 pm Post subject: |
|
|
BTW: We can modify script so it will request data from remote system or you can modify it by yourself (using hostname, login and password parameters for call service.Connect procedure call)
Regards
Alex |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|