Reply Value to change CDate

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
RRing
Posts: 39
Joined: Wed Aug 16, 2006 9:14 am

Reply Value to change CDate

Post by RRing »

I am running the following WMI Check
select LastBootUpTime from Win32_OperatingSystem which returns
20080720160058.000000-30
and would like to display the Normal Date/Time instead of the Cdate using the TuneUpReply. What value do I need in the Tune Up Reply to accomplish this?

Thanks

Rodney
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Sorry, HostMonitor cannot do that.
May be we implement some additional functions in future :roll:

Regards
Alex
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Re: Reply Value to change CDate

Post by KS-Soft Europe »

RRing wrote:and would like to display the Normal Date/Time instead of the Cdate using the TuneUpReply. What value do I need in the Tune Up Reply to accomplish this?
I think, you may use "Active Script" test method: http://www.ks-soft.net/hostmon.eng/mfra ... htm#script
You just should slightly modify script below to match "Active Script" requirements:

Code: Select all

strComputer = "."

Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
 
For Each objOS in colOperatingSystems
    dtmBootup = objOS.LastBootUpTime
    dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
    dtmSystemUptime = DateDiff("n", dtmLastBootUpTime, Now)
    Wscript.Echo dtmSystemUptime & " minutes"
Next
 
Function WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _
        Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
            & " " & Mid (dtmBootup, 9, 2) & ":" & _
                Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function
Regards,
Max
RRing
Posts: 39
Joined: Wed Aug 16, 2006 9:14 am

VB Script Attempt

Post by RRing »

Alex,

I tried the script and get the following error?
Error in script:
Error number :1002
Source :Microsoft VBScript compilation error
Description :Syntax error
Text :Function WMIDateStringToDate(dtmBootup)
Line :23
Column :0
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Foregoing script was given you just as an example. It is not designed for "Active Script" test method. To make it work with HostMonitor you should modify it to match "Active Script" requirements. Quote from the manual: http://www.ks-soft.net/hostmon.eng/mfra ... htm#script
===========================================
Requirements to the script:
HostMonitor has just a few requirements:
1. script must contain "performtest" function. HM always call function with this name
2. "performtest" function must not have any parameters
3. "performtest" function must return string value. This string contains two parts separated by colon (:). First obligatory part contains test status, it can take following values:

* "Host is alive"
* "No answer"
* "Unknown"
* "Unknown host"
* "Ok"
* "Bad"
* "Bad contents"

Second optional part contains "Reply" value, HostMonitor displays this value in Reply field, writes to log files, uses to displays charts (Log Analyzer), etc.
Several examples:
return "Host is alive:1000 ms" | Jscript; Status: Host is alive; Reply: 1000 ms
return "Unknown host:" | Jscript; Status: Unknown host; Reply: empty
performtest = "Ok:300 Kb" | VBscript; Status: Ok; Reply: 300 Kb
performtest = "Bad:90 %" | VBscript; Status: Bad; Reply: 90 %
===========================================

Ok. Below isthe script, you may use with "Active Script" test method. It just sets the status "Ok" and shows the system uptime in minutes. You may modify it on your own. Examples of the scripts are located in "\Examples\Scripts" subfolder of the HostMonitor folder.

Code: Select all

Option Explicit

const statusAlive       = "Host is alive:"
const statusDead        = "No answer:"
const statusUnknown     = "Unknown:"
const statusNotResolved = "Unknown host:"
const statusOk          = "Ok:"
const statusBad         = "Bad:"
const statusBadContents = "Bad contents:"

dim objWMIService, colOperatingSystems, dtmBootup, dtmLastBootupTime, dtmSystemUptime, objOS

const strComputer = "."


FUNCTION performtest()


Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
 
For Each objOS in colOperatingSystems
    dtmBootup = objOS.LastBootUpTime
    dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
    dtmSystemUptime = DateDiff("n", dtmLastBootUpTime, Now)
    performtest = statusOk+CStr(dtmSystemUptime)
Next
End Function

 
Function WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _
        Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
            & " " & Mid (dtmBootup, 9, 2) & ":" & _
                Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function
Regards,
Max
RRing
Posts: 39
Joined: Wed Aug 16, 2006 9:14 am

Sytem UPTime

Post by RRing »

Thanks Max, All works fine
Post Reply