2016-03-03 02:06 AM
We are facing the issue related to the trace files created by MS SQL 2005 & 2000, as the trace files created are not going into the proper folder C:\MyTraceFiles and are getting stored in C:\.Also the issues is the stored files are not getting auto deleted which is creating the space issue.
2016-05-18 04:06 AM
Buen día.
Podrías proporcionarme tu procedimiento completo al aplicar la auditoria sobre tu SQL server.
Escríbeme a enriquecb99@gmail.com.
Saludos
2016-05-19 04:58 AM
SQL Trace files get deleted when they are collected.
Are there any errors on the log collector regarding odbc collection to this source?
2016-05-19 06:20 AM
El problema lo tienen al momento de realizar el mapeo, ya que no importa donde generemos nuestro Tracefile.
Lo importante es darle una ruta para que la puedamos extraer por medio de algún método de recolección
Esta es la solución
USE master
GO
CREATE CERTIFICATE SQLCLRTestCert
FROM EXECUTABLE FILE ='C:\MyDBApp\RSA_MSSQLAuditStoredProcedures.dll'
CREATE LOGIN SQLCLRTestLogin FROM CERTIFICATE SQLCLRTestCert GRANT EXTERNAL ACCESS ASSEMBLY TO SQLCLRTestLogin
GO
En tu DNS le ingresas la ruta de extracción
2016-05-19 06:29 AM
Note if you are patching your SQL Server then perform the following steps:
--- First Shutdown Trace
--- We keep any existing trace files.
IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[dbo].[nic_aud_init_trace]') AND type in (N'P', N'PC'))
exec nic_aud_init_trace 0
GO
IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[dbo].[rsa_delete_trace_files]') AND type in (N'P', N'PC'))
drop procedure rsa_delete_trace_files
GO
IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[dbo].[rsa_file_exists]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
drop function rsa_file_exists
GO
IF EXISTS (SELECT * FROM sys.assemblies WHERE name = 'RSA_MSSQLAuditStoredProcedures')
drop assembly RSA_MSSQLAuditStoredProcedures
GO
----- END SCRIPT
------
PATCH AND
RESTART SQL SERVER SERVICE
-----
SCRIPT TO RESTART TRACING
--We recreate the assemby
CREATE ASSEMBLY RSA_MSSQLAuditStoredProcedures
FROM 'C:\MyDBApp\RSA_MSSQLAuditStoredProcedures.dll'
WITH PERMISSION_SET = EXTERNAL_ACCESS;
GO
---------------------------------------------
-- CLR Endpoint Function
-- to check if a file existProcedure
-- to delete trace files
---------------------------------------------
create function rsa_file_exists
(
@filepath nvarchar(255)
)
returns int
as external name RSA_MSSQLAuditStoredProcedures.[RSA_MSSQLAuditStoredProcedures.RSA_MSSQLAuditStoredProcedures].rsa_file_exists;
go
---------------------------------------------
-- CLR Endpoint Procedure
-- to delete trace files
---------------------------------------------
create procedure rsa_delete_trace_files
(
@filepath nvarchar(255)
)
as external name RSA_MSSQLAuditStoredProcedures.[RSA_MSSQLAuditStoredProcedures.RSA_MSSQLAuditStoredProcedures].rsa_delete_trace_files;
go
IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[dbo].[nic_aud_init_trace]') AND type in (N'P', N'PC'))
exec nic_aud_init_trace 0
GO
---END SCRIPT
During the period that the SQL Server is being patched you will see the following messages in the /var/log/messages of the log collector ( Taken from my test system)
Apr 19 13:30:46 REMOTELOGCOL NwLogCollector[25428]: [OdbcCollection] [failure] [mssql.ECAT_MSSQL] [processing] [ECAT_MSSQL] [processing] Publish error: Error calling SQLMoreResults: Statement: "exec nic_aud_swap_trace 30, 'c:\MyTraceFiles\', 1, 'WHERE StartTime > 2016-04-19 14:22:09.623'"; Reason: state: S1000; error-code: 139814070390809; description: [RSA][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Cannot find either column "dbo" or the user-defined function or aggregate "dbo.rsa_file_exists", or the name is ambiguous.state: S1000; error-code: 139814070390809; description: [RSA][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Cannot find either column "dbo" or the user-defined function or aggregate "dbo.rsa_file_exists", or the name is ambiguous.state: S1008; error-code: 139814070390309; description: [RSA][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]The statement has been terminated.state: 23000; error-code: 139814070389315; description: [RSA][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Violation of PRIMARY KEY constraint 'PK__nic_aud___9A5818ED427D50A8'. Cannot insert duplicate key in object 'dbo.nic_aud_trace'. The duplicate key value is (c:\MyTraceFiles\).state: S1000; error-code: 139814070390809; description: [RSA][ODBC SQL Server Wire Protocol driver][Microsoft SQL Server]Cannot find either column "dbo" or the user-defined function or aggregate "dbo.rsa_file_exists", or the name is ambiguous.
2016-05-19 06:40 AM
El error exec nic_aud_swap_trace 30, y s.state: S1008 fue corregido habilitando el firewall y ejecutando en una consola de MS-DOS como administrador las siguientes lineas de comando, posteriormente se dio de baja el firewall.
set winrm/config/service @ {AllowUnencrypted="true"}
winrm e winrm/config/listener
winrm quickconfig
winrm set winrm/config/service @{AllowUnencrypted="true"}
Saludos
2022-07-06 07:52 AM
Hello David I am facing same the issue related to the trace files created by MS SQL 2008, as the trace files created are not going into the proper folder C:\MyTraceFiles and are getting stored in C:\. Also the issues is the stored files are not getting auto deleted which is creating the space issue also now i change the configuration from drive C to Drive in ODBC but still trace files are being stored in drive C, I am receiving the logs aswell. Need your support that trace files are not deleting by it self keep eating the storage.