November 2005 - Posts

Awhile back I started at a new customer doing some project work and some production support work (sigh). One thing the customer requested was for a DBA to run a script on all production servers and review the output to make sure nothing was wrong, then email a summary to the other DBAs so they also knew nothing was wrong.  The interesting thing was that there was no clear cut set of criteria of what "wrong" was.  This all sounded rather automatable to me, so I set out to save myself and fellow DBAs some time and learn some things I had been meaning to learn, namely Reporting Services. 

In addition to saving time every day,  I also wanted to be able to track some stats that were collected over time, especially things like disk space remaining, DB size, etc.  The current monitoring solution employed by the customer didn't have this feature, so it would be a helpful addition.  I also wanted to nail down what the DBAs were looking for, so there was consistency in the monitoring, and I wanted to make it a push subscription instead of having to physically do something each day. Here's was I did.

First I created a new DBA database on each server to be monitored.  Then I turned pieces of the daily monitoring script the DBAs were using into stored procedures, but I altered them only to collect data that I didn't already have or didn't care about - no dups, no extra error messages, nothing I didn't want to see. BTW, this gave me a lot of cool scripts to use in other engagements, too. Next I scheduled these stored procs to run each day, collecting data to tables in my DBA database.

Next I created a repository for centralized reporting - a monitoring ODS of sorts.  The tables in the repository were identical in structure to the local server repositories.  I then created a DTS package to copy the data from the source server to the repository.  This would run each night sometime after the stored procs were executed on each server.

Finally, I created some reports.  The first reports were detail reports for things like errorlogs, backups, jobs, etc. The really important report was the summary report(see below), which the DBA team subscribes to as a daily email.  It basically provides a dash board for each production server. You can see at a glance where the problems are.  Oh, yeah, I also worked with the DBAs to determine what "wrong" meant, and what were acceptable thresholds for the things to be monitored. Each of the items drills down into the detail reports, so you can see specific data on each server.  So if you see something is "Not OK", you can find out why. (Note there's a lot of conditional formatting that you can't see unfortunately due to some limitations either of the posting tool, or my HTML abilities)

Daily Monitoring Summary
Server Name Backup Status Error Log Status Job Status Disk Status  
Server1 OK OK OK OK  
Server2 OK OK OK OK  
Server3 OK OK OK OK  
Server4 OK NOT OK OK OK  
Server5 OK OK OK OK  
Server6 OK OK OK OK  
Server7 OK OK OK OK  
Server8 OK NOT OK OK OK  
Server9 OK OK OK OK  
Server10 OK NOT OK OK OK  
Server11 OK NOT OK OK OK  
Server12 OK OK OK OK  

I thought this was pretty cool.  It has saved quite a bit of time.  We estimate it saves about 2-3 hours a week.  That's a good bit of savings.

I have lots of ideas of how to improve it including more parameterization and categories to check.  I've also thought about creating an online service where maybe people submit an XML document over SOAP with the details from each server to monitor, and then they can use the reports for their own environment.  Just a thought.

I'm sure I'm not the only one to do something like this. What have you done?

Jon

 

with 0 Comments

I came across something where I was executing a util from xp_cmdshell (:$), and it behaved differently in Windows 2003 than in Windows 2000.  Thus the need for some code to determine which version of Windows my SQL box sits on.  Here's my shot at it.  Anyone have a better idea?

select case

when substring(@@version, charindex('5.',@@version), 3) > '5.0' THEN '2003'

ELSE '2000'

END

with 1 Comments

As most SQL Server users know Enterprise Manager, and I believe Visual Studio, saved Stored Procedures with a .PRC extension when saving to a file.  However, when you open files with this extension in SQL Server Management Studio, the file is not available to edit.  This was at first very strange and annoying, so I went digging.  In Tools | Options you can set the Text Editor for specific file extensions.  Microsoft in their benevolent wisdom has not included .PRC in the list of file extensions for RTM :-P.  If you add it yourself, all will be well. 

BTW...I also checked the box to open extensionless files in a Source Code (Text) Editor.  I thought this would be less annoying than if I tried opening say a binary file, and it tried to open in a SQL Editor.

Hopefully, this is helpful. 

Jon Baker

with 0 Comments

After my presentation Tuesday in Detroit, there were a couple of questions about Database Mail. 

The first was about how to setup profiles.  That answer is relatively easy, so I'll take a little time and address it.  First open SQL Server Surface Area Config and turn on Database Mail.  You can also do this from sp_configure. 

sp_configure 'Database Mail XPs', 1

Next open SSMS and navigate to the Management Folder. Right Click on Database Mail.  Follow the wizard to create a profile specifying a name for the sender and reply to accounts and point to the appropriate SMTP server.  I found this to be really straightforward and not worth belabouring in this post.  If you have questions, feel free to email.  I'll walk you through it.

The other was a question that was really insightful (my apologies for not having your name to give you credit). He asked if it would be possible to use SQL Server 2005 Database Mail to email query results from SQL Server 2000 instance over a linked server.  I could not come up with a reason why this would not work, but I thought I'd test it just to be sure. 

Before we do that, you might be saying, why would you want to do that.  Well, if you want to avoid using a MAPI client on your server, and you want to have the feature to attach query results to an email, this was fairly difficult in SQL 2000.  You could use Gert Drapers' xp_smtp_sendmail (http://www.sqldev.net/xp/xpsmtp.htm) and pick up a result file from a disk to attach and email, but that was cumbersome.  The native xp_sendmail has that nice feature just to include the results in the body of an email or as an attachment, which many I like very much.

Below is the result of that test as well as some sample queries and descriptions about the setup.

ServerA = SQL Server 2005 (RTM)

ServerB = SQL Server 2000 (SP3a+818 hotfix)

First, setup Linked Server on ServerA pointing to ServerB

EXEC master.dbo.sp_addlinkedserver @server = N'ServerB', @srvproduct=N'SQL Server'
GO

Next, Setup Security for the linked server.  For my test I just set all users to be impersonated as SA.  Of course, don't do this in production.  You'll want to setup an account for this, or allow the service account for ServerA access on ServerB.

Finally, execute the stored procedure and specify the query and to attach results in a file

EXEC msdb.dbo.sp_send_dbmail

@recipients=N'jon@evergreencco.com',

@body=N'Test', @query =N'select * from ServerB.dba_repository.dbo.dba_servers',

@attach_query_result_as_file = 1, @profile_name = 'test'

;

This absolutely yielded the results I'd hoped for!  I received an email with the query results attached.

So you can begin eliminating MAPI from your servers right away, just by putting up one instance of SQL Server 2005 and using linked servers and database mail.  Thank you again to the very bright attenders at the Detroit launch event for your suggestions on this one.  Great idea!

Jon

 

with 1 Comments

I would like to be able to open the same file connected to multiple instances at the same time.  Today if I open the file and connect to instanceA, then try to open the file and connect to instanceB, Management Studio just takes me back to the original document connected to instanceA.  Yes, I could just change connection, but I want to be able to run a script against multiple environments at the same time.  I know I could use SQLCMD commands, but I don't want to.

This just seems to be a bug in the interface that could easily be corrected. I'm sending to SQLWISH to see what happens.  Will post back here if I get a reply

 

Jon

with 3 Comments

The crowd is huge with over 2200 people at the Rennaissance Center - well those who could find it (Mapquest directions were a little off).  The keynote was hilarious.  David White actually changed clothes in the middle of the presentation to represent the difference between a developer and a DBA.  Nice!

I'm sitting in the speaker lounge working on the slides for the Thursday User Group event, talking to Kai Axford.  He just told me about Culminis, the IT Pro version of INETA.  http://usa.culminis.com/.  They provide speakers for local user groups.  I'm definitely looking into this.

We'll be heading to the ATE session in just a minute.  Right now, I'm trying to learn my lines to transform into Bond, James Bond - using the gadgets of  SQL Server to monitor and profile my arch-enemy, those infamous developers! 

Letterman fans, there's plenty of Explod-A-Pop popcorn for anyone who asks questions.  That's right America's only Atomic Popping corn.  Nothing but the best for our audience.

 

Jon

with 0 Comments

I just started looking through the DVDs that arrived in the mail for the launch event next week.  You already know about Microsoft giving away SQL Server and Visual Studio 2005 to all attendees.  There is another give away!  I don't want to steal Microsoft's thunder, but it is related to another announcement they are making at the events.  It's not Biztalk, but you will probably be excited about it. 

I haven't heard from anyone going to the Detroit event, but I know it's full.  If you are going, let me know.  I'll be in the Ask the Expert area from 1:30 to 3:30, and presenting the Data Platform track, Managing and Monitoring SQL Server 2005.  Stop by and say Hello!

Jon Baker

 

with 1 Comments

A friend of mine, Dave Donaldson, has created a cool online service, www.codekeep.net.  It allows you to store, search, retrieve, and share code snippets or scripts that you think others might find handy.  It comes with a great add-in for Visual Studio. It doesn't look like it will work for Management Studio, yet, but I'm sure Dave will keep it up to date.  I've already started uploading my scripts, so I can get to them no matter where I might be or if I've forgotten my USB key :)

Here's a link to the RSS feed for CodeKeep to stay up on the latest updates. http://www.codekeep.net/rss.aspx?id=Main

Do you use code snippets?  How do you keep track of them?  What about version control?  Share your thoughts on this.

BTW...Dave was just named a C# MVP.  If you know Dave, send him an email congratulating him.

Jon

 

with 1 Comments

This is a RANT.  I just want to spell that out right away.  I've been trying for 2 days to sign up for the SQL Server 2005 beta exams online, but it is much harder than you might think.  I expect a big shiny button that says SIGN UP HERE, but no, I've been digging and still can't find it. Yes I've been invited to participate, and I've created all the proper accounts to login and sign up, but I can't find the exams I want to take!  Argh. 

Am I the only one to have this problem?

 

 

with 4 Comments