Debugging 64bit App Pools

December 7th, 2009 No comments »

So version 1.1 of MS Debug Diagnostics is currently the latest version of the debugger, however on Win 2008 x64 the only thing you can do with it directly is use the Analysis portion. It will not allow you to create dumps, so we will have to create one manually.

To capture a dump of an Application Pool we need to use adplus which is part of the debugging tools.  Adplus can be targeted at either a process name (w3wp.exe) or a PID.

To determine which PID belongs to our application pool we can use the native IIS tools:

H:\>%windir%\system32\inetsrv\appcmd list wp
WP “4072″ (applicationPool:RDWebAccess)

Then we can target that PID with adplus like this:

adplus –quiet –crash –p 4072 –o PATH_TO_DUMPFILE

Slow SQL Queries

December 2nd, 2009 No comments »

Here is a query that works with SQL 2005 to pull the top 100 slowest queries of a database:

SELECT TOP 100

[Object_Name] = object_name(st.objectid),

creation_time,

last_execution_time,

total_cpu_time = total_worker_time / 1000,

avg_cpu_time = (total_worker_time / execution_count) / 1000,

min_cpu_time = min_worker_time / 1000,

max_cpu_time = max_worker_time / 1000,

last_cpu_time = last_worker_time / 1000,

total_time_elapsed = total_elapsed_time / 1000 ,

avg_time_elapsed = (total_elapsed_time / execution_count) / 1000,

min_time_elapsed = min_elapsed_time / 1000,

max_time_elapsed = max_elapsed_time / 1000,

avg_physical_reads = total_physical_reads / execution_count,

avg_logical_reads = total_logical_reads / execution_count,

execution_count,

SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,

(

(

CASE statement_end_offset

WHEN -1 THEN DATALENGTH(st.text)

ELSE qs.statement_end_offset

END

- qs.statement_start_offset

) /2

) + 1

) as statement_text

FROM

sys.dm_exec_query_stats qs

CROSS APPLY

sys.dm_exec_sql_text(qs.sql_handle) st

ORDER BY

total_worker_time / execution_count DESC

Urchin Profile Stuck

November 12th, 2009 No comments »

Occasionally Urchin 5.x.x will stop processing data. If one looks in the scheduler section the parse will be labeled as running and typically only at 0%. In this situation, one needs to use the Urchin utils command line to reset some flags in the database so Urchin can run the report again. Typically the utils folder is located at C:\Program Files\Urchin5\utils>

Type all the commands in order substituting MyProfile for the name of the profile that is stuck.

uconf-driver action=set_parameter table=task name=”MyProfile” cr_runnow=0

uconf-driver action=set_parameter table=task name=”MyProfile” ct_runstatus=2

uconf-driver action=set_parameter table=task name=”MyProfile” ct_completed=0

uconf-driver action=set_parameter table=task name=”MyProfile” ct_status=1

uconf-driver action=set_parameter table=task name=”MyProfile” ct_lockid=0

Parsing the Windows logs for a Specific User.

October 26th, 2009 No comments »

Sometimes you need to know each time a user did something like logged in during a time period. Since the logs can be quite large, I’ve used this method to get results pretty fast. You will need Microsoft’s Log Parser 2.2 installed to use this query. In this case I have it set to look for the name Jeff, but that can be changed to any name.

logparser “SELECT TimeGenerated, SID, Message FROM Security, Application, System WHERE Message like ‘%jeff%’” -i:EVT -resolveSIDs ON > c:\logresult.txt

Script for Testing CDONTS

October 19th, 2009 No comments »

First a couple of notes. Cdonts.dll is not installed by default on Windows 2003. Typically you can grab it from an old Windows 2000 install CD. Upload it to %windir%\system32 directory.

The DLL needs to be registered once it’s uploaded. As long as it’s in the system32 directory, just go to Start -> Run.. and type:

regsvr32 cdonts.dll


<p style="margin: 0in; font-family: Verdana; font-size: 10pt;"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Test CDONTS asp Page</title>
</head>
<body bgcolor="#FFFFFF" text="#000033">
<div align="center">
<basefont face="ariallana" color="Black">
<b><font size="+1"><%= error%></font></b>
<%
message = message &amp;amp;amp; "==========Test==============" &amp;amp;amp; chr(13)
message = message &amp;amp;amp; "If you received this message, the CDONTS is working properly on your server" &amp;amp;amp; chr(13) &amp;amp;amp; chr(13)
message = message &amp;amp;amp; "Feel Free to modify this script to your needs to get your scripts working properly" &amp;amp;amp; chr(13) &amp;amp;amp; chr(13)
' Replace the email address below with your email address to test.'
MailTo = "youremailaddress@yourdomain.com"
MailFrom = "CDO-Test@domain.com"
if message <> "" then
set objNewMail = CreateObject("CDONTS.NewMail")
objNewMail.From = MailFrom
objNewMail.To = MailTo
objNewMail.Subject = "CDO Test Mail"
objNewMail.Body = message
objNewMail.BodyFormat = 0
objNewMail.MailFormat = 1
objNewMail.Importance = 1
objNewMail.Send
set objNewMail = Nothing
end if
%>
Thank you for testing the CDONTS on this server.<br>
Please check the email for <%= MailTo %> to verify it was successful
</body>
</html>
<p style="margin: 0in; font-family: Verdana; font-size: 10pt;"></p>
<p style="margin: 0in; font-family: Verdana; font-size: 10pt;">

Create a Dummy File for Testing

October 12th, 2009 No comments »

Sometimes you just need a specific sized file for something. For instance testing FTP transfers. This handy command line tool will create a file of any size for you. Just open a command prompt and type the following:

fsutil file creatnew myfile.txt <size>

You can replace myfile.txt with any file name and extension. Size will need to be a number in bytes. So for a 1GB file you can use 1073741824.

fsutil file createnew myfile.txt 1073741824

Install IIS6 to Somewhere Other than C:

October 5th, 2009 No comments »

Create a text file and name it answer.txt. Save it in a location that can be easily accessed via the command line. The root of the alternate partition is a good place. For this example we will install IIS on a partition that has been assigned the letter “D” Paste the information below inside the answer.txt file and save it.

[Components]
iis_common = on
iis_inetmgr = on
iis_www = on
iis_ftp = on
iis_smtp = on
iis_asp = on
aspnet= on

[InternetServer]
PathFTPRoot=”D:\InetPub\FTPRoot”
PathWWWRoot=”D:\InetPub\wwwroot”

Launch a command prompt and run the following command:

sysocmgr.exe /i:sysoc.inf /u:D:\answer.txt

If for some reason sysocmgr is not in the path you may need to run the command from within the system32 dirctory.

Mount a Windows Share From a Linux Client

September 28th, 2009 No comments »

I don’t work with Linux as often as Windows, but sometimes need to pull some data to a Linux box. It’s as much of a reference for me as anyone. I’ve used this on Ubuntu and Fedora, but it should work for pretty much any distro.

Test for a share:
smbclient -L <windows-box> -U <username>

Make a directoy for the mountpoint:
mkdir /mnt/<name-of-mountpoint>
For this example I will name the mountpoint ntserver

Mount the share utilizing cifs:
mount -t cifs //servername/share -o username=myUsername,password=myPassword /mnt/ntserver

Remove the share when finished:
Umount  /mnt/<mount-point>

Cdosys Test Script

September 21st, 2009 No comments »

This script can be used to test CDONTS mail functionality on a server. It’s very straightforward and simple. A typical use for this code is to troubleshoot the service without having to rely on code that could be buried deep in the code of a web app and may have bugs that interfere with the service.

1.    Create a file called testcdosys.asp and put it into a site.
2.    Insert the code below into the file.
3.    Ensure the MailTo and MailFrom fields are modified to valid values.
4.    Browse the file in a web browser.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Test CDOSYS</title>
</head>

<body bgcolor="#FFFFFF" text="#000033">
<div align="center">
<basefont face="ariallana" color="Black">
<b><font size="+1"><%= error%></font></b>

<p>

<%

message = message &amp;amp; "==========Test==============" &amp;amp; vbCrLf
message = message &amp;amp; "If you received this message, the CDOSYS is working properly on your server" &amp;amp; vbCrLf &amp;amp; vbCrLf
message = message &amp;amp; "Feel Free to modify this script to your needs to get your scripts working properly" &amp;amp; vbCrLf &amp;amp; vbCrLf

' Replace the email address below with your email address to test.'

MailTo = "youremailaddress@youdomain.com"
MailFrom = "CDOSYS-Test@yourdomain.com"

if message <> "" then

sch = "http://schemas.microsoft.com/cdo/configuration/"

Set cdoConfig = Server.CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item(sch &amp;amp; "sendusing") = 1 ' cdoSendUsingPickup
.Item(sch &amp;amp; "smtpserver") = "127.0.0.1"
.update
End With

Set cdoMessage = Server.CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = MailFrom
.To = MailTo
.Subject = "CDOSYS Test Mail"
.TextBody = message
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing

end if

%><p>Thank you for testing the CDOSYS on this server.<br>
Please check the email for <%= MailTo %> to verify it was successful
</body>
</html>

Move IIS6 to an Alternative Partition

September 14th, 2009 1 comment »

In this example I will assume that IIS is currently located at “C:\InetPub” and it’s logs are located at  “C:\iislogs.” Both directories will be migrated to the “D:” partition.

1. Stop all IIS services
This can be done via the command line by going to Start -> Run -> cmd and using the command net stop http /y .
Or this can be done via the services snap in by going to Start -> Run -> services.msc. Once in the services menu, locate the IIS Admin Service. Right-Click the service and select Stop. A message will appear listing all the services that will be set to stopped. Click Ok.

2.    Copy the folder  and contents of “C:\inetpub” and “C:\iislogs” to D:

3.    Create a backup of the metabase by making a copy of the metabase.xml file located at “c:\windows\system32\inetsrv” and rename to metabase.xml.bak

4.    Using a text editor with a find and replace feature, open the metabase.xml file and replace instances of “C:” with “D:” Be very careful to not use an automated accept method, ensure that the text editor ask for confirmation for each line change before applying it. Specifically you are looking for lines similar to:
Path=”C:\Inetpub\wwwroot” which would be changed to Path=”D:\Inetpub\wwwroot”
LogFileDirectory=”C:\IISLogs” which would be changed to LogFileDirectory=”D:\IISLogs”

5.    Launch the registry editor. Start -> Run -> regedit

6.    Locate the key hklm\system\currentcontrolset\services\http\parameters

7.    Locate the key “ErrorLoggingDir” and modify the value to D:\IISLogs. This key may have to be created if you have never modified the location of your IIS log files.

8.    Reboot the server to apply the updated registry settings.

9.    After the reboot it is recommended to review the Windows Event logs for errors.