-
How to write a script which keep on checking database status?
How to write a script which keep on checking database status(availability) once in a min at OS Level for Windows.
Script should check service availability once a minute
J Gangadhar
-
use Task Scheduler, execute a batch file,
and within a batch file, execute a script that test the availability of a server.
-
write a program, which will test the service status
Code:
// Open Service Manager
m_schSCManager = OpenSCManager(lpMachineName, lpDatabaseName, dwDesiredAccess);
// Open Specific Service
schService = OpenService(
m_schSCManager,
m_pService,
dwDesiredAccess);
// Query Service Status
SERVICE_STATUS lServiceStatus;
QueryServiceStatus(schService, &lServiceStatus);
// get the status from the structure
if (lServiceStatus.dwCurrentState == SERVICE_RUNNING)
cout << "Service " << m_pService << " Is Running" << endl;
else
cout << "Service " << m_pService << " Is Not Running" << endl;
// Close Service and Manager
CloseServiceHandle(schService);
CloseServiceHandle(m_schSCManager);
Write a thread that wakes up every minute and tests the service.
Cheers,
It is better to ask and appear ignorant, than to remain silent and remain ignorant.
Oracle OCP DBA 9i,
C++, Java developer
-
Oh, there's a lot more that can go wrong besides the service dying.
Simplest is probably to run a SQL*Plus to read a row that you know should exist, spool this and do whatever you need to do with the output file.
I started with this to do something more sophisticated: http://www.amazon.com/exec/obidos/tg...glance&s=books
-
If there's budget, you can achieve much more sophisticated results on monitoring using software from IBM (Tivoli), Quest (Foglight) or Embarcadero.
An ounce of action is worth a ton of theory.
—Friedrich Engels
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|