SQL Server 'Last Job Run' Metric / Alerting
Hi,
I am looking at implementing Grid Control monitoring on our SQL Server estate.
One of the items we need to monitor for is SQL Server jobs which have failed. There is a metric in Grid Control that covers this ('Last Job Run') and successfully notifies me if a job fails, however it returns the 'job ID' (random 32 char alphanumeric internal SQL Server identifier) rather than the 'job name'.
I know that Grid collects the job name as in All Metrics-->Database Job you can see the 'job name' metric/data, however I can not find a way of including this data in an alert or monitoring metric.
Does anyone have an idea of how this can be done. I'm sure I must be missing a trick here as it would seem strange that this information is being collected but can't be put into a metric or notification.
Any assistance or pointers greatly appreciated!
Anything is possible.
So, just to reiterate, running the job manually works, running the scheduled job does not result in errors neither data arriving to the DW, right? And it used to, correct?
If so, the 1st step would be to examine the configuration(s). But not before you inspect the package. Do you have an ability to export it to a file system and open in BIDS?
Arthur My Blog
Similar Messages
-
Hi All,
We have a scenario where we have to run 30 pkgs at same second. Each pkg is designed to fetch 60 lakh per day records and load it into Oracle/OLEDB destination.
For which we have created 30 SQL agent jobs for each pkg running every 5 mins 24/7. We want to test running with option(1) these 30 jobs on single sql server instance and option(2) 10 jobs each on 3 sql server instances. Can someone please help me out to understand
which would give me the better results.
a) The main advantage of multiple sql server instance scenario when compared with single sql server instance?
b) How much does the hardware configurations impact on the performance?
Thanks in Advance....1. Exposed to race conditions means ?
2. What you mean distributing computing? Can't the SQL Server handle this much load ?
3. Yes, 60 lakh records per day.
4. Multiple Instances on the same machine. The jobs might scale up to 300 jobs.
So, please suggest whether multiple instances would help the approach in scaling up ? Or the Single instance can handle all the 300 jobs at same second?
Please advice which approach would be best and why?
Re #1: means it will step on each other
#2: is when you take a chunk of data and process each separately at the same time. SQL Server or not will use the resources available on the machine. And they are not elastic.
#3: So thanks @Vaibhav it is 600K records to process so per 5 min it is 300 records which not too many for even one SSIS package on a commodity server. Question though is how long is the record. And what needs to be done to "process", if it takes
longer than 5 min - boom you are trouble with your approach (#1 happens)
Lastly, how do you know it will scale?
To answer you need
1) Provide with technical specs of your prod machine
2) Do a proof of concept
3) Profile a load to see where improvements can be done because in ETL it is common to get more and more data as the time goes by. I also fail to understand how the concurrently running packages will understand what data not to process because another package
grabbed it.
Arthur
MyBlog
Twitter -
Hi. I am newer to SQL server security and am reviewing some of our SQL server's configuration to make sure the services are running under accounts with least privilege. I have a SQL server 2012 instance whose Agent service is configured to run
under an AD user account named 'SQLServices'. The jobs on this server are configured to run as 'SQL server agent service account', which means they should execute as user 'SQLServices'. The jobs are set up to execute SSIS packages which read and
write to a database on the same server where the agent job is scheduled and SSIS package installed (all on same server). The jobs are currently executing without error and are reading writing data correctly. Upon close examination, it turns out the
SQLServices account is not assigned to the 'sysadmin' role and had no users mapped to any databases on this server. How are these jobs working? I verified in profiler that the login name indeed is 'SqlServices'. I also verified
that SQLServices login has no database access by remote-ing onto the server and trying to log into the DB, and access was denied as expected. According to the literature, the Agent service needs to be a member of 'sysadmin role' but I am reading
some cases where that is not necessarily the case. So this is not so concerning. What is concerning is that the login 'SQLServices' had no access to the databases on that server yet it is reading and writing to the databases as if it does.
The only thing I can think of is maybe jobs run as 'SQL server agent service account' on the same server as the databases it r/w to somehow has some kind of default access. What am I missing here? Any input would be helpful.After 2 days on this forum I found the answer to my own question. In retrospect, I should have posted this under 'SQL Server Security', but I didn't know it existed.
The 2 threads below explain that Sql agent actually runs using SID (service) NT SERVICE\SQLSERVERAGENT if you chose that when you installed. This will automatically create an associated login NT SERVICE\SQLSERVERAGENT in SQL server with sqladmin
role. This is the login that Agent uses to connect to the local instance of SQL server. If you changed to domain account to run the service during install or after using config manager, basically NT SERVICE\SQLSERVERAGENT is still
used to connect to your local instance behind the scenes (even though you will still see your domain user as account), and the domain account is used to reach outside the server.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/9e6bb2de-8fd0-45de-ab02-d59bbe05f72e/servicedatabase-accounts-nt-servicemssqlserver-nt-servicesqlserveragent-what-are-they-for
https://social.technet.microsoft.com/Forums/sqlserver/en-US/b83a52fd-fe11-4c28-a27b-88be8ae79f2a/how-do-i-change-sql-server-agent-service-account-to-nt-servicesqlserveragent?forum=sqlsecurity -
SQL Server Agent Job Duration monitor alerts incorrectly
As per SQL Server MP guide, changes in Dec 2007 update : Fixed a script that was resulting in invalid alerts being generated from the agent job's Job Duration monitor.
In my SCOM 2012 environment on few SQL servers I'm getting an alert from Job Duration monitor for SQL jobs that have completed well within the defined thresholds. Interestingly this monitor then resets on its own(The monitor has been initialized for
the first time or it has exited maintenance mode) and immediately turns critical again. I do not see any pattern around these state changes. These are weekly jobs, however the Job Duration monitor continues to alert for these specific jobs 10-15 times a day.
This is creating unnecessary noise in the environment.
Is anyone else facing this issue? I know I can disable this default monitor and create my own monitor. However I want to check if this is a known bug in this SQL MP(version 6.4.1.0).
Note : I'm aware about an updated MP version 6.5.1.0, however the release note doesn't specify if it fixes this issue.
Thanks,
Harry
Thanks, Harry :-)Resolution: The issue was that the SCOM Agent was getting restarted repeatedly. Post restart health calculation was done again and the SQL Job duration monitors would reset and generate new alerts.
There is a recovery configured in an aggregate monitor to restart the SCOM Agent if Handle Count/Private Bytes of Health Service/Monitoring Host breach a set threshold. I had to create an override to change the thresholds for all Health Service/Monitoring
Host and exclude the recovery on Physical servers.
If there are large number of workflow on an SCOM Agent due to multiple MP(SQL, HP, etc.), the increase in Handle Count/Private Bytes is usual.
Thanks, Harry :-) -
Hello,
Here is my problem:
Data was imported into the staging area. After resolving some errors and running the job, I got the data to move over to the next area. From there, data should be moving over into the DW. I have been troubleshooting for hours and cannot reslove this
issue. I have restarted the sql service services, I have ran a couple packages manually, and the job is running successfully.
What are some reasons why data is not getting into the data warehouse? Where should I be looking?
Your help is greatly appreciated!!Anything is possible.
So, just to reiterate, running the job manually works, running the scheduled job does not result in errors neither data arriving to the DW, right? And it used to, correct?
If so, the 1st step would be to examine the configuration(s). But not before you inspect the package. Do you have an ability to export it to a file system and open in BIDS?
Arthur My Blog -
SQL Server Agent Jobs error for Slowly changing dimension
Hi,
I have implemented Slowly changing dimension in 5 of my packages for lookup insert/update.
All the packages are running good in SSDT. And when i deployed the project to SSISDB and run the packages all are running successfully. But when i created a job out of that and run the packages, then 3 packages ran successfully and 2 packages failed.
When i opened All Execution Report. I found the following error:
Message
Message Source Name
Subcomponent Name
Process Provider:Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description:
"Login timeout expired". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "A network-related or instance-specific error has occurred while establishing
a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.". An OLE DB record is available.
Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Named Pipes Provider: Could not open a connection to SQL Server [53]. ".
Process Provider
Slowly Changing Dimension [212]
Then i opened Provider package in SSDT and changed the source reading record limit from 4,00,000 to 15,000 in source query and deployed again and run, then the job succeeded. more than 15,000 failed.
And in the 2nd experiment, I removed slowly changing dimension task and implemented normal lookup for insert/update, and set the source reading limit again to 4,00,000 and deployed again and run, then the job succeeded.
Now i am not able to figure out, what exactly is the problem with Slowly changing dimension task for more than 15,00 records in SQL Server Agent Job run?
Can anybody pls help me out.
Thanks
BikramHi Vikash,
As i have mentioned in the above post, below 2 scenarios:
"Then i opened Provider package in SSDT and changed the source reading record limit from 4,00,000 to 15,000 in source
query and deployed again and run, then the job succeeded. more than 15,000 failed.
And in the 2nd experiment, I removed slowly changing dimension task and implemented normal lookup for insert/update, and set the source reading limit again to 4,00,000 and deployed again and run, then the job succeeded."
That means i am able to connect to sql server.
But if i change the 1st scenario and read 4,00,000 records, the job fails and shows the above mentioned error.
Similarly in the 2nd scenario, if i implement SCD look up, the job fails and shows the above mentioned error.
And i am consistently reproducing this.
Thanks
Bikram -
One sql server agent job suspend
One sql server agent job--run full backup of one database is suspended from activity monitor.
How to find why it is suspended and troubleshoot?"Suspended" is a common status for a thread. It indicates the thread is waiting on an external resource, which backups often are
Check few things:
1. Database size, how much backup is completed from below command and location where backup files are being placed
select session_id,command, percent_complete
from sys.dm_exec_requests
If that on network than might be due to slow netword backup take some time.
2. Check job history, expected
completion time of backup job and also if any change in the I/O and CPU time for the SPID
3.Check wait type of suspended spid, SQL server and event viewer logs. If any I/O issue on the server. Like disk responding slowly that might be a cause of delay.
Please click the Mark as answer button and vote as helpful if this reply solves your problem -
What SQL Server Agent jobs are currently running and for how long
Is there a way to tell what SQL Server Agent jobs are currently running and for how long? View history isn't working in my case because it's only showing completed jobs. John Schroeder
You can use the "Job Activity Monitor" for doing this. Do the following steps. It will open up the Job Activity Monitor.
1. In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
2. Expand SQL Server Agent.
3. Right-click Job Activity Monitor and click View Job Activity.
4. In the Job Activity Monitor, you can view details about each job that is defined for this server.
In Job Activity Monitor page, we have column called Status. It will indicate whether job is executing or idle. Last Run column will give you the last invocation time of this job.
Use the following link for further reference.
http://msdn.microsoft.com/en-us/library/ms187449.aspx
Thanks,
Sateesh.
Mark Post as helpful if it provides any help.Otherwise,leave it as it is. -
I've seen some conflicting things in terms of dynamic Excel commands running in a SSISDB Package and a scheduled SQL Server Agent Job...things like that it's not supported...that it won't work...etc...
It's a pretty simple script...to open up a .xlsx file and save it as a .xls file. I am trying to be proactive here and the reason I did it this way is because I could not source the .xlsx file and then I couldn't use OLE DB sourcing because I think the .xlsx
file wants you to use Microsoft.ACE.OLEDB.12.0 and that entails installing the 64-bit Microsoft Access Database Engine and I cannot do that because our network version of Microsoft Office 2010 is 32-bit and in order to install the 64-bit Microsoft Access Database
Engine 2010 it's prompting me to uninstall Microsoft Office 2010 and that is not possible.
Ugh!
So I'm hoping that I can promote and deploy this current SSIS Package to Production and create a SQL Server Agent Job that will successfully run this and its dynamic Excel commands.
Do you know of any hurdles with this? Any anomalies...struggles...
Thanks for your review and am hopeful for a reply.
Here's the C# Script...which works perfectly client side...
string StrFileName = (Dts.Variables["User::FileName"].Value.ToString());
StrFileName = Path.GetFileNameWithoutExtension(StrFileName);
string StringSourceFile = (Dts.Variables["User::FilePath"].Value.ToString()) + StrFileName + ".xlsx";
string StringDestinationFile = (Dts.Variables["User::FilePath"].Value.ToString()) + StrFileName + ".xls";
// This initiates the Excel Application
Microsoft.Office.Interop.Excel.Application excelApplication = new Microsoft.Office.Interop.Excel.Application();
// This Opens the Source .xlsx File from Emdeon ePaySmart
Workbook workbook = excelApplication.Workbooks.Open(StringSourceFile, XlUpdateLinks.xlUpdateLinksNever, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// This will Save the Source .xlsx Emdeon ePaySmart File as a .xls File...note xlFileFormat.xlExcel5
workbook.SaveAs(StringDestinationFile, XlFileFormat.xlExcel8, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// This will Close the Source
workbook.Close(false, Type.Missing, Type.Missing);
// This shuts down the Excel Application
excelApplication.Quit();This should work if you use a proxy to run this package in the Agent; see:
http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Arthur
MyBlog
Twitter -
SQL Server Agent Job intermittently running for packages on SSISDB
I created an SSIS package to pull data from OLAP Cube and push it into SQL Server using SSIS 2o12. I deployed the same on the SQL Server SSIS DB and created a SQL Server Agent Job to run the package. I have an account configured to run the job (not by
creating proxy in the job, but SQL Server Agent is running under that account), that has access to the OLAP Cube. The job is running sometimes and failing sometimes. Why the job behaving weirdly. Any help on the issue will help me a lot. I am using SQL Server
2012 SP1 enterprise edition (11.0.3000.0) (if it helps). The error message which pops up when it fails is :
OLE DB Source failed the pre-execute phase and returned error code 0xC0202009
SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E05.
An OLE DB record is available. Source: ""Microsoft OLE DB Provider for SQL Server 2012 Analysis Services."" Hresult: 0x00000001 Description: ""Error Code = 0x80040E05, External Code = 0x00000000:."".
"Hi,
You are using Execute SQL Task to run a MDX query, right? If so, here is an approach/workaround for your reference. If the MDX query doesn’t have parameters, you can create a view in SQL running the MDX query and make the Execute SQL Task to get data
from that view. If the MDX query has parameters, you can try a Function and create a stored procedure, and then set the Execute SQL Task to execute that stored procedure.
Regards,
Mike Yin
TechNet Community Support -
VBScript Runs Correctly From Command Prompt, But Not From SQL Server Agent Job
I'm trying to run this script on my local machine to do some post-batch cleanup and it doesn't run correctly from the scheduled job (or when I invoke the job).
Here's the script in question:
Option Explicit
Const filePath = "C:\Documents and Settings\jmunn\My Documents\Visual Studio 2008\Logs\"
Const holdDays = 6
main
Sub Main()
ClearArchive
End Sub
Sub ClearArchive()
Dim fso 'As Scripting.FileSystemObject
Dim fld 'As Scripting.Folder
Dim f 'As Scripting.File
Dim delLogName, delLogOut, delCtr
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(filePath)
delLogName = filePath & "Nightly Backup - Backup Logs Deleted" & ".txt"
Set delLogOut = fso.CreateTextFile(delLogName, True)
delLogOut.WriteLine(delLogName)
delLogOut.WriteLine("")
delLogOut.WriteLine("-- The following log files were deleted on " & DateValue(Now()) & " at " & TimeValue(Now()))
delLogOut.WriteLine("")
delCtr = 0
For Each f In fld.Files
If Left(f.Name, 48) = "Nightly Backup - SQL Server Databases_Subplan_1_" And Right(LCase(f.Name), 4) = ".txt" Then
If DateDiff("d", f.DateCreated, Date()) > holdDays Then
delLogOut.WriteLine(f.Name)
fso.DeleteFile f, True
delCtr = delCtr + 1
End If
End If
Next
If delCtr = 0 Then
delLogOut.WriteLine("No log files were deleted this run...")
End If
Set fld = Nothing
Set fso = Nothing
delLogOut.Close
End Sub
If I put the script in its own file and run it from the command prompt, it runs just fine. If the script runs from the SQL Server Agent job, the for-loop will delete the files correctly, but the filenames
do not get written to the deletion log file and the counter does not get incremented, so according to the job log, nothing was deleted. Why does the script run differently from each invocation? It can't be a permission thing, the service that logs in has full
access to the directory and the files do get deleted. Any ideas out there?
Between this and other outstanding issues, I'm quickly losing faith in SQL Server. >=o(
Thanks in advance for your thoughts!
John
Version Info:
Microsoft SQL Server Management Studio 10.0.2531.0
Microsoft Analysis Services Client Tools 10.0.1600.22
Microsoft Data Access Components (MDAC) 3.85.1132
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 8.0.6001.18702
Microsoft .NET Framework 2.0.50727.3603
Operating System 5.1.2600
"A bus station is where a bus stops. A train station is where a train stops. On my desk I have a workstation..."Hi
jrmunn
i am trying to execute VB script to refresh my excel files.. using Vbscript file through SQL Agent job step.
i have copied VBscript in a file with the extension RefreshExcel.vbs kept in C:\RefreshExcel.vbs
Below is the script used inside the file (RefreshExcel.vbs)
//---Script code-----------------------------------------------------------------
Dim objXL, objWB
Dim FileLocation, FileName
On Error Resume Next
'lgnConn = 1
FileLocation = "F:\Reports\Reports"
Set objXL = CreateObject("Excel.Application")
objXL.DisplayAlerts = False
FileName = "ReportFile1.xlsx"
'MsgBox (FileLocation & "/" & FileName)
Set objWB = objXL.Workbooks.Open(FileLocation & "/" & FileName)
objWB.EnableConnections
objXL.CalculateUntilAsyncQueriesDone
objWB.RefreshAll
objXL.CalculateUntilAsyncQueriesDone
objWB.RefreshAll
objXL.CalculateUntilAsyncQueriesDone
objWB.Save
objWB.Close
Set objWS = Nothing
Set objWB = Nothing
objXL.Quit
Set objXL = Nothing
'MsgBox ("Refresh Completed")
---------------------------------------------------------------------------------------------------//Script complete
Now when i am trying to call this script file in SQL agent job step (as you mentioned )
as Type -cmdExec(OperatingSystem)
cscript "C:\RefreshExcel.vbs"
Issue: job step executed succesfully ,,but without performing any refresh on the excel. So i am not understandig what is going wrong. the same script file work when i am calling it through a batch file (window scheuler task). But it doesnt support
to run the file "when user is not logged in"
that is why i want to refresh my excel file through sql agent ,which can be scheduled to any time and cab be run as SQL agent credentials.
Can you please help me on this ...i have tried all the option but nothing working .. found hope by seeing your solution.
Thanks in advance.
Please help me. :-( -
What windows account to use as proxy account to schedule a package to run in sql server 2005 job
I have successfully set up a credential and proxy in SQL Server 2005 to run a SSIS 2005 job under my windows account. The problem I got is the password of my account will expire sometime so the job execution will fail until I change the password
in the credential. I am thinking either to ask our IT administrator to set my account to password never expire or use a different account for the credential. I have very limited knowledge regarding windows security. So if I go the second option what account
should I use for the credential/proxy? I need to know about this before asking our IT admin.It must be a domain wide service account (with a strong, non-expiring password), not a private account with just enough rights to run packages (this implies the account must be able to connect to remote data sources and shares). Oftentimes, such
an account also needs write access to the %temp% directory.
Arthur My Blog
Thanks. I will try to tell our admin see if it makes sense to him. -
How to run a SQL Server Agent job step on certain days/frequency
I've a SQL Server Agent job. One of the requirement is that a particular step should only run on certain frequency i.e. Certain Date and time. Any suggestions how can that be done?
GBMyes
1. Make first step as a Transact SQL step. Keep command as below
IF DAY(GETDATE()) = <Your date value>
AND DATEPART(hh,GETDATE()) = <your time hour)
AND DATEPART(minute,GETDATE()) = <your time minute)
SELECT 1
ELSE
RAISERROR 'Job cant be run at this time'
Then for job step properties set the following properties in advanced tab
This would make sure it will quit the job without executing other core steps untill it reaches the required day and time
You can add more conditions in IF based on requirement like if you want time to be on certain second or month to be particular value etc
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to run Exe file through Sql server agent job
Hello All
i have 2 servers
1.Application Server
2.Database server
Application server has a .exe file so i wanted to run this exe file through SQL server agent job from database server.
What is the process for run this Exe file
Can you plz suggest me step by step process
KamalWhile i'm trying to implement this below method
Step1 : Right Click SQL Server Agent. Select New -> Job. This will open a wizard to schedule a new
job.
Step2 : Select Steps from options given on the left side of wizard. This is the main place to set your
exe\program as a running step. Give some name to this step, Select Operating System (cmdexec) for the Type and give the full path of exe in Text box for Command.
ex:\\10.11.00.98(your application serverIP)\ch.exe
Thanks vanchan-Please
mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers
I got this below error
Message
Executed as user:NJROSJ345\SYSTEM. The process could not be created for step1 of job
(Reason:Access is Denied)The step failed.
But i have sys admin rights on the both the servers
Kamal -
Running .exe file on remote computer using SQL server Agent JOb
I am trying to run exec file on a remote server by using sql server Agent job,
what is the best way to do this
kConfigure it as an operating system job step:
http://technet.microsoft.com/en-us/library/ms190264.aspx
Alternate: build an SSIS package and schedule it as a job.
Kalman Toth Database & OLAP Architect
SELECT Video Tutorials 4 Hours
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012
Maybe you are looking for
-
Prior to this version of Firefox 36.0.1, the <textarea> in my HTML forms was working; displaying carriage returns. In version 36.0.1 they no longer function properly. Instead when I enter a carriage return, it displays a space instead of a newline. I
-
Windows 8.1 will not run my install CD for Photoshop 5.0. What can I do ?
Windows 8.1 will not run my install CD for Photoshop 5.0. What can I do ?
-
Is it possible to convert footage shot in widescreen mode to standard ?
We used two cameras. One with standard settings and the other with accidental wide-screen settings and now need to have them look similar in a project. Please help.When we expand the wide-screen footage it blurs a bit. Thanks!
-
how to check the database version ? my databases are not connected but i need to know which version i.e either standard or enterprise 10g or 11g please can you tell me how to look that ? BKPCCTB:/home/oracle>sp SQL*Plus: Release 10.2.0.2.0 - Producti
-
How to Connect to Remote ECC 5.0 System from EP ?
Hi, We are using EP6.0 - located in India, and our client ECC5.0 System is in US. Can anyone please let me know the steps how to connect to Remote ECC 5.0 System?. Thanks in advance. Krishna Kumar J