Navigation
Learn About
Developing With
Ingres Talk
Information
Toolbox
Views
Ingstatus
From Ingres Community Wiki
Contents |
ingstatus utility for Windows
ingstatus is a utility found on the Linux and UNIX platforms that gives an indication of the servers that are running in the instance. This utility is not available for on the Windows platform so here's an example using the functions available in the iilibutil.dll library.
The source for this example can be downloaded from ingstatus.zip.
This example loads three functions from the library:- II_PingServers
- II_GetEnvVariable
- II_GetIngresMessage
Describing the code
The II_PingServers function is really all that is needed. II_GetEnvVariable is used to obtain the Ingres instance identifier from the execution environment. II_GetIngresMessage is used to find text messages associated with Ingres status codes, but isn't enabled in this example code.
II_PingServers
Return a list of running servers registered with an Ingres instance name server. A message requesting a list of running servers registered with the Ingres name server is sent to the name server. The name server in the instance responds with a list of registered server classes. Well known classes are compared with the returned classes and compiled into the IISVRINFO structure.
II_GetEnvVariable
Retrieve the value of a named environment variable. If the name does not exist in the system environment and the name to be retrieved is not II_SYSTEM then the value is retrieved from the Ingres environment area.
II_GetIngresMessage
Return the text associated with the Ingres status. The function returns the text associated with the Ingres status including the decoded facility representation of the status in the text.
The start of the example deals with the attempt to load the libraries at runtime.
for (i=0; libs[i] != NULL &&
(II_LibraryInst = LoadLibrary(libs[i])) == NULL; i+=1);
The LoadLibrary is attempted for iilibutil.dll and oiutil.dll which reflects the library name change between Ingres R3 and Ingres 2006 (9.0.4).
Pointers to each of the three functions are obtained.
pII_PingServers = (int (WINAPI *)(IISVRINFO*))GetProcAddress(
II_LibraryInst, "II_PingServers" );
pII_GetEnvVariable = (void (WINAPI *)(char*, char**))GetProcAddress(
II_LibraryInst, "II_GetEnvVariable" );
pII_GetIngresMessage =
(int (WINAPI *)(unsigned int, int*, char*))GetProcAddress(
II_LibraryInst, "II_GetIngresMessage" );
if ((pII_PingServers != NULL) && (pII_GetEnvVariable != NULL) &&
(pII_GetIngresMessage != NULL))
{
...
}
The heart of the utility is the II_PingServers function which returns a bit mask of the active servers. It only knows about the well known server classes. The remaining code converts the bit mask into a list of servers and their statuses.
svrinfo.size = sizeof(IISVRINFO);
svrinfo.servers = 0;
pII_GetEnvVariable( env, &envVal );
if ((status = pII_PingServers( &svrinfo )) == II_SUCCESSFUL)
{
for (i=0; (i < BITS_IN(long)) && (i < ARRAY_SIZE(iisvrclass)); i+=1)
{
if ((1<<i)&svrinfo.servers)
{
printf("Ingres %s %s - running\n", envVal, iisvrclass[i]);
}
else
{
switch((1<<i))
{
case II_JDBC:
break;
default:
printf("Ingres %s %s - not active\n", envVal,
iisvrclass[i]);
break;
}
}
}
}
The JDBC server is superseded by the Data Access Server (DAS) in Ingres 2006 so there is no message for it if it isn't running.
If there are no servers running then nothing is output; if the libraries cannot be loaded the message Unable to load required library is displayed and if a function cannot be loaded the message Unable to load functions is displayed.
Requirements
This example was developed on Windows XP using the compiler Version 13.10.3077 for 80x86 from Microsoft Visual Studio .NET 2003.
The code includes a C header file tngapi.h from the Ingres %II_SYSTEM%\ingres\files directory.
The iilibutil.dll imports from the following libraries:- iilibcompat.dll
- iilibcompatdata.dll
- iilibgcf.dll
- iilibembed.dll

