2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * Afsmon-win: Curses interface for the Afsmonitor using the gtx library.
13 *-------------------------------------------------------------------------*/
15 #include <afsconfig.h>
16 #include <afs/param.h>
27 #include <afs/gtxwindows.h> /*Generic window package */
28 #include <afs/gtxobjects.h> /*Object definitions */
29 #include <afs/gtxkeymap.h>
30 #include <afs/gtxlightobj.h> /*Light object interface */
31 #include <afs/gtxcurseswin.h> /*Curses window package */
32 #include <afs/gtxdumbwin.h> /*Dumb terminal window package */
33 #include <afs/gtxX11win.h> /*X11 window package */
34 #include <afs/gtxframe.h> /*Frame package */
36 #include <afs/xstat_fs.h>
37 #include <afs/xstat_cm.h>
41 #include "afsmonitor.h"
42 #include "afsmon-labels.h"
45 /* afsmonitor version number */
46 static char afsmon_version[] = "1.0";
48 /* EXTERNAL VARIABLES (from afsmonitor.c) */
50 extern int afsmon_debug; /* debug info to file ? */
51 extern FILE *debugFD; /* debugging file descriptor */
52 extern char errMsg[256]; /* buffers used to print error messages after */
53 extern char errMsg1[256]; /* gtx is initialized (stderr/stdout gone !) */
55 /* number of fileservers and cache managers to monitor */
59 /* number of FS alerts and number of hosts on FS alerts */
60 extern int num_fs_alerts;
61 extern int numHosts_onfs_alerts;
63 /* number of CM alerts and number of hosts on FS alerts */
64 extern int num_cm_alerts;
65 extern int numHosts_oncm_alerts;
67 /* ptr to array holding the results of FS probes in ascii format */
68 extern struct fs_Display_Data *prev_fsData;
70 /* ptr to array holding the results of CM probes in ascii format */
71 extern struct cm_Display_Data *prev_cmData;
73 extern int afsmon_fs_curr_probeNum; /* current fs probe number */
74 extern int afsmon_fs_prev_probeNum; /* previous fs probe number */
75 extern int afsmon_cm_curr_probeNum; /* current cm probe number */
76 extern int afsmon_cm_prev_probeNum; /* previous cm probe number */
78 extern int afsmon_probefreq; /* probe frequency */
80 /* map of fs results items we must display. This array contains indices to
81 the fs_varNames[] array corresponding to the stats we want to display. It is
82 initialized while processing the config file */
84 extern short fs_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN];
85 extern int fs_DisplayItems_count; /* number of items to display */
87 extern short cm_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN];
88 extern int cm_DisplayItems_count; /* number of items to display */
93 /* minimum window size */
98 #define RIGHT_JUSTIFY 0
99 #define LEFT_JUSTIFY 1
102 /* width of overview frame objects */
103 /* field widths include the terminating null character */
105 #define PROGNAME_O_WIDTH (maxX/2) /* program name object */
106 #define OVW_PAGENUM_O_WIDTH 29 /* page number object */
107 #define OVW_PROBENUM_O_WIDTH 39 /* probe number object */
108 #define OVW_CMD_O_WIDTH (maxX/2) /* cmd line object */
109 #define OVW_NUMFS_O_WIDTH 40 /* num FSs monitored */
110 #define OVW_NUMCM_O_WIDTH 40 /* num CMs monitored */
111 #define OVW_FSALERTS_O_WIDTH 40 /* num FS alerts */
112 #define OVW_CMALERTS_O_WIDTH 40 /* num CM alerts */
113 #define OVW_HOSTNAME_O_WIDTH (maxX / 2) /* FS & CM host names */
114 #define OVW_HOSTNAME_O_WIDTH_HGL 30 /* cosmetic, atleast this many chars
115 * will be highlightned */
117 /* widths of FS and CM frame objects */
118 #define FC_NUMHOSTS_O_WIDTH (maxX - 8) /* number of fs monitored. leave 4
119 * chars on either side for '<<','>>' */
120 #define FC_PAGENUM_O_WIDTH 43
121 #define FC_HOSTNAME_O_WIDTH 11 /* width of FS hostnames column */
122 #define FC_CMD_O_WIDTH 55 /* width of cmd line */
123 #define FC_PROBENUM_O_WIDTH 30 /* width of probe number object */
124 #define FC_ARROWS_O_WIDTH 4 /* width of arrow indicators */
125 #define FC_COLUMN_WIDTH 11 /* width of data columns */
127 /* bit definitions for use in resolving command line */
128 /* these bits are set in the xx_pageType variables to indicate what commands
131 #define CMD_NEXT 1 /* next page ? */
132 #define CMD_PREV 2 /* previous page ? */
133 #define CMD_LEFT 4 /* left scroll ? */
134 #define CMD_RIGHT 8 /* right scroll ? */
135 #define CMD_FS 16 /* file servers frame exists ? */
136 #define CMD_CM 32 /* cache managers frame exists ? */
139 #define FC_NUM_FIXED_LINES 10 /* number of fixed lines */
140 #define FC_FIRST_HOST_ROW 8 /* first host entry row number */
141 #define FC_FIRST_LABEL_ROW 4 /* first label row number */
143 /* number of fixed lines (that dont change) on the overview screen */
144 #define OVW_NUM_FIXED_LINES 7
145 #define OVW_FIRST_HOST_ROW 5 /* row index of first host entry in ovw frame */
147 #define HIGHLIGHT 1 /* highlight object? */
149 static char blankline[256]; /* blank line */
151 /* maximum X & Y coordinates of the frames */
155 struct gwin *afsmon_win; /* afsmonitor window */
156 int gtx_initialized = 0;
158 /* Overview screen related definitions */
160 struct gtx_frame *ovwFrame; /* overview screen frame */
161 struct gwin_sizeparams frameDims; /* frame dimensions. all frames have
164 /* overview frame object names */
165 struct onode *ovw_progName_o; /* program name object */
166 struct onode *ovw_pageNum_o; /* page number onject */
167 struct onode *ovw_cmd_o; /* command line object */
168 struct onode *ovw_probeNum_o; /* probe number object */
169 struct onode *ovw_numFS_o; /* num FS monitored */
170 struct onode *ovw_numCM_o; /* num CM monitored */
171 struct onode *ovw_FSalerts_o; /* nunber of FS alerts */
172 struct onode *ovw_CMalerts_o; /* nunber of CM alerts */
173 struct onode *initMsg_o; /* initialization message */
175 /* number of pages of data for the overview frame */
176 int ovw_numPages = 0;
177 int ovw_currPage = 1; /* current page number */
179 static int ovw_pageType = 0; /* one of the above types */
181 /* number of rows of server names that can be displayed on one overview page*/
182 int ovw_numHosts_perPage;
184 /* ptr to a block of ovw_numHosts_perPage number of objects for file servers */
185 struct onode **ovw_fsNames_o;
186 /*ptr to a block of ovw_numHosts_perPage number of objects for cache managers */
187 struct onode **ovw_cmNames_o;
189 /* When the ovw_refresh routine is called by the keyboard handlers the
190 following variable is used to determine if fs/cm/fs&cm info must be updated */
191 int ovw_update_info = 0;
193 /* Variables needed to display an intialization message on startup */
194 static char *initMsg = "AFSMonitor Collecting Statistics ...";
195 static int initMsg_on = 0; /* message on ? */
197 /* FILE SERVER Screen related definitions */
199 struct gtx_frame *fsFrame; /* File Server screen frame */
201 struct onode *fs_pageNum_o; /* fs page number object */
202 struct onode *fs_cmd_o; /* fs command line object */
203 struct onode *fs_probeNum_o; /* fs probe number object */
204 struct onode *fs_numFS_o; /* fs number of FSs object */
205 struct onode *fs_leftArrows_o; /* fs cols on left signal object */
206 struct onode *fs_rightArrows_o; /* fs cols on right signal object */
207 struct onode **fs_hostNames_o; /* ptr to host names objects */
209 /* bit-map to characterize page type and contents of command prompt */
210 static int fs_pageType = 0;
212 /* coordinates for the File Servers screen */
214 /* we use page numbers to navigate vertically (ie, across hosts) and column
215 numbers to navigate horizontally */
217 int fs_numHosts_perPage; /* number of file servers per page */
218 int fs_cols_perPage; /* number of data columns per file server page */
219 int fs_currPage; /* current FS page number */
220 int fs_numPages; /* number of FS pages */
222 /* column numbers are index to the mapping structure fs_Display_map. this
223 map contains the indices of datums that should be displayed */
225 int fs_numCols; /* number of columns of FS data (excluding hostname) */
226 /* this is the same as fs_DisplayItems_count */
227 /* following column indices run from 1 to (fs_numCols -1) */
228 int fs_curr_LCol = 0; /* column number of leftmost column on display */
229 int fs_curr_RCol = 0; /* column number of rightmost column on display */
230 int fs_Data_Available = 0; /* atleast one fs probe cycle completed ? */
233 /* structure that defines a line of data in the fs/cm frames */
235 /* we store each datum value in two objects, one below the other. The reason
236 for doing this is to conserve screen area. most of the datums are just longs
237 and will fit into one object. some of them are timing values and require 13
238 characters to be displayed - such fields may overflow to the second object
239 placed below the first one. */
241 struct ServerInfo_line {
242 struct onode *host_o; /* hostname object */
243 struct onode **data_o[2]; /* ptrs to two arrays of data objects. */
247 struct ServerInfo_line *fs_lines; /* ptr to the file server data objects */
249 /* file server label onodes - three rows of them */
250 struct onode **fsLabels_o[3];
252 /* CACHE MANAGER Screen related definitions */
254 struct gtx_frame *cmFrame; /* Cache Manager screen frame */
256 struct onode *cm_pageNum_o; /* cm page number object */
257 struct onode *cm_cmd_o; /* cm command line object */
258 struct onode *cm_probeNum_o; /* cm probe number object */
259 struct onode *cm_numCM_o; /* cm number of FSs object */
260 struct onode *cm_leftArrows_o; /* fs cols on left signal object */
261 struct onode *cm_rightArrows_o; /* fs cols on right signal object */
263 struct onode **cm_hostNames_o; /* ptr to host names objects */
265 /* bit-map to characterize page type and contents of command prompt */
266 static int cm_pageType = 0;
268 /* coordinates for the Cache Managers screen */
270 /* we use page numbers to navigate vertically (ie, across hosts) and column
271 numbers to navigate horizontally */
273 int cm_numHosts_perPage; /* number of cache managers per page */
274 int cm_cols_perPage; /* number of data columns per file server page */
275 int cm_currPage; /* current CM page number */
276 int cm_numPages; /* number of CM pages */
278 /* column numbers are index to the mapping structure cm_Display_map. this
279 map contains the indices of datums that should be displayed */
281 int cm_numCols; /* number of columns of FS data (excluding hostname) */
282 /* this is the same as cm_DisplayItems_count */
283 /* following column indices run from 1 to (cm_numCols -1) */
284 int cm_curr_LCol = 0; /* column number of leftmost column on display */
285 int cm_curr_RCol = 0; /* column number of rightmost column on display */
286 int cm_Data_Available = 0; /* atleast one cm probe cycle completed ? */
289 /* structure that defines a line of data in the fs/cm frames */
290 struct ServerInfo_line *cm_lines; /* ptr to the file server data objects */
292 /* file server label onodes - three rows of them */
293 struct onode **cmLabels_o[3];
297 /*------------------------------------------------------------------------
301 * Create and initialize a light onode according to the given
303 * ( Borrowed from scout.c )
306 * char *a_name : Ptr to the light's string name.
307 * int a_x : X offset.
308 * int a_y : Y offset.
309 * int a_width : Width in chars.
310 * struct gwin *a_win : Ptr to window structure.
313 * Ptr to new light onode on success,
314 * A null pointer otherwise.
321 *------------------------------------------------------------------------*/
323 static struct onode *
324 initLightObject(char *a_name, int a_x, int a_y, int a_width,
326 { /*initLightObject */
327 struct onode *newlightp; /*Ptr to new light onode */
328 struct gator_light_crparams light_crparams; /*Light creation params */
330 /* the following debug statement floods the debug file */
331 #ifdef DEBUG_DETAILED
334 "[ %s ] Called, a_name= %s, a_x= %d, a_y= %d, a_width= %d, a_win= %d\n",
335 rn, a_name, a_x, a_y, a_width, a_win);
343 * Set up the creation parameters according to the information we've
346 light_crparams.onode_params.cr_type = GATOR_OBJ_LIGHT;
348 if (a_width >= sizeof(light_crparams.onode_params.cr_name))
349 a_width = sizeof(light_crparams.onode_params.cr_name) - 1;
354 if (strlcpy(light_crparams.onode_params.cr_name, a_name, a_width + 1) >= a_width + 1)
355 /* The name is truncated, put a '*' at the end to note */
356 light_crparams.onode_params.cr_name[a_width - 1] = '*';
358 light_crparams.onode_params.cr_x = a_x;
359 light_crparams.onode_params.cr_y = a_y;
360 light_crparams.onode_params.cr_width = a_width;
361 light_crparams.onode_params.cr_height = 1;
362 light_crparams.onode_params.cr_window = a_win;
363 light_crparams.onode_params.cr_home_obj = NULL;
364 light_crparams.onode_params.cr_prev_obj = NULL;
365 light_crparams.onode_params.cr_parent_obj = NULL;
366 light_crparams.onode_params.cr_helpstring = NULL;
368 light_crparams.appearance = 0;
369 light_crparams.flashfreq = 0;
370 sprintf(light_crparams.label, "%s", a_name);
371 light_crparams.label_x = 0;
372 light_crparams.label_y = 0;
375 gator_objects_create((struct onode_createparams *)(&light_crparams));
378 * Return the news, happy or not.
382 } /*initLightObject */
386 /*------------------------------------------------------------------------
390 * Place the chars in the source buffer into the target buffer
391 * with the desired justification, either centered, left-justified
392 * or right-justified. Also, support inidication of truncation
393 * with a star (*), either on the left or right of the string,
394 * and whether we're justifying a labeled disk quantity.
396 * (derived from mini_justify() in scout.c)
399 * char *a_srcbuff : Ptr to source char buffer.
400 * char *a_dstbuff : Ptr to dest char buffer.
401 * int a_dstwidth : Width of dest buffer in chars.
402 * int a_justification : Kind of justification.
403 * int a_rightTrunc : If non-zero, place the truncation char
404 * on the right of the string. Otherwise,
405 * place it on the left.
411 *------------------------------------------------------------------------*/
414 justify_light(char *a_srcbuff, char *a_dstbuff, int a_dstwidth,
415 int a_justification, int a_rightTrunc)
418 static char rn[] = "justify_light"; /*Routine name */
419 int leftpad_chars; /*# of chars for left-padding */
420 int num_src_chars; /*# of chars in source */
421 int true_num_src_chars; /*# src chars before truncation */
422 int trunc_needed; /*Is truncation needed? */
425 /* the following debug statement floods the debug file */
426 #ifdef DEBUG_DETAILED
429 "[ %s ] Called, a_srcbuff= %s, a_dstbuff= %d, a_dstwidth= %d, a_justification= %d, a_rightTrunc= %d\n",
430 rn, a_srcbuff, a_dstbuff, a_dstwidth, a_justification,
438 * If the destination width will overrun the gtx string storage,
439 * we automatically shorten up.
441 if (a_dstwidth > GATOR_LABEL_CHARS) {
443 * if (afsmon_debug) {
445 * "[%s] Dest width (%d) > gtx buflen (%d), shrinking dest width\n",
446 * rn, a_dstwidth, GATOR_LABEL_CHARS);
450 a_dstwidth = GATOR_LABEL_CHARS;
454 * If our source string is too long, prepare for truncation.
456 true_num_src_chars = strlen(a_srcbuff);
457 if (true_num_src_chars >= a_dstwidth) {
459 num_src_chars = a_dstwidth - 1;
462 a_srcbuff += (true_num_src_chars - num_src_chars);
465 num_src_chars = true_num_src_chars;
468 * Compute the necessary left-padding.
470 switch (a_justification) {
473 leftpad_chars = (a_dstwidth - 1) - num_src_chars;
478 * This is the really easy one.
484 leftpad_chars = ((a_dstwidth - 1) - num_src_chars) / 2;
489 fprintf(debugFD, "[%s] Illegal justification command: %d", rn,
491 fprintf(debugFD, "[%s] Called with '%s', dest width=%d\n", rn,
492 a_srcbuff, a_dstwidth);
496 } /*Switch on justification type */
500 * Clear out the dest buffer, then place the source string at the
501 * appropriate padding location. Remember to place a string
502 * terminator at the end of the dest buffer, plus whatever truncation
503 * may be needed. If we're left-truncating, we've already shifted
504 * the src buffer appropriately.
506 strncpy(a_dstbuff, blankline, a_dstwidth);
507 strncpy(a_dstbuff + leftpad_chars, a_srcbuff, num_src_chars);
508 *(a_dstbuff + a_dstwidth - 1) = '\0';
511 *(a_dstbuff + a_dstwidth - 2) = '*'; /*Truncate on the right */
513 *a_dstbuff = '*'; /*Truncate on the left, non-disk */
517 /*Handle truncations */
519 * Return the good news.
527 /*-----------------------------------------------------------------------
531 * Call the exit routine. This function is mapped
532 * to the keys Q and
\ 3 in all the frames and is called by the
534 *----------------------------------------------------------------------*/
537 afsmonExit_gtx(void *d1, void *d2)
539 static char rn[] = "afsmonExit_gtx";
542 fprintf(debugFD, "[ %s ] Called\n", rn);
547 return 0; /* not reached */
551 /*-----------------------------------------------------------------------
555 * Refresh the overview screen with the contents of the specified page.
556 * There are two parts to the overview screen - the file server column
557 * and the cache manager column and each of them is independent of the
558 * other. Hence it takes as an argumnet the "type" of update to be
563 * Failure: Exits afsmonitor.
564 *----------------------------------------------------------------------*/
567 ovw_refresh(int a_pageNum, /* page to refresh overview display */
568 int a_updateType) /* OVW_UPDATE_FS = update fs column only,
569 * OVW_UPDATE_CM = update cm column only,
570 * OVW_UPDATE_BOTH = update fs & cm columns. Note that
571 * we do not want to update a column until the
572 * corresponding probe cycle has completed */
575 static char rn[] = "ovw_refresh"; /* routine name */
576 struct onode **tmp_fsNames_o; /* ptr to fsNames onodes */
577 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
578 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
579 struct onode **tmp_cmNames_o; /* ptr to fsNames onodes */
580 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
581 int fsIdx; /* for counting # of CM hosts */
582 int cmIdx; /* for counting # of CM hosts */
583 char cmdLine[80]; /* buffer for command line */
584 char printBuf[256]; /* buffer to print to screen */
590 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_updateType= %d\n",
591 rn, a_pageNum, a_updateType);
595 /* if the data is not yet available ie., not one probe cycle has
596 * completed, do nothing */
598 if ((a_updateType & OVW_UPDATE_FS) && !fs_Data_Available)
600 if ((a_updateType & OVW_UPDATE_CM) && !cm_Data_Available)
604 /* validate page number */
605 if (a_pageNum < 1 || a_pageNum > ovw_numPages) {
606 sprintf(errMsg, "[ %s ] called with incorrect page number %d\n", rn,
611 /* set the current page number */
612 ovw_currPage = a_pageNum;
614 /* turn off init message */
617 gtxframe_RemoveFromList(ovwFrame, initMsg_o);
620 /* update the labels */
623 tmp_lightobj = (struct gator_lightobj *)ovw_progName_o->o_data;
624 sprintf(printBuf, "AFSMonitor [Version %s]", afsmon_version);
625 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
627 gator_light_set(ovw_progName_o, 1);
629 /* page number label */
630 tmp_lightobj = (struct gator_lightobj *)ovw_pageNum_o->o_data;
631 sprintf(printBuf, "[System Overview, p. %d of %d]", ovw_currPage,
633 justify_light(printBuf, tmp_lightobj->label, OVW_PAGENUM_O_WIDTH,
635 gator_light_set(ovw_pageNum_o, 1);
637 /* file servers monitored label */
638 tmp_lightobj = (struct gator_lightobj *)ovw_numFS_o->o_data;
639 sprintf(printBuf, " %d File Servers monitored", numFS);
640 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
643 /* cache managers monitored label */
644 tmp_lightobj = (struct gator_lightobj *)ovw_numCM_o->o_data;
645 sprintf(printBuf, " %d Cache Managers monitored", numCM);
646 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
650 /* no. of fs alerts label */
651 tmp_lightobj = (struct gator_lightobj *)ovw_FSalerts_o->o_data;
652 sprintf(printBuf, " %d alerts on %d machines", num_fs_alerts,
653 numHosts_onfs_alerts);
654 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
657 /* no. of cm alerts label */
658 tmp_lightobj = (struct gator_lightobj *)ovw_CMalerts_o->o_data;
659 sprintf(printBuf, " %d alerts on %d machines", num_cm_alerts,
660 numHosts_oncm_alerts);
661 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
665 /* determine if we have fs/cm, more/previous pages of data to display */
668 if (numFS && fs_Data_Available)
669 ovw_pageType |= CMD_FS; /* we have an fs frame & data avail. */
670 if (numCM && cm_Data_Available)
671 ovw_pageType |= CMD_CM; /* we have a cm frame & data avail. */
672 if (ovw_currPage > 1)
673 ovw_pageType |= CMD_PREV; /* got a previous page */
674 if (ovw_currPage < ovw_numPages)
675 ovw_pageType |= CMD_NEXT; /* got a next page */
677 strcpy(cmdLine, "Command [");
678 if ((ovw_pageType & CMD_FS) && (ovw_pageType & CMD_CM))
679 strcat(cmdLine, "fs, cm");
680 else if (ovw_pageType & CMD_FS)
681 strcat(cmdLine, "fs");
682 else if (ovw_pageType & CMD_CM)
683 strcat(cmdLine, "cm");
685 if (ovw_pageType & CMD_PREV)
686 strcat(cmdLine, ", prev");
687 if (ovw_pageType & CMD_NEXT)
688 strcat(cmdLine, ", next");
690 strcat(cmdLine, "]? ");
692 /* display the command line */
693 tmp_lightobj = (struct gator_lightobj *)ovw_cmd_o->o_data;
694 sprintf(printBuf, "%s", cmdLine);
695 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
697 gator_light_set(ovw_cmd_o, 1);
699 /* display probe numbers line */
700 tmp_lightobj = (struct gator_lightobj *)ovw_probeNum_o->o_data;
701 sprintf(printBuf, "[probes %d(fs) %d(cm), freq=%d sec]",
702 afsmon_fs_prev_probeNum, afsmon_cm_prev_probeNum,
704 justify_light(printBuf, tmp_lightobj->label, OVW_PROBENUM_O_WIDTH,
706 gator_light_set(ovw_probeNum_o, 1);
708 /* update the file server names column if we are asked to */
710 if (numFS && (a_updateType & OVW_UPDATE_FS)) {
712 /* move to the right spot in the FS display data array */
713 fsDataP = prev_fsData;
715 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
720 /* get the address to the first FS name */
721 tmp_fsNames_o = ovw_fsNames_o;
723 for (i = 0; i < ovw_numHosts_perPage; i++) {
724 if (fsIdx < numFS) { /* this could be the last & partial page */
726 if (fsDataP->hostName[0] == '\0') {
727 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
731 /* check if the probe succeeded. if it did check for thresholds
732 * overflow. A failed probe is indicated by "PF" */
734 if (!fsDataP->probeOK) {
735 sprintf(printBuf, "[ PF] %s", fsDataP->hostName);
736 } else if (fsDataP->ovfCount) /* thresholds overflow */
737 sprintf(printBuf, "[%3d] %s", fsDataP->ovfCount,
740 sprintf(printBuf, " %s", fsDataP->hostName);
744 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
747 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
749 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
750 len = OVW_HOSTNAME_O_WIDTH_HGL;
752 len = strlen(printBuf) + 1;
755 justify_light(printBuf, tmp_lightobj->label, len,
759 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
764 /* highlighten if overflowed or probe failed */
766 if (fsDataP->ovfCount || !fsDataP->probeOK)
767 gator_light_set(*tmp_fsNames_o, 1);
769 gator_light_set(*tmp_fsNames_o, 0);
772 } else { /* no more hosts, blank the rest of the entries */
774 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
775 sprintf(tmp_lightobj->label, "%s", "");
778 tmp_fsNames_o++; /* next onode */
779 fsDataP++; /* next host's data */
780 fsIdx++; /* host index */
785 /* if we have any cache managers, update them if we are asked to */
786 if (numCM && (a_updateType & OVW_UPDATE_CM)) {
788 /* move to the right spot in the CM display data array */
789 cmDataP = prev_cmData;
791 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
796 /* get the address to the first CM name */
797 tmp_cmNames_o = ovw_cmNames_o;
799 for (i = 0; i < ovw_numHosts_perPage; i++) {
800 if (cmIdx < numCM) { /* this could be the last & partial page */
802 if (cmDataP->hostName[0] == '\0') {
803 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
807 /* check if the probe succeeded. if it did check for thresholds
808 * overflow. A failed probe is indicated by "PF" */
810 if (!cmDataP->probeOK) {
811 sprintf(printBuf, "[ PF] %s", cmDataP->hostName);
812 } else if (cmDataP->ovfCount) { /* thresholds overflow */
813 sprintf(printBuf, "[%3d] %s", cmDataP->ovfCount,
816 sprintf(printBuf, " %s", cmDataP->hostName);
819 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
822 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
824 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
825 len = OVW_HOSTNAME_O_WIDTH_HGL;
827 len = strlen(printBuf) + 1;
830 justify_light(printBuf, tmp_lightobj->label, len,
834 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
839 /* highlighten if overflow or if probe failed */
840 if (cmDataP->ovfCount || !cmDataP->probeOK)
841 gator_light_set(*tmp_cmNames_o, 1);
843 gator_light_set(*tmp_cmNames_o, 0);
846 } else { /* no more hosts, blank the rest of the entries */
848 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
849 sprintf(tmp_lightobj->label, "%s", "");
852 tmp_cmNames_o++; /* next onode */
853 cmDataP++; /* next host's data */
854 cmIdx++; /* host index */
859 /* redraw the display if the overview screen is currently displayed */
860 if (afsmon_win->w_frame == ovwFrame)
861 WOP_DISPLAY(afsmon_win);
869 /*-----------------------------------------------------------------------
873 * Switch from the overview screen to the FS screen
874 *----------------------------------------------------------------------*/
876 Switch_ovw_2_fs(void *d1, void *d2)
878 static char rn[] = "Switch_ovw_2_fs";
881 fprintf(debugFD, "[ %s ] Called\n", rn);
885 /* bind the File Server frame to the window */
886 if (ovw_pageType & CMD_FS)
887 gtxframe_SetFrame(afsmon_win, fsFrame);
891 /*-----------------------------------------------------------------------
895 * Switch from the overview screen to the CM screen
896 *----------------------------------------------------------------------*/
898 Switch_ovw_2_cm(void *d1, void *d2)
900 static char rn[] = "Switch_ovw_2_cm";
903 fprintf(debugFD, "[ %s ] Called\n", rn);
907 /* bind the Cache Managers frame to the window */
908 if (ovw_pageType & CMD_CM)
909 gtxframe_SetFrame(afsmon_win, cmFrame);
913 /*-----------------------------------------------------------------------
917 * Switch to the next page in overview screen
918 *----------------------------------------------------------------------*/
920 Switch_ovw_next(void *d1, void *d2)
922 static char rn[] = "Switch_ovw_next";
925 fprintf(debugFD, "[ %s ] Called\n", rn);
929 if (ovw_pageType & CMD_NEXT) {
930 /* call refresh with the next page number */
931 ovw_refresh(ovw_currPage + 1, ovw_update_info);
937 /*-----------------------------------------------------------------------
941 * Switch to the last page in the overview screen
942 *----------------------------------------------------------------------*/
944 Switch_ovw_last(void *d1, void *d2)
946 static char rn[] = "Switch_ovw_last";
949 fprintf(debugFD, "[ %s ] Called\n", rn);
953 if (ovw_pageType & CMD_NEXT) {
954 /* call refresh with the last page number */
955 ovw_refresh(ovw_numPages, ovw_update_info);
961 /*-----------------------------------------------------------------------
965 * Switch to the previous page in the overview screen
966 *----------------------------------------------------------------------*/
968 Switch_ovw_prev(void *d1, void *d2)
970 static char rn[] = "Switch_ovw_prev";
973 fprintf(debugFD, "[ %s ] Called\n", rn);
977 if (ovw_pageType & CMD_PREV) {
978 /* call refresh with the previous page number */
979 ovw_refresh(ovw_currPage - 1, ovw_update_info);
984 /*-----------------------------------------------------------------------
988 * Switch to the first page in the overview screen
989 *----------------------------------------------------------------------*/
991 Switch_ovw_first(void *d1, void *d2)
993 static char rn[] = "Switch_ovw_first";
996 fprintf(debugFD, "[ %s ] Called\n", rn);
1000 if (ovw_pageType & CMD_PREV) {
1001 /* refresh with the first page number */
1002 ovw_refresh(1, ovw_update_info);
1007 /*-----------------------------------------------------------------------
1008 * create_ovwFrame_objects()
1011 * Create the gtx objects (onodes) for the overview frame and setup
1012 * the keyboard bindings.
1013 * Only as many objects as can fit on the display are created. The
1014 * positions and lengths of all these objects are fixed at creation.
1015 * These objects are updated with new data at the end of each probe
1020 * Failure: Exits afsmonitor.
1021 *----------------------------------------------------------------------*/
1024 create_ovwFrame_objects(void)
1025 { /* create_ovwFrame_objects */
1027 static char rn[] = "create_ovwFrame_objects";
1028 int hostLines; /* number of lines of host names to display */
1029 struct onode **ovw_fsNames_o_Ptr; /* index to list of fs names onodes */
1030 struct onode **ovw_cmNames_o_Ptr; /* index to list of cm names onodes */
1034 fprintf(debugFD, "[ %s ] Called\n", rn);
1038 /* get frame dimensions, it must be atleast MINXxMINY for any sensible output */
1039 WOP_GETDIMENSIONS(ovwFrame->window, &frameDims);
1040 maxX = frameDims.maxx;
1041 maxY = frameDims.maxy;
1042 if (maxX + 1 < MINX || maxY + 1 < MINY) {
1043 sprintf(errMsg1, "[ %s ] Window size %dx%d; must be at least %dx%d\n",
1044 rn, maxX + 1, maxY + 1, MINX, MINY);
1048 fprintf(debugFD, "maxX = %d maxY = %d\n", maxX, maxY);
1051 /* Print an Intial message to the screen. The init message is 36 chars
1054 initLightObject(initMsg, maxX / 2 - 18, maxY / 3, sizeof(initMsg),
1056 if (initMsg_o == NULL) {
1057 sprintf(errMsg, "[ %s ] Failed to create initMsg_o onode\n", rn);
1060 gtxframe_AddToList(ovwFrame, initMsg_o);
1061 gator_light_set(initMsg_o, HIGHLIGHT);
1066 /* create the command line object */
1068 ovw_cmd_o = initLightObject("", 0, maxY - 1, OVW_CMD_O_WIDTH, afsmon_win);
1069 if (ovw_cmd_o == NULL) {
1070 sprintf(errMsg, "[ %s ] Failed to create command onode\n", rn);
1073 gtxframe_AddToList(ovwFrame, ovw_cmd_o);
1074 gator_light_set(ovw_cmd_o, HIGHLIGHT);
1076 /* create the program name object */
1078 ovw_progName_o = initLightObject("", 0, 0, PROGNAME_O_WIDTH, afsmon_win);
1079 if (ovw_progName_o == NULL) {
1080 sprintf(errMsg, "[ %s ] Failed to create programName onode\n", rn);
1083 gtxframe_AddToList(ovwFrame, ovw_progName_o);
1084 gator_light_set(ovw_progName_o, HIGHLIGHT);
1086 /* create the page number object */
1089 initLightObject("", maxX - OVW_PAGENUM_O_WIDTH, 0,
1090 OVW_PAGENUM_O_WIDTH, afsmon_win);
1091 if (ovw_pageNum_o == NULL) {
1092 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
1095 gtxframe_AddToList(ovwFrame, ovw_pageNum_o);
1096 gator_light_set(ovw_pageNum_o, HIGHLIGHT);
1098 /* create the probe number object */
1100 initLightObject("", maxX - OVW_PROBENUM_O_WIDTH, maxY - 1,
1101 OVW_PROBENUM_O_WIDTH, afsmon_win);
1102 if (ovw_probeNum_o == NULL) {
1103 sprintf(errMsg, "[ %s ] Failed to create probe number onode\n", rn);
1106 gtxframe_AddToList(ovwFrame, ovw_probeNum_o);
1107 gator_light_set(ovw_probeNum_o, HIGHLIGHT);
1109 /* create the numFS monitored object */
1110 ovw_numFS_o = initLightObject("", 0, 2, FC_NUMHOSTS_O_WIDTH, afsmon_win);
1111 if (ovw_numFS_o == NULL) {
1112 sprintf(errMsg, "[ %s ] Failed to create numFS onode\n", rn);
1115 gtxframe_AddToList(ovwFrame, ovw_numFS_o);
1117 /* create the numCM monitored object */
1119 initLightObject("", maxX / 2, 2, OVW_NUMCM_O_WIDTH, afsmon_win);
1120 if (ovw_numCM_o == NULL) {
1121 sprintf(errMsg, "[ %s ] Failed to create numCM_o onode\n", rn);
1124 gtxframe_AddToList(ovwFrame, ovw_numCM_o);
1126 /* create the number-of-FS-alerts object */
1128 initLightObject("", 0, 3, OVW_FSALERTS_O_WIDTH, afsmon_win);
1129 if (ovw_FSalerts_o == NULL) {
1130 sprintf(errMsg, "[ %s ] Failed to create FSalerts_o onode\n", rn);
1133 gtxframe_AddToList(ovwFrame, ovw_FSalerts_o);
1135 /* create the number-of-CM-alerts object */
1137 initLightObject("", maxX / 2, 3, OVW_CMALERTS_O_WIDTH, afsmon_win);
1138 if (ovw_CMalerts_o == NULL) {
1139 sprintf(errMsg, "[ %s ] Failed to create CMalerts_o onode\n", rn);
1142 gtxframe_AddToList(ovwFrame, ovw_CMalerts_o);
1144 /* create file-server-name and cache-manager-names objects */
1145 ovw_numHosts_perPage = maxY - OVW_NUM_FIXED_LINES;
1147 /* allocate memory for a list of onode pointers for file server names */
1148 ovw_fsNames_o = malloc(sizeof(struct onode *) * ovw_numHosts_perPage);
1149 if (ovw_fsNames_o == NULL) {
1150 sprintf(errMsg, "[ %s ] Failed to allocate memory for FS onodes\n",
1155 /* create file server name objects */
1156 ovw_fsNames_o_Ptr = ovw_fsNames_o;
1157 for (i = 0; i < ovw_numHosts_perPage; i++) {
1158 *ovw_fsNames_o_Ptr =
1159 initLightObject("", 0, OVW_FIRST_HOST_ROW + i,
1160 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1161 if (*ovw_fsNames_o_Ptr == NULL) {
1162 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
1166 * if (afsmon_debug) {
1167 * fprintf(debugFD,"[ %s ] fsName_o %d: %d\n",
1168 * rn,i,*ovw_fsNames_o_Ptr);
1172 gtxframe_AddToList(ovwFrame, *ovw_fsNames_o_Ptr);
1173 ovw_fsNames_o_Ptr++;
1178 /* allocate memory for a list of onode pointers for cache manager names */
1179 ovw_cmNames_o = malloc(sizeof(struct onode *) * ovw_numHosts_perPage);
1180 if (ovw_cmNames_o == NULL) {
1181 sprintf(errMsg, "[ %s ] Failed to allocate memory for CM onodes\n",
1186 /* create cache manager name objects */
1187 ovw_cmNames_o_Ptr = ovw_cmNames_o;
1188 for (i = 0; i < ovw_numHosts_perPage; i++) {
1189 *ovw_cmNames_o_Ptr =
1190 initLightObject("", maxX / 2, OVW_FIRST_HOST_ROW + i,
1191 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1192 if (*ovw_cmNames_o_Ptr == NULL) {
1193 sprintf(errMsg, "[ %s ] Failed to create a CM name onode\n", rn);
1196 gtxframe_AddToList(ovwFrame, *ovw_cmNames_o_Ptr);
1197 ovw_cmNames_o_Ptr++;
1201 /* Calculate the number of pages of overview data to display */
1202 /* host information starts at the 6th line from top and stops at 3rd
1203 * line from bottom of screen */
1210 ovw_numPages = hostLines / (maxY - OVW_NUM_FIXED_LINES);
1211 if (hostLines % (maxY - OVW_NUM_FIXED_LINES))
1215 fprintf(debugFD, "[ %s ] number of ovw pages = %d\n", rn,
1218 /* When the ovw_refresh() routine is called by the keyboard handlers the
1219 * following variable is used to determine if fs/cm/fs&cm info must be
1221 ovw_update_info = 0;
1223 ovw_update_info |= OVW_UPDATE_FS;
1225 ovw_update_info |= OVW_UPDATE_CM;
1227 /* bind the overview frame to a keyboard input handler */
1229 /* bind Q and
\ 3 to exit */
1230 keymap_BindToString(ovwFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
1231 keymap_BindToString(ovwFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
1233 /* f -> switch of fs frame */
1234 keymap_BindToString(ovwFrame->keymap, "f", Switch_ovw_2_fs, NULL, NULL);
1235 /* c -> switch of cm frame */
1236 keymap_BindToString(ovwFrame->keymap, "c", Switch_ovw_2_cm, NULL, NULL);
1237 /* n -> switch to next overview page */
1238 keymap_BindToString(ovwFrame->keymap, "n", Switch_ovw_next, NULL, NULL);
1239 /* N -> switch to last overview page */
1240 keymap_BindToString(ovwFrame->keymap, "N", Switch_ovw_last, NULL, NULL);
1241 /* p -> switch to previous overview page */
1242 keymap_BindToString(ovwFrame->keymap, "p", Switch_ovw_prev, NULL, NULL);
1243 /* P -> switch to first overview page */
1244 keymap_BindToString(ovwFrame->keymap, "P", Switch_ovw_first, NULL, NULL);
1248 } /* create_ovwFrame_objects */
1251 /*-----------------------------------------------------------------------
1255 * This function is called to determine the permissible keyboard
1256 * operations on the FS and CM frames. This information is used
1257 * to create an appropriate command line prompt. It also generates
1258 * a bit map of the permissible operations on this page which is
1259 * used by the keyboard-input handler routines.
1262 * Success: page-type (bit map of permissible operations)
1264 *----------------------------------------------------------------------*/
1267 resolve_CmdLine(char *a_buffer, /* buffer to copy command line */
1268 int a_currFrame, /* current frame ovw, fs or cm? */
1269 int a_currPage, /* current page number */
1270 int a_numPages, /* number of pages of data */
1271 int a_numCols, /* number of columns of data to display */
1272 int a_curr_LCol, /* current number of leftmost column */
1273 int a_cols_perPage, /* number of columns per page */
1274 int a_Data_Available)
1275 { /* resolve_CmdLine */
1276 static char rn[] = "resolve_CmdLine";
1281 "[ %s ] Called, a_buffer= %p, a_currFrame= %d, a_currPage= %d, a_numPages= %d, a_numCols= %d, a_curr_LCol= %d, a_cols_perPage= %d\n",
1282 rn, a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols,
1283 a_curr_LCol, a_cols_perPage);
1289 /* determine if we have fs/cm frames. If we do, note that we should not
1290 * let the user seen the initial junk we have there until the probe
1291 * results are available */
1292 if (a_currFrame == 1) { /* in the fs frame */
1293 if (numCM && cm_Data_Available)
1295 } else if (a_currFrame == 2) { /* in the cm frame */
1296 if (numFS && fs_Data_Available)
1300 fprintf(debugFD, "[ %s ] Wrong frame type %d\n", rn, a_currFrame);
1306 /* do we have next/previous pages */
1307 if (a_currPage < a_numPages)
1308 pageType |= CMD_NEXT; /* have a next page */
1310 pageType |= CMD_PREV; /* have a previous page */
1312 if (a_numCols > a_cols_perPage) {
1313 if (a_curr_LCol > 0)
1314 pageType |= CMD_LEFT; /* have columns on left */
1315 if ((a_curr_LCol + a_cols_perPage) < a_numCols)
1316 pageType |= CMD_RIGHT; /* have columns on right */
1319 /* now build the command line */
1321 strcpy(a_buffer, "Command [oview");
1322 if (pageType & CMD_FS)
1323 strcat(a_buffer, ", fs");
1324 if (pageType & CMD_CM)
1325 strcat(a_buffer, ", cm");
1326 if (pageType & CMD_PREV)
1327 strcat(a_buffer, ", prev");
1328 if (pageType & CMD_NEXT)
1329 strcat(a_buffer, ", next");
1330 if (pageType & CMD_LEFT)
1331 strcat(a_buffer, ", left");
1332 if (pageType & CMD_RIGHT)
1333 strcat(a_buffer, ", right");
1334 strcat(a_buffer, "]? ");
1338 } /* resolve_CmdLine */
1340 /*-----------------------------------------------------------------------
1341 * display_Server_datum()
1344 * The data in the file server & cache manager frames are displayed
1345 * in two objects, one below the other. If the data is too long to
1346 * fit in the first object it will overflow into the next. This is
1347 * to conserve real estate on the screen. This function copies the
1348 * contents of the source buffer adjusted to the two objects if the
1349 * probe had succeded. Otherwise it enters "--" in the first object
1350 * blanks out the second. If the object needs to be highlightned
1351 * (due to a threshold crossing) it is done.
1355 *----------------------------------------------------------------------*/
1357 display_Server_datum(char *a_srcBuf, /* source buffer */
1358 struct onode *a_firstObj_o, /* first object */
1359 struct onode *a_secondObj_o, /* second object */
1360 int a_probeOK, /* probe OK ? */
1361 int a_just, /* justification */
1362 int a_highlight) /* highlight object ? */
1363 { /* display_Server_datum */
1365 static char rn[] = "display_Server_datum";
1366 struct gator_lightobj *tmp_lightobj1;
1367 struct gator_lightobj *tmp_lightobj2;
1368 char part1[FC_COLUMN_WIDTH + 2];
1369 char part2[FC_COLUMN_WIDTH + 2];
1375 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %p, a_secondObj_o= %p, a_probeOK= %d, a_just= %d, a_highlight= %d\n",
1376 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK,
1377 a_just, a_highlight);
1382 tmp_lightobj1 = (struct gator_lightobj *)a_firstObj_o->o_data;
1383 tmp_lightobj2 = (struct gator_lightobj *)a_secondObj_o->o_data;
1385 if (a_probeOK) { /* probe is ok so fill in the data */
1387 /* check if it would fit in one object */
1388 if (strlen(a_srcBuf) < FC_COLUMN_WIDTH) {
1389 strcpy(part1, a_srcBuf);
1392 /* break up the src string into 2 parts */
1393 /* note that column width includes terminator */
1394 strncpy(part1, a_srcBuf, FC_COLUMN_WIDTH - 1);
1395 part1[FC_COLUMN_WIDTH - 1] = '\0';
1396 strncpy(part2, a_srcBuf + FC_COLUMN_WIDTH - 1,
1397 FC_COLUMN_WIDTH - 1);
1401 } else { /* probe failed, enter "--"s */
1402 strcpy(part1, "--");
1406 /* if (afsmon_debug) {
1407 * fprintf(debugFD,"[ %s ] %s split to %s & %s\n",rn,a_srcBuf,part1,part2);
1411 /* initialize both the objects */
1414 justify_light(part1, tmp_lightobj1->label, FC_COLUMN_WIDTH, a_just,
1418 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1424 justify_light(part2, tmp_lightobj2->label, FC_COLUMN_WIDTH, a_just,
1428 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1433 /* highlight them */
1434 if (a_highlight && (part1[0] != '-'))
1435 gator_light_set(a_firstObj_o, 1);
1437 gator_light_set(a_firstObj_o, 0);
1438 if (a_highlight && (part2[0] != '\0'))
1439 gator_light_set(a_secondObj_o, 1);
1441 gator_light_set(a_secondObj_o, 0);
1447 } /* display_Server_datum */
1450 /*-----------------------------------------------------------------------
1451 * display_Server_label()
1454 * Display the given server label in three objects. The label is
1455 * partitioned into three parts by '/'s and each part is copied
1456 * into each label object.
1460 *----------------------------------------------------------------------*/
1463 display_Server_label(char *a_srcBuf,
1464 struct onode *a_firstObj_o, /* first object */
1465 struct onode *a_secondObj_o, /* second object */
1466 struct onode *a_thirdObj_o) /* third object */
1467 { /* display_Server_label */
1468 static char rn[] = "display_Server_label";
1469 char part[3][20]; /* buffer for three parts of label */
1471 struct gator_lightobj *tmp_lightobj;
1472 struct onode *objPtr_o[3];
1479 /* the following debug statement floods the debug file */
1480 #ifdef DEBUG_DETAILED
1483 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_thirdObj_o= %d\n",
1484 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o);
1490 /* break the label string into three parts */
1495 /* now for a dumb precaution */
1497 strLen = strlen(a_srcBuf);
1500 for (i = 0; i < 3; i++) {
1502 while (*strPtr != '\0' && (len++ <= strLen)) {
1503 if (*strPtr == '/') {
1507 part[i][j] = *strPtr;
1515 * if (afsmon_debug) {
1516 * fprintf(debugFD,"[ %s ] LABELS %s -> %s %s %s\n",
1517 * rn, a_srcBuf, part[0], part[1], part[2]);
1522 objPtr_o[0] = a_firstObj_o;
1523 objPtr_o[1] = a_secondObj_o;
1524 objPtr_o[2] = a_thirdObj_o;
1526 /* display each label justified CENTER */
1528 for (i = 0; i < 3; i++) {
1529 tmp_lightobj = (struct gator_lightobj *)objPtr_o[i]->o_data;
1531 justify_light(part[i], tmp_lightobj->label, FC_COLUMN_WIDTH,
1535 fprintf(debugFD, "[ %s ] justify_light %d failed \n", rn, i);
1541 } /* display_Server_label */
1547 /*-----------------------------------------------------------------------
1551 * Refresh the File Servers screen with the given page number starting
1552 * at the given left-column number. The appropriate contents of
1553 * prev_fsData are displayed.
1554 * First the status labels at the four corners of the screen are
1555 * updated. Next the column labels are updated and then each row
1560 * Failure: Exits afsmoitor on a severe error.
1561 *----------------------------------------------------------------------*/
1565 fs_refresh(int a_pageNum, /* page to display */
1566 int a_LcolNum) /* starting (leftmost) column number */
1569 static char rn[] = "fs_refresh"; /* routine name */
1570 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
1571 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
1572 struct ServerInfo_line *tmp_fs_lines_P; /* tmp ptr to fs_lines */
1573 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
1574 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
1575 struct onode **fsLabels_o_Ptr1; /* ptr to label row 0 */
1576 struct onode **fsLabels_o_Ptr2; /* ptr to label row 1 */
1577 struct onode **fsLabels_o_Ptr3; /* ptr to label row 2 */
1578 char cmdLine[80]; /* buffer for command line */
1579 char printBuf[256]; /* buffer to print to screen */
1586 int dataIndex; /* index to the data[] field of
1587 * struct fs_Display_Data */
1590 fprintf(debugFD, "[ %s ] Called with row %d col %d \n", rn, a_pageNum,
1596 /* if the data is not yet available, ie., not one probe cycle has
1597 * completed, do nothing */
1599 if (!fs_Data_Available)
1603 /* validate the page number & column number */
1604 if (a_pageNum < 1 || a_pageNum > fs_numPages) {
1606 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
1612 if (a_LcolNum < 0 || a_LcolNum > fs_numCols) {
1614 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
1623 /* update the fixed labels */
1625 /* we reuse the ovw version lable and hence do not have to do anything
1628 /* page number label */
1629 tmp_lightobj = (struct gator_lightobj *)fs_pageNum_o->o_data;
1630 sprintf(printBuf, "[File Servers, p. %d of %d, c. %d of %d]", a_pageNum,
1631 fs_numPages, a_LcolNum + 1, fs_numCols);
1632 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
1634 gator_light_set(fs_pageNum_o, 1);
1636 /* file servers monitored label */
1637 tmp_lightobj = (struct gator_lightobj *)fs_numFS_o->o_data;
1638 sprintf(printBuf, "%d File Servers monitored, %d alerts on %d machines",
1639 numFS, num_fs_alerts, numHosts_onfs_alerts);
1640 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
1646 /* figure out what we need to show in the prompt & set the page type */
1647 /* the fs_pageType variable is in turn used by the keyboard handler
1648 * routines to call fs_refresh() with the correct parameters */
1650 fs_pageType = resolve_CmdLine(cmdLine, 1 /* fs frame */ , a_pageNum,
1651 fs_numPages, fs_numCols, a_LcolNum,
1652 fs_cols_perPage, 0);
1654 /* display the command line */
1655 tmp_lightobj = (struct gator_lightobj *)fs_cmd_o->o_data;
1656 sprintf(printBuf, "%s", cmdLine);
1657 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
1659 gator_light_set(fs_cmd_o, 1);
1661 /* update the probe number label */
1662 tmp_lightobj = (struct gator_lightobj *)fs_probeNum_o->o_data;
1663 sprintf(printBuf, "[FS probes %d, freq=%d sec]", afsmon_fs_prev_probeNum,
1665 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
1667 gator_light_set(fs_probeNum_o, 1);
1669 /* update "columns on left" signal */
1670 tmp_lightobj = (struct gator_lightobj *)fs_leftArrows_o->o_data;
1671 if (fs_pageType & CMD_LEFT)
1672 strcpy(printBuf, "<<<");
1674 strcpy(printBuf, "");
1675 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1677 gator_light_set(fs_leftArrows_o, 0);
1679 /* update "columns on right" signal */
1680 tmp_lightobj = (struct gator_lightobj *)fs_rightArrows_o->o_data;
1681 if (fs_pageType & CMD_RIGHT)
1682 strcpy(printBuf, ">>>");
1684 strcpy(printBuf, "");
1685 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1687 gator_light_set(fs_rightArrows_o, 0);
1691 /* UPDATE THE COLUMN LABELS */
1693 /* the column index is also used to index the label arrays */
1694 labelIdx = a_LcolNum;
1696 /* get the pointers to the three arrays of label onodes */
1697 fsLabels_o_Ptr1 = fsLabels_o[0];
1698 fsLabels_o_Ptr2 = fsLabels_o[1];
1699 fsLabels_o_Ptr3 = fsLabels_o[2];
1701 for (k = 0; k < fs_cols_perPage; k++) {
1703 if (labelIdx < fs_numCols) {
1704 dataIndex = fs_Display_map[labelIdx];
1705 display_Server_label(fs_labels[dataIndex], *fsLabels_o_Ptr1,
1706 *fsLabels_o_Ptr2, *fsLabels_o_Ptr3);
1708 labelIdx++; /* next label */
1710 display_Server_label("//", *fsLabels_o_Ptr1, *fsLabels_o_Ptr2,
1714 fsLabels_o_Ptr1++; /* next onode in label row 1 */
1715 fsLabels_o_Ptr2++; /* next onode in label row 2 */
1716 fsLabels_o_Ptr3++; /* next onode in label row 3 */
1718 } /* labels for each column */
1721 /* UPDATE THE FILE SERVER STATISTICS */
1723 /* move to the right spot in the FS display data array */
1724 fsDataP = prev_fsData;
1726 for (i = 0; i < ((a_pageNum - 1) * fs_numHosts_perPage); i++) {
1731 if (fsIdx >= numFS) { /* whoops! screwed up */
1732 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
1736 /* get the pointer to the first line of onodes of the file server frame */
1737 tmp_fs_lines_P = fs_lines;
1739 for (i = 0; i < fs_numHosts_perPage; i++) {
1742 /* if this is the last page we may not have file servers to fill up
1743 * the page, so check the index */
1744 if (fsIdx < numFS) {
1746 if (fsDataP->hostName[0] == '\0') {
1747 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
1751 /* display the hostname , first names only please! */
1753 sprintf(printBuf, "%s", fsDataP->hostName);
1754 for (j = 0; j < strlen(printBuf); j++) {
1755 if (printBuf[j] == '.') {
1762 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1764 justify_light(printBuf, tmp_lightobj->label,
1765 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
1767 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1772 /* use the current column value to index into the fs_Display_map
1773 * array to obtain the index of the item to display. check if its
1774 * overflow flag is set and highlight if so. if the probe had failed
1775 * enter "--" is all columns */
1777 /* each host has two rows of slots for datums. get the pointers to
1778 * both the arrays */
1780 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1781 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1782 fs_curr_RCol = a_LcolNum; /* starting column number from which
1783 * we are asked to display data */
1785 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
1787 /* if there is another column of data */
1788 if (fs_curr_RCol < fs_numCols) {
1790 dataIndex = fs_Display_map[fs_curr_RCol];
1792 display_Server_datum(fsDataP->data[dataIndex],
1795 fsDataP->probeOK, RIGHT_JUSTIFY,
1796 fsDataP->threshOvf[dataIndex]);
1799 } else { /* no more data, blank out columns */
1800 display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
1801 RIGHT_JUSTIFY, 0); /* no overflow */
1805 firstSlot_o_Ptr++; /* onode of next column */
1806 secondSlot_o_Ptr++; /* onode of next column */
1808 } /* for each column */
1810 /* the loop could have taken the right-column-index one over,
1812 if (fs_curr_RCol == fs_numCols)
1820 /* if fdIdx < numFS */
1821 /* if fsIdx >= numFS , blank out all succeding rows */
1822 if (fsIdx >= numFS) {
1824 /* blank out host name object */
1826 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1828 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
1831 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1836 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1837 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1839 for (k = 0; k < fs_cols_perPage; k++) {
1840 display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
1841 RIGHT_JUSTIFY, 0); /* dont highlight */
1849 /* fsIDx >= numFS */
1850 tmp_fs_lines_P++; /* pointer to next line in the frame */
1851 fsDataP++; /* next host's data */
1852 fsIdx++; /* host index */
1855 } /* for each row in the File Servers frame */
1857 /* redraw the display if the File Servers screen is currently displayed */
1858 if (afsmon_win->w_frame == fsFrame)
1859 WOP_DISPLAY(afsmon_win);
1861 /* update the global page & column numbers to reflect the changes */
1862 fs_currPage = a_pageNum;
1863 fs_curr_LCol = a_LcolNum;;
1872 /*-----------------------------------------------------------------------
1876 * Switch from the File Server screen to the Overview Screen
1877 *----------------------------------------------------------------------*/
1879 Switch_fs_2_ovw(void *d1, void *d2)
1881 /* bind the overview frame to the window */
1882 gtxframe_SetFrame(afsmon_win, ovwFrame);
1886 /*-----------------------------------------------------------------------
1890 * Switch from the File Server screen to the Cache Managers screen.
1891 *----------------------------------------------------------------------*/
1893 Switch_fs_2_cm(void *d1, void *d2)
1895 if (fs_pageType & CMD_CM) {
1896 /* bind the overview Cache Managers to the window */
1897 gtxframe_SetFrame(afsmon_win, cmFrame);
1902 /*-----------------------------------------------------------------------
1906 * Switch to next page of file server screen
1907 *----------------------------------------------------------------------*/
1909 Switch_fs_next(void *d1, void *d2)
1911 if (fs_pageType & CMD_NEXT) {
1912 /* we have a next page, refresh with next page number */
1913 fs_refresh(fs_currPage + 1, fs_curr_LCol);
1919 /*-----------------------------------------------------------------------
1923 * Switch to last page of file server screen
1924 *----------------------------------------------------------------------*/
1926 Switch_fs_last(void *d1, void *d2)
1928 if (fs_pageType & CMD_NEXT) {
1929 /* we have a next page, refresh with the last page number */
1930 fs_refresh(fs_numPages, fs_curr_LCol);
1936 /*-----------------------------------------------------------------------
1940 * Switch to previous page of file server screen
1941 *----------------------------------------------------------------------*/
1943 Switch_fs_prev(void *d1, void *d2)
1945 if (fs_pageType & CMD_PREV) {
1946 /* we have a previous page, refresh with the rpevious page number */
1947 fs_refresh(fs_currPage - 1, fs_curr_LCol);
1952 /*-----------------------------------------------------------------------
1956 * Switch to first page of file server screen
1957 *----------------------------------------------------------------------*/
1959 Switch_fs_first(void *d1, void *d2)
1961 if (fs_pageType & CMD_PREV) {
1962 /* we have a previous page, got to first page */
1963 fs_refresh(1, fs_curr_LCol);
1968 /*-----------------------------------------------------------------------
1972 * Scroll left on the file server screen
1973 *----------------------------------------------------------------------*/
1975 Switch_fs_left(void *d1, void *d2)
1977 if (fs_pageType & CMD_LEFT) {
1978 /* we have columns on left, refresh with new column number */
1979 fs_refresh(fs_currPage, fs_curr_LCol - fs_cols_perPage);
1985 /*-----------------------------------------------------------------------
1986 * Switch_fs_leftmost()
1989 * Scroll to first column on the file server screen
1990 *----------------------------------------------------------------------*/
1992 Switch_fs_leftmost(void *d1, void *d2)
1994 if (fs_pageType & CMD_LEFT) {
1995 /* we have columns on left, go to the first */
1996 fs_refresh(fs_currPage, 0);
2001 /*-----------------------------------------------------------------------
2005 * Scroll right on the file server screen
2006 *----------------------------------------------------------------------*/
2008 Switch_fs_right(void *d1, void *d2)
2010 if (fs_pageType & CMD_RIGHT) {
2011 /* we have columns on right, refresh with new column number */
2012 fs_refresh(fs_currPage, fs_curr_LCol + fs_cols_perPage);
2017 /*-----------------------------------------------------------------------
2018 * Switch_fs_rightmost()
2021 * Scroll to last column on the file server screen
2022 *----------------------------------------------------------------------*/
2024 Switch_fs_rightmost(void *d1, void *d2)
2028 if (fs_pageType & CMD_RIGHT) {
2029 /* we have columns on right, go to the last column */
2030 if (fs_numCols % fs_cols_perPage)
2031 curr_LCol = (fs_numCols / fs_cols_perPage) * fs_cols_perPage;
2034 ((fs_numCols / fs_cols_perPage) - 1) * fs_cols_perPage;
2036 fs_refresh(fs_currPage, curr_LCol);
2042 /*-----------------------------------------------------------------------
2043 * create_FSframe_objects()
2046 * Create the gtx objects (onodes) for the Fileservers frame and setup
2047 * the keyboard bindings.
2048 * Only as many objects as can fit on the display are created. The
2049 * positions and lengths of all these objects are fixed at creation.
2050 * These objects are updated with new data at the end of each probe
2055 * Failure: Exits afsmonitor.
2056 *----------------------------------------------------------------------*/
2059 create_FSframe_objects(void)
2060 { /* create_FSframe_objects */
2061 static char rn[] = "create_FSframe_objects";
2062 struct ServerInfo_line *fs_lines_Ptr;
2063 struct onode **fs_data_o_Ptr;
2064 struct onode **fsLabels_o_Ptr;
2074 fprintf(debugFD, "[ %s ] Called\n", rn);
2078 /* create the command line object */
2080 initLightObject("Command [oview, cm, prev, next, left, right] ? ", 0,
2081 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2082 if (fs_cmd_o == NULL) {
2083 sprintf(errMsg, "[ %s ] Failed to create fs command onode\n", rn);
2086 gtxframe_AddToList(fsFrame, fs_cmd_o);
2087 gator_light_set(fs_cmd_o, HIGHLIGHT);
2089 /* we already have the dimensions for the frame - same as the ovw frame */
2090 /* use the ovw program name object for the fs screen too */
2092 gtxframe_AddToList(fsFrame, ovw_progName_o);
2095 /* create the page number object */
2097 initLightObject("[File Servers, p. X of X, c. Y of Y]",
2098 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2100 if (fs_pageNum_o == NULL) {
2101 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2104 gtxframe_AddToList(fsFrame, fs_pageNum_o);
2105 gator_light_set(fs_pageNum_o, HIGHLIGHT);
2107 /* create the probe number object */
2109 initLightObject("[FS probes 1, freq=30 sec]",
2110 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2111 FC_PROBENUM_O_WIDTH, afsmon_win);
2112 if (fs_probeNum_o == NULL) {
2113 sprintf(errMsg, "[ %s ] Failed to create fs probeNum onode\n", rn);
2116 gtxframe_AddToList(fsFrame, fs_probeNum_o);
2117 gator_light_set(fs_probeNum_o, HIGHLIGHT);
2120 /* create the numFS monitored object */
2123 (" 0 File Servers monitored, 0 alerts on 0 machines", 4, 2,
2124 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2125 if (fs_numFS_o == NULL) {
2127 "[ %s ] Failed to create numFS onode for the fs frame\n", rn);
2130 gtxframe_AddToList(fsFrame, fs_numFS_o);
2132 /* create the "more columns to left" indicator */
2134 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
2135 if (fs_leftArrows_o == NULL) {
2137 "[ %s ] Failed to create leftArrows onode for the fs frame\n",
2141 gtxframe_AddToList(fsFrame, fs_leftArrows_o);
2143 /* create the "more columns to right" indicator */
2145 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
2147 if (fs_rightArrows_o == NULL) {
2149 "[ %s ] Failed to create rightArrows onode for the fs frame\n",
2153 gtxframe_AddToList(fsFrame, fs_rightArrows_o);
2158 /* calculate the maximum number of hosts per page (2 rows per host) */
2159 fs_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
2161 /* determine the number of data columns that can fit in a page */
2162 fs_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
2165 fprintf(debugFD, "[ %s ] fs_numHosts_perPage=%d fs_cols_perPage=%d\n",
2166 rn, fs_numHosts_perPage, fs_cols_perPage);
2170 /* the above two variables give us the information needed to create
2171 * the objects for displaying the file server information */
2173 /* allocate memory for all the onode pointers required to display
2174 * the file server statistics */
2176 numBytes = fs_numHosts_perPage * sizeof(struct ServerInfo_line);
2177 fs_lines = malloc(numBytes);
2178 if (fs_lines == (struct ServerInfo_line *)0) {
2180 "[ %s ] Failed to allocate %d bytes for FS data lines\n", rn,
2185 /* for each line of server statistics allocate memory to store two arrays
2188 fs_lines_Ptr = fs_lines;
2189 for (i = 0; i < fs_numHosts_perPage; i++) {
2190 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
2191 numBytes = fs_cols_perPage * sizeof(struct onode *);
2192 fs_lines_Ptr->data_o[arrIdx] = malloc(numBytes);
2193 if (fs_lines_Ptr->data_o[arrIdx] == NULL) {
2195 "[ %s ] Failed to allocate %d bytes for FS data onodes\n",
2203 /* now allocate the onodes itself */
2205 fs_lines_Ptr = fs_lines;
2206 for (i = 0; i < fs_numHosts_perPage; i++) {
2208 /* initialize host name onode */
2209 fs_lines_Ptr->host_o =
2210 initLightObject("FSHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
2211 FC_HOSTNAME_O_WIDTH, afsmon_win);
2212 if (fs_lines_Ptr->host_o == NULL) {
2213 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
2216 gtxframe_AddToList(fsFrame, fs_lines_Ptr->host_o);
2218 /* if (afsmon_debug) {
2219 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
2220 * rn,fs_lines_Ptr->host_o,i);
2224 /* initialize data onodes for this host */
2226 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
2228 fs_data_o_Ptr = fs_lines_Ptr->data_o[arrIdx];
2229 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
2233 /* determine x & y coordinate for this data object */
2234 /* the 1's are for leaving a blank after each column */
2235 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
2236 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
2238 sprintf(tmpBuf, "-FSData %d-", arrIdx);
2240 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
2242 if (*fs_data_o_Ptr == NULL) {
2244 "[ %s ] Failed to create an FS data onode\n", rn);
2247 gtxframe_AddToList(fsFrame, *fs_data_o_Ptr);
2250 } /* for each column */
2251 } /* for each onode array index */
2254 } /* for each host slot */
2257 /* INITIALIZE COLUMN LABELS */
2260 /* allocate memory for two arrays of onode pointers for file server column
2262 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
2264 fsLabels_o[arrIdx] = malloc(sizeof(struct onode *) * fs_cols_perPage);
2265 if (fsLabels_o[arrIdx] == NULL) {
2267 "[ %s ] Failed to allocate memory for FS label onodes\n",
2272 /* create cache manager name objects */
2273 fsLabels_o_Ptr = fsLabels_o[arrIdx];
2274 for (i = 0; i < fs_cols_perPage; i++) {
2276 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
2277 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
2280 if (*fsLabels_o_Ptr == NULL) {
2281 sprintf(errMsg, "[ %s ] Failed to create a FS label onode\n",
2285 gtxframe_AddToList(fsFrame, *fsLabels_o_Ptr);
2292 /* initialize the column & page counters */
2295 fs_numCols = fs_DisplayItems_count;
2296 fs_numPages = numFS / fs_numHosts_perPage;
2297 if (numFS % fs_numHosts_perPage)
2299 fs_curr_LCol = 0; /* leftmost col */
2300 fs_curr_RCol = 0; /* rightmost col */
2302 /* create keyboard bindings */
2303 /* bind Q and
\ 3 to exit */
2304 keymap_BindToString(fsFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
2305 keymap_BindToString(fsFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
2307 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
2308 * N = last page, P = first page, L = leftmost col, R = rightmost col */
2310 keymap_BindToString(fsFrame->keymap, "o", Switch_fs_2_ovw, NULL, NULL);
2311 keymap_BindToString(fsFrame->keymap, "c", Switch_fs_2_cm, NULL, NULL);
2312 keymap_BindToString(fsFrame->keymap, "n", Switch_fs_next, NULL, NULL);
2313 keymap_BindToString(fsFrame->keymap, "N", Switch_fs_last, NULL, NULL);
2314 keymap_BindToString(fsFrame->keymap, "p", Switch_fs_prev, NULL, NULL);
2315 keymap_BindToString(fsFrame->keymap, "P", Switch_fs_first, NULL, NULL);
2316 keymap_BindToString(fsFrame->keymap, "l", Switch_fs_left, NULL, NULL);
2317 keymap_BindToString(fsFrame->keymap, "L", Switch_fs_leftmost, NULL, NULL);
2318 keymap_BindToString(fsFrame->keymap, "r", Switch_fs_right, NULL, NULL);
2319 keymap_BindToString(fsFrame->keymap, "R", Switch_fs_rightmost, NULL,
2323 } /* create_FSframe_objects */
2326 /*-----------------------------------------------------------------------
2327 * Function: cm_refresh()
2330 * Refresh the Cache Managers screen with the given page number starting
2331 * at the given left-column number. The appropriate contents of
2332 * prev_cmData are displayed.
2333 * First the status labels at the four corners of the screen are
2334 * updated. Next the column labels are updated and then each row
2339 * Failure: Exits afsmoitor on a severe error.
2340 *----------------------------------------------------------------------*/
2343 cm_refresh(int a_pageNum, /* page to display */
2344 int a_LcolNum) /* starting (leftmost) column number */
2347 static char rn[] = "cm_refresh"; /* routine name */
2348 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
2349 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
2350 struct ServerInfo_line *tmp_cm_lines_P; /* tmp ptr to cm_lines */
2351 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
2352 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
2353 struct onode **cmLabels_o_Ptr1; /* ptr to label row 0 */
2354 struct onode **cmLabels_o_Ptr2; /* ptr to label row 1 */
2355 struct onode **cmLabels_o_Ptr3; /* ptr to label row 2 */
2356 char cmdLine[80]; /* buffer for command line */
2357 char printBuf[256]; /* buffer to print to screen */
2364 int dataIndex; /* index to the data[] field of
2365 * struct cm_Display_Data */
2368 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_LcolNum= %d \n", rn,
2369 a_pageNum, a_LcolNum);
2374 /* if the data is not yet available, ie., not one probe cycle has
2375 * completed, do nothing */
2377 if (!cm_Data_Available)
2381 /* validate the page number & column number */
2382 if (a_pageNum < 1 || a_pageNum > cm_numPages) {
2384 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
2390 if (a_LcolNum < 0 || a_LcolNum > cm_numCols) {
2392 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
2401 /* update the fixed labels */
2403 /* we reuse the ovw version lable and hence do not have to do anything
2406 /* page number label */
2407 tmp_lightobj = (struct gator_lightobj *)cm_pageNum_o->o_data;
2408 sprintf(printBuf, "[Cache Managers, p.%d of %d, c.%d of %d]", a_pageNum,
2409 cm_numPages, a_LcolNum + 1, cm_numCols);
2410 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
2412 gator_light_set(cm_pageNum_o, 1);
2414 /* file servers monitored label */
2415 tmp_lightobj = (struct gator_lightobj *)cm_numCM_o->o_data;
2416 sprintf(printBuf, "%d Cache Managers monitored, %d alerts on %d machines",
2417 numCM, num_cm_alerts, numHosts_oncm_alerts);
2418 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
2424 /* figure out what we need to show in the prompt & set the page type */
2425 /* the cm_pageType variable is in turn used by the keyboard handler
2426 * routines to call cm_refresh() with the correct parameters */
2428 cm_pageType = resolve_CmdLine(cmdLine, 2 /* cm frame */ , a_pageNum,
2429 cm_numPages, cm_numCols, a_LcolNum,
2430 cm_cols_perPage, 0);
2432 /* display the command line */
2433 tmp_lightobj = (struct gator_lightobj *)cm_cmd_o->o_data;
2434 sprintf(printBuf, "%s", cmdLine);
2435 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
2437 gator_light_set(cm_cmd_o, 1);
2439 /* update the probe number label */
2440 tmp_lightobj = (struct gator_lightobj *)cm_probeNum_o->o_data;
2441 sprintf(printBuf, "[CM probes %d, freq=%d sec]", afsmon_cm_prev_probeNum,
2443 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
2445 gator_light_set(cm_cmd_o, 1);
2447 /* update "columns on left" signal */
2448 tmp_lightobj = (struct gator_lightobj *)cm_leftArrows_o->o_data;
2449 if (cm_pageType & CMD_LEFT)
2450 strcpy(printBuf, "<<<");
2452 strcpy(printBuf, "");
2453 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2455 gator_light_set(cm_leftArrows_o, 0);
2457 /* update "columns on right" signal */
2458 tmp_lightobj = (struct gator_lightobj *)cm_rightArrows_o->o_data;
2459 if (cm_pageType & CMD_RIGHT)
2460 strcpy(printBuf, ">>>");
2462 strcpy(printBuf, "");
2463 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2465 gator_light_set(cm_rightArrows_o, 0);
2469 /* UPDATE THE COLUMN LABELS */
2471 /* the column index is also used to index the label arrays */
2472 labelIdx = a_LcolNum;
2474 /* get the pointers to the three arrays of label onodes */
2475 cmLabels_o_Ptr1 = cmLabels_o[0];
2476 cmLabels_o_Ptr2 = cmLabels_o[1];
2477 cmLabels_o_Ptr3 = cmLabels_o[2];
2479 for (k = 0; k < cm_cols_perPage; k++) {
2481 if (labelIdx < cm_numCols) {
2482 dataIndex = cm_Display_map[labelIdx];
2483 display_Server_label(cm_labels[dataIndex], *cmLabels_o_Ptr1,
2484 *cmLabels_o_Ptr2, *cmLabels_o_Ptr3);
2486 labelIdx++; /* next label */
2488 display_Server_label("//", *cmLabels_o_Ptr1, *cmLabels_o_Ptr2,
2492 cmLabels_o_Ptr1++; /* next onode in label row 1 */
2493 cmLabels_o_Ptr2++; /* next onode in label row 2 */
2494 cmLabels_o_Ptr3++; /* next onode in label row 3 */
2496 } /* labels for each column */
2499 /* UPDATE THE FILE SERVER STATISTICS */
2501 /* move to the right spot in the CM display data array */
2502 cmDataP = prev_cmData;
2504 for (i = 0; i < ((a_pageNum - 1) * cm_numHosts_perPage); i++) {
2509 if (cmIdx >= numCM) { /* whoops! screwed up */
2510 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
2514 /* get the pointer to the first line of onodes of the file server frame */
2515 tmp_cm_lines_P = cm_lines;
2517 for (i = 0; i < cm_numHosts_perPage; i++) {
2520 /* if this is the last page we may not have file servers to fill up
2521 * the page, so check the index */
2522 if (cmIdx < numCM) {
2524 if (cmDataP->hostName[0] == '\0') {
2525 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
2529 /* display the hostname , first names only please! */
2531 sprintf(printBuf, "%s", cmDataP->hostName);
2532 for (j = 0; j < strlen(printBuf); j++) {
2533 if (printBuf[j] == '.') {
2540 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2542 justify_light(printBuf, tmp_lightobj->label,
2543 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
2545 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2550 /* use the current column value to index into the cm_Display_map
2551 * array to obtain the index of the item to display. check if its
2552 * overflow flag is set and highlight if so. if the probe had failed
2553 * enter "--" is all columns */
2555 /* each host has two rows of slots for datums. get the pointers to
2556 * both the arrays */
2558 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2559 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2560 cm_curr_RCol = a_LcolNum; /* starting column number from which
2561 * we are asked to display data */
2563 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
2565 /* if there is another column of data */
2566 if (cm_curr_RCol < cm_numCols) {
2568 dataIndex = cm_Display_map[cm_curr_RCol];
2570 display_Server_datum(cmDataP->data[dataIndex],
2573 cmDataP->probeOK, RIGHT_JUSTIFY,
2574 cmDataP->threshOvf[dataIndex]);
2577 } else { /* no more data, blank out columns */
2578 display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
2579 RIGHT_JUSTIFY, 0); /* no overflow */
2583 firstSlot_o_Ptr++; /* onode of next column */
2584 secondSlot_o_Ptr++; /* onode of next column */
2586 } /* for each column */
2588 /* the loop could have taken the right-column-index one over,
2590 if (cm_curr_RCol == cm_numCols)
2598 /* if fdIdx < numCM */
2599 /* if cmIdx >= numCM , blank out all succeding rows */
2600 if (cmIdx >= numCM) {
2602 /* blank out host name object */
2604 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2606 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
2609 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2614 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2615 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2617 for (k = 0; k < cm_cols_perPage; k++) {
2618 display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
2619 RIGHT_JUSTIFY, 0); /* dont highlight */
2627 /* cmIDx >= numCM */
2628 tmp_cm_lines_P++; /* pointer to next line in the frame */
2629 cmDataP++; /* next host's data */
2630 cmIdx++; /* host index */
2633 } /* for each row in the Cache Manager frame */
2635 /* redraw the display if the Cache Managers screen is currently displayed */
2636 if (afsmon_win->w_frame == cmFrame)
2637 WOP_DISPLAY(afsmon_win);
2639 /* update the global page & column numbers to reflect the changes */
2640 cm_currPage = a_pageNum;
2641 cm_curr_LCol = a_LcolNum;;
2649 /*-----------------------------------------------------------------------
2653 * Switch from the Cache Manager screen to the Overview Screen
2654 *----------------------------------------------------------------------*/
2656 Switch_cm_2_ovw(void *d1, void *d2)
2658 /* bind the overview frame to the window */
2659 gtxframe_SetFrame(afsmon_win, ovwFrame);
2663 /*-----------------------------------------------------------------------
2667 * Switch from the Cache Manager screen to the File Servers screen
2668 *----------------------------------------------------------------------*/
2670 Switch_cm_2_fs(void *d1, void *d2)
2672 if (cm_pageType & CMD_FS) {
2673 /* bind the file servers frame to the window */
2674 gtxframe_SetFrame(afsmon_win, fsFrame);
2679 /*-----------------------------------------------------------------------
2683 * Switch to next page of cache managers screen
2684 *----------------------------------------------------------------------*/
2686 Switch_cm_next(void *d1, void *d2)
2688 if (cm_pageType & CMD_NEXT) {
2689 /* we have a next page, refresh with next page number */
2690 cm_refresh(cm_currPage + 1, cm_curr_LCol);
2696 /*-----------------------------------------------------------------------
2700 * Switch to last page of file server screen
2701 *----------------------------------------------------------------------*/
2703 Switch_cm_last(void *d1, void *d2)
2705 if (cm_pageType & CMD_NEXT) {
2706 /* we have a next page, refresh with last page number */
2707 cm_refresh(cm_numPages, cm_curr_LCol);
2713 /*-----------------------------------------------------------------------
2717 * Switch to previous page of cache managers screen
2718 *----------------------------------------------------------------------*/
2720 Switch_cm_prev(void *d1, void *d2)
2722 if (cm_pageType & CMD_PREV) {
2723 /* we have a previous page, refresh to previous page */
2724 cm_refresh(cm_currPage - 1, cm_curr_LCol);
2729 /*-----------------------------------------------------------------------
2733 * Switch to first page of cache managers screen
2734 *----------------------------------------------------------------------*/
2736 Switch_cm_first(void *d1, void *d2)
2738 if (cm_pageType & CMD_PREV) {
2739 /* we have a previous page, refresh to first page */
2740 cm_refresh(1, cm_curr_LCol);
2745 /*-----------------------------------------------------------------------
2749 * Scroll left on the cache managers screen
2750 *----------------------------------------------------------------------*/
2752 Switch_cm_left(void *d1, void *d2)
2754 if (cm_pageType & CMD_LEFT) {
2755 /* we have columns on left, refresh with new column number */
2756 cm_refresh(cm_currPage, cm_curr_LCol - cm_cols_perPage);
2762 /*-----------------------------------------------------------------------
2763 * Switch_cm_leftmost()
2766 * Scroll to first column on the cache managers screen
2767 *----------------------------------------------------------------------*/
2769 Switch_cm_leftmost(void *d1, void *d2)
2771 if (cm_pageType & CMD_LEFT) {
2772 /* we have columns on left, go to the first column */
2773 cm_refresh(cm_currPage, 0);
2778 /*-----------------------------------------------------------------------
2782 * Scroll right on the cache managers screen
2783 *----------------------------------------------------------------------*/
2785 Switch_cm_right(void *d1, void *d2)
2787 if (cm_pageType & CMD_RIGHT) {
2788 /* we have columns on right, refresh with new column number */
2789 cm_refresh(cm_currPage, cm_curr_LCol + cm_cols_perPage);
2794 /*-----------------------------------------------------------------------
2795 * Switch_cm_rightmost()
2798 * Scroll to last column on the cache managers screen
2799 *----------------------------------------------------------------------*/
2801 Switch_cm_rightmost(void *d1, void *d2)
2805 if (cm_pageType & CMD_RIGHT) {
2806 /* we have columns on right, go to the last column */
2807 if (cm_numCols % cm_cols_perPage)
2808 curr_LCol = (cm_numCols / cm_cols_perPage) * cm_cols_perPage;
2811 ((cm_numCols / cm_cols_perPage) - 1) * cm_cols_perPage;
2812 cm_refresh(cm_currPage, curr_LCol);
2818 /*-----------------------------------------------------------------------
2819 * create_CMframe_objects()
2822 * Create the gtx objects (onodes) for the Cache Managers frame and setup
2823 * the keyboard bindings.
2824 * Only as many objects as can fit on the display are created. The
2825 * positions and lengths of all these objects are fixed at creation.
2826 * These objects are updated with new data at the end of each probe
2831 * Failure: Exits afsmonitor.
2832 *----------------------------------------------------------------------*/
2835 create_CMframe_objects(void)
2836 { /* create_CMframe_objects */
2837 static char rn[] = "create_CMframe_objects";
2838 struct ServerInfo_line *cm_lines_Ptr;
2839 struct onode **cm_data_o_Ptr;
2840 struct onode **cmLabels_o_Ptr;
2849 fprintf(debugFD, "[ %s ] Called\n", rn);
2855 /* create the command line object */
2857 initLightObject("Command [oview, fs, prev, next, left, right] ? ", 0,
2858 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2859 if (cm_cmd_o == NULL) {
2860 sprintf(errMsg, "[ %s ] Failed to create cm command onode\n", rn);
2863 gtxframe_AddToList(cmFrame, cm_cmd_o);
2864 gator_light_set(cm_cmd_o, HIGHLIGHT);
2867 /* we already have the dimensions for the frame - same as the ovw frame */
2868 /* use the ovw program name object for the cm screen too */
2870 gtxframe_AddToList(cmFrame, ovw_progName_o);
2873 /* create the page number object */
2875 initLightObject("[Cache Managers, p. X of X, c. Y of Y]",
2876 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2878 if (cm_pageNum_o == NULL) {
2879 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2882 gtxframe_AddToList(cmFrame, cm_pageNum_o);
2883 gator_light_set(cm_pageNum_o, HIGHLIGHT);
2885 /* create the probe number object */
2887 initLightObject("[CM probes 1, freq=30 sec]",
2888 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2889 FC_PROBENUM_O_WIDTH, afsmon_win);
2890 if (cm_probeNum_o == NULL) {
2891 sprintf(errMsg, "[ %s ] Failed to create cm probeNum onode\n", rn);
2894 gtxframe_AddToList(cmFrame, cm_probeNum_o);
2895 gator_light_set(cm_probeNum_o, HIGHLIGHT);
2898 /* create the numCM monitored object */
2901 (" 0 Cache Mangers monitored, 0 alerts on 0 machines", 4, 2,
2902 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2903 if (cm_numCM_o == NULL) {
2905 "[ %s ] Failed to create numCM onode for the cm frame\n", rn);
2908 gtxframe_AddToList(cmFrame, cm_numCM_o);
2910 /* create the "more columns to left" indicator */
2912 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
2913 if (cm_leftArrows_o == NULL) {
2915 "[ %s ] Failed to create leftArrows onode for the cm frame\n",
2919 gtxframe_AddToList(cmFrame, cm_leftArrows_o);
2921 /* create the "more columns to right" indicator */
2923 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
2925 if (cm_rightArrows_o == NULL) {
2927 "[ %s ] Failed to create rightArrows onode for the cm frame\n",
2931 gtxframe_AddToList(cmFrame, cm_rightArrows_o);
2936 /* calculate the maximum number of hosts per page (2 rows per host) */
2937 cm_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
2939 /* determine the number of data columns that can fit in a page */
2940 cm_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
2943 fprintf(debugFD, "[ %s ] cm_numHosts_perPage=%d cm_cols_perPage=%d\n",
2944 rn, cm_numHosts_perPage, cm_cols_perPage);
2948 /* the above two variables give us the information needed to create
2949 * the objects for displaying the file server information */
2951 /* allocate memory for all the onode pointers required to display
2952 * the file server statistics */
2954 numBytes = cm_numHosts_perPage * sizeof(struct ServerInfo_line);
2955 cm_lines = malloc(numBytes);
2956 if (cm_lines == (struct ServerInfo_line *)0) {
2958 "[ %s ] Failed to allocate %d bytes for CM data lines\n", rn,
2963 /* for each line of server statistics allocate memory to store two arrays
2966 cm_lines_Ptr = cm_lines;
2967 for (i = 0; i < cm_numHosts_perPage; i++) {
2968 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
2969 numBytes = cm_cols_perPage * sizeof(struct onode *);
2970 cm_lines_Ptr->data_o[arrIdx] = malloc(numBytes);
2971 if (cm_lines_Ptr->data_o[arrIdx] == NULL) {
2973 "[ %s ] Failed to allocate %d bytes for CM data onodes\n",
2981 /* now allocate the onodes itself */
2983 cm_lines_Ptr = cm_lines;
2984 for (i = 0; i < cm_numHosts_perPage; i++) {
2986 /* initialize host name onode */
2987 cm_lines_Ptr->host_o =
2988 initLightObject("CMHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
2989 FC_HOSTNAME_O_WIDTH, afsmon_win);
2990 if (cm_lines_Ptr->host_o == NULL) {
2991 sprintf(errMsg, "[ %s ] Failed to create an CM name onode\n", rn);
2994 gtxframe_AddToList(cmFrame, cm_lines_Ptr->host_o);
2996 /* if (afsmon_debug) {
2997 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
2998 * rn,cm_lines_Ptr->host_o,i);
3002 /* initialize data onodes for this host */
3004 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
3006 cm_data_o_Ptr = cm_lines_Ptr->data_o[arrIdx];
3007 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
3011 /* determine x & y coordinate for this data object */
3012 /* the 1's are for leaving a blank after each column */
3013 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
3014 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
3016 sprintf(tmpBuf, "-CMData %d-", arrIdx);
3018 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
3020 if (*cm_data_o_Ptr == NULL) {
3022 "[ %s ] Failed to create an CM data onode\n", rn);
3025 gtxframe_AddToList(cmFrame, *cm_data_o_Ptr);
3028 } /* for each column */
3029 } /* for each onode array index */
3032 } /* for each host slot */
3035 /* INITIALIZE COLUMN LABELS */
3038 /* allocate memory for two arrays of onode pointers for file server column
3040 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
3042 cmLabels_o[arrIdx] = malloc(sizeof(struct onode *) * cm_cols_perPage);
3043 if (cmLabels_o[arrIdx] == NULL) {
3045 "[ %s ] Failed to allocate memory for CM label onodes\n",
3050 /* create cache manager name objects */
3051 cmLabels_o_Ptr = cmLabels_o[arrIdx];
3052 for (i = 0; i < cm_cols_perPage; i++) {
3054 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
3055 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
3058 if (*cmLabels_o_Ptr == NULL) {
3059 sprintf(errMsg, "[ %s ] Failed to create a CM label onode\n",
3063 gtxframe_AddToList(cmFrame, *cmLabels_o_Ptr);
3069 /* initialize the column & page counters */
3072 cm_numCols = cm_DisplayItems_count;
3073 cm_numPages = numCM / cm_numHosts_perPage;
3074 if (numCM % cm_numHosts_perPage)
3076 cm_curr_LCol = 0; /* leftmost col */
3077 cm_curr_RCol = 0; /* rightmost col */
3079 /* create keyboard bindings */
3080 /* bind Q and
\ 3 to exit */
3081 keymap_BindToString(cmFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
3082 keymap_BindToString(cmFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
3084 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
3085 * N = last page, P = first page, L = leftmost col, R = rightmost col */
3087 keymap_BindToString(cmFrame->keymap, "o", Switch_cm_2_ovw, NULL, NULL);
3088 keymap_BindToString(cmFrame->keymap, "f", Switch_cm_2_fs, NULL, NULL);
3089 keymap_BindToString(cmFrame->keymap, "n", Switch_cm_next, NULL, NULL);
3090 keymap_BindToString(cmFrame->keymap, "N", Switch_cm_last, NULL, NULL);
3091 keymap_BindToString(cmFrame->keymap, "p", Switch_cm_prev, NULL, NULL);
3092 keymap_BindToString(cmFrame->keymap, "P", Switch_cm_first, NULL, NULL);
3093 keymap_BindToString(cmFrame->keymap, "l", Switch_cm_left, NULL, NULL);
3094 keymap_BindToString(cmFrame->keymap, "L", Switch_cm_leftmost, NULL, NULL);
3095 keymap_BindToString(cmFrame->keymap, "r", Switch_cm_right, NULL, NULL);
3096 keymap_BindToString(cmFrame->keymap, "R", Switch_cm_rightmost, NULL,
3100 } /* create_CMframe_objects */
3104 /*-----------------------------------------------------------------------
3108 * Initialize the gtx package and call routines to create the objects
3109 * for the overview, File Servers & Cache Managers screens.
3110 *----------------------------------------------------------------------*/
3112 gtx_initialize(void)
3113 { /* gtx_initialize */
3114 static char rn[] = "gtx_initialize"; /* routine name */
3118 fprintf(debugFD, "[ %s ] Called\n", rn);
3122 afsmon_win = gtx_Init(0, -1); /* 0 => dont start input server,
3123 * 1 => use curses */
3124 if (afsmon_win == NULL) {
3125 sprintf(errMsg, "[ %s ] gtx initialization failed\n", rn);
3128 gtx_initialized = 1;
3130 /* Create the Overview frame */
3132 ovwFrame = gtxframe_Create();
3133 if (ovwFrame == (struct gtx_frame *)0) {
3134 sprintf(errMsg, "[ %s ] Failed to create overview frame\n", rn);
3138 /* bind the overview frame to the window */
3139 gtxframe_SetFrame(afsmon_win, ovwFrame);
3141 /* create overview frame objects */
3142 code = create_ovwFrame_objects();
3144 sprintf(errMsg, "[ %s ] Error in creating ovw frame objects\n", rn);
3149 /* Create the File Server frame */
3150 fsFrame = gtxframe_Create();
3151 if (fsFrame == (struct gtx_frame *)0) {
3152 sprintf(errMsg, "[ %s ] Failed to create file server frame\n", rn);
3157 /* Create File Server frame objects */
3158 code = create_FSframe_objects();
3160 sprintf(errMsg, "[ %s ] Error in creating FS frame objects\n", rn);
3164 /* Create the Cache Managers frame */
3165 cmFrame = gtxframe_Create();
3166 if (cmFrame == (struct gtx_frame *)0) {
3167 sprintf(errMsg, "[ %s ] Failed to create Cache Managers frame\n", rn);
3171 /* Create Cache Managers frame objects */
3172 code = create_CMframe_objects();
3174 sprintf(errMsg, "[ %s ] Error in creating CM frame objects\n", rn);
3178 /* misc initializations */
3179 sprintf(blankline, "%255s", " ");
3182 } /* gtx_initialize */