Need automation script to detect deadlocks in a system.

Hi ,
I need a automation script to detect deadlocks in my system.  If any body have any scripts. please share with me.. that would be very helpful to me.
Note : if i ran the script that would show the list of deadlock occurred in my system that must be automatic process..
Thanks in advance
Yangamuni Prasad M

Hi pradas,
you can even runthe following and as uri Said Traceflag 1222 must be on (DBCC TRACEON(1222, -1).
IF
OBJECT_ID(
'dbo.usp_DeadlockNotification')
IS NOT NULL
DROP
PROC dbo.usp_DeadlockNotification
--GO
CREATE
PROC dbo.usp_DeadlockNotification
@FilterBIT
= 0,
@Minutes
INT = 30
AS
DECLARE @ErrorLog
TABLE
LogDate
DATETIME NOT
NULL,
ProcessInfo
VARCHAR(75),
LogInfo
VARCHAR(MAX)
create a SQL job and run
DECLARE @Count
INT,
@StartDate
DATETIME,
@EndDate
DATETIME
SET @Count
= 0
SET
NOCOUNT ON
-- Step I: Import Errorlog
INSERT
INTO @Errorlog
EXEC
xp_readerrorlog
---- Step II: How to search Errorlog
IF
(@Filter
<> 0)
BEGIN
SELECT @EndDate
= GETDATE()
SELECT @StartDate
= DATEADD(mi,
-@Minutes, @EndDate)
SELECT @Count
= COUNT(*)
FROM @Errorlog
WHERE LogDate
BETWEEN @StartDate AND @EndDate
AND LogInfo
LIKE '%Deadlock%'
END
ELSE
BEGIN
SELECT @Count
= COUNT(*)
FROM @Errorlog
WHERE LogInfo
LIKE '%Deadlock%'
END
---- Step III: Send Email
IF
(@Count
> 0)
BEGIN
EXEC msdb.dbo.sp_send_dbmail
@profile_name
= 'ABC',
@recipients
= '[email protected]',
@subject
= 'Deadlocks',
@body
= 'Deadlocks'
END
Create a agent job and schedule it accordingly as per you requirment and add following step in the job
EXEC dbo.usp_DeadlockNotification 1, 30
Thanks,Suhas V

Similar Messages

  • I need an automator script to play a folder of movies

    I have a folder of quicktime movies. I have a Mac Mini with Lion. I have a TV. I need an automator script to grab the list of movie files from the folder and play them full-screen, one-by-one and then loop through the process to continue playing them, unattended, all day.
    I cannot get the proper steps in automator to accomplish this (seems to me it should be easy) job.
    Any ideas?
    Doug Jansen
    Tokyo

    Dave,
    Thanks for the tip. I didn't know that Quick Look would display a folder of files one-by-one. Once I set the first file to full screen, the rest also played full screen one after the other. Now I need a way to automatically launch Quick Look, set full screen and loop. This site http://automator.us/leopard/downloads/index.html has an automator action that uses Quick View, but on my Lion machine it just displays the first movie and only the first frame of the movie. It stops at that point.

  • Writing commands to get specific data channels in the output report via script or automated script generation..

    In my project I have to make certain calculation and then get the data plotted in the given report template. I am using automated script for this. My script is doing all the calculations and then it not selecting and drag-dropping the selected channels on the report template. Its saving the blank report template.
    I am struggling to get the data for specific channels plotted by using the script. I need the selected channels to be plotted on this report template and then get it saved.
    Any help will be deeply appreciated. Thanks
    Solved!
    Go to Solution.

    Hi LaxG,
    Brad is absolute right. It is possible to create your whole layout via script.
    If you have loaded  the example report layout you can copy these lines to create a new line in your plot. This is the recommended object oriented way.
    call Report.Sheets("Blatt 1").Objects("2D-Axis1").Curves2D.Add(e2DShapeLine, "anyName")
    Report.Sheets("Blatt 1").Objects("2D-Axis1").Curves2D.Item("anyName").Shape.XChannel.Reference               = "[1]/Zeit"
    Report.Sheets("Blatt 1").Objects("2D-Axis1").Curves2D.Item("anyName").Shape.YChannel.Reference               = "[1]/Geschwindigkeit"
    For performance reasons it's recommended to use the it like this.
    dim oLine
    set oLine = Report.Sheets("Blatt 1").Objects("2D-Axis1").Curves2D.Item("anyName").Shape
    oLine.XChannel.Reference               = "[1]/Zeit"
    oLine.YChannel.Reference               = "[1]/Geschwindigkeit"
    Like Brad mentioned it is much easier, that you have a stored template of your report with all setings and customisations already done.
    You open this layout file and have stored the names of your calculated channels. When you are doing this with a script they always have the same name and belong to the same group.
    Now you can customize the references of the line items.
    Kind Regards,
    Philipp K.
    AE | NI Germany

  • Using a SecureString password in an automated script?

    Hello all,
    I've been having issues getting a secure string to work with an automated script.
    Basically, a piece of software we use can accept commands via powershell/command shell but requires a password for the commands to be run.
    I've spent a fair amount of time researching the ConvertFrom and ConvertTo methods and tried without success. (When trying to use the ConvertFrom/To methods the software gives back incorrect password errors).
    Can anyone please assist?

    Hi Jonathan,
    you can simply use the $SecurePassword variable from Basty's example (if you need a secure string) and pass this as Password. Please note though, this will only work if the account writing the credentials to file is also the same account used to read it
    from file.
    If you need to encode it for another account (like local system), you can use the
    Encrypt-Credential function-script (The example on how to retrieve a clear-text password in memory will also work with Basty's $cred object).
    On a final note:
    Encrypted or not, try to avoid writing passwords down if you can somehow avoid it. If possible, assign permissions to the account running the task, if the service you are accessing supports windows authentication and privileges.
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • Service failure automation script

    Hi All,
    I have configured the below mentioned code on our prod servers services to send email notifications when ever a service fails. 
    On Error Resume Next
    strComputer = "USDFW16AS61"
    Const cdoSendUsingPickup = 1
    Const cdoSendUsingPort = 2
    'Function block to dynamically retrieve the file size of the report file.
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    'Authentication type used for SMTP server.
    'We are currently using 0, cdoAnonymous
    Const cdoAnonymous = 0 'Do not authenticate
    Const cdoBasic = 1 'basic (clear-text) authentication
    Const cdoNTLM = 2 'NTLM
    'Creates message subject, we are using variables declared earlier in the script
    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "CMS Production service iwutild is stopped"
    'Sets the From address
    objMessage.From = """Support DL"[email protected]
    'Sets the destination, or TO address
    objMessage.To = [email protected]
    'Sets the CC address. Only used for testing purpose at the moment. Should be commented out when in use.
    'objMessage.CC = ""
    'Sets the message body, the actual email message. Variables are used in the message which was declared earlier.
    objMessage.TextBody = "Dear Administrators, the xyz service is now in STOPPED state." & vbCRLF & vbCRLF & "Please do not reply to this message as it was sent to you by an automated Script."& vbCRLF & vbCRLF &
    "Thanks and regards"
    'objMessage.TextBody = "Dear Application Administrators,"  & vbCRLF & ""& vbCRLF & ""& vbCRLF &
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    'Name or IP of Remote SMTP Server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "servername"
    'Type of authentication, NONE, Basic (Base64 encoded), NTLM
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous
    'Your UserID on the SMTP server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusername") = ""
    'Your password on the SMTP server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""
    'Server port (typically 25)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    'Use SSL for the connection (False or True)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
    'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    objMessage.Configuration.Fields.Update
    '==End remote SMTP server configuration section==
    'Sends the message using code.
    objMessage.Send
    This script is able to send notification only for the respective service that I have configured it to Run upon failure.
    My requirement now is that the script should be able to detect out of the 6 app services that are down & should append the email body with the name of that service & send an email.
    I understand Wscript.argument(0) can be of use but not able to use it. Could you kindly help?
    Thanks,
    Pankaj
    P.S: I am not a developer, so kindly bear with me :)
    Pankaj Dhoot

    Hi Pankaj,
    To solve the script issue, I would like to recommend you to post in the Visual Studio Languages forum for more effective support:
    http://social.msdn.microsoft.com/Forums/en-US/home?category=vslanguages
    or The Official Scripting Guys Forum!
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG&filter=alltypes&sort=lastpostdesc
    Thank you for your understanding.

  • I need a script that copies the filename into the file

    I need a script that copies the filename into 4th column of each line in the text doc file.
    I have over 2000 different file names each containing 6 columns and ~50-100 rows.
    I can do this manually using this script:
    awk '{print $1"\t"$2"t\"$3"\t <name> \t"$6}'
    But I would like an automation command or script. Is there any command that I can use instead of <name> that will copy the filename into the column?
    Thanks
    Monica

    Oops, I forgot the redirect to a file. It's not a good idea to edit files in place. A script could fail and you're left with at least one file ruined. It's better to create new files then delete the old files.
    for file in *; do
        while read col1 col2 col3 col4 col5 col6; do              
            printf "%s\t%s\t%s\t%s\t%s\n" $col1 $col2 $col3 $file $col6
        done < $file > n$file
    done
    You could narrow the files listed such as
    for file in *.tsv
    and redirect the new files to another directory. Such as
    done < $file > /absolute/path/to/directory/$file

  • Location of iCal Automator Scripts (Plugins?)

    AHHHH.  Apple you drive me crazy with this stuff!!!
    I need to alter an automator script I made for iCal.   ...  but I can't figure out where these things are stored in my hidden, buried, locked and unalterable system.  If I open a iCal set up in Automator, create something new and his save -- where is tha new file hidden!  I've looked everywhere!

    Finally found it.  It's under ~/Library/Workflows/
    Just in case anybody else runs into this problem.

  • Automator Script - How to Batch Convert PDF files to max 200x200px JPG Files

    I have tried several different Automator scripts and can't seem to get it right.
    Each day I have 25 different PDF files. I need to convert the first page of each PDF file to a max width and height of 200x200px jpg file (not jpeg).
    In automator, how do you do a batch convert of the first page of PDF files to a max width and height of 200x200 JPG files?
    Thanks!

    Try
    GraphicsMagick.

  • Copy Automator Script

    I have an iMac G4 running Mac OS 10.4.11 on which I created an Automator script years ago. I now need to have that script on an iMac G5 running Mac OS 10.5.8. Can I just copy the script on the G4 and put it on the G5? I'm assuming the script is stored in either the ~/Library/Automator or HD/Library/Automator folders (I can't recall if I made the script for all accounts or just for one).

    Well, I can't find it there and Mac OS 10.4.11 doesn't have an Automator folder in either Library folder. I have an alias on the Desktop of the G4 to the script I created years ago, but neither Get Info nor Spotlight shows the actual file. I guess I'll have to ask in the Mac OS 10.4 forum.

  • Help with simple Automator script

    I have a simple Automator script for updating a specified folder with files from another folder. It consists of only two actions:
    1. Get Folder Contents (from the folder I drop on the Automator executable).
    2. Copy Finder Items.
    I left the option "replace existing files" unchecked because there's no point in replacing a bunch of files that already exist (we're talking about 4000-5000 files in the source folder).  I assumed that meant to ignore any existing files but, on the contrary, I found out that the script is copying duplicates of all the existing files -- making my target folder about 9000 files strong!
    How do I get a command into the middle of this script to restrict the Copy Finder Items command to files that do not already exist in the target folder? (It would be even nicer if it could check for files that are older than the files being copied and actually replace (only) those as well.)
    Any ideas?

    If you need the Terminal window to stay open, then you're looking at scripting Terminal. You can do this with Automator's run applescript action, or you can just use Script Editor (in Applications > AppleScript). Either way you will need to save the workflow/script as an application and drag it to your Login Items (in System Preferences > Accounts).
    click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">tell application "Terminal"
    activate
    set commands to "cd /Users/lenny/ventrilo/ 
    /Users/lenny/ventrilo/ventrilo_srv"
    do script commands in front window
    end tell</pre>
    PowerMac G5 (June 2004) 2x1.8GHz 1.25GB, PowerBook G4 (12-inch DVI) 1x1GHz 768MB   Mac OS X (10.4.3)  

  • Need a script for archive/copy IMAP Emails older than 25 days to local mailbox

    Hi there,
    I am really troubling with archiving my IMAP mails. So far I was using standard rules, which have a major drawback - they only work on incoming mails. But I want to copy only mails to my local mailbox that are older than 25 days. The reason is that by copying all incoming mails, mail also copies all spam and unimportant mails into the local mailbox. However I only want to copy the mails that I was able to read and consider to be important, which I am able to do within a couple of days. However, I am not able to to that on a daily basis and that is why I chose the 25 days window, because my hoster deletes them automatically after 30 days. I read in a lot of forums that rules wont help, since they only work for incoming mails, therefore I am guessing that I would need a script because I want this to be automated and only applied to mails that passed the 25 day timeframe. Is the anybody that could help me out? Thank you so much in advance.

    Hi adayzdone,
    thanks for your reply but I am not a Gmail user, I am using Strato. Therefore the handy Google Scripts won't help.
    I need a script in Apple, that only copies or moves the mail from my inbox to a local mailbox once they are past the 25 days line. Within those 25 day I have deleted all unnessecary mails, marks or higlighted the important once and know only the remaining once are worth keeping. But I still want them to be available in Mail and none of those archiving solutions that create pdfs or import them into their one database will help.

  • Automator Script to move GPS data out of iPhoto

    Hi All,
    I've been looking for ways to get my photo library out of iphoto, and do so with all of the GPS data I added through the iPhoto interface and I have a solution. Unfortunately I have to enter commands one file at a time (and I have 12000 photos!). I was hoping some Automator experts here might be able to help me out.
    My plan is this:
    1.     Export "Original" files, sorted by Event Name.
    2.     Export jpegs with location data included in to a separate but itentical directory tree.
    3.     Use the command line tool "exiftool" to move GPS data from each file to the original.
    This will preserve my RAW files, and inlcude the data I want. I've made it work one file at a time with the following command:
    exiftool -overwrite_original_in_place -tagsFromFile ~/Pictures/iPhoto\ Export\ \-\ jpeg/Event\ Name/001.jpg -gps:all ~/Pictures/iPhoto\ Export\ \-\ RAW/Event\ Name/001.NEF
    So essentially I need an Automator script to take the output of an "ls" command with fill directory ftree for each file, put that in as the first argument, then change the file name and directory tree from jpeg to RAW and put that in as the econd argument, and run it for 12000 files. Anyone have any ideas?
    Thanks a ton to anyone who can respond.

    That's correct. Although the project file might suggest otherwise, the physical project structure for the initial Creator release is fixed, patterned after the Jakarta source structure http://jakarta.apache.org/tomcat/tomcat-5.0-doc/appdev/source.html
    Importing existing project structures is likely to become a priority in future updates/releases.

  • Is there anyway to have an Automator script working on any OSX computer?

    Hi,
    I'm trying to have an automator script working on computer from 10.5 to 10.8. I have two issues.
    First, some action are outofdate on 10.5 (like the finder filter)
    Second, I use a custom action to upload a text file on a server. This action is unknown on the other computers. How can I embed it on my script in order to have it working?
    Thanks for your support!

    An action can specify the resources that it needs, which will trigger alerts if they are not there.  Assuming that the system resources are there, you can include actions in an application bundle - see the Installing Actions section of the Automator Programming Guide.

  • Automated script for deploying, removing, install again the WSP using stsadm command line

    Hi,
    Am having a requirement in my  staging and  prod  env. to add, install,retract and remove wsp.
    In my dev env i used to perform with  Visual Studio ,so i didnt  face any issues regarding retracting and removing the wsp from solution store.
    But in my staging and prod since i dont hav VS installed, i would like to have a automated script[ NOT in POWERSHELL] using stsadm command line tool which adds the solution from a folder [say D:\DeployWSPs in staging and Prod] to the solution
    store  and installed onto a particular web application [  NOT "All WebApplications"].
    and if  the wsp already exists , i need to retract it & remove from solution store and add it and install again.
    can someone pls help me with the  automated script .also if  the folder contains multiple WSPs how can i doa  for each loop [ iterate through  wach ".wsp"  file and perform install/...task].
    i know stsadm -o adddsolution, deletesolution,m retractsolution etc. But the issue is that customer asked me to do this ina automated fashion.  manually entering all these commands is a  cumbersome activity.
    note: when i used powershell on 2 / 3 occasions, the wsp was retracted successfully,but failed to successfully remove from the
    soln store.
    so i thought i will depend upon on stsadm again like old version of SP since its supported.
    Das

    I would recommend you to use Power Shell so that you can do the automation easily. You can use
    power shell for earlier version of SharePoint as well. 
    Look why removing the solution is getting failed. May be you are trying to remove before the solution is retracted. Wait for retract and remove the solution. Refer to the following post for more information
    http://www.codeproject.com/Articles/570011/PowerShellplus-plusWaitplusforplusRetractplus-fpl
    http://consultingblogs.emc.com/mattlally/archive/2011/03/29/sharepoint-server-2010-multiple-solution-deployment-script.aspx
    Cheers,

  • Automator scripts

    Hello to All.
    I would ask a question to those who use Automator to perform regular, mundane questions.
    Which Automator scripts, available in the downloads section of Apple's website, are worth taking on board in respect of photography in your opinion?
    I am shortly going to begin using AP2 to download and archive RAW images and those images that need adjustments will be made in Photoshop CS3.
    I hope I have understood that the transfer to CS3 from AP2 needs no Automator scripts but I expect further down the line Leopard will come into its own for everyday functions I can't think of now!!
    Any tips and quips welcome. Thanks in advance.

    Try this
    http://automator.us/leopard/aperture/

Maybe you are looking for