Skip to Main Content
  • Questions
  • Alert message on Listener Log growth

Breadcrumb

May 4th

Question and Answer

Connor McDonald

Thanks for the question, Binoj.

Asked: June 20, 2017 - 10:52 am UTC

Last updated: June 29, 2017 - 1:56 am UTC

Version: 12.1.0.1

Viewed 1000+ times

You Asked

Hi,

Need suggestion to get an Alert message over the Listener Log file's growth, now each file gets 10M.
We want an alert message over 1GB of the combined listener log files.

Regards
Binoj

and Connor said...

I assume you are referring to the XML files (10m) in the 'alert' directory.

You can also just look at the listener.log file in the 'trace' directory, that's the equivalent of them.

So you could just use some powershell to check that file and send an email.

I'm not a powershell expert, but something like:

$smtpServer = "my_mail_server"
$smtpFrom = "alert@my_company.com"
$smtpTo = "dba@my_company.com"
$messageSubject = "Listener size"
$messageBody = "The listener is more than 1000M"
$file = 'c:\....\listener.log'

if (Test-Path $file) { (Get-Item $file).length -gt 1000mb }
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpFrom,$smtpTo,$messagesubject,$messagebody)


Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Binoj P N, June 21, 2017 - 6:53 am UTC

Hi,

Thanks for the suggestion, we are using Windows.
Still I will try to convert this powershell according to the Windows script.

Regards
Binoj
Connor McDonald
June 22, 2017 - 4:52 am UTC

if you get a powershell script running nicely, be sure to post it or blog about it so others will benefit as well

IF condition for folder size.

Binoj P N, June 27, 2017 - 7:47 am UTC

Hi,

I am managed to do something, but not table to make the exact IF Condition.

$smtpServer = "IP Address"
$smtpFrom = "name@com"
$smtpTo = "name@com"
$messageSubject = "Listener size"
$messageBody = "The listener size is:"
$file = 'path\'



$objFSO = New-Object -com Scripting.FileSystemObject
"{0:N2}" -f (($objFSO.GetFolder($file).Size) / 1MB)


if ($objFSO = 277.75)
{
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpFrom,$smtpTo,$messagesubject,$objFSO)
}


I want to send alert mail, if the entire FOLDER's size cross 1 GB.

But when I tried, it is not accepting either greater than nor less than symbols.

It accepts only the equal to value.

Need your advice.

Regards
Binoj

Connor McDonald
June 28, 2017 - 12:48 am UTC

Let me reiterate

"I'm not a powershell expert"

:-)

Found the solution

Binoj P N, June 28, 2017 - 6:53 am UTC

Hi,

Finally I have found the solution.

Here it is.

$smtpServer = "my_mail_server"
$smtpFrom = "alert@my_company.com"
$smtpTo = "dba@my_company.com"
$messageSubject = "Listener size"
$messageBody = "The listener is more than 1000M"
$file = 'c:\....\listener.log'

$mail="The folder's total size is:- "



$objFSO = New-Object -com Scripting.FileSystemObject
"{0:N2}" -f (($objFSO.GetFolder($file).Size) / 1MB)

$value= (($objFSO.GetFolder($file).Size) / 1MB)

if ($value -gt 278)

{
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpFrom,$smtpTo,$messagesubject,$mail+$value)
}


Regards
Binoj
Connor McDonald
June 29, 2017 - 1:56 am UTC

Thanks for taking the time to come back here and post this.

It will be helpful for other people on Windows.