• 0
Sign in to follow this  
joshlowit1

Log Files

Question

I have successfully created an alert for a log file. My question is, How do I monitor the log file regardless of drive letter? I monitor the same log file on several servers but on some of the servers the log is under Drive E: and others it is Drive D:. 

Thank you

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

What kind of alert and how is the datasource configured for this log file?  If it's in a script, you could just iterate through all of the possible drives it could be on testing for the existence of that directory.  That's the easiest way I could think of doing it.

 

Share this post


Link to post
Share on other sites
  • 0

It is a log file collector. I'm currently using an absolute path in the Logfile Path section, but was wondering if I could use wildcards since the logfile could be on drive E: or drive D:.

Share this post


Link to post
Share on other sites
  • 0

Are you using PowerShell for this?  If so, something like this should work

$logfileExists=0
if(test-path D:\path\to\logfile.txt)
{
	$logfileExists=1
}
elseif(test-path E:\path\to\logfile.txt)
{
	$logfileExists=1
}
else
{
	$logfileExists=0
}
$outString="logfileExists="+$logfileExists

write-host $outString

Otherwise - you can run a command like this

$drives = GET-WMIOBJECT win32_logicaldisk | select DeviceID

foreach($drive in $drives)
{
    #do a test-path to the path on each drive
}

Hope that helps.

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0

I've had to do the same as Matt has suggested.  In my case it's limited to a handful of drives, so I the script doesn't have many tests to perform.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this