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>
29 #include <gtxwindows.h> /*Generic window package */
30 #include <gtxobjects.h> /*Object definitions */
32 #include <gtxtextcb.h> /*Text object circular buffer interface */
33 #include <gtxtextobj.h> /*Text object interface */
35 #include <gtxlightobj.h> /*Light object interface */
36 #include <gtxcurseswin.h> /*Curses window package */
37 #include <gtxdumbwin.h> /*Dumb terminal window package */
38 #include <gtxX11win.h> /*X11 window package */
39 #include <gtxframe.h> /*Frame package */
41 #include <afs/xstat_fs.h>
42 #include <afs/xstat_cm.h>
45 #include "afsmonitor.h"
46 #include "afsmon-labels.h"
49 /* afsmonitor version number */
50 static char afsmon_version[] = "1.0";
52 /* EXTERNAL VARIABLES (from afsmonitor.c) */
54 extern int afsmon_debug; /* debug info to file ? */
55 extern FILE *debugFD; /* debugging file descriptor */
56 extern char errMsg[256]; /* buffers used to print error messages after */
57 extern char errMsg1[256]; /* gtx is initialized (stderr/stdout gone !) */
59 /* number of fileservers and cache managers to monitor */
63 /* number of FS alerts and number of hosts on FS alerts */
64 extern int num_fs_alerts;
65 extern int numHosts_onfs_alerts;
67 /* number of CM alerts and number of hosts on FS alerts */
68 extern int num_cm_alerts;
69 extern int numHosts_oncm_alerts;
71 /* ptr to array holding the results of FS probes in ascii format */
72 extern struct fs_Display_Data *prev_fsData;
74 /* ptr to array holding the results of CM probes in ascii format */
75 extern struct cm_Display_Data *prev_cmData;
77 extern int afsmon_fs_curr_probeNum; /* current fs probe number */
78 extern int afsmon_fs_prev_probeNum; /* previous fs probe number */
79 extern int afsmon_cm_curr_probeNum; /* current cm probe number */
80 extern int afsmon_cm_prev_probeNum; /* previous cm probe number */
82 extern int afsmon_probefreq; /* probe frequency */
84 /* map of fs results items we must display. This array contains indices to
85 the fs_varNames[] array corresponding to the stats we want to display. It is
86 initialized while processing the config file */
88 extern short fs_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN];
89 extern int fs_DisplayItems_count; /* number of items to display */
91 extern short cm_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN];
92 extern int cm_DisplayItems_count; /* number of items to display */
97 /* minimum window size */
102 #define RIGHT_JUSTIFY 0
103 #define LEFT_JUSTIFY 1
106 /* width of overview frame objects */
107 /* field widths include the terminating null character */
109 #define PROGNAME_O_WIDTH (maxX/2) /* program name object */
110 #define OVW_PAGENUM_O_WIDTH 29 /* page number object */
111 #define OVW_PROBENUM_O_WIDTH 39 /* probe number object */
112 #define OVW_CMD_O_WIDTH (maxX/2) /* cmd line object */
113 #define OVW_NUMFS_O_WIDTH 40 /* num FSs monitored */
114 #define OVW_NUMCM_O_WIDTH 40 /* num CMs monitored */
115 #define OVW_FSALERTS_O_WIDTH 40 /* num FS alerts */
116 #define OVW_CMALERTS_O_WIDTH 40 /* num CM alerts */
117 #define OVW_HOSTNAME_O_WIDTH (maxX / 2) /* FS & CM host names */
118 #define OVW_HOSTNAME_O_WIDTH_HGL 30 /* cosmetic, atleast this many chars
119 * will be highlightned */
121 /* widths of FS and CM frame objects */
122 #define FC_NUMHOSTS_O_WIDTH (maxX - 8) /* number of fs monitored. leave 4
123 * chars on either side for '<<','>>' */
124 #define FC_PAGENUM_O_WIDTH 43
125 #define FC_HOSTNAME_O_WIDTH 11 /* width of FS hostnames column */
126 #define FC_CMD_O_WIDTH 55 /* width of cmd line */
127 #define FC_PROBENUM_O_WIDTH 30 /* width of probe number object */
128 #define FC_ARROWS_O_WIDTH 4 /* width of arrow indicators */
129 #define FC_COLUMN_WIDTH 11 /* width of data columns */
131 /* bit definitions for use in resolving command line */
132 /* these bits are set in the xx_pageType variables to indicate what commands
135 #define CMD_NEXT 1 /* next page ? */
136 #define CMD_PREV 2 /* previous page ? */
137 #define CMD_LEFT 4 /* left scroll ? */
138 #define CMD_RIGHT 8 /* right scroll ? */
139 #define CMD_FS 16 /* file servers frame exists ? */
140 #define CMD_CM 32 /* cache managers frame exists ? */
143 #define FC_NUM_FIXED_LINES 10 /* number of fixed lines */
144 #define FC_FIRST_HOST_ROW 8 /* first host entry row number */
145 #define FC_FIRST_LABEL_ROW 4 /* first label row number */
147 /* number of fixed lines (that dont change) on the overview screen */
148 #define OVW_NUM_FIXED_LINES 7
149 #define OVW_FIRST_HOST_ROW 5 /* row index of first host entry in ovw frame */
151 #define HIGHLIGHT 1 /* highlight object? */
153 static char blankline[256]; /* blank line */
155 /* maximum X & Y coordinates of the frames */
159 struct gwin *afsmon_win; /* afsmonitor window */
160 int gtx_initialized = 0;
162 /* Overview screen related definitions */
164 struct gtx_frame *ovwFrame; /* overview screen frame */
165 struct gwin_sizeparams frameDims; /* frame dimensions. all frames have
168 /* overview frame object names */
169 struct onode *ovw_progName_o; /* program name object */
170 struct onode *ovw_pageNum_o; /* page number onject */
171 struct onode *ovw_cmd_o; /* command line object */
172 struct onode *ovw_probeNum_o; /* probe number object */
173 struct onode *ovw_numFS_o; /* num FS monitored */
174 struct onode *ovw_numCM_o; /* num CM monitored */
175 struct onode *ovw_FSalerts_o; /* nunber of FS alerts */
176 struct onode *ovw_CMalerts_o; /* nunber of CM alerts */
177 struct onode *initMsg_o; /* initialization message */
179 /* number of pages of data for the overview frame */
180 int ovw_numPages = 0;
181 int ovw_currPage = 1; /* current page number */
183 static int ovw_pageType = 0; /* one of the above types */
185 /* number of rows of server names that can be displayed on one overview page*/
186 int ovw_numHosts_perPage;
188 /* ptr to a block of ovw_numHosts_perPage number of objects for file servers */
189 struct onode **ovw_fsNames_o;
190 /*ptr to a block of ovw_numHosts_perPage number of objects for cache managers */
191 struct onode **ovw_cmNames_o;
193 /* When the ovw_refresh routine is called by the keyboard handlers the
194 following variable is used to determine if fs/cm/fs&cm info must be updated */
195 int ovw_update_info = 0;
197 /* Variables needed to display an intialization message on startup */
198 static char *initMsg = "AFSMonitor Collecting Statistics ...";
199 static int initMsg_on = 0; /* message on ? */
201 /* FILE SERVER Screen related definitions */
203 struct gtx_frame *fsFrame; /* File Server screen frame */
205 struct onode *fs_pageNum_o; /* fs page number object */
206 struct onode *fs_cmd_o; /* fs command line object */
207 struct onode *fs_probeNum_o; /* fs probe number object */
208 struct onode *fs_numFS_o; /* fs number of FSs object */
209 struct onode *fs_leftArrows_o; /* fs cols on left signal object */
210 struct onode *fs_rightArrows_o; /* fs cols on right signal object */
211 struct onode **fs_hostNames_o; /* ptr to host names objects */
213 /* bit-map to characterize page type and contents of command prompt */
214 static int fs_pageType = 0;
216 /* coordinates for the File Servers screen */
218 /* we use page numbers to navigate vertically (ie, across hosts) and column
219 numbers to navigate horizontally */
221 int fs_numHosts_perPage; /* number of file servers per page */
222 int fs_cols_perPage; /* number of data columns per file server page */
223 int fs_currPage; /* current FS page number */
224 int fs_numPages; /* number of FS pages */
226 /* column numbers are index to the mapping structure fs_Display_map. this
227 map contains the indices of datums that should be displayed */
229 int fs_numCols; /* number of columns of FS data (excluding hostname) */
230 /* this is the same as fs_DisplayItems_count */
231 /* following column indices run from 1 to (fs_numCols -1) */
232 int fs_curr_LCol = 0; /* column number of leftmost column on display */
233 int fs_curr_RCol = 0; /* column number of rightmost column on display */
234 int fs_Data_Available = 0; /* atleast one fs probe cycle completed ? */
237 /* structure that defines a line of data in the fs/cm frames */
239 /* we store each datum value in two objects, one below the other. The reason
240 for doing this is to conserve screen area. most of the datums are just longs
241 and will fit into one object. some of them are timing values and require 13
242 characters to be displayed - such fields may overflow to the second object
243 placed below the first one. */
245 struct ServerInfo_line {
246 struct onode *host_o; /* hostname object */
247 struct onode **data_o[2]; /* ptrs to two arrays of data objects. */
251 struct ServerInfo_line *fs_lines; /* ptr to the file server data objects */
253 /* file server label onodes - three rows of them */
254 struct onode **fsLabels_o[3];
256 /* CACHE MANAGER Screen related definitions */
258 struct gtx_frame *cmFrame; /* Cache Manager screen frame */
260 struct onode *cm_pageNum_o; /* cm page number object */
261 struct onode *cm_cmd_o; /* cm command line object */
262 struct onode *cm_probeNum_o; /* cm probe number object */
263 struct onode *cm_numCM_o; /* cm number of FSs object */
264 struct onode *cm_leftArrows_o; /* fs cols on left signal object */
265 struct onode *cm_rightArrows_o; /* fs cols on right signal object */
267 struct onode **cm_hostNames_o; /* ptr to host names objects */
269 /* bit-map to characterize page type and contents of command prompt */
270 static int cm_pageType = 0;
272 /* coordinates for the Cache Managers screen */
274 /* we use page numbers to navigate vertically (ie, across hosts) and column
275 numbers to navigate horizontally */
277 int cm_numHosts_perPage; /* number of cache managers per page */
278 int cm_cols_perPage; /* number of data columns per file server page */
279 int cm_currPage; /* current CM page number */
280 int cm_numPages; /* number of CM pages */
282 /* column numbers are index to the mapping structure cm_Display_map. this
283 map contains the indices of datums that should be displayed */
285 int cm_numCols; /* number of columns of FS data (excluding hostname) */
286 /* this is the same as cm_DisplayItems_count */
287 /* following column indices run from 1 to (cm_numCols -1) */
288 int cm_curr_LCol = 0; /* column number of leftmost column on display */
289 int cm_curr_RCol = 0; /* column number of rightmost column on display */
290 int cm_Data_Available = 0; /* atleast one cm probe cycle completed ? */
293 /* structure that defines a line of data in the fs/cm frames */
294 struct ServerInfo_line *cm_lines; /* ptr to the file server data objects */
296 /* file server label onodes - three rows of them */
297 struct onode **cmLabels_o[3];
301 /*------------------------------------------------------------------------
305 * Create and initialize a light onode according to the given
307 * ( Borrowed from scout.c )
310 * char *a_name : Ptr to the light's string name.
311 * int a_x : X offset.
312 * int a_y : Y offset.
313 * int a_width : Width in chars.
314 * struct gwin *a_win : Ptr to window structure.
317 * Ptr to new light onode on success,
318 * A null pointer otherwise.
325 *------------------------------------------------------------------------*/
327 static struct onode *
328 initLightObject(a_name, a_x, a_y, a_width, a_win)
335 { /*initLightObject */
337 static char rn[] = "initLightObject"; /*Routine name */
338 struct onode *newlightp; /*Ptr to new light onode */
339 struct gator_light_crparams light_crparams; /*Light creation params */
340 char *truncname; /*Truncated name, if needed */
341 int name_len; /*True length of name */
343 /* the following debug statement floods the debug file */
344 #ifdef DEBUG_DETAILED
347 "[ %s ] Called, a_name= %s, a_x= %d, a_y= %d, a_width= %d, a_win= %d\n",
348 rn, a_name, a_x, a_y, a_width, a_win);
356 * Set up the creation parameters according to the information we've
359 light_crparams.onode_params.cr_type = GATOR_OBJ_LIGHT;
360 name_len = strlen(a_name);
362 if (name_len <= a_width)
363 sprintf(light_crparams.onode_params.cr_name, "%s", a_name);
366 * We need to truncate the given name, leaving a `*' at the end to
367 * show us it's been truncated.
369 truncname = light_crparams.onode_params.cr_name;
370 strncpy(truncname, a_name, a_width - 1);
371 truncname[a_width - 1] = '*';
372 truncname[a_width] = 0;
374 light_crparams.onode_params.cr_x = a_x;
375 light_crparams.onode_params.cr_y = a_y;
376 light_crparams.onode_params.cr_width = a_width;
377 light_crparams.onode_params.cr_height = 1;
378 light_crparams.onode_params.cr_window = a_win;
379 light_crparams.onode_params.cr_home_obj = NULL;
380 light_crparams.onode_params.cr_prev_obj = NULL;
381 light_crparams.onode_params.cr_parent_obj = NULL;
382 light_crparams.onode_params.cr_helpstring = NULL;
384 light_crparams.appearance = 0;
385 light_crparams.flashfreq = 0;
386 sprintf(light_crparams.label, "%s", a_name);
387 light_crparams.label_x = 0;
388 light_crparams.label_y = 0;
391 gator_objects_create((struct onode_createparams *)(&light_crparams));
394 * Return the news, happy or not.
398 } /*initLightObject */
402 /*------------------------------------------------------------------------
406 * Place the chars in the source buffer into the target buffer
407 * with the desired justification, either centered, left-justified
408 * or right-justified. Also, support inidication of truncation
409 * with a star (*), either on the left or right of the string,
410 * and whether we're justifying a labeled disk quantity.
412 * (derived from mini_justify() in scout.c)
415 * char *a_srcbuff : Ptr to source char buffer.
416 * char *a_dstbuff : Ptr to dest char buffer.
417 * int a_dstwidth : Width of dest buffer in chars.
418 * int a_justification : Kind of justification.
419 * int a_rightTrunc : If non-zero, place the truncation char
420 * on the right of the string. Otherwise,
421 * place it on the left.
427 *------------------------------------------------------------------------*/
430 justify_light(a_srcbuff, a_dstbuff, a_dstwidth, a_justification, a_rightTrunc)
439 static char rn[] = "justify_light"; /*Routine name */
440 int leftpad_chars; /*# of chars for left-padding */
441 int num_src_chars; /*# of chars in source */
442 int true_num_src_chars; /*# src chars before truncation */
443 int trunc_needed; /*Is truncation needed? */
446 /* the following debug statement floods the debug file */
447 #ifdef DEBUG_DETAILED
450 "[ %s ] Called, a_srcbuff= %s, a_dstbuff= %d, a_dstwidth= %d, a_justification= %d, a_rightTrunc= %d\n",
451 rn, a_srcbuff, a_dstbuff, a_dstwidth, a_justification,
459 * If the destination width will overrun the gtx string storage,
460 * we automatically shorten up.
462 if (a_dstwidth > GATOR_LABEL_CHARS) {
464 * if (afsmon_debug) {
466 * "[%s] Dest width (%d) > gtx buflen (%d), shrinking dest width\n",
467 * rn, a_dstwidth, GATOR_LABEL_CHARS);
471 a_dstwidth = GATOR_LABEL_CHARS;
475 * If our source string is too long, prepare for truncation.
477 true_num_src_chars = strlen(a_srcbuff);
478 if (true_num_src_chars >= a_dstwidth) {
480 num_src_chars = a_dstwidth - 1;
483 a_srcbuff += (true_num_src_chars - num_src_chars);
486 num_src_chars = true_num_src_chars;
489 * Compute the necessary left-padding.
491 switch (a_justification) {
494 leftpad_chars = (a_dstwidth - 1) - num_src_chars;
499 * This is the really easy one.
505 leftpad_chars = ((a_dstwidth - 1) - num_src_chars) / 2;
510 fprintf(debugFD, "[%s] Illegal justification command: %d", rn,
512 fprintf(debugFD, "[%s] Called with '%s', dest width=%d\n", rn,
513 a_srcbuff, a_dstwidth);
517 } /*Switch on justification type */
521 * Clear out the dest buffer, then place the source string at the
522 * appropriate padding location. Remember to place a string
523 * terminator at the end of the dest buffer, plus whatever truncation
524 * may be needed. If we're left-truncating, we've already shifted
525 * the src buffer appropriately.
527 strncpy(a_dstbuff, blankline, a_dstwidth);
528 strncpy(a_dstbuff + leftpad_chars, a_srcbuff, num_src_chars);
529 *(a_dstbuff + a_dstwidth - 1) = '\0';
532 *(a_dstbuff + a_dstwidth - 2) = '*'; /*Truncate on the right */
534 *a_dstbuff = '*'; /*Truncate on the left, non-disk */
538 /*Handle truncations */
540 * Return the good news.
548 /*-----------------------------------------------------------------------
552 * Call the exit routine. This function is mapped
553 * to the keys Q and
\ 3 in all the frames and is called by the
555 *----------------------------------------------------------------------*/
560 static char rn[] = "afsmonExit_gtx";
563 fprintf(debugFD, "[ %s ] Called\n", rn);
571 /*-----------------------------------------------------------------------
575 * Refresh the overview screen with the contents of the specified page.
576 * There are two parts to the overview screen - the file server column
577 * and the cache manager column and each of them is independent of the
578 * other. Hence it takes as an argumnet the "type" of update to be
583 * Failure: Exits afsmonitor.
584 *----------------------------------------------------------------------*/
587 ovw_refresh(a_pageNum, a_updateType)
588 int a_pageNum; /* page to refresh overview display */
589 int a_updateType; /* OVW_UPDATE_FS = update fs column only,
590 * OVW_UPDATE_CM = update cm column only,
591 * OVW_UPDATE_BOTH = update fs & cm columns. Note that
592 * we do not want to update a column until the
593 * corresponding probe cycle has completed */
596 static char rn[] = "ovw_refresh"; /* routine name */
597 struct onode **tmp_fsNames_o; /* ptr to fsNames onodes */
598 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
599 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
600 struct onode **tmp_cmNames_o; /* ptr to fsNames onodes */
601 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
602 int fsIdx; /* for counting # of CM hosts */
603 int cmIdx; /* for counting # of CM hosts */
604 int next_page = 0; /* is there a next ovw page ? */
605 int prev_page = 0; /* is there a previous ovw page */
606 char cmdLine[80]; /* buffer for command line */
607 char printBuf[256]; /* buffer to print to screen */
613 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_updateType= %d\n",
614 rn, a_pageNum, a_updateType);
618 /* if the data is not yet available ie., not one probe cycle has
619 * completed, do nothing */
621 if ((a_updateType & OVW_UPDATE_FS) && !fs_Data_Available)
623 if ((a_updateType & OVW_UPDATE_CM) && !cm_Data_Available)
627 /* validate page number */
628 if (a_pageNum < 1 || a_pageNum > ovw_numPages) {
629 sprintf(errMsg, "[ %s ] called with incorrect page number %d\n", rn,
634 /* set the current page number */
635 ovw_currPage = a_pageNum;
637 /* turn off init message */
640 gtxframe_RemoveFromList(ovwFrame, initMsg_o);
643 /* update the labels */
646 tmp_lightobj = (struct gator_lightobj *)ovw_progName_o->o_data;
647 sprintf(printBuf, "AFSMonitor [Version %s]", afsmon_version);
648 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
650 gator_light_set(ovw_progName_o, 1);
652 /* page number label */
653 tmp_lightobj = (struct gator_lightobj *)ovw_pageNum_o->o_data;
654 sprintf(printBuf, "[System Overview, p. %d of %d]", ovw_currPage,
656 justify_light(printBuf, tmp_lightobj->label, OVW_PAGENUM_O_WIDTH,
658 gator_light_set(ovw_pageNum_o, 1);
660 /* file servers monitored label */
661 tmp_lightobj = (struct gator_lightobj *)ovw_numFS_o->o_data;
662 sprintf(printBuf, " %d File Servers monitored", numFS);
663 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
666 /* cache managers monitored label */
667 tmp_lightobj = (struct gator_lightobj *)ovw_numCM_o->o_data;
668 sprintf(printBuf, " %d Cache Managers monitored", numCM);
669 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
673 /* no. of fs alerts label */
674 tmp_lightobj = (struct gator_lightobj *)ovw_FSalerts_o->o_data;
675 sprintf(printBuf, " %d alerts on %d machines", num_fs_alerts,
676 numHosts_onfs_alerts);
677 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
680 /* no. of cm alerts label */
681 tmp_lightobj = (struct gator_lightobj *)ovw_CMalerts_o->o_data;
682 sprintf(printBuf, " %d alerts on %d machines", num_cm_alerts,
683 numHosts_oncm_alerts);
684 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
688 /* determine if we have fs/cm, more/previous pages of data to display */
691 if (numFS && fs_Data_Available)
692 ovw_pageType |= CMD_FS; /* we have an fs frame & data avail. */
693 if (numCM && cm_Data_Available)
694 ovw_pageType |= CMD_CM; /* we have a cm frame & data avail. */
695 if (ovw_currPage > 1)
696 ovw_pageType |= CMD_PREV; /* got a previous page */
697 if (ovw_currPage < ovw_numPages)
698 ovw_pageType |= CMD_NEXT; /* got a next page */
700 strcpy(cmdLine, "Command [");
701 if ((ovw_pageType & CMD_FS) && (ovw_pageType & CMD_CM))
702 strcat(cmdLine, "fs, cm");
703 else if (ovw_pageType & CMD_FS)
704 strcat(cmdLine, "fs");
705 else if (ovw_pageType & CMD_CM)
706 strcat(cmdLine, "cm");
708 if (ovw_pageType & CMD_PREV)
709 strcat(cmdLine, ", prev");
710 if (ovw_pageType & CMD_NEXT)
711 strcat(cmdLine, ", next");
713 strcat(cmdLine, "]? ");
718 /* display the command line */
719 tmp_lightobj = (struct gator_lightobj *)ovw_cmd_o->o_data;
720 sprintf(printBuf, "%s", cmdLine);
721 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
723 gator_light_set(ovw_cmd_o, 1);
725 /* display probe numbers line */
726 tmp_lightobj = (struct gator_lightobj *)ovw_probeNum_o->o_data;
727 sprintf(printBuf, "[probes %d(fs) %d(cm), freq=%d sec]",
728 afsmon_fs_prev_probeNum, afsmon_cm_prev_probeNum,
730 justify_light(printBuf, tmp_lightobj->label, OVW_PROBENUM_O_WIDTH,
732 gator_light_set(ovw_probeNum_o, 1);
736 /* update the file server names column if we are asked to */
738 if (numFS && (a_updateType & OVW_UPDATE_FS)) {
740 /* move to the right spot in the FS display data array */
741 fsDataP = prev_fsData;
743 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
748 /* get the address to the first FS name */
749 tmp_fsNames_o = ovw_fsNames_o;
751 for (i = 0; i < ovw_numHosts_perPage; i++) {
752 if (fsIdx < numFS) { /* this could be the last & partial page */
754 if (fsDataP->hostName[0] == '\0') {
755 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
759 /* check if the probe succeeded. if it did check for thresholds
760 * overflow. A failed probe is indicated by "PF" */
762 if (!fsDataP->probeOK) {
763 sprintf(printBuf, "[ PF] %s", fsDataP->hostName);
764 } else if (fsDataP->ovfCount) /* thresholds overflow */
765 sprintf(printBuf, "[%3d] %s", fsDataP->ovfCount,
768 sprintf(printBuf, " %s", fsDataP->hostName);
772 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
775 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
777 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
778 len = OVW_HOSTNAME_O_WIDTH_HGL;
780 len = strlen(printBuf) + 1;
783 justify_light(printBuf, tmp_lightobj->label, len,
787 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
792 /* highlighten if overflowed or probe failed */
794 if (fsDataP->ovfCount || !fsDataP->probeOK)
795 code = gator_light_set(*tmp_fsNames_o, 1);
797 code = gator_light_set(*tmp_fsNames_o, 0);
800 } else { /* no more hosts, blank the rest of the entries */
802 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
803 sprintf(tmp_lightobj->label, "%s", "");
806 tmp_fsNames_o++; /* next onode */
807 fsDataP++; /* next host's data */
808 fsIdx++; /* host index */
813 /* if we have any cache managers, update them if we are asked to */
814 if (numCM && (a_updateType & OVW_UPDATE_CM)) {
816 /* move to the right spot in the CM display data array */
817 cmDataP = prev_cmData;
819 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
824 /* get the address to the first CM name */
825 tmp_cmNames_o = ovw_cmNames_o;
827 for (i = 0; i < ovw_numHosts_perPage; i++) {
828 if (cmIdx < numCM) { /* this could be the last & partial page */
830 if (cmDataP->hostName[0] == '\0') {
831 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
835 /* check if the probe succeeded. if it did check for thresholds
836 * overflow. A failed probe is indicated by "PF" */
838 if (!cmDataP->probeOK) {
839 sprintf(printBuf, "[ PF] %s", cmDataP->hostName);
840 } else if (cmDataP->ovfCount) { /* thresholds overflow */
841 sprintf(printBuf, "[%3d] %s", cmDataP->ovfCount,
844 sprintf(printBuf, " %s", cmDataP->hostName);
847 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
850 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
852 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
853 len = OVW_HOSTNAME_O_WIDTH_HGL;
855 len = strlen(printBuf) + 1;
858 justify_light(printBuf, tmp_lightobj->label, len,
862 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
867 /* highlighten if overflow or if probe failed */
868 if (cmDataP->ovfCount || !cmDataP->probeOK)
869 code = gator_light_set(*tmp_cmNames_o, 1);
871 code = gator_light_set(*tmp_cmNames_o, 0);
874 } else { /* no more hosts, blank the rest of the entries */
876 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
877 sprintf(tmp_lightobj->label, "%s", "");
880 tmp_cmNames_o++; /* next onode */
881 cmDataP++; /* next host's data */
882 cmIdx++; /* host index */
887 /* redraw the display if the overview screen is currently displayed */
888 if (afsmon_win->w_frame == ovwFrame)
889 WOP_DISPLAY(afsmon_win);
897 /*-----------------------------------------------------------------------
901 * Switch from the overview screen to the FS screen
902 *----------------------------------------------------------------------*/
906 static char rn[] = "Switch_ovw_2_fs";
909 fprintf(debugFD, "[ %s ] Called\n", rn);
913 /* bind the File Server frame to the window */
914 if (ovw_pageType & CMD_FS)
915 gtxframe_SetFrame(afsmon_win, fsFrame);
919 /*-----------------------------------------------------------------------
923 * Switch from the overview screen to the CM screen
924 *----------------------------------------------------------------------*/
928 static char rn[] = "Switch_ovw_2_cm";
931 fprintf(debugFD, "[ %s ] Called\n", rn);
935 /* bind the Cache Managers frame to the window */
936 if (ovw_pageType & CMD_CM)
937 gtxframe_SetFrame(afsmon_win, cmFrame);
941 /*-----------------------------------------------------------------------
945 * Switch to the next page in overview screen
946 *----------------------------------------------------------------------*/
950 static char rn[] = "Switch_ovw_next";
953 fprintf(debugFD, "[ %s ] Called\n", rn);
957 if (ovw_pageType & CMD_NEXT) {
958 /* call refresh with the next page number */
959 ovw_refresh(ovw_currPage + 1, ovw_update_info);
965 /*-----------------------------------------------------------------------
969 * Switch to the last page in the overview screen
970 *----------------------------------------------------------------------*/
974 static char rn[] = "Switch_ovw_last";
977 fprintf(debugFD, "[ %s ] Called\n", rn);
981 if (ovw_pageType & CMD_NEXT) {
982 /* call refresh with the last page number */
983 ovw_refresh(ovw_numPages, ovw_update_info);
989 /*-----------------------------------------------------------------------
993 * Switch to the previous page in the overview screen
994 *----------------------------------------------------------------------*/
998 static char rn[] = "Switch_ovw_prev";
1001 fprintf(debugFD, "[ %s ] Called\n", rn);
1005 if (ovw_pageType & CMD_PREV) {
1006 /* call refresh with the previous page number */
1007 ovw_refresh(ovw_currPage - 1, ovw_update_info);
1012 /*-----------------------------------------------------------------------
1013 * Switch_ovw_first()
1016 * Switch to the first page in the overview screen
1017 *----------------------------------------------------------------------*/
1021 static char rn[] = "Switch_ovw_first";
1024 fprintf(debugFD, "[ %s ] Called\n", rn);
1028 if (ovw_pageType & CMD_PREV) {
1029 /* refresh with the first page number */
1030 ovw_refresh(1, ovw_update_info);
1035 /*-----------------------------------------------------------------------
1036 * create_ovwFrame_objects()
1039 * Create the gtx objects (onodes) for the overview frame and setup
1040 * the keyboard bindings.
1041 * Only as many objects as can fit on the display are created. The
1042 * positions and lengths of all these objects are fixed at creation.
1043 * These objects are updated with new data at the end of each probe
1048 * Failure: Exits afsmonitor.
1049 *----------------------------------------------------------------------*/
1052 create_ovwFrame_objects()
1053 { /* create_ovwFrame_objects */
1055 static char rn[] = "create_ovwFrame_objects";
1056 int hostLines; /* number of lines of host names to display */
1057 struct onode **ovw_fsNames_o_Ptr; /* index to list of fs names onodes */
1058 struct onode **ovw_cmNames_o_Ptr; /* index to list of cm names onodes */
1063 fprintf(debugFD, "[ %s ] Called\n", rn);
1067 /* get frame dimensions, it must be atleast MINXxMINY for any sensible output */
1068 WOP_GETDIMENSIONS(ovwFrame->window, &frameDims);
1069 maxX = frameDims.maxx;
1070 maxY = frameDims.maxy;
1071 if (maxX + 1 < MINX || maxY + 1 < MINY) {
1072 sprintf(errMsg1, "[ %s ] Window size %dx%d; must be at least %dx%d\n",
1073 rn, maxX + 1, maxY + 1, MINX, MINY);
1077 fprintf(debugFD, "maxX = %d maxY = %d\n", maxX, maxY);
1080 /* Print an Intial message to the screen. The init message is 36 chars
1083 initLightObject(initMsg, maxX / 2 - 18, maxY / 3, sizeof(initMsg),
1085 if (initMsg_o == NULL) {
1086 sprintf(errMsg, "[ %s ] Failed to create initMsg_o onode\n", rn);
1089 code = gtxframe_AddToList(ovwFrame, initMsg_o);
1090 code = gator_light_set(initMsg_o, HIGHLIGHT);
1095 /* create the command line object */
1097 ovw_cmd_o = initLightObject("", 0, maxY - 1, OVW_CMD_O_WIDTH, afsmon_win);
1098 if (ovw_cmd_o == NULL) {
1099 sprintf(errMsg, "[ %s ] Failed to create command onode\n", rn);
1102 code = gtxframe_AddToList(ovwFrame, ovw_cmd_o);
1103 code = gator_light_set(ovw_cmd_o, HIGHLIGHT);
1105 /* create the program name object */
1107 ovw_progName_o = initLightObject("", 0, 0, PROGNAME_O_WIDTH, afsmon_win);
1108 if (ovw_progName_o == NULL) {
1109 sprintf(errMsg, "[ %s ] Failed to create programName onode\n", rn);
1112 code = gtxframe_AddToList(ovwFrame, ovw_progName_o);
1113 code = gator_light_set(ovw_progName_o, HIGHLIGHT);
1115 /* create the page number object */
1118 initLightObject("", maxX - OVW_PAGENUM_O_WIDTH, 0,
1119 OVW_PAGENUM_O_WIDTH, afsmon_win);
1120 if (ovw_pageNum_o == NULL) {
1121 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
1124 code = gtxframe_AddToList(ovwFrame, ovw_pageNum_o);
1125 code = gator_light_set(ovw_pageNum_o, HIGHLIGHT);
1127 /* create the probe number object */
1129 initLightObject("", maxX - OVW_PROBENUM_O_WIDTH, maxY - 1,
1130 OVW_PROBENUM_O_WIDTH, afsmon_win);
1131 if (ovw_probeNum_o == NULL) {
1132 sprintf(errMsg, "[ %s ] Failed to create probe number onode\n", rn);
1135 code = gtxframe_AddToList(ovwFrame, ovw_probeNum_o);
1136 code = gator_light_set(ovw_probeNum_o, HIGHLIGHT);
1138 /* create the numFS monitored object */
1139 ovw_numFS_o = initLightObject("", 0, 2, FC_NUMHOSTS_O_WIDTH, afsmon_win);
1140 if (ovw_numFS_o == NULL) {
1141 sprintf(errMsg, "[ %s ] Failed to create numFS onode\n", rn);
1144 code = gtxframe_AddToList(ovwFrame, ovw_numFS_o);
1146 /* create the numCM monitored object */
1148 initLightObject("", maxX / 2, 2, OVW_NUMCM_O_WIDTH, afsmon_win);
1149 if (ovw_numCM_o == NULL) {
1150 sprintf(errMsg, "[ %s ] Failed to create numCM_o onode\n", rn);
1153 code = gtxframe_AddToList(ovwFrame, ovw_numCM_o);
1155 /* create the number-of-FS-alerts object */
1157 initLightObject("", 0, 3, OVW_FSALERTS_O_WIDTH, afsmon_win);
1158 if (ovw_FSalerts_o == NULL) {
1159 sprintf(errMsg, "[ %s ] Failed to create FSalerts_o onode\n", rn);
1162 code = gtxframe_AddToList(ovwFrame, ovw_FSalerts_o);
1164 /* create the number-of-CM-alerts object */
1166 initLightObject("", maxX / 2, 3, OVW_CMALERTS_O_WIDTH, afsmon_win);
1167 if (ovw_CMalerts_o == NULL) {
1168 sprintf(errMsg, "[ %s ] Failed to create CMalerts_o onode\n", rn);
1171 code = gtxframe_AddToList(ovwFrame, ovw_CMalerts_o);
1173 /* create file-server-name and cache-manager-names objects */
1174 ovw_numHosts_perPage = maxY - OVW_NUM_FIXED_LINES;
1176 /* allocate memory for a list of onode pointers for file server names */
1178 (struct onode **)malloc(sizeof(struct onode *) *
1179 ovw_numHosts_perPage);
1180 if (ovw_fsNames_o == NULL) {
1181 sprintf(errMsg, "[ %s ] Failed to allocate memory for FS onodes\n",
1186 /* create file server name objects */
1187 ovw_fsNames_o_Ptr = ovw_fsNames_o;
1188 for (i = 0; i < ovw_numHosts_perPage; i++) {
1189 *ovw_fsNames_o_Ptr =
1190 initLightObject("", 0, OVW_FIRST_HOST_ROW + i,
1191 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1192 if (*ovw_fsNames_o_Ptr == NULL) {
1193 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
1197 * if (afsmon_debug) {
1198 * fprintf(debugFD,"[ %s ] fsName_o %d: %d\n",
1199 * rn,i,*ovw_fsNames_o_Ptr);
1203 code = gtxframe_AddToList(ovwFrame, *ovw_fsNames_o_Ptr);
1204 ovw_fsNames_o_Ptr++;
1209 /* allocate memory for a list of onode pointers for cache manager names */
1211 (struct onode **)malloc(sizeof(struct onode *) *
1212 ovw_numHosts_perPage);
1213 if (ovw_cmNames_o == NULL) {
1214 sprintf(errMsg, "[ %s ] Failed to allocate memory for CM onodes\n",
1219 /* create cache manager name objects */
1220 ovw_cmNames_o_Ptr = ovw_cmNames_o;
1221 for (i = 0; i < ovw_numHosts_perPage; i++) {
1222 *ovw_cmNames_o_Ptr =
1223 initLightObject("", maxX / 2, OVW_FIRST_HOST_ROW + i,
1224 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1225 if (*ovw_cmNames_o_Ptr == NULL) {
1226 sprintf(errMsg, "[ %s ] Failed to create a CM name onode\n", rn);
1229 code = gtxframe_AddToList(ovwFrame, *ovw_cmNames_o_Ptr);
1230 ovw_cmNames_o_Ptr++;
1234 /* Calculate the number of pages of overview data to display */
1235 /* host information starts at the 6th line from top and stops at 3rd
1236 * line from bottom of screen */
1243 ovw_numPages = hostLines / (maxY - OVW_NUM_FIXED_LINES);
1244 if (hostLines % (maxY - OVW_NUM_FIXED_LINES))
1248 fprintf(debugFD, "[ %s ] number of ovw pages = %d\n", rn,
1251 /* When the ovw_refresh() routine is called by the keyboard handlers the
1252 * following variable is used to determine if fs/cm/fs&cm info must be
1254 ovw_update_info = 0;
1256 ovw_update_info |= OVW_UPDATE_FS;
1258 ovw_update_info |= OVW_UPDATE_CM;
1260 /* bind the overview frame to a keyboard input handler */
1262 /* bind Q and
\ 3 to exit */
1263 keymap_BindToString(ovwFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
1264 keymap_BindToString(ovwFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
1266 /* f -> switch of fs frame */
1267 keymap_BindToString(ovwFrame->keymap, "f", Switch_ovw_2_fs, NULL, NULL);
1268 /* c -> switch of cm frame */
1269 keymap_BindToString(ovwFrame->keymap, "c", Switch_ovw_2_cm, NULL, NULL);
1270 /* n -> switch to next overview page */
1271 keymap_BindToString(ovwFrame->keymap, "n", Switch_ovw_next, NULL, NULL);
1272 /* N -> switch to last overview page */
1273 keymap_BindToString(ovwFrame->keymap, "N", Switch_ovw_last, NULL, NULL);
1274 /* p -> switch to previous overview page */
1275 keymap_BindToString(ovwFrame->keymap, "p", Switch_ovw_prev, NULL, NULL);
1276 /* P -> switch to first overview page */
1277 keymap_BindToString(ovwFrame->keymap, "P", Switch_ovw_first, NULL, NULL);
1281 } /* create_ovwFrame_objects */
1284 /*-----------------------------------------------------------------------
1288 * This function is called to determine the permissible keyboard
1289 * operations on the FS and CM frames. This information is used
1290 * to create an appropriate command line prompt. It also generates
1291 * a bit map of the permissible operations on this page which is
1292 * used by the keyboard-input handler routines.
1295 * Success: page-type (bit map of permissible operations)
1297 *----------------------------------------------------------------------*/
1300 resolve_CmdLine(a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols,
1301 a_curr_LCol, a_cols_perPage, a_Data_Available)
1302 char *a_buffer; /* buffer to copy command line */
1303 int a_currFrame; /* current frame ovw, fs or cm? */
1304 int a_currPage; /* current page number */
1305 int a_numPages; /* number of pages of data */
1306 int a_numCols; /* number of columns of data to display */
1307 int a_curr_LCol; /* current number of leftmost column */
1308 int a_cols_perPage; /* number of columns per page */
1310 { /* resolve_CmdLine */
1311 static char rn[] = "resolve_CmdLine";
1316 "[ %s ] Called, a_buffer= %d, a_currFrame= %d, a_currPage= %d, a_numPages= %d, a_numCols= %d, a_curr_LCol= %d, a_cols_perPage= %d\n",
1317 rn, a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols,
1318 a_curr_LCol, a_cols_perPage);
1324 /* determine if we have fs/cm frames. If we do, note that we should not
1325 * let the user seen the initial junk we have there until the probe
1326 * results are available */
1327 if (a_currFrame == 1) { /* in the fs frame */
1328 if (numCM && cm_Data_Available)
1330 } else if (a_currFrame == 2) { /* in the cm frame */
1331 if (numFS && fs_Data_Available)
1335 fprintf(debugFD, "[ %s ] Wrong frame type %d\n", rn, a_currFrame);
1341 /* do we have next/previous pages */
1342 if (a_currPage < a_numPages)
1343 pageType |= CMD_NEXT; /* have a next page */
1345 pageType |= CMD_PREV; /* have a previous page */
1347 if (a_numCols > a_cols_perPage) {
1348 if (a_curr_LCol > 0)
1349 pageType |= CMD_LEFT; /* have columns on left */
1350 if ((a_curr_LCol + a_cols_perPage) < a_numCols)
1351 pageType |= CMD_RIGHT; /* have columns on right */
1354 /* now build the command line */
1356 strcpy(a_buffer, "Command [oview");
1357 if (pageType & CMD_FS)
1358 strcat(a_buffer, ", fs");
1359 if (pageType & CMD_CM)
1360 strcat(a_buffer, ", cm");
1361 if (pageType & CMD_PREV)
1362 strcat(a_buffer, ", prev");
1363 if (pageType & CMD_NEXT)
1364 strcat(a_buffer, ", next");
1365 if (pageType & CMD_LEFT)
1366 strcat(a_buffer, ", left");
1367 if (pageType & CMD_RIGHT)
1368 strcat(a_buffer, ", right");
1369 strcat(a_buffer, "]? ");
1373 } /* resolve_CmdLine */
1375 /*-----------------------------------------------------------------------
1376 * display_Server_datum()
1379 * The data in the file server & cache manager frames are displayed
1380 * in two objects, one below the other. If the data is too long to
1381 * fit in the first object it will overflow into the next. This is
1382 * to conserve real estate on the screen. This function copies the
1383 * contents of the source buffer adjusted to the two objects if the
1384 * probe had succeded. Otherwise it enters "--" in the first object
1385 * blanks out the second. If the object needs to be highlightned
1386 * (due to a threshold crossing) it is done.
1390 *----------------------------------------------------------------------*/
1392 display_Server_datum(a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK, a_just,
1395 char *a_srcBuf; /* source buffer */
1396 struct onode *a_firstObj_o; /* first object */
1397 struct onode *a_secondObj_o; /* second object */
1398 int a_probeOK; /* probe OK ? */
1399 int a_just; /* justification */
1400 int a_highlight; /* highlight object ? */
1402 { /* display_Server_datum */
1404 static char rn[] = "display_Server_datum";
1405 struct gator_lightobj *tmp_lightobj1;
1406 struct gator_lightobj *tmp_lightobj2;
1407 char part1[FC_COLUMN_WIDTH + 2];
1408 char part2[FC_COLUMN_WIDTH + 2];
1414 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_probeOK= %d, a_just= %d, a_highlight= %d\n",
1415 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK,
1416 a_just, a_highlight);
1421 tmp_lightobj1 = (struct gator_lightobj *)a_firstObj_o->o_data;
1422 tmp_lightobj2 = (struct gator_lightobj *)a_secondObj_o->o_data;
1424 if (a_probeOK) { /* probe is ok so fill in the data */
1426 /* check if it would fit in one object */
1427 if (strlen(a_srcBuf) < FC_COLUMN_WIDTH) {
1428 strcpy(part1, a_srcBuf);
1431 /* break up the src string into 2 parts */
1432 /* note that column width includes terminator */
1433 strncpy(part1, a_srcBuf, FC_COLUMN_WIDTH - 1);
1434 part1[FC_COLUMN_WIDTH - 1] = '\0';
1435 strncpy(part2, a_srcBuf + FC_COLUMN_WIDTH - 1,
1436 FC_COLUMN_WIDTH - 1);
1440 } else { /* probe failed, enter "--"s */
1441 strcpy(part1, "--");
1445 /* if (afsmon_debug) {
1446 * fprintf(debugFD,"[ %s ] %s split to %s & %s\n",rn,a_srcBuf,part1,part2);
1450 /* initialize both the objects */
1453 justify_light(part1, tmp_lightobj1->label, FC_COLUMN_WIDTH, a_just,
1457 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1463 justify_light(part2, tmp_lightobj2->label, FC_COLUMN_WIDTH, a_just,
1467 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1472 /* highlight them */
1473 if (a_highlight && (part1[0] != '-'))
1474 gator_light_set(a_firstObj_o, 1);
1476 gator_light_set(a_firstObj_o, 0);
1477 if (a_highlight && (part2[0] != '\0'))
1478 gator_light_set(a_secondObj_o, 1);
1480 gator_light_set(a_secondObj_o, 0);
1486 } /* display_Server_datum */
1489 /*-----------------------------------------------------------------------
1490 * display_Server_label()
1493 * Display the given server label in three objects. The label is
1494 * partitioned into three parts by '/'s and each part is copied
1495 * into each label object.
1499 *----------------------------------------------------------------------*/
1502 display_Server_label(a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o)
1504 struct onode *a_firstObj_o; /* first object */
1505 struct onode *a_secondObj_o; /* second object */
1506 struct onode *a_thirdObj_o; /* third object */
1508 { /* display_Server_label */
1510 static char rn[] = "display_Server_label";
1511 char part[3][20]; /* buffer for three parts of label */
1513 struct gator_lightobj *tmp_lightobj;
1514 struct onode *objPtr_o[3];
1521 /* the following debug statement floods the debug file */
1522 #ifdef DEBUG_DETAILED
1525 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_thirdObj_o= %d\n",
1526 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o);
1532 /* break the label string into three parts */
1537 /* now for a dumb precaution */
1539 strLen = strlen(a_srcBuf);
1542 for (i = 0; i < 3; i++) {
1544 while (*strPtr != '\0' && (len++ <= strLen)) {
1545 if (*strPtr == '/') {
1549 part[i][j] = *strPtr;
1557 * if (afsmon_debug) {
1558 * fprintf(debugFD,"[ %s ] LABELS %s -> %s %s %s\n",
1559 * rn, a_srcBuf, part[0], part[1], part[2]);
1564 objPtr_o[0] = a_firstObj_o;
1565 objPtr_o[1] = a_secondObj_o;
1566 objPtr_o[2] = a_thirdObj_o;
1568 /* display each label justified CENTER */
1570 for (i = 0; i < 3; i++) {
1571 tmp_lightobj = (struct gator_lightobj *)objPtr_o[i]->o_data;
1573 justify_light(part[i], tmp_lightobj->label, FC_COLUMN_WIDTH,
1577 fprintf(debugFD, "[ %s ] justify_light %d failed \n", rn, i);
1583 } /* display_Server_label */
1589 /*-----------------------------------------------------------------------
1593 * Refresh the File Servers screen with the given page number starting
1594 * at the given left-column number. The appropriate contents of
1595 * prev_fsData are displayed.
1596 * First the status labels at the four corners of the screen are
1597 * updated. Next the column labels are updated and then each row
1602 * Failure: Exits afsmoitor on a severe error.
1603 *----------------------------------------------------------------------*/
1607 fs_refresh(a_pageNum, a_LcolNum)
1608 int a_pageNum; /* page to display */
1609 int a_LcolNum; /* starting (leftmost) column number */
1613 static char rn[] = "fs_refresh"; /* routine name */
1614 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
1615 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
1616 struct ServerInfo_line *tmp_fs_lines_P; /* tmp ptr to fs_lines */
1617 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
1618 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
1619 struct onode **fsLabels_o_Ptr1; /* ptr to label row 0 */
1620 struct onode **fsLabels_o_Ptr2; /* ptr to label row 1 */
1621 struct onode **fsLabels_o_Ptr3; /* ptr to label row 2 */
1622 char cmdLine[80]; /* buffer for command line */
1623 char printBuf[256]; /* buffer to print to screen */
1630 int dataIndex; /* index to the data[] field of
1631 * struct fs_Display_Data */
1634 fprintf(debugFD, "[ %s ] Called with row %d col %d \n", rn, a_pageNum,
1640 /* if the data is not yet available, ie., not one probe cycle has
1641 * completed, do nothing */
1643 if (!fs_Data_Available)
1647 /* validate the page number & column number */
1648 if (a_pageNum < 1 || a_pageNum > fs_numPages) {
1650 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
1656 if (a_LcolNum < 0 || a_LcolNum > fs_numCols) {
1658 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
1667 /* update the fixed labels */
1669 /* we reuse the ovw version lable and hence do not have to do anything
1672 /* page number label */
1673 tmp_lightobj = (struct gator_lightobj *)fs_pageNum_o->o_data;
1674 sprintf(printBuf, "[File Servers, p. %d of %d, c. %d of %d]", a_pageNum,
1675 fs_numPages, a_LcolNum + 1, fs_numCols);
1676 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
1678 gator_light_set(fs_pageNum_o, 1);
1680 /* file servers monitored label */
1681 tmp_lightobj = (struct gator_lightobj *)fs_numFS_o->o_data;
1682 sprintf(printBuf, "%d File Servers monitored, %d alerts on %d machines",
1683 numFS, num_fs_alerts, numHosts_onfs_alerts);
1684 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
1690 /* figure out what we need to show in the prompt & set the page type */
1691 /* the fs_pageType variable is in turn used by the keyboard handler
1692 * routines to call fs_refresh() with the correct parameters */
1694 fs_pageType = resolve_CmdLine(cmdLine, 1 /* fs frame */ , a_pageNum,
1695 fs_numPages, fs_numCols, a_LcolNum,
1698 /* display the command line */
1699 tmp_lightobj = (struct gator_lightobj *)fs_cmd_o->o_data;
1700 sprintf(printBuf, "%s", cmdLine);
1701 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
1703 gator_light_set(fs_cmd_o, 1);
1705 /* update the probe number label */
1706 tmp_lightobj = (struct gator_lightobj *)fs_probeNum_o->o_data;
1707 sprintf(printBuf, "[FS probes %d, freq=%d sec]", afsmon_fs_prev_probeNum,
1709 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
1711 gator_light_set(fs_probeNum_o, 1);
1713 /* update "columns on left" signal */
1714 tmp_lightobj = (struct gator_lightobj *)fs_leftArrows_o->o_data;
1715 if (fs_pageType & CMD_LEFT)
1716 strcpy(printBuf, "<<<");
1718 strcpy(printBuf, "");
1719 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1721 gator_light_set(fs_leftArrows_o, 0);
1723 /* update "columns on right" signal */
1724 tmp_lightobj = (struct gator_lightobj *)fs_rightArrows_o->o_data;
1725 if (fs_pageType & CMD_RIGHT)
1726 strcpy(printBuf, ">>>");
1728 strcpy(printBuf, "");
1729 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1731 gator_light_set(fs_rightArrows_o, 0);
1735 /* UPDATE THE COLUMN LABELS */
1737 /* the column index is also used to index the label arrays */
1738 labelIdx = a_LcolNum;
1740 /* get the pointers to the three arrays of label onodes */
1741 fsLabels_o_Ptr1 = fsLabels_o[0];
1742 fsLabels_o_Ptr2 = fsLabels_o[1];
1743 fsLabels_o_Ptr3 = fsLabels_o[2];
1745 for (k = 0; k < fs_cols_perPage; k++) {
1747 if (labelIdx < fs_numCols) {
1748 dataIndex = fs_Display_map[labelIdx];
1750 display_Server_label(fs_labels[dataIndex], *fsLabels_o_Ptr1,
1751 *fsLabels_o_Ptr2, *fsLabels_o_Ptr3);
1753 labelIdx++; /* next label */
1756 display_Server_label("//", *fsLabels_o_Ptr1, *fsLabels_o_Ptr2,
1760 fsLabels_o_Ptr1++; /* next onode in label row 1 */
1761 fsLabels_o_Ptr2++; /* next onode in label row 2 */
1762 fsLabels_o_Ptr3++; /* next onode in label row 3 */
1764 } /* labels for each column */
1767 /* UPDATE THE FILE SERVER STATISTICS */
1769 /* move to the right spot in the FS display data array */
1770 fsDataP = prev_fsData;
1772 for (i = 0; i < ((a_pageNum - 1) * fs_numHosts_perPage); i++) {
1777 if (fsIdx >= numFS) { /* whoops! screwed up */
1778 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
1782 /* get the pointer to the first line of onodes of the file server frame */
1783 tmp_fs_lines_P = fs_lines;
1785 for (i = 0; i < fs_numHosts_perPage; i++) {
1788 /* if this is the last page we may not have file servers to fill up
1789 * the page, so check the index */
1790 if (fsIdx < numFS) {
1792 if (fsDataP->hostName[0] == '\0') {
1793 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
1797 /* display the hostname , first names only please! */
1799 sprintf(printBuf, fsDataP->hostName);
1800 for (j = 0; j < strlen(printBuf); j++) {
1801 if (printBuf[j] == '.') {
1808 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1810 justify_light(printBuf, tmp_lightobj->label,
1811 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
1813 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1818 /* use the current column value to index into the fs_Display_map
1819 * array to obtain the index of the item to display. check if its
1820 * overflow flag is set and highlight if so. if the probe had failed
1821 * enter "--" is all columns */
1823 /* each host has two rows of slots for datums. get the pointers to
1824 * both the arrays */
1826 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1827 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1828 fs_curr_RCol = a_LcolNum; /* starting column number from which
1829 * we are asked to display data */
1831 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
1833 /* if there is another column of data */
1834 if (fs_curr_RCol < fs_numCols) {
1836 dataIndex = fs_Display_map[fs_curr_RCol];
1839 display_Server_datum(fsDataP->data[dataIndex],
1842 fsDataP->probeOK, RIGHT_JUSTIFY,
1843 fsDataP->threshOvf[dataIndex]);
1846 } else { /* no more data, blank out columns */
1847 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
1848 RIGHT_JUSTIFY, 0); /* no overflow */
1852 firstSlot_o_Ptr++; /* onode of next column */
1853 secondSlot_o_Ptr++; /* onode of next column */
1855 } /* for each column */
1857 /* the loop could have taken the right-column-index one over,
1859 if (fs_curr_RCol == fs_numCols)
1867 /* if fdIdx < numFS */
1868 /* if fsIdx >= numFS , blank out all succeding rows */
1869 if (fsIdx >= numFS) {
1871 /* blank out host name object */
1873 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1875 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
1878 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1883 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1884 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1886 for (k = 0; k < fs_cols_perPage; k++) {
1887 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
1888 RIGHT_JUSTIFY, 0); /* dont highlight */
1896 /* fsIDx >= numFS */
1897 tmp_fs_lines_P++; /* pointer to next line in the frame */
1898 fsDataP++; /* next host's data */
1899 fsIdx++; /* host index */
1902 } /* for each row in the File Servers frame */
1904 /* redraw the display if the File Servers screen is currently displayed */
1905 if (afsmon_win->w_frame == fsFrame)
1906 WOP_DISPLAY(afsmon_win);
1908 /* update the global page & column numbers to reflect the changes */
1909 fs_currPage = a_pageNum;
1910 fs_curr_LCol = a_LcolNum;;
1919 /*-----------------------------------------------------------------------
1923 * Switch from the File Server screen to the Overview Screen
1924 *----------------------------------------------------------------------*/
1928 /* bind the overview frame to the window */
1929 gtxframe_SetFrame(afsmon_win, ovwFrame);
1933 /*-----------------------------------------------------------------------
1937 * Switch from the File Server screen to the Cache Managers screen.
1938 *----------------------------------------------------------------------*/
1942 if (fs_pageType & CMD_CM) {
1943 /* bind the overview Cache Managers to the window */
1944 gtxframe_SetFrame(afsmon_win, cmFrame);
1949 /*-----------------------------------------------------------------------
1953 * Switch to next page of file server screen
1954 *----------------------------------------------------------------------*/
1958 static char rn[] = "Switch_fs_next";
1960 if (fs_pageType & CMD_NEXT) {
1961 /* we have a next page, refresh with next page number */
1962 fs_refresh(fs_currPage + 1, fs_curr_LCol);
1968 /*-----------------------------------------------------------------------
1972 * Switch to last page of file server screen
1973 *----------------------------------------------------------------------*/
1977 static char rn[] = "Switch_fs_last";
1980 if (fs_pageType & CMD_NEXT) {
1981 /* we have a next page, refresh with the last page number */
1982 fs_refresh(fs_numPages, fs_curr_LCol);
1988 /*-----------------------------------------------------------------------
1992 * Switch to previous page of file server screen
1993 *----------------------------------------------------------------------*/
1997 static char rn[] = "Switch_fs_prev";
1999 if (fs_pageType & CMD_PREV) {
2000 /* we have a previous page, refresh with the rpevious page number */
2001 fs_refresh(fs_currPage - 1, fs_curr_LCol);
2006 /*-----------------------------------------------------------------------
2010 * Switch to first page of file server screen
2011 *----------------------------------------------------------------------*/
2015 static char rn[] = "Switch_fs_first";
2017 if (fs_pageType & CMD_PREV) {
2018 /* we have a previous page, got to first page */
2019 fs_refresh(1, fs_curr_LCol);
2024 /*-----------------------------------------------------------------------
2028 * Scroll left on the file server screen
2029 *----------------------------------------------------------------------*/
2033 static char rn[] = "Switch_fs_left";
2035 if (fs_pageType & CMD_LEFT) {
2036 /* we have columns on left, refresh with new column number */
2037 fs_refresh(fs_currPage, fs_curr_LCol - fs_cols_perPage);
2043 /*-----------------------------------------------------------------------
2044 * Switch_fs_leftmost()
2047 * Scroll to first column on the file server screen
2048 *----------------------------------------------------------------------*/
2050 Switch_fs_leftmost()
2052 static char rn[] = "Switch_fs_leftmost";
2054 if (fs_pageType & CMD_LEFT) {
2055 /* we have columns on left, go to the first */
2056 fs_refresh(fs_currPage, 0);
2061 /*-----------------------------------------------------------------------
2065 * Scroll right on the file server screen
2066 *----------------------------------------------------------------------*/
2070 static char rn[] = "Switch_fs_right";
2072 if (fs_pageType & CMD_RIGHT) {
2073 /* we have columns on right, refresh with new column number */
2074 fs_refresh(fs_currPage, fs_curr_LCol + fs_cols_perPage);
2079 /*-----------------------------------------------------------------------
2080 * Switch_fs_rightmost()
2083 * Scroll to last column on the file server screen
2084 *----------------------------------------------------------------------*/
2086 Switch_fs_rightmost()
2088 static char rn[] = "Switch_fs_rightmost";
2092 if (fs_pageType & CMD_RIGHT) {
2093 /* we have columns on right, go to the last column */
2094 if (fs_numCols % fs_cols_perPage)
2095 curr_LCol = (fs_numCols / fs_cols_perPage) * fs_cols_perPage;
2098 ((fs_numCols / fs_cols_perPage) - 1) * fs_cols_perPage;
2100 fs_refresh(fs_currPage, curr_LCol);
2106 /*-----------------------------------------------------------------------
2107 * create_FSframe_objects()
2110 * Create the gtx objects (onodes) for the Fileservers frame and setup
2111 * the keyboard bindings.
2112 * Only as many objects as can fit on the display are created. The
2113 * positions and lengths of all these objects are fixed at creation.
2114 * These objects are updated with new data at the end of each probe
2119 * Failure: Exits afsmonitor.
2120 *----------------------------------------------------------------------*/
2123 create_FSframe_objects()
2124 { /* create_FSframe_objects */
2125 static char rn[] = "create_FSframe_objects";
2126 struct ServerInfo_line *fs_lines_Ptr;
2127 struct onode **fs_data_o_Ptr;
2128 struct onode **fsLabels_o_Ptr;
2139 fprintf(debugFD, "[ %s ] Called\n", rn);
2143 /* create the command line object */
2145 initLightObject("Command [oview, cm, prev, next, left, right] ? ", 0,
2146 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2147 if (fs_cmd_o == NULL) {
2148 sprintf(errMsg, "[ %s ] Failed to create fs command onode\n", rn);
2151 code = gtxframe_AddToList(fsFrame, fs_cmd_o);
2152 code = gator_light_set(fs_cmd_o, HIGHLIGHT);
2154 /* we already have the dimensions for the frame - same as the ovw frame */
2155 /* use the ovw program name object for the fs screen too */
2157 code = gtxframe_AddToList(fsFrame, ovw_progName_o);
2160 /* create the page number object */
2162 initLightObject("[File Servers, p. X of X, c. Y of Y]",
2163 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2165 if (fs_pageNum_o == NULL) {
2166 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2169 code = gtxframe_AddToList(fsFrame, fs_pageNum_o);
2170 code = gator_light_set(fs_pageNum_o, HIGHLIGHT);
2172 /* create the probe number object */
2174 initLightObject("[FS probes 1, freq=30 sec]",
2175 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2176 FC_PROBENUM_O_WIDTH, afsmon_win);
2177 if (fs_probeNum_o == NULL) {
2178 sprintf(errMsg, "[ %s ] Failed to create fs probeNum onode\n", rn);
2181 code = gtxframe_AddToList(fsFrame, fs_probeNum_o);
2182 code = gator_light_set(fs_probeNum_o, HIGHLIGHT);
2185 /* create the numFS monitored object */
2188 (" 0 File Servers monitored, 0 alerts on 0 machines", 4, 2,
2189 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2190 if (fs_numFS_o == NULL) {
2192 "[ %s ] Failed to create numFS onode for the fs frame\n", rn);
2195 code = gtxframe_AddToList(fsFrame, fs_numFS_o);
2197 /* create the "more columns to left" indicator */
2199 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
2200 if (fs_leftArrows_o == NULL) {
2202 "[ %s ] Failed to create leftArrows onode for the fs frame\n",
2206 code = gtxframe_AddToList(fsFrame, fs_leftArrows_o);
2208 /* create the "more columns to right" indicator */
2210 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
2212 if (fs_rightArrows_o == NULL) {
2214 "[ %s ] Failed to create rightArrows onode for the fs frame\n",
2218 code = gtxframe_AddToList(fsFrame, fs_rightArrows_o);
2223 /* calculate the maximum number of hosts per page (2 rows per host) */
2224 fs_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
2226 /* determine the number of data columns that can fit in a page */
2227 fs_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
2230 fprintf(debugFD, "[ %s ] fs_numHosts_perPage=%d fs_cols_perPage=%d\n",
2231 rn, fs_numHosts_perPage, fs_cols_perPage);
2235 /* the above two variables give us the information needed to create
2236 * the objects for displaying the file server information */
2238 /* allocate memory for all the onode pointers required to display
2239 * the file server statistics */
2241 numBytes = fs_numHosts_perPage * sizeof(struct ServerInfo_line);
2242 fs_lines = (struct ServerInfo_line *)malloc(numBytes);
2243 if (fs_lines == (struct ServerInfo_line *)0) {
2245 "[ %s ] Failed to allocate %d bytes for FS data lines\n", rn,
2250 /* for each line of server statistics allocate memory to store two arrays
2253 fs_lines_Ptr = fs_lines;
2254 for (i = 0; i < fs_numHosts_perPage; i++) {
2255 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
2256 numBytes = fs_cols_perPage * sizeof(struct onode *);
2257 fs_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes);
2258 if (fs_lines_Ptr->data_o[arrIdx] == NULL) {
2260 "[ %s ] Failed to allocate %d bytes for FS data onodes\n",
2268 /* now allocate the onodes itself */
2270 fs_lines_Ptr = fs_lines;
2271 for (i = 0; i < fs_numHosts_perPage; i++) {
2273 /* initialize host name onode */
2274 fs_lines_Ptr->host_o =
2275 initLightObject("FSHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
2276 FC_HOSTNAME_O_WIDTH, afsmon_win);
2277 if (fs_lines_Ptr->host_o == NULL) {
2278 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
2281 code = gtxframe_AddToList(fsFrame, fs_lines_Ptr->host_o);
2283 /* if (afsmon_debug) {
2284 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
2285 * rn,fs_lines_Ptr->host_o,i);
2289 /* initialize data onodes for this host */
2291 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
2293 fs_data_o_Ptr = fs_lines_Ptr->data_o[arrIdx];
2294 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
2298 /* determine x & y coordinate for this data object */
2299 /* the 1's are for leaving a blank after each column */
2300 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
2301 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
2303 sprintf(tmpBuf, "-FSData %d-", arrIdx);
2305 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
2307 if (*fs_data_o_Ptr == NULL) {
2309 "[ %s ] Failed to create an FS data onode\n", rn);
2312 code = gtxframe_AddToList(fsFrame, *fs_data_o_Ptr);
2315 } /* for each column */
2316 } /* for each onode array index */
2319 } /* for each host slot */
2322 /* INITIALIZE COLUMN LABELS */
2325 /* allocate memory for two arrays of onode pointers for file server column
2327 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
2329 fsLabels_o[arrIdx] =
2330 (struct onode **)malloc(sizeof(struct onode *) * fs_cols_perPage);
2331 if (fsLabels_o[arrIdx] == NULL) {
2333 "[ %s ] Failed to allocate memory for FS label onodes\n",
2338 /* create cache manager name objects */
2339 fsLabels_o_Ptr = fsLabels_o[arrIdx];
2340 for (i = 0; i < fs_cols_perPage; i++) {
2342 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
2343 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
2346 if (*fsLabels_o_Ptr == NULL) {
2347 sprintf(errMsg, "[ %s ] Failed to create a FS label onode\n",
2351 code = gtxframe_AddToList(fsFrame, *fsLabels_o_Ptr);
2358 /* initialize the column & page counters */
2361 fs_numCols = fs_DisplayItems_count;
2362 fs_numPages = numFS / fs_numHosts_perPage;
2363 if (numFS % fs_numHosts_perPage)
2365 fs_curr_LCol = 0; /* leftmost col */
2366 fs_curr_RCol = 0; /* rightmost col */
2368 /* create keyboard bindings */
2369 /* bind Q and
\ 3 to exit */
2370 keymap_BindToString(fsFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
2371 keymap_BindToString(fsFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
2373 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
2374 * N = last page, P = first page, L = leftmost col, R = rightmost col */
2376 keymap_BindToString(fsFrame->keymap, "o", Switch_fs_2_ovw, NULL, NULL);
2377 keymap_BindToString(fsFrame->keymap, "c", Switch_fs_2_cm, NULL, NULL);
2378 keymap_BindToString(fsFrame->keymap, "n", Switch_fs_next, NULL, NULL);
2379 keymap_BindToString(fsFrame->keymap, "N", Switch_fs_last, NULL, NULL);
2380 keymap_BindToString(fsFrame->keymap, "p", Switch_fs_prev, NULL, NULL);
2381 keymap_BindToString(fsFrame->keymap, "P", Switch_fs_first, NULL, NULL);
2382 keymap_BindToString(fsFrame->keymap, "l", Switch_fs_left, NULL, NULL);
2383 keymap_BindToString(fsFrame->keymap, "L", Switch_fs_leftmost, NULL, NULL);
2384 keymap_BindToString(fsFrame->keymap, "r", Switch_fs_right, NULL, NULL);
2385 keymap_BindToString(fsFrame->keymap, "R", Switch_fs_rightmost, NULL,
2389 } /* create_FSframe_objects */
2392 /*-----------------------------------------------------------------------
2393 * Function: cm_refresh()
2396 * Refresh the Cache Managers screen with the given page number starting
2397 * at the given left-column number. The appropriate contents of
2398 * prev_cmData are displayed.
2399 * First the status labels at the four corners of the screen are
2400 * updated. Next the column labels are updated and then each row
2405 * Failure: Exits afsmoitor on a severe error.
2406 *----------------------------------------------------------------------*/
2409 cm_refresh(a_pageNum, a_LcolNum)
2410 int a_pageNum; /* page to display */
2411 int a_LcolNum; /* starting (leftmost) column number */
2415 static char rn[] = "cm_refresh"; /* routine name */
2416 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
2417 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
2418 struct ServerInfo_line *tmp_cm_lines_P; /* tmp ptr to cm_lines */
2419 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
2420 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
2421 struct onode **cmLabels_o_Ptr1; /* ptr to label row 0 */
2422 struct onode **cmLabels_o_Ptr2; /* ptr to label row 1 */
2423 struct onode **cmLabels_o_Ptr3; /* ptr to label row 2 */
2424 char cmdLine[80]; /* buffer for command line */
2425 char printBuf[256]; /* buffer to print to screen */
2432 int dataIndex; /* index to the data[] field of
2433 * struct cm_Display_Data */
2436 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_LcolNum= %d \n", rn,
2437 a_pageNum, a_LcolNum);
2442 /* if the data is not yet available, ie., not one probe cycle has
2443 * completed, do nothing */
2445 if (!cm_Data_Available)
2449 /* validate the page number & column number */
2450 if (a_pageNum < 1 || a_pageNum > cm_numPages) {
2452 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
2458 if (a_LcolNum < 0 || a_LcolNum > cm_numCols) {
2460 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
2469 /* update the fixed labels */
2471 /* we reuse the ovw version lable and hence do not have to do anything
2474 /* page number label */
2475 tmp_lightobj = (struct gator_lightobj *)cm_pageNum_o->o_data;
2476 sprintf(printBuf, "[Cache Managers, p.%d of %d, c.%d of %d]", a_pageNum,
2477 cm_numPages, a_LcolNum + 1, cm_numCols);
2478 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
2480 gator_light_set(cm_pageNum_o, 1);
2482 /* file servers monitored label */
2483 tmp_lightobj = (struct gator_lightobj *)cm_numCM_o->o_data;
2484 sprintf(printBuf, "%d Cache Managers monitored, %d alerts on %d machines",
2485 numCM, num_cm_alerts, numHosts_oncm_alerts);
2486 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
2492 /* figure out what we need to show in the prompt & set the page type */
2493 /* the cm_pageType variable is in turn used by the keyboard handler
2494 * routines to call cm_refresh() with the correct parameters */
2496 cm_pageType = resolve_CmdLine(cmdLine, 2 /* cm frame */ , a_pageNum,
2497 cm_numPages, cm_numCols, a_LcolNum,
2500 /* display the command line */
2501 tmp_lightobj = (struct gator_lightobj *)cm_cmd_o->o_data;
2502 sprintf(printBuf, "%s", cmdLine);
2503 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
2505 gator_light_set(cm_cmd_o, 1);
2507 /* update the probe number label */
2508 tmp_lightobj = (struct gator_lightobj *)cm_probeNum_o->o_data;
2509 sprintf(printBuf, "[CM probes %d, freq=%d sec]", afsmon_cm_prev_probeNum,
2511 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
2513 gator_light_set(cm_cmd_o, 1);
2515 /* update "columns on left" signal */
2516 tmp_lightobj = (struct gator_lightobj *)cm_leftArrows_o->o_data;
2517 if (cm_pageType & CMD_LEFT)
2518 strcpy(printBuf, "<<<");
2520 strcpy(printBuf, "");
2521 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2523 gator_light_set(cm_leftArrows_o, 0);
2525 /* update "columns on right" signal */
2526 tmp_lightobj = (struct gator_lightobj *)cm_rightArrows_o->o_data;
2527 if (cm_pageType & CMD_RIGHT)
2528 strcpy(printBuf, ">>>");
2530 strcpy(printBuf, "");
2531 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2533 gator_light_set(cm_rightArrows_o, 0);
2537 /* UPDATE THE COLUMN LABELS */
2539 /* the column index is also used to index the label arrays */
2540 labelIdx = a_LcolNum;
2542 /* get the pointers to the three arrays of label onodes */
2543 cmLabels_o_Ptr1 = cmLabels_o[0];
2544 cmLabels_o_Ptr2 = cmLabels_o[1];
2545 cmLabels_o_Ptr3 = cmLabels_o[2];
2547 for (k = 0; k < cm_cols_perPage; k++) {
2549 if (labelIdx < cm_numCols) {
2550 dataIndex = cm_Display_map[labelIdx];
2552 display_Server_label(cm_labels[dataIndex], *cmLabels_o_Ptr1,
2553 *cmLabels_o_Ptr2, *cmLabels_o_Ptr3);
2555 labelIdx++; /* next label */
2558 display_Server_label("//", *cmLabels_o_Ptr1, *cmLabels_o_Ptr2,
2562 cmLabels_o_Ptr1++; /* next onode in label row 1 */
2563 cmLabels_o_Ptr2++; /* next onode in label row 2 */
2564 cmLabels_o_Ptr3++; /* next onode in label row 3 */
2566 } /* labels for each column */
2569 /* UPDATE THE FILE SERVER STATISTICS */
2571 /* move to the right spot in the CM display data array */
2572 cmDataP = prev_cmData;
2574 for (i = 0; i < ((a_pageNum - 1) * cm_numHosts_perPage); i++) {
2579 if (cmIdx >= numCM) { /* whoops! screwed up */
2580 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
2584 /* get the pointer to the first line of onodes of the file server frame */
2585 tmp_cm_lines_P = cm_lines;
2587 for (i = 0; i < cm_numHosts_perPage; i++) {
2590 /* if this is the last page we may not have file servers to fill up
2591 * the page, so check the index */
2592 if (cmIdx < numCM) {
2594 if (cmDataP->hostName[0] == '\0') {
2595 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
2599 /* display the hostname , first names only please! */
2601 sprintf(printBuf, cmDataP->hostName);
2602 for (j = 0; j < strlen(printBuf); j++) {
2603 if (printBuf[j] == '.') {
2610 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2612 justify_light(printBuf, tmp_lightobj->label,
2613 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
2615 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2620 /* use the current column value to index into the cm_Display_map
2621 * array to obtain the index of the item to display. check if its
2622 * overflow flag is set and highlight if so. if the probe had failed
2623 * enter "--" is all columns */
2625 /* each host has two rows of slots for datums. get the pointers to
2626 * both the arrays */
2628 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2629 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2630 cm_curr_RCol = a_LcolNum; /* starting column number from which
2631 * we are asked to display data */
2633 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
2635 /* if there is another column of data */
2636 if (cm_curr_RCol < cm_numCols) {
2638 dataIndex = cm_Display_map[cm_curr_RCol];
2641 display_Server_datum(cmDataP->data[dataIndex],
2644 cmDataP->probeOK, RIGHT_JUSTIFY,
2645 cmDataP->threshOvf[dataIndex]);
2648 } else { /* no more data, blank out columns */
2649 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
2650 RIGHT_JUSTIFY, 0); /* no overflow */
2654 firstSlot_o_Ptr++; /* onode of next column */
2655 secondSlot_o_Ptr++; /* onode of next column */
2657 } /* for each column */
2659 /* the loop could have taken the right-column-index one over,
2661 if (cm_curr_RCol == cm_numCols)
2669 /* if fdIdx < numCM */
2670 /* if cmIdx >= numCM , blank out all succeding rows */
2671 if (cmIdx >= numCM) {
2673 /* blank out host name object */
2675 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2677 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
2680 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2685 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2686 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2688 for (k = 0; k < cm_cols_perPage; k++) {
2689 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
2690 RIGHT_JUSTIFY, 0); /* dont highlight */
2698 /* cmIDx >= numCM */
2699 tmp_cm_lines_P++; /* pointer to next line in the frame */
2700 cmDataP++; /* next host's data */
2701 cmIdx++; /* host index */
2704 } /* for each row in the Cache Manager frame */
2706 /* redraw the display if the Cache Managers screen is currently displayed */
2707 if (afsmon_win->w_frame == cmFrame)
2708 WOP_DISPLAY(afsmon_win);
2710 /* update the global page & column numbers to reflect the changes */
2711 cm_currPage = a_pageNum;
2712 cm_curr_LCol = a_LcolNum;;
2720 /*-----------------------------------------------------------------------
2724 * Switch from the Cache Manager screen to the Overview Screen
2725 *----------------------------------------------------------------------*/
2729 /* bind the overview frame to the window */
2730 gtxframe_SetFrame(afsmon_win, ovwFrame);
2734 /*-----------------------------------------------------------------------
2738 * Switch from the Cache Manager screen to the File Servers screen
2739 *----------------------------------------------------------------------*/
2743 if (cm_pageType & CMD_FS) {
2744 /* bind the file servers frame to the window */
2745 gtxframe_SetFrame(afsmon_win, fsFrame);
2750 /*-----------------------------------------------------------------------
2754 * Switch to next page of cache managers screen
2755 *----------------------------------------------------------------------*/
2759 static char rn[] = "Switch_cm_next";
2761 if (cm_pageType & CMD_NEXT) {
2762 /* we have a next page, refresh with next page number */
2763 cm_refresh(cm_currPage + 1, cm_curr_LCol);
2769 /*-----------------------------------------------------------------------
2773 * Switch to last page of file server screen
2774 *----------------------------------------------------------------------*/
2778 static char rn[] = "Switch_cm_last";
2781 if (cm_pageType & CMD_NEXT) {
2782 /* we have a next page, refresh with last page number */
2783 cm_refresh(cm_numPages, cm_curr_LCol);
2789 /*-----------------------------------------------------------------------
2793 * Switch to previous page of cache managers screen
2794 *----------------------------------------------------------------------*/
2798 static char rn[] = "Switch_cm_prev";
2800 if (cm_pageType & CMD_PREV) {
2801 /* we have a previous page, refresh to previous page */
2802 cm_refresh(cm_currPage - 1, cm_curr_LCol);
2807 /*-----------------------------------------------------------------------
2811 * Switch to first page of cache managers screen
2812 *----------------------------------------------------------------------*/
2816 static char rn[] = "Switch_cm_first";
2818 if (cm_pageType & CMD_PREV) {
2819 /* we have a previous page, refresh to first page */
2820 cm_refresh(1, cm_curr_LCol);
2825 /*-----------------------------------------------------------------------
2829 * Scroll left on the cache managers screen
2830 *----------------------------------------------------------------------*/
2834 static char rn[] = "Switch_cm_left";
2836 if (cm_pageType & CMD_LEFT) {
2837 /* we have columns on left, refresh with new column number */
2838 cm_refresh(cm_currPage, cm_curr_LCol - cm_cols_perPage);
2844 /*-----------------------------------------------------------------------
2845 * Switch_cm_leftmost()
2848 * Scroll to first column on the cache managers screen
2849 *----------------------------------------------------------------------*/
2851 Switch_cm_leftmost()
2853 static char rn[] = "Switch_cm_leftmost";
2855 if (cm_pageType & CMD_LEFT) {
2856 /* we have columns on left, go to the first column */
2857 cm_refresh(cm_currPage, 0);
2862 /*-----------------------------------------------------------------------
2866 * Scroll right on the cache managers screen
2867 *----------------------------------------------------------------------*/
2871 static char rn[] = "Switch_cm_right";
2873 if (cm_pageType & CMD_RIGHT) {
2874 /* we have columns on right, refresh with new column number */
2875 cm_refresh(cm_currPage, cm_curr_LCol + cm_cols_perPage);
2880 /*-----------------------------------------------------------------------
2881 * Switch_cm_rightmost()
2884 * Scroll to last column on the cache managers screen
2885 *----------------------------------------------------------------------*/
2887 Switch_cm_rightmost()
2889 static char rn[] = "Switch_cm_rightmost";
2893 if (cm_pageType & CMD_RIGHT) {
2894 /* we have columns on right, go to the last column */
2895 if (cm_numCols % cm_cols_perPage)
2896 curr_LCol = (cm_numCols / cm_cols_perPage) * cm_cols_perPage;
2899 ((cm_numCols / cm_cols_perPage) - 1) * cm_cols_perPage;
2900 cm_refresh(cm_currPage, curr_LCol);
2906 /*-----------------------------------------------------------------------
2907 * create_CMframe_objects()
2910 * Create the gtx objects (onodes) for the Cache Managers frame and setup
2911 * the keyboard bindings.
2912 * Only as many objects as can fit on the display are created. The
2913 * positions and lengths of all these objects are fixed at creation.
2914 * These objects are updated with new data at the end of each probe
2919 * Failure: Exits afsmonitor.
2920 *----------------------------------------------------------------------*/
2923 create_CMframe_objects()
2924 { /* create_CMframe_objects */
2925 static char rn[] = "create_CMframe_objects";
2926 struct ServerInfo_line *cm_lines_Ptr;
2927 struct onode **cm_data_o_Ptr;
2928 struct onode **cmLabels_o_Ptr;
2938 fprintf(debugFD, "[ %s ] Called\n", rn);
2944 /* create the command line object */
2946 initLightObject("Command [oview, fs, prev, next, left, right] ? ", 0,
2947 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2948 if (cm_cmd_o == NULL) {
2949 sprintf(errMsg, "[ %s ] Failed to create cm command onode\n", rn);
2952 code = gtxframe_AddToList(cmFrame, cm_cmd_o);
2953 code = gator_light_set(cm_cmd_o, HIGHLIGHT);
2956 /* we already have the dimensions for the frame - same as the ovw frame */
2957 /* use the ovw program name object for the cm screen too */
2959 code = gtxframe_AddToList(cmFrame, ovw_progName_o);
2962 /* create the page number object */
2964 initLightObject("[Cache Managers, p. X of X, c. Y of Y]",
2965 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2967 if (cm_pageNum_o == NULL) {
2968 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2971 code = gtxframe_AddToList(cmFrame, cm_pageNum_o);
2972 code = gator_light_set(cm_pageNum_o, HIGHLIGHT);
2974 /* create the probe number object */
2976 initLightObject("[CM probes 1, freq=30 sec]",
2977 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2978 FC_PROBENUM_O_WIDTH, afsmon_win);
2979 if (cm_probeNum_o == NULL) {
2980 sprintf(errMsg, "[ %s ] Failed to create cm probeNum onode\n", rn);
2983 code = gtxframe_AddToList(cmFrame, cm_probeNum_o);
2984 code = gator_light_set(cm_probeNum_o, HIGHLIGHT);
2987 /* create the numCM monitored object */
2990 (" 0 Cache Mangers monitored, 0 alerts on 0 machines", 4, 2,
2991 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2992 if (cm_numCM_o == NULL) {
2994 "[ %s ] Failed to create numCM onode for the cm frame\n", rn);
2997 code = gtxframe_AddToList(cmFrame, cm_numCM_o);
2999 /* create the "more columns to left" indicator */
3001 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
3002 if (cm_leftArrows_o == NULL) {
3004 "[ %s ] Failed to create leftArrows onode for the cm frame\n",
3008 code = gtxframe_AddToList(cmFrame, cm_leftArrows_o);
3010 /* create the "more columns to right" indicator */
3012 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
3014 if (cm_rightArrows_o == NULL) {
3016 "[ %s ] Failed to create rightArrows onode for the cm frame\n",
3020 code = gtxframe_AddToList(cmFrame, cm_rightArrows_o);
3025 /* calculate the maximum number of hosts per page (2 rows per host) */
3026 cm_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
3028 /* determine the number of data columns that can fit in a page */
3029 cm_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
3032 fprintf(debugFD, "[ %s ] cm_numHosts_perPage=%d cm_cols_perPage=%d\n",
3033 rn, cm_numHosts_perPage, cm_cols_perPage);
3037 /* the above two variables give us the information needed to create
3038 * the objects for displaying the file server information */
3040 /* allocate memory for all the onode pointers required to display
3041 * the file server statistics */
3043 numBytes = cm_numHosts_perPage * sizeof(struct ServerInfo_line);
3044 cm_lines = (struct ServerInfo_line *)malloc(numBytes);
3045 if (cm_lines == (struct ServerInfo_line *)0) {
3047 "[ %s ] Failed to allocate %d bytes for CM data lines\n", rn,
3052 /* for each line of server statistics allocate memory to store two arrays
3055 cm_lines_Ptr = cm_lines;
3056 for (i = 0; i < cm_numHosts_perPage; i++) {
3057 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
3058 numBytes = cm_cols_perPage * sizeof(struct onode *);
3059 cm_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes);
3060 if (cm_lines_Ptr->data_o[arrIdx] == NULL) {
3062 "[ %s ] Failed to allocate %d bytes for CM data onodes\n",
3070 /* now allocate the onodes itself */
3072 cm_lines_Ptr = cm_lines;
3073 for (i = 0; i < cm_numHosts_perPage; i++) {
3075 /* initialize host name onode */
3076 cm_lines_Ptr->host_o =
3077 initLightObject("CMHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
3078 FC_HOSTNAME_O_WIDTH, afsmon_win);
3079 if (cm_lines_Ptr->host_o == NULL) {
3080 sprintf(errMsg, "[ %s ] Failed to create an CM name onode\n", rn);
3083 code = gtxframe_AddToList(cmFrame, cm_lines_Ptr->host_o);
3085 /* if (afsmon_debug) {
3086 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
3087 * rn,cm_lines_Ptr->host_o,i);
3091 /* initialize data onodes for this host */
3093 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
3095 cm_data_o_Ptr = cm_lines_Ptr->data_o[arrIdx];
3096 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
3100 /* determine x & y coordinate for this data object */
3101 /* the 1's are for leaving a blank after each column */
3102 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
3103 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
3105 sprintf(tmpBuf, "-CMData %d-", arrIdx);
3107 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
3109 if (*cm_data_o_Ptr == NULL) {
3111 "[ %s ] Failed to create an CM data onode\n", rn);
3114 code = gtxframe_AddToList(cmFrame, *cm_data_o_Ptr);
3117 } /* for each column */
3118 } /* for each onode array index */
3121 } /* for each host slot */
3124 /* INITIALIZE COLUMN LABELS */
3127 /* allocate memory for two arrays of onode pointers for file server column
3129 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
3131 cmLabels_o[arrIdx] =
3132 (struct onode **)malloc(sizeof(struct onode *) * cm_cols_perPage);
3133 if (cmLabels_o[arrIdx] == NULL) {
3135 "[ %s ] Failed to allocate memory for CM label onodes\n",
3140 /* create cache manager name objects */
3141 cmLabels_o_Ptr = cmLabels_o[arrIdx];
3142 for (i = 0; i < cm_cols_perPage; i++) {
3144 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
3145 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
3148 if (*cmLabels_o_Ptr == NULL) {
3149 sprintf(errMsg, "[ %s ] Failed to create a CM label onode\n",
3153 code = gtxframe_AddToList(cmFrame, *cmLabels_o_Ptr);
3164 /* initialize the column & page counters */
3167 cm_numCols = cm_DisplayItems_count;
3168 cm_numPages = numCM / cm_numHosts_perPage;
3169 if (numCM % cm_numHosts_perPage)
3171 cm_curr_LCol = 0; /* leftmost col */
3172 cm_curr_RCol = 0; /* rightmost col */
3174 /* create keyboard bindings */
3175 /* bind Q and
\ 3 to exit */
3176 keymap_BindToString(cmFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
3177 keymap_BindToString(cmFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
3179 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
3180 * N = last page, P = first page, L = leftmost col, R = rightmost col */
3182 keymap_BindToString(cmFrame->keymap, "o", Switch_cm_2_ovw, NULL, NULL);
3183 keymap_BindToString(cmFrame->keymap, "f", Switch_cm_2_fs, NULL, NULL);
3184 keymap_BindToString(cmFrame->keymap, "n", Switch_cm_next, NULL, NULL);
3185 keymap_BindToString(cmFrame->keymap, "N", Switch_cm_last, NULL, NULL);
3186 keymap_BindToString(cmFrame->keymap, "p", Switch_cm_prev, NULL, NULL);
3187 keymap_BindToString(cmFrame->keymap, "P", Switch_cm_first, NULL, NULL);
3188 keymap_BindToString(cmFrame->keymap, "l", Switch_cm_left, NULL, NULL);
3189 keymap_BindToString(cmFrame->keymap, "L", Switch_cm_leftmost, NULL, NULL);
3190 keymap_BindToString(cmFrame->keymap, "r", Switch_cm_right, NULL, NULL);
3191 keymap_BindToString(cmFrame->keymap, "R", Switch_cm_rightmost, NULL,
3195 } /* create_CMframe_objects */
3199 /*-----------------------------------------------------------------------
3203 * Initialize the gtx package and call routines to create the objects
3204 * for the overview, File Servers & Cache Managers screens.
3205 *----------------------------------------------------------------------*/
3208 { /* gtx_initialize */
3209 static char rn[] = "gtx_initialize"; /* routine name */
3213 fprintf(debugFD, "[ %s ] Called\n", rn);
3217 afsmon_win = gtx_Init(0, -1); /* 0 => dont start input server,
3218 * 1 => use curses */
3219 if (afsmon_win == NULL) {
3220 sprintf(errMsg, "[ %s ] gtx initialization failed\n", rn);
3223 gtx_initialized = 1;
3225 /* Create the Overview frame */
3227 ovwFrame = gtxframe_Create();
3228 if (ovwFrame == (struct gtx_frame *)0) {
3229 sprintf(errMsg, "[ %s ] Failed to create overview frame\n", rn);
3233 /* bind the overview frame to the window */
3234 gtxframe_SetFrame(afsmon_win, ovwFrame);
3236 /* create overview frame objects */
3237 code = create_ovwFrame_objects();
3239 sprintf(errMsg, "[ %s ] Error in creating ovw frame objects\n", rn);
3244 /* Create the File Server frame */
3245 fsFrame = gtxframe_Create();
3246 if (fsFrame == (struct gtx_frame *)0) {
3247 sprintf(errMsg, "[ %s ] Failed to create file server frame\n", rn);
3252 /* Create File Server frame objects */
3253 code = create_FSframe_objects();
3255 sprintf(errMsg, "[ %s ] Error in creating FS frame objects\n", rn);
3259 /* Create the Cache Managers frame */
3260 cmFrame = gtxframe_Create();
3261 if (cmFrame == (struct gtx_frame *)0) {
3262 sprintf(errMsg, "[ %s ] Failed to create Cache Managers frame\n", rn);
3266 /* Create Cache Managers frame objects */
3267 code = create_CMframe_objects();
3269 sprintf(errMsg, "[ %s ] Error in creating CM frame objects\n", rn);
3273 /* misc initializations */
3274 sprintf(blankline, "%255s", " ");
3277 } /* gtx_initialize */