SystemMonitor
Monitor certain critical FairCom Server events.
Short Name
SYSMON()
Type
Server-only function
Declaration
COUNT SystemMonitor(COUNT mode, LONG timeout, pTEXT buffer, VRLEN buflen)
Description
SystemMonitor() provides the ability for a client to monitor certain critical FairCom Server events. Each event causes a message to be written to an internal queue. Each call to SystemMonitor() reads a message from this queue. If no message is available, it waits for a message or times out.
mode can take on two values:
timeout specifies the time in seconds for a forced return of SystemMonitor() in the event that no event occurs. A value of -1L indicates an unlimited wait: SystemMonitor returns only when an event occurs or the Server stops. Note that the monitor is still in effect after a timeout return. For another process to start monitoring, the client currently monitoring must disconnect from the Server or call SystemMonitor() with the SYSMON_OFF mode.
buffer points to the buffer which receives a descriptive Server monitor message.
buflen is the length of the buffer.
Return
SystemMonitor() returns one of the following values. More events may be added in future releases.
Value |
Symbolic Constant |
Explanation |
---|---|---|
0 |
NO_ERROR |
When Server terminates. |
156 |
NTIM_ERR |
Monitor timed-out without event. |
454 |
NSUP_ERR |
System monitor not supported (non-server). |
542 |
MCRE_ERR |
Could not create mirror file. |
543 |
MOPN_ERR |
Could not open mirror file. |
544 |
MCLS_ERR |
Could not close mirror file. |
545 |
MDLT_ERR |
Could not delete mirror file. |
546 |
MWRT_ERR |
Could not write to mirror file. |
547 |
MSAV_ERR |
Could not save mirror file. |
548 |
MRED_ERR |
Could not read (header) in mirror. |
549 |
MHDR_ERR |
Mismatch between mirror headers. |
550 |
MSKP_ERR |
Attempt to open primary w/o mirror. |
551 |
MNOT_ERR |
File already opened without mirror. |
555 |
PREA_ERR |
Could not read primary file, all I/O performed on mirror file only. |
556 |
PWRT_ERR |
Could not write primary file, all I/O performed on mirror file only. |
557 |
CWRT_ERR |
Could not write mirror file, all I/O performed on primary file only. |
558 |
PSAV_ERR |
Could not save primary file, all I/O performed on mirror file only. |
559 |
CSAV_ERR |
Could not save mirror file, all I/O performed on primary file only. |
560 |
SMON_ERR |
Only one of each monitor at a time. |
561 |
DDMP_BEG |
Dynamic dump begins. |
562 |
DDMP_END |
Dynamic dump ends. |
563 |
DDMP_ERR |
Dynamic dump ends with errors. |
When coding the “switch” or other constructs to handle the SystemMonitor() return codes, be sure to provide a default to handle return codes which may be added in future implementations. See c-tree Error Codes in the c-tree Programmer’s Reference Guide for a complete listing of valid c-tree error values.
Example
VRLEN buflen=128;
TEXT buffer[128]; /* input buffer */
LONG timeout = 10;
while(SystemMonitor(SYSMON_MAIN,timeout,buffer,buflen)) {
switch(uerr_cod){
case NSUP_ERR:
printf("No monitor support\n");
StopUser();
exit(0);
case NTIM_ERR:
break;
case PREA_ERR:
case PWRT_ERR:
case PSAV_ERR:
printf("Primary file not operational (%d)\n%s\n", uerr_cod,buffer);
break;
case CWRT_ERR:
case CSAV_ERR:
printf("Mirror file not operational (%d)\n%s\n", uerr_cod,buffer);
break;
default:
printf("other monitor event(%d)\n%s\n", uerr_cod, buffer);
break;
} /* end of switch */
} /* end of while */
/* if server has terminated */
StopUser();
exit(0);
Limitations
Available only with the FairCom Server. A call to SystemMonitor() on a non-server system results in error return NSUP_ERR (454).
Only one application connected to each Server may have SystemMonitor() active.