FTAM/9000 Programmer's Guide
Chapter 9 347
Handling Errors
Example Program Containing Error Information
Example Program Containing Error
Information
Given a vendor_code, the following example creates a log filter file
(/tmp/input_file) that the troubleshooting tool osidump uses to check for
errors (via log instances in the log file). The file created records a time
period (during which the error is assumed to have occurred), the log class
to filter on, and the log instance. Following the program is sample
output.
/* This routine creates a input FORMAT file for use by the “osidump”
* command. The FORMAT file is created with two time lines, time_from
* and time_to. A log class of ERROR is used to search on, and if a
* log instance is present (upper 16 bits of the vendor code), then
* the instance will also be added to the filter file.
*/
search_log(vcode)
int vcode;
{
FILE *fp, *fopen();
long now, time();
int log_instance;
struct tm *localtime();
struct tm *clock;
extern long timezone;
/* open a /tmp file to store the FORMAT data */
if ((fp = fopen(“/tmp/input_file”, “w”)) == NULL) {
fprintf(stderr, “fopen error\n”);
exit(1);
}
/* get current time */
now = time ((long *) 0);
clock = localtime(& now);
/* get the upper 16 bits of the vendor_code */
log_instance = vcode >> 16;
/* write log filter file */
fprintf(fp, “FORMATTER\tfilter\ttime_from\t”);
if (clock->tm_min > 2)
fprintf(fp, “%d:%02d:%02d\t”, clock->tm_hour,
clock->tm_min - 3, clock->tm_sec);
else
fprintf(fp, “%d:%02d:%02d\t”, (clock->tm_hour + 23)%24,
(clock->tm_min + 57)%60, clock->tm_sec);