| | | Forum Newbie
       
Group: Forum Members Last Login: 6/23/2008 2:51:06 PM Posts: 3, Visits: 17 |
| I know this has been discussed, but I haven't found the other threads to be very helpful. We have several NAS boxes and network shares that are mission critical, and we'd like to monitor them through WUG. We don't even really care about drive space... we only care that the drives are on the network. I know I can create an active script to monitor the existence of a folder, which seems to be the right way to go, but since WUG runs as a local service and not a domain account (which is something we really don't want), it doesn't have permission to access the network drive, so it reports that it doesn't exist. However, we have set up a domain account that WUG uses to monitor Windows services that should have access to the network drives, so we'd like to use that. That account info is stored as Windows Credentials. In pseudocode, this is what I've been trying to figure out how to tell either JScript or VBScript to do:
username = Windows Credentials username
password = Windows Credentials password
if (folderexists('\\\\fileserver\\path', username, password)) {
Success!
} else {
Fail!
}
In theory, it sounds very easy to do, I just can't figure out the actual script to do it. I can get the username and password in JScript, but not in VBScript. However, I can't figure out how to pass the username and password to any function that could check the existence of the folder. Anyone have any advice? |
| | | | Time Traveler
       
Group: Forum Members Last Login: 2 days ago @ 2:20:31 PM Posts: 142, Visits: 38 |
| | its been a while, but I think if you set your check up as a passive monitor (drop the username/password in your script) you can associate your creds with that action.
Don Click Network Manager Denton County, Texas |
| | | | Junior Member
       
Group: Forum Members Last Login: 6/24/2008 8:34:27 AM Posts: 20, Visits: 150 |
| omatsei (5/8/2008) I know this has been discussed, but I haven't found the other threads to be very helpful. We have several NAS boxes and network shares that are mission critical, and we'd like to monitor them through WUG. We don't even really care about drive space... we only care that the drives are on the network. I know I can create an active script to monitor the existence of a folder, which seems to be the right way to go, but since WUG runs as a local service and not a domain account (which is something we really don't want), it doesn't have permission to access the network drive, so it reports that it doesn't exist. However, we have set up a domain account that WUG uses to monitor Windows services that should have access to the network drives, so we'd like to use that. That account info is stored as Windows Credentials. In pseudocode, this is what I've been trying to figure out how to tell either JScript or VBScript to do:
username = Windows Credentials username
password = Windows Credentials password
if (folderexists('\\\\fileserver\\path', username, password)) {
Success!
} else {
Fail!
}
In theory, it sounds very easy to do, I just can't figure out the actual script to do it. I can get the username and password in JScript, but not in VBScript. However, I can't figure out how to pass the username and password to any function that could check the existence of the folder. Anyone have any advice?
Try this script:
sysAddress = Context.GetProperty("Address")
sysAdminUser = Context.GetProperty("CredWindows omainAndUserid")
sysAdminPass = Context.GetProperty("CredWindows assword")
Context.LogMessage "Checking " & sysAddress & " for folder 'c:\program files'."
Set objLocator = CreateObject( "WbemScripting.SWbemLocator" )
Set objWMIService = objLocator.ConnectServer(sysAddress, "root/cimv2", sysAdminUser , sysAdminPass)
objWMIService.Security_.impersonationlevel = 3
Set wbemFolderSet = objWMIService.ExecQuery ( _
"Select * from Win32_Directory where Name = 'c:\\program files'")
If IsNull(wbemFolderSet) Then
Context.LogMessage "wbemFolderSet is null"
Context.SetResult 1, "Failed to poll the reference variables."
Else
If wbemFolderSet.Count Then
For Each wbemFolder In wbemFolderSet
FolderExists = True
Context.LogMessage "Folder 'c:\program files' exists."
Next
Context.SetResult 0, "Polled folder successfully."
Else
Context.SetResult 1, "Folder 'c:\program files' does not exist."
End If
End If
Set wbemFolderSet = Nothing
Set objWMIService = Nothing
Set objLocator = Nothing
I tried using a variable to do the test, so that you would only need to change the actual file name in one place, but for some reason, it wouldn't work, so I left it hard-coded in the script. |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 6/23/2008 2:51:06 PM Posts: 3, Visits: 17 |
| | I actually ended up doing something very similar, except it maps the network path as a local drive, then checks the existence of the drive letter. It's definitely not perfect, and it's constantly reporting it as "down" but as long as it doesn't get to "down at least 5 minutes", we won't get paged. I'll test your script to see if it can handle UNC paths, because that would be very much preferable. |
| | | | Junior Member
       
Group: Forum Members Last Login: 6/9/2008 12:39:38 PM Posts: 15, Visits: 11 |
| | Ignore if you read this, I spoke too soon and can't delete the post.  |
| |
|
|