Checking a Network Path

To the Ipswitch web site

Ipswitch Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Checking a Network PathExpand / Collapse
Author
Message
Posted 5/8/2008 9:46:54 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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?
Post #43585
Posted 5/8/2008 2:23:29 PM
Time Traveler

Time TravelerTime TravelerTime TravelerTime TravelerTime TravelerTime TravelerTime TravelerTime Traveler

Group: Forum Members
Last Login: 7/3/2008 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

Post #43602
Posted 5/9/2008 10:59:24 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior 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("CredWindowsomainAndUserid")
sysAdminPass = Context.GetProperty("CredWindowsassword")
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.
Post #43643
Posted 5/12/2008 7:54:59 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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.
Post #43677
Posted 6/9/2008 11:54:21 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior 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.

Post #44433
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Mark Singh, kevin r gillis, Jason Benton, Brandon Felger, Ben Henderson, Tripp Allen, Will Sansbury, Hush, FTPplanet.com, Hugh Garber, George Dailey, WUP-PM, mmulryan@ipswitch.com, mswimm

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 11:10am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.047. 8 queries. Compression Enabled.