powershell -Command "Send-MailMessage -To to@recepient.com -Cc cc@recepient.com -From from@sender.com -SmtpServer 127.0.0.1 -Subject $('Mail from computer: ' + (hostname)) -Body $((date).ToString() + ' Mail from computer: ' + (hostname))
Wednesday, June 25, 2014
Tuesday, June 24, 2014
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot find the user 'AdtServer', because it does not exist or you do not have permission
I was installing SCOM ACS 2012 R2 and configuring it to use SQL authentication. This is not to collect events from an untrusted domain, I was just implementing redundant ACS collectors as described here which would require the collectors to use SQL authentication to connect to the backend database.
ACS setup completed successfully on all ACS collector servers, but the Audit Collection Services shuts down shortly after starting and logs this event
Error occured on database connection:
Status: 0x04080000
ODBC Error: 15151
ODBC State: 42000
Message: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot find the user 'AdtServer', because it does not exist or you do not have permission.
Database: SqlWriter
Connection: Maintenance
Statement:
/**********************************************************
The reason this happened was because I precreated the SQL account and gave it dbcreator role then supplied it to the ACS setup. I then discovered that the ACS installer would actually create the account itself, surprisingly it did not complain that the account already existed and completed successfully but apparently something was still broken.
I uninstalled ACS, deleted the SQL account then reinstalled ACS and now it works.
ACS setup completed successfully on all ACS collector servers, but the Audit Collection Services shuts down shortly after starting and logs this event
Error occured on database connection:
Status: 0x04080000
ODBC Error: 15151
ODBC State: 42000
Message: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot find the user 'AdtServer', because it does not exist or you do not have permission.
Database: SqlWriter
Connection: Maintenance
Statement:
/**********************************************************
The reason this happened was because I precreated the SQL account and gave it dbcreator role then supplied it to the ACS setup. I then discovered that the ACS installer would actually create the account itself, surprisingly it did not complain that the account already existed and completed successfully but apparently something was still broken.
I uninstalled ACS, deleted the SQL account then reinstalled ACS and now it works.
Wednesday, June 4, 2014
Find MAC address of a physical NIC after it has been assigned to Hyper-V Virtual Network
wmic nic get netconnectionid,macaddress
Sunday, September 22, 2013
The SQL Server (MSSQLSERVER) service terminated with service-specific error %%17058.
While trying to failover the SQL server to another node, it refused to start and this error was getting logged in the Event Viewer
The SQL Server (MSSQLSERVER) service terminated with service-specific error %%17058.
The problem turned out to be with ERRORLOG being set to read only.
After I cleared the read only attribute from MSSQL\LOG\ERRORLOG the service started successfully.
The SQL Server (MSSQLSERVER) service terminated with service-specific error %%17058.
The problem turned out to be with ERRORLOG being set to read only.
After I cleared the read only attribute from MSSQL\LOG\ERRORLOG the service started successfully.
Tuesday, April 2, 2013
Top SQL Queries
select
highest_cpu_queries.plan_handle,
highest_cpu_queries.total_worker_time,
highest_cpu_queries.total_logical_reads,
highest_cpu_queries.total_logical_writes,
highest_cpu_queries.execution_count,
q.dbid,
q.objectid,
q.number,
q.encrypted,
q.[text]
from
(select top 20
qs.plan_handle,
qs.total_worker_time,
qs.total_logical_reads,
qs.total_logical_writes,
qs.execution_count
from
sys.dm_exec_query_stats qs
order by qs.total_worker_time desc) as highest_cpu_queries
cross apply sys.dm_exec_sql_text(plan_handle) as q
order by highest_cpu_queries.total_worker_time desc
--order by highest_cpu_queries.total_logical_reads desc
--order by highest_cpu_queries.total_logical_writes desc
--order by highest_cpu_queries.execution_count desc
--select top 10 * from sys.dm_exec_query_stats qs
highest_cpu_queries.plan_handle,
highest_cpu_queries.total_worker_time,
highest_cpu_queries.total_logical_reads,
highest_cpu_queries.total_logical_writes,
highest_cpu_queries.execution_count,
q.dbid,
q.objectid,
q.number,
q.encrypted,
q.[text]
from
(select top 20
qs.plan_handle,
qs.total_worker_time,
qs.total_logical_reads,
qs.total_logical_writes,
qs.execution_count
from
sys.dm_exec_query_stats qs
order by qs.total_worker_time desc) as highest_cpu_queries
cross apply sys.dm_exec_sql_text(plan_handle) as q
order by highest_cpu_queries.total_worker_time desc
--order by highest_cpu_queries.total_logical_reads desc
--order by highest_cpu_queries.total_logical_writes desc
--order by highest_cpu_queries.execution_count desc
--select top 10 * from sys.dm_exec_query_stats qs
Thursday, March 28, 2013
Converting IIS logs time from UTC to local time
If you notice that the time logged in IIS logs does not match your server's local time, this is because IIS logs time in UTC (GMT) to conform with the W3C log format so if you are in a different time zone for example UTC -3 you will find the time 3 hours ahead in the logs.
To change that, you can choose a different log format from the IIS manager or you can convert the log file using Log Parser.
Download and install Log Parser then run the following command
LogParser.exe "SELECT DATE,TO_LOCALTIME(time) AS time,s-ip,cs-method,cs-uri-stem,cs-uri-query,s-port,cs-username,c-ip,cs(User-Agent),sc-status,sc-substatus,sc-win32-status,time-taken INTO c:\ayman\output.log FROM c:\ayman\input.log" -i:IISW3C -o:W3C
To change that, you can choose a different log format from the IIS manager or you can convert the log file using Log Parser.
Download and install Log Parser then run the following command
LogParser.exe "SELECT DATE,TO_LOCALTIME(time) AS time,s-ip,cs-method,cs-uri-stem,cs-uri-query,s-port,cs-username,c-ip,cs(User-Agent),sc-status,sc-substatus,sc-win32-status,time-taken INTO c:\ayman\output.log FROM c:\ayman\input.log" -i:IISW3C -o:W3C
Wednesday, March 27, 2013
Check for TempDB PAGELATCH waits
SELECT
session_id,
wait_type,
wait_duration_ms,
blocking_session_id,
resource_description,
ResourceType = CASE
WHEN PageID = 1 OR PageID % 8088 = 0 THEN 'Is PFS Page'
WHEN PageID = 2 OR PageID % 511232 = 0 THEN 'Is GAM Page'
WHEN PageID = 3 OR (PageID - 1) % 511232 = 0 THEN 'Is SGAM Page'
ELSE 'Is Not PFS, GAM, or SGAM page'
END
FROM ( SELECT
session_id,
wait_type,
wait_duration_ms,
blocking_session_id,
resource_description,
CAST(RIGHT(resource_description, LEN(resource_description)
- CHARINDEX(':', resource_description, 3)) AS INT) AS PageID
FROM sys.dm_os_waiting_tasks
WHERE wait_type LIKE 'PAGE%LATCH_%'
AND resource_description LIKE '2:%') AS tab;
session_id,
wait_type,
wait_duration_ms,
blocking_session_id,
resource_description,
ResourceType = CASE
WHEN PageID = 1 OR PageID % 8088 = 0 THEN 'Is PFS Page'
WHEN PageID = 2 OR PageID % 511232 = 0 THEN 'Is GAM Page'
WHEN PageID = 3 OR (PageID - 1) % 511232 = 0 THEN 'Is SGAM Page'
ELSE 'Is Not PFS, GAM, or SGAM page'
END
FROM ( SELECT
session_id,
wait_type,
wait_duration_ms,
blocking_session_id,
resource_description,
CAST(RIGHT(resource_description, LEN(resource_description)
- CHARINDEX(':', resource_description, 3)) AS INT) AS PageID
FROM sys.dm_os_waiting_tasks
WHERE wait_type LIKE 'PAGE%LATCH_%'
AND resource_description LIKE '2:%') AS tab;
Subscribe to:
Posts (Atom)
