Author |
Topic |
krajdba
Starting Member
43 Posts |
Posted - 2007-09-24 : 06:55:17
|
Hi How to Create SMTP Notifications using SQL Server 2000.Thanks & Regards-RajRaj. |
|
alexjamesbrown
Starting Member
48 Posts |
|
krajdba
Starting Member
43 Posts |
Posted - 2007-10-12 : 05:47:00
|
Hi How to implement alert notification mails on Operating System....Processor% Processor TimeMemory Available MegabytesPage Faults/SecondsLogicalDisk%Free Space etcUrgent please.ThanksRaj. |
|
|
AnimalMagic
Starting Member
28 Posts |
Posted - 2007-10-12 : 12:03:07
|
quote: Originally posted by krajdba Hi How to implement alert notification mails on Operating System....Processor% Processor TimeMemory Available MegabytesPage Faults/SecondsLogicalDisk%Free Space etcUrgent please.ThanksRaj.
In EM go to alerts, right click -> new. then set up an alert based on a windows performance condition, and notify your operators in the response tab. Its all fairly straight forward to set up a simple alert. |
|
|
krajdba
Starting Member
43 Posts |
Posted - 2007-10-16 : 03:55:42
|
Hi Could you please give me an example for %Free Space.thanksRaj. |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-16 : 04:10:49
|
"example for %Free Space"Disk space?Database free space?Log free space?Something else?"Urgent please."How urgent? You got a reply within a few hours but its taken you 4 days to come back with your follow-up ...Kristen |
|
|
krajdba
Starting Member
43 Posts |
Posted - 2007-10-16 : 11:28:00
|
Disk space,Log free space.........PleasethanksRaj. |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-16 : 11:52:48
|
Disk space = xp_fixeddrivesLog space = DBCC SQLPERF ( LOGSPACE )Kristen |
|
|
krajdba
Starting Member
43 Posts |
Posted - 2007-10-17 : 03:31:22
|
Hi Guess, if the hard disk space has reached 80%. I would like to get an alert mail.How can we do this?ThanksRaj. |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-17 : 03:57:09
|
I would schedule a job that ran the Sproc and if the value was above the threshold send me an Email (or one of the other alerts available).I don't think you can actually place an alert on that condition occurring (but I could be wrong!) hence the idea of a job scheduled to run every minute, or hour, depending on how quickly you would need to know.Kristen |
|
|
AnimalMagic
Starting Member
28 Posts |
Posted - 2007-10-17 : 06:06:27
|
quote: Originally posted by Kristen I would schedule a job that ran the Sproc and if the value was above the threshold send me an Email (or one of the other alerts available).I don't think you can actually place an alert on that condition occurring (but I could be wrong!) hence the idea of a job scheduled to run every minute, or hour, depending on how quickly you would need to know.Kristen
Kristen,Sorry to jump in on this thread, but i noticed you mentioned about using xp_fixeddrives to look at free disk space. I currently use this to alert me when a disk falls below a user defined MB size. I couldnt however find anything which told me the total disk size, and was therefore unable to work anything out on percentages (as mentioned above). How do you currently work out the total disk space?RegardsJohn |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-10-17 : 06:48:39
|
We launch a Batch file which does:DIR C:\*.* /ON /SDIR D:\*.* /ON /S...and we store all changed file details in the DB. We can then attempt to predict size of individually changing files over time - and alert if some virus or Muppet changes a bunch of file dates - as Slammer or one of those intruders did, and our ISP claimed their firewall wouldn't let it through and it was impossible that ANY files on our system had been changed by it. The DIR listing from the day before / after showed otherwise and they are no longer our ISP. Result!Kristen |
|
|
AnimalMagic
Starting Member
28 Posts |
Posted - 2007-10-17 : 06:51:51
|
For you both - and anyone else that wants it, i managed to find a script and amend it a bit to satisfy the request above. Thanks to the following link for the scripthttp://www.lazydba.com/sql/1__16047.htmlAnd here is the finished SP script (with the email bit added, and 2 variables added)-- Example -- exec sp_diskspace 10,10 (will send an email when any drive is below 10% free)SET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS OFFGOCREATE PROCEDURE sp_diskspace@CThreshold int,@OtherThreshold intASSET NOCOUNT ONDECLARE @hr intDECLARE @fso intDECLARE @drive char(1)DECLARE @odrive intDECLARE @TotalSize varchar(20) DECLARE @MB Numeric SET @MB = 1048576CREATE TABLE #drives (drive char(1) PRIMARY KEY, FreeSpace int NULL,TotalSize int NULL) INSERT #drives(drive,FreeSpace) EXEC master.dbo.xp_fixeddrives EXEC @hr=sp_OACreate 'Scripting.FileSystemObject',@fso OUT IF @hr <> 0 EXEC sp_OAGetErrorInfo @fsoDECLARE dcur CURSOR LOCAL FAST_FORWARDFOR SELECT drive from #drives ORDER by driveOPEN dcur FETCH NEXT FROM dcur INTO @driveWHILE @@FETCH_STATUS=0BEGINEXEC @hr = sp_OAMethod @fso,'GetDrive', @odrive OUT, @driveIF @hr <> 0 EXEC sp_OAGetErrorInfo @fso EXEC @hr =sp_OAGetProperty@odrive,'TotalSize', @TotalSize OUT IF @hr <> 0 EXEC sp_OAGetErrorInfo@odrive UPDATE #drives SET TotalSize=@TotalSize/@MB WHEREdrive=@drive FETCH NEXT FROM dcur INTO @driveEndClose dcurDEALLOCATE dcurEXEC @hr=sp_OADestroy @fso IF @hr <> 0 EXEC sp_OAGetErrorInfo @fso/*SELECTdrive, FreeSpace as 'Free(MB)', TotalSize as 'Total(MB)',CAST((FreeSpace/(TotalSize*1.0))*100.0 as int) as 'Free(%)' FROM #drivesORDER BY drive */declare @EmDrv varchar(3)declare @Emfree intdeclare @msg varchar(100)DECLARE emailcursor CURSOR LOCAL FAST_FORWARD FOR SELECT drive,CAST((FreeSpace/(TotalSize*1.0))*100.0 as int) from #drives ORDER by driveOPEN emailcursor FETCH NEXT FROM emailcursor INTO @EmDrv, @EmfreeWHILE @@FETCH_STATUS=0BEGIN if @EmDrv = 'C' and @EmFree <= @CThreshold Begin set @msg = 'Disk space on C is less than the threshold set: Down to ' + cast(@Emfree as varchar(10)) + '% Free' exec master..xp_sendmail @recipients = 'JohnMo', @message = @msg End if @EmDrv <> 'C' and @EmFree <= @OtherThreshold Begin set @msg = 'Disk space on C is less than the threshold set: Down to ' + cast(@Emfree as varchar(10)) + '% Free' exec master..xp_sendmail @recipients = 'JohnMo', @message = @msg EndFETCH NEXT FROM emailcursor INTO @EmDrv, @EmfreeENDClose emailcursorDEALLOCATE emailcursorDROP TABLE #drives ReturnGOSET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS ONGO |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-10-17 : 07:18:36
|
moved to script library._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
|
|
|