Skip to content

Instantly share code, notes, and snippets.

View mattiaswolff's full-sized avatar

Mattias Wolff mattiaswolff

View GitHub Profile
SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time / 1000/60 AS Total_Elapsed_Time_Min
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
order by 6 desc
@mattiaswolff
mattiaswolff / backend.conf
Last active September 11, 2015 16:18
logstash.conf
input {
udp {
type => "backend"
port => 5000
codec => multiline {
pattern => "^\w+\s+\w+\s+[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}.*$"
negate => "true"
what => "previous"
}
}
@mattiaswolff
mattiaswolff / backend.conf
Last active August 29, 2015 14:14
logstash config for azure iis logs
input {
file {
type => "backend"
path => "C:/Users/mattiasw/Desktop/logs/backend/*.txt"
start_position => "beginning"
codec => multiline {
pattern => "^\w+\s+[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}.*$"
negate => "true"
what => "previous"
}
SELECT
session_id,status,
command,sql_handle,database_id
,(SELECT text FROM sys.dm_exec_sql_text(sql_handle)) AS query_text
FROM sys.dm_exec_requests r
WHERE session_id >= 51
For more detail about was has been running, try:
select s.session_id, s.login_name, s.host_name, s.status,
@mattiaswolff
mattiaswolff / MediusCustom.xml
Last active December 16, 2015 13:39
Mediusflow XI: New relic custom functions
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (c) 2008-2014 New Relic, Inc. All rights reserved. --><!--
When you edit this file, please use an XML aware editor (such as Visual Studio),
and pair with the companion file extension.xsd to minimize the
chance of introducing typos that may confuse the agent when it is run.
--><extension xmlns="urn:newrelic-extension">
<instrumentation>
<tracerFactory>
<match assemblyName="Medius.Core.Platform" className="Medius.Core.Platform.Services.TaskManager">
<exactMethodMatcher methodName="CompleteTask" />
<exactMethodMatcher methodName="ShouldSaveTask" />
@mattiaswolff
mattiaswolff / gist:4469124
Last active December 10, 2015 17:38
Path with SQL Server Agent Tokens
D:\SQLData\MSSQL10.MSSQLSERVER\MSSQL\Log\ClearLogTable_$(ESCAPE_SQUOTE(JOBID))_$(ESCAPE_SQUOTE(STEPID))_$(ESCAPE_SQUOTE(STRTDT))_$(ESCAPE_SQUOTE(STRTTM)).txt
<system.webServer>
<urlCompression doDynamicCompression="true" />
</system.webServer>
@mattiaswolff
mattiaswolff / gist:3877589
Created October 12, 2012 06:14
SQL: Get SQL table size
DECLARE @TableName VARCHAR(100) --For storing values in the cursor
--Cursor to get the name of all user tables from the sysobjects listing
DECLARE tableCursor CURSOR
FOR
select [name]
from dbo.sysobjects
where OBJECTPROPERTY(id, N'IsUserTable') = 1
FOR READ ONLY
@mattiaswolff
mattiaswolff / gist:3781457
Created September 25, 2012 12:23
Mediusflow: Handlde errands where integration status not in sync
DECLARE @intErrandId integer
DECLARE @intPaymenttransferred integer
DECLARE @strVerificationIdentity nvarchar (20)
SET @intErrandId = [[Errand Id]]
SET @strVerificationIdentity = '[[Verification Identity]]'
-- Get payment transsferred status based on statusId
SELECT @intPaymenttransferred = CASE (e.statusid)
@mattiaswolff
mattiaswolff / gist:3760910
Created September 21, 2012 11:01
SQL: Database optimization script
USE [msdb]
GO
/****** Object: Job [MediusFlow optimization job] Script Date: 09/12/2012 18:24:14 ******/
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
/****** Object: JobCategory [[Uncategorized (Local)]]] Script Date: 09/12/2012 18:24:14 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
BEGIN