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);
568 return 0; /* not reached */
572 /*-----------------------------------------------------------------------
576 * Refresh the overview screen with the contents of the specified page.
577 * There are two parts to the overview screen - the file server column
578 * and the cache manager column and each of them is independent of the
579 * other. Hence it takes as an argumnet the "type" of update to be
584 * Failure: Exits afsmonitor.
585 *----------------------------------------------------------------------*/
588 ovw_refresh(a_pageNum, a_updateType)
589 int a_pageNum; /* page to refresh overview display */
590 int a_updateType; /* OVW_UPDATE_FS = update fs column only,
591 * OVW_UPDATE_CM = update cm column only,
592 * OVW_UPDATE_BOTH = update fs & cm columns. Note that
593 * we do not want to update a column until the
594 * corresponding probe cycle has completed */
597 static char rn[] = "ovw_refresh"; /* routine name */
598 struct onode **tmp_fsNames_o; /* ptr to fsNames onodes */
599 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
600 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
601 struct onode **tmp_cmNames_o; /* ptr to fsNames onodes */
602 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
603 int fsIdx; /* for counting # of CM hosts */
604 int cmIdx; /* for counting # of CM hosts */
605 int next_page = 0; /* is there a next ovw page ? */
606 int prev_page = 0; /* is there a previous ovw page */
607 char cmdLine[80]; /* buffer for command line */
608 char printBuf[256]; /* buffer to print to screen */
614 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_updateType= %d\n",
615 rn, a_pageNum, a_updateType);
619 /* if the data is not yet available ie., not one probe cycle has
620 * completed, do nothing */
622 if ((a_updateType & OVW_UPDATE_FS) && !fs_Data_Available)
624 if ((a_updateType & OVW_UPDATE_CM) && !cm_Data_Available)
628 /* validate page number */
629 if (a_pageNum < 1 || a_pageNum > ovw_numPages) {
630 sprintf(errMsg, "[ %s ] called with incorrect page number %d\n", rn,
635 /* set the current page number */
636 ovw_currPage = a_pageNum;
638 /* turn off init message */
641 gtxframe_RemoveFromList(ovwFrame, initMsg_o);
644 /* update the labels */
647 tmp_lightobj = (struct gator_lightobj *)ovw_progName_o->o_data;
648 sprintf(printBuf, "AFSMonitor [Version %s]", afsmon_version);
649 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
651 gator_light_set(ovw_progName_o, 1);
653 /* page number label */
654 tmp_lightobj = (struct gator_lightobj *)ovw_pageNum_o->o_data;
655 sprintf(printBuf, "[System Overview, p. %d of %d]", ovw_currPage,
657 justify_light(printBuf, tmp_lightobj->label, OVW_PAGENUM_O_WIDTH,
659 gator_light_set(ovw_pageNum_o, 1);
661 /* file servers monitored label */
662 tmp_lightobj = (struct gator_lightobj *)ovw_numFS_o->o_data;
663 sprintf(printBuf, " %d File Servers monitored", numFS);
664 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
667 /* cache managers monitored label */
668 tmp_lightobj = (struct gator_lightobj *)ovw_numCM_o->o_data;
669 sprintf(printBuf, " %d Cache Managers monitored", numCM);
670 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
674 /* no. of fs alerts label */
675 tmp_lightobj = (struct gator_lightobj *)ovw_FSalerts_o->o_data;
676 sprintf(printBuf, " %d alerts on %d machines", num_fs_alerts,
677 numHosts_onfs_alerts);
678 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
681 /* no. of cm alerts label */
682 tmp_lightobj = (struct gator_lightobj *)ovw_CMalerts_o->o_data;
683 sprintf(printBuf, " %d alerts on %d machines", num_cm_alerts,
684 numHosts_oncm_alerts);
685 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
689 /* determine if we have fs/cm, more/previous pages of data to display */
692 if (numFS && fs_Data_Available)
693 ovw_pageType |= CMD_FS; /* we have an fs frame & data avail. */
694 if (numCM && cm_Data_Available)
695 ovw_pageType |= CMD_CM; /* we have a cm frame & data avail. */
696 if (ovw_currPage > 1)
697 ovw_pageType |= CMD_PREV; /* got a previous page */
698 if (ovw_currPage < ovw_numPages)
699 ovw_pageType |= CMD_NEXT; /* got a next page */
701 strcpy(cmdLine, "Command [");
702 if ((ovw_pageType & CMD_FS) && (ovw_pageType & CMD_CM))
703 strcat(cmdLine, "fs, cm");
704 else if (ovw_pageType & CMD_FS)
705 strcat(cmdLine, "fs");
706 else if (ovw_pageType & CMD_CM)
707 strcat(cmdLine, "cm");
709 if (ovw_pageType & CMD_PREV)
710 strcat(cmdLine, ", prev");
711 if (ovw_pageType & CMD_NEXT)
712 strcat(cmdLine, ", next");
714 strcat(cmdLine, "]? ");
719 /* display the command line */
720 tmp_lightobj = (struct gator_lightobj *)ovw_cmd_o->o_data;
721 sprintf(printBuf, "%s", cmdLine);
722 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
724 gator_light_set(ovw_cmd_o, 1);
726 /* display probe numbers line */
727 tmp_lightobj = (struct gator_lightobj *)ovw_probeNum_o->o_data;
728 sprintf(printBuf, "[probes %d(fs) %d(cm), freq=%d sec]",
729 afsmon_fs_prev_probeNum, afsmon_cm_prev_probeNum,
731 justify_light(printBuf, tmp_lightobj->label, OVW_PROBENUM_O_WIDTH,
733 gator_light_set(ovw_probeNum_o, 1);
737 /* update the file server names column if we are asked to */
739 if (numFS && (a_updateType & OVW_UPDATE_FS)) {
741 /* move to the right spot in the FS display data array */
742 fsDataP = prev_fsData;
744 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
749 /* get the address to the first FS name */
750 tmp_fsNames_o = ovw_fsNames_o;
752 for (i = 0; i < ovw_numHosts_perPage; i++) {
753 if (fsIdx < numFS) { /* this could be the last & partial page */
755 if (fsDataP->hostName[0] == '\0') {
756 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
760 /* check if the probe succeeded. if it did check for thresholds
761 * overflow. A failed probe is indicated by "PF" */
763 if (!fsDataP->probeOK) {
764 sprintf(printBuf, "[ PF] %s", fsDataP->hostName);
765 } else if (fsDataP->ovfCount) /* thresholds overflow */
766 sprintf(printBuf, "[%3d] %s", fsDataP->ovfCount,
769 sprintf(printBuf, " %s", fsDataP->hostName);
773 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
776 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
778 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
779 len = OVW_HOSTNAME_O_WIDTH_HGL;
781 len = strlen(printBuf) + 1;
784 justify_light(printBuf, tmp_lightobj->label, len,
788 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
793 /* highlighten if overflowed or probe failed */
795 if (fsDataP->ovfCount || !fsDataP->probeOK)
796 code = gator_light_set(*tmp_fsNames_o, 1);
798 code = gator_light_set(*tmp_fsNames_o, 0);
801 } else { /* no more hosts, blank the rest of the entries */
803 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
804 sprintf(tmp_lightobj->label, "%s", "");
807 tmp_fsNames_o++; /* next onode */
808 fsDataP++; /* next host's data */
809 fsIdx++; /* host index */
814 /* if we have any cache managers, update them if we are asked to */
815 if (numCM && (a_updateType & OVW_UPDATE_CM)) {
817 /* move to the right spot in the CM display data array */
818 cmDataP = prev_cmData;
820 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
825 /* get the address to the first CM name */
826 tmp_cmNames_o = ovw_cmNames_o;
828 for (i = 0; i < ovw_numHosts_perPage; i++) {
829 if (cmIdx < numCM) { /* this could be the last & partial page */
831 if (cmDataP->hostName[0] == '\0') {
832 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
836 /* check if the probe succeeded. if it did check for thresholds
837 * overflow. A failed probe is indicated by "PF" */
839 if (!cmDataP->probeOK) {
840 sprintf(printBuf, "[ PF] %s", cmDataP->hostName);
841 } else if (cmDataP->ovfCount) { /* thresholds overflow */
842 sprintf(printBuf, "[%3d] %s", cmDataP->ovfCount,
845 sprintf(printBuf, " %s", cmDataP->hostName);
848 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
851 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
853 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
854 len = OVW_HOSTNAME_O_WIDTH_HGL;
856 len = strlen(printBuf) + 1;
859 justify_light(printBuf, tmp_lightobj->label, len,
863 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
868 /* highlighten if overflow or if probe failed */
869 if (cmDataP->ovfCount || !cmDataP->probeOK)
870 code = gator_light_set(*tmp_cmNames_o, 1);
872 code = gator_light_set(*tmp_cmNames_o, 0);
875 } else { /* no more hosts, blank the rest of the entries */
877 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
878 sprintf(tmp_lightobj->label, "%s", "");
881 tmp_cmNames_o++; /* next onode */
882 cmDataP++; /* next host's data */
883 cmIdx++; /* host index */
888 /* redraw the display if the overview screen is currently displayed */
889 if (afsmon_win->w_frame == ovwFrame)
890 WOP_DISPLAY(afsmon_win);
898 /*-----------------------------------------------------------------------
902 * Switch from the overview screen to the FS screen
903 *----------------------------------------------------------------------*/
907 static char rn[] = "Switch_ovw_2_fs";
910 fprintf(debugFD, "[ %s ] Called\n", rn);
914 /* bind the File Server frame to the window */
915 if (ovw_pageType & CMD_FS)
916 gtxframe_SetFrame(afsmon_win, fsFrame);
920 /*-----------------------------------------------------------------------
924 * Switch from the overview screen to the CM screen
925 *----------------------------------------------------------------------*/
929 static char rn[] = "Switch_ovw_2_cm";
932 fprintf(debugFD, "[ %s ] Called\n", rn);
936 /* bind the Cache Managers frame to the window */
937 if (ovw_pageType & CMD_CM)
938 gtxframe_SetFrame(afsmon_win, cmFrame);
942 /*-----------------------------------------------------------------------
946 * Switch to the next page in overview screen
947 *----------------------------------------------------------------------*/
951 static char rn[] = "Switch_ovw_next";
954 fprintf(debugFD, "[ %s ] Called\n", rn);
958 if (ovw_pageType & CMD_NEXT) {
959 /* call refresh with the next page number */
960 ovw_refresh(ovw_currPage + 1, ovw_update_info);
966 /*-----------------------------------------------------------------------
970 * Switch to the last page in the overview screen
971 *----------------------------------------------------------------------*/
975 static char rn[] = "Switch_ovw_last";
978 fprintf(debugFD, "[ %s ] Called\n", rn);
982 if (ovw_pageType & CMD_NEXT) {
983 /* call refresh with the last page number */
984 ovw_refresh(ovw_numPages, ovw_update_info);
990 /*-----------------------------------------------------------------------
994 * Switch to the previous page in the overview screen
995 *----------------------------------------------------------------------*/
999 static char rn[] = "Switch_ovw_prev";
1002 fprintf(debugFD, "[ %s ] Called\n", rn);
1006 if (ovw_pageType & CMD_PREV) {
1007 /* call refresh with the previous page number */
1008 ovw_refresh(ovw_currPage - 1, ovw_update_info);
1013 /*-----------------------------------------------------------------------
1014 * Switch_ovw_first()
1017 * Switch to the first page in the overview screen
1018 *----------------------------------------------------------------------*/
1022 static char rn[] = "Switch_ovw_first";
1025 fprintf(debugFD, "[ %s ] Called\n", rn);
1029 if (ovw_pageType & CMD_PREV) {
1030 /* refresh with the first page number */
1031 ovw_refresh(1, ovw_update_info);
1036 /*-----------------------------------------------------------------------
1037 * create_ovwFrame_objects()
1040 * Create the gtx objects (onodes) for the overview frame and setup
1041 * the keyboard bindings.
1042 * Only as many objects as can fit on the display are created. The
1043 * positions and lengths of all these objects are fixed at creation.
1044 * These objects are updated with new data at the end of each probe
1049 * Failure: Exits afsmonitor.
1050 *----------------------------------------------------------------------*/
1053 create_ovwFrame_objects()
1054 { /* create_ovwFrame_objects */
1056 static char rn[] = "create_ovwFrame_objects";
1057 int hostLines; /* number of lines of host names to display */
1058 struct onode **ovw_fsNames_o_Ptr; /* index to list of fs names onodes */
1059 struct onode **ovw_cmNames_o_Ptr; /* index to list of cm names onodes */
1064 fprintf(debugFD, "[ %s ] Called\n", rn);
1068 /* get frame dimensions, it must be atleast MINXxMINY for any sensible output */
1069 WOP_GETDIMENSIONS(ovwFrame->window, &frameDims);
1070 maxX = frameDims.maxx;
1071 maxY = frameDims.maxy;
1072 if (maxX + 1 < MINX || maxY + 1 < MINY) {
1073 sprintf(errMsg1, "[ %s ] Window size %dx%d; must be at least %dx%d\n",
1074 rn, maxX + 1, maxY + 1, MINX, MINY);
1078 fprintf(debugFD, "maxX = %d maxY = %d\n", maxX, maxY);
1081 /* Print an Intial message to the screen. The init message is 36 chars
1084 initLightObject(initMsg, maxX / 2 - 18, maxY / 3, sizeof(initMsg),
1086 if (initMsg_o == NULL) {
1087 sprintf(errMsg, "[ %s ] Failed to create initMsg_o onode\n", rn);
1090 code = gtxframe_AddToList(ovwFrame, initMsg_o);
1091 code = gator_light_set(initMsg_o, HIGHLIGHT);
1096 /* create the command line object */
1098 ovw_cmd_o = initLightObject("", 0, maxY - 1, OVW_CMD_O_WIDTH, afsmon_win);
1099 if (ovw_cmd_o == NULL) {
1100 sprintf(errMsg, "[ %s ] Failed to create command onode\n", rn);
1103 code = gtxframe_AddToList(ovwFrame, ovw_cmd_o);
1104 code = gator_light_set(ovw_cmd_o, HIGHLIGHT);
1106 /* create the program name object */
1108 ovw_progName_o = initLightObject("", 0, 0, PROGNAME_O_WIDTH, afsmon_win);
1109 if (ovw_progName_o == NULL) {
1110 sprintf(errMsg, "[ %s ] Failed to create programName onode\n", rn);
1113 code = gtxframe_AddToList(ovwFrame, ovw_progName_o);
1114 code = gator_light_set(ovw_progName_o, HIGHLIGHT);
1116 /* create the page number object */
1119 initLightObject("", maxX - OVW_PAGENUM_O_WIDTH, 0,
1120 OVW_PAGENUM_O_WIDTH, afsmon_win);
1121 if (ovw_pageNum_o == NULL) {
1122 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
1125 code = gtxframe_AddToList(ovwFrame, ovw_pageNum_o);
1126 code = gator_light_set(ovw_pageNum_o, HIGHLIGHT);
1128 /* create the probe number object */
1130 initLightObject("", maxX - OVW_PROBENUM_O_WIDTH, maxY - 1,
1131 OVW_PROBENUM_O_WIDTH, afsmon_win);
1132 if (ovw_probeNum_o == NULL) {
1133 sprintf(errMsg, "[ %s ] Failed to create probe number onode\n", rn);
1136 code = gtxframe_AddToList(ovwFrame, ovw_probeNum_o);
1137 code = gator_light_set(ovw_probeNum_o, HIGHLIGHT);
1139 /* create the numFS monitored object */
1140 ovw_numFS_o = initLightObject("", 0, 2, FC_NUMHOSTS_O_WIDTH, afsmon_win);
1141 if (ovw_numFS_o == NULL) {
1142 sprintf(errMsg, "[ %s ] Failed to create numFS onode\n", rn);
1145 code = gtxframe_AddToList(ovwFrame, ovw_numFS_o);
1147 /* create the numCM monitored object */
1149 initLightObject("", maxX / 2, 2, OVW_NUMCM_O_WIDTH, afsmon_win);
1150 if (ovw_numCM_o == NULL) {
1151 sprintf(errMsg, "[ %s ] Failed to create numCM_o onode\n", rn);
1154 code = gtxframe_AddToList(ovwFrame, ovw_numCM_o);
1156 /* create the number-of-FS-alerts object */
1158 initLightObject("", 0, 3, OVW_FSALERTS_O_WIDTH, afsmon_win);
1159 if (ovw_FSalerts_o == NULL) {
1160 sprintf(errMsg, "[ %s ] Failed to create FSalerts_o onode\n", rn);
1163 code = gtxframe_AddToList(ovwFrame, ovw_FSalerts_o);
1165 /* create the number-of-CM-alerts object */
1167 initLightObject("", maxX / 2, 3, OVW_CMALERTS_O_WIDTH, afsmon_win);
1168 if (ovw_CMalerts_o == NULL) {
1169 sprintf(errMsg, "[ %s ] Failed to create CMalerts_o onode\n", rn);
1172 code = gtxframe_AddToList(ovwFrame, ovw_CMalerts_o);
1174 /* create file-server-name and cache-manager-names objects */
1175 ovw_numHosts_perPage = maxY - OVW_NUM_FIXED_LINES;
1177 /* allocate memory for a list of onode pointers for file server names */
1179 (struct onode **)malloc(sizeof(struct onode *) *
1180 ovw_numHosts_perPage);
1181 if (ovw_fsNames_o == NULL) {
1182 sprintf(errMsg, "[ %s ] Failed to allocate memory for FS onodes\n",
1187 /* create file server name objects */
1188 ovw_fsNames_o_Ptr = ovw_fsNames_o;
1189 for (i = 0; i < ovw_numHosts_perPage; i++) {
1190 *ovw_fsNames_o_Ptr =
1191 initLightObject("", 0, OVW_FIRST_HOST_ROW + i,
1192 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1193 if (*ovw_fsNames_o_Ptr == NULL) {
1194 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
1198 * if (afsmon_debug) {
1199 * fprintf(debugFD,"[ %s ] fsName_o %d: %d\n",
1200 * rn,i,*ovw_fsNames_o_Ptr);
1204 code = gtxframe_AddToList(ovwFrame, *ovw_fsNames_o_Ptr);
1205 ovw_fsNames_o_Ptr++;
1210 /* allocate memory for a list of onode pointers for cache manager names */
1212 (struct onode **)malloc(sizeof(struct onode *) *
1213 ovw_numHosts_perPage);
1214 if (ovw_cmNames_o == NULL) {
1215 sprintf(errMsg, "[ %s ] Failed to allocate memory for CM onodes\n",
1220 /* create cache manager name objects */
1221 ovw_cmNames_o_Ptr = ovw_cmNames_o;
1222 for (i = 0; i < ovw_numHosts_perPage; i++) {
1223 *ovw_cmNames_o_Ptr =
1224 initLightObject("", maxX / 2, OVW_FIRST_HOST_ROW + i,
1225 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1226 if (*ovw_cmNames_o_Ptr == NULL) {
1227 sprintf(errMsg, "[ %s ] Failed to create a CM name onode\n", rn);
1230 code = gtxframe_AddToList(ovwFrame, *ovw_cmNames_o_Ptr);
1231 ovw_cmNames_o_Ptr++;
1235 /* Calculate the number of pages of overview data to display */
1236 /* host information starts at the 6th line from top and stops at 3rd
1237 * line from bottom of screen */
1244 ovw_numPages = hostLines / (maxY - OVW_NUM_FIXED_LINES);
1245 if (hostLines % (maxY - OVW_NUM_FIXED_LINES))
1249 fprintf(debugFD, "[ %s ] number of ovw pages = %d\n", rn,
1252 /* When the ovw_refresh() routine is called by the keyboard handlers the
1253 * following variable is used to determine if fs/cm/fs&cm info must be
1255 ovw_update_info = 0;
1257 ovw_update_info |= OVW_UPDATE_FS;
1259 ovw_update_info |= OVW_UPDATE_CM;
1261 /* bind the overview frame to a keyboard input handler */
1263 /* bind Q and
\ 3 to exit */
1264 keymap_BindToString(ovwFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
1265 keymap_BindToString(ovwFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
1267 /* f -> switch of fs frame */
1268 keymap_BindToString(ovwFrame->keymap, "f", Switch_ovw_2_fs, NULL, NULL);
1269 /* c -> switch of cm frame */
1270 keymap_BindToString(ovwFrame->keymap, "c", Switch_ovw_2_cm, NULL, NULL);
1271 /* n -> switch to next overview page */
1272 keymap_BindToString(ovwFrame->keymap, "n", Switch_ovw_next, NULL, NULL);
1273 /* N -> switch to last overview page */
1274 keymap_BindToString(ovwFrame->keymap, "N", Switch_ovw_last, NULL, NULL);
1275 /* p -> switch to previous overview page */
1276 keymap_BindToString(ovwFrame->keymap, "p", Switch_ovw_prev, NULL, NULL);
1277 /* P -> switch to first overview page */
1278 keymap_BindToString(ovwFrame->keymap, "P", Switch_ovw_first, NULL, NULL);
1282 } /* create_ovwFrame_objects */
1285 /*-----------------------------------------------------------------------
1289 * This function is called to determine the permissible keyboard
1290 * operations on the FS and CM frames. This information is used
1291 * to create an appropriate command line prompt. It also generates
1292 * a bit map of the permissible operations on this page which is
1293 * used by the keyboard-input handler routines.
1296 * Success: page-type (bit map of permissible operations)
1298 *----------------------------------------------------------------------*/
1301 resolve_CmdLine(a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols,
1302 a_curr_LCol, a_cols_perPage, a_Data_Available)
1303 char *a_buffer; /* buffer to copy command line */
1304 int a_currFrame; /* current frame ovw, fs or cm? */
1305 int a_currPage; /* current page number */
1306 int a_numPages; /* number of pages of data */
1307 int a_numCols; /* number of columns of data to display */
1308 int a_curr_LCol; /* current number of leftmost column */
1309 int a_cols_perPage; /* number of columns per page */
1311 { /* resolve_CmdLine */
1312 static char rn[] = "resolve_CmdLine";
1317 "[ %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",
1318 rn, a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols,
1319 a_curr_LCol, a_cols_perPage);
1325 /* determine if we have fs/cm frames. If we do, note that we should not
1326 * let the user seen the initial junk we have there until the probe
1327 * results are available */
1328 if (a_currFrame == 1) { /* in the fs frame */
1329 if (numCM && cm_Data_Available)
1331 } else if (a_currFrame == 2) { /* in the cm frame */
1332 if (numFS && fs_Data_Available)
1336 fprintf(debugFD, "[ %s ] Wrong frame type %d\n", rn, a_currFrame);
1342 /* do we have next/previous pages */
1343 if (a_currPage < a_numPages)
1344 pageType |= CMD_NEXT; /* have a next page */
1346 pageType |= CMD_PREV; /* have a previous page */
1348 if (a_numCols > a_cols_perPage) {
1349 if (a_curr_LCol > 0)
1350 pageType |= CMD_LEFT; /* have columns on left */
1351 if ((a_curr_LCol + a_cols_perPage) < a_numCols)
1352 pageType |= CMD_RIGHT; /* have columns on right */
1355 /* now build the command line */
1357 strcpy(a_buffer, "Command [oview");
1358 if (pageType & CMD_FS)
1359 strcat(a_buffer, ", fs");
1360 if (pageType & CMD_CM)
1361 strcat(a_buffer, ", cm");
1362 if (pageType & CMD_PREV)
1363 strcat(a_buffer, ", prev");
1364 if (pageType & CMD_NEXT)
1365 strcat(a_buffer, ", next");
1366 if (pageType & CMD_LEFT)
1367 strcat(a_buffer, ", left");
1368 if (pageType & CMD_RIGHT)
1369 strcat(a_buffer, ", right");
1370 strcat(a_buffer, "]? ");
1374 } /* resolve_CmdLine */
1376 /*-----------------------------------------------------------------------
1377 * display_Server_datum()
1380 * The data in the file server & cache manager frames are displayed
1381 * in two objects, one below the other. If the data is too long to
1382 * fit in the first object it will overflow into the next. This is
1383 * to conserve real estate on the screen. This function copies the
1384 * contents of the source buffer adjusted to the two objects if the
1385 * probe had succeded. Otherwise it enters "--" in the first object
1386 * blanks out the second. If the object needs to be highlightned
1387 * (due to a threshold crossing) it is done.
1391 *----------------------------------------------------------------------*/
1393 display_Server_datum(a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK, a_just,
1396 char *a_srcBuf; /* source buffer */
1397 struct onode *a_firstObj_o; /* first object */
1398 struct onode *a_secondObj_o; /* second object */
1399 int a_probeOK; /* probe OK ? */
1400 int a_just; /* justification */
1401 int a_highlight; /* highlight object ? */
1403 { /* display_Server_datum */
1405 static char rn[] = "display_Server_datum";
1406 struct gator_lightobj *tmp_lightobj1;
1407 struct gator_lightobj *tmp_lightobj2;
1408 char part1[FC_COLUMN_WIDTH + 2];
1409 char part2[FC_COLUMN_WIDTH + 2];
1415 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_probeOK= %d, a_just= %d, a_highlight= %d\n",
1416 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK,
1417 a_just, a_highlight);
1422 tmp_lightobj1 = (struct gator_lightobj *)a_firstObj_o->o_data;
1423 tmp_lightobj2 = (struct gator_lightobj *)a_secondObj_o->o_data;
1425 if (a_probeOK) { /* probe is ok so fill in the data */
1427 /* check if it would fit in one object */
1428 if (strlen(a_srcBuf) < FC_COLUMN_WIDTH) {
1429 strcpy(part1, a_srcBuf);
1432 /* break up the src string into 2 parts */
1433 /* note that column width includes terminator */
1434 strncpy(part1, a_srcBuf, FC_COLUMN_WIDTH - 1);
1435 part1[FC_COLUMN_WIDTH - 1] = '\0';
1436 strncpy(part2, a_srcBuf + FC_COLUMN_WIDTH - 1,
1437 FC_COLUMN_WIDTH - 1);
1441 } else { /* probe failed, enter "--"s */
1442 strcpy(part1, "--");
1446 /* if (afsmon_debug) {
1447 * fprintf(debugFD,"[ %s ] %s split to %s & %s\n",rn,a_srcBuf,part1,part2);
1451 /* initialize both the objects */
1454 justify_light(part1, tmp_lightobj1->label, FC_COLUMN_WIDTH, a_just,
1458 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1464 justify_light(part2, tmp_lightobj2->label, FC_COLUMN_WIDTH, a_just,
1468 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1473 /* highlight them */
1474 if (a_highlight && (part1[0] != '-'))
1475 gator_light_set(a_firstObj_o, 1);
1477 gator_light_set(a_firstObj_o, 0);
1478 if (a_highlight && (part2[0] != '\0'))
1479 gator_light_set(a_secondObj_o, 1);
1481 gator_light_set(a_secondObj_o, 0);
1487 } /* display_Server_datum */
1490 /*-----------------------------------------------------------------------
1491 * display_Server_label()
1494 * Display the given server label in three objects. The label is
1495 * partitioned into three parts by '/'s and each part is copied
1496 * into each label object.
1500 *----------------------------------------------------------------------*/
1503 display_Server_label(a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o)
1505 struct onode *a_firstObj_o; /* first object */
1506 struct onode *a_secondObj_o; /* second object */
1507 struct onode *a_thirdObj_o; /* third object */
1509 { /* display_Server_label */
1511 static char rn[] = "display_Server_label";
1512 char part[3][20]; /* buffer for three parts of label */
1514 struct gator_lightobj *tmp_lightobj;
1515 struct onode *objPtr_o[3];
1522 /* the following debug statement floods the debug file */
1523 #ifdef DEBUG_DETAILED
1526 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_thirdObj_o= %d\n",
1527 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o);
1533 /* break the label string into three parts */
1538 /* now for a dumb precaution */
1540 strLen = strlen(a_srcBuf);
1543 for (i = 0; i < 3; i++) {
1545 while (*strPtr != '\0' && (len++ <= strLen)) {
1546 if (*strPtr == '/') {
1550 part[i][j] = *strPtr;
1558 * if (afsmon_debug) {
1559 * fprintf(debugFD,"[ %s ] LABELS %s -> %s %s %s\n",
1560 * rn, a_srcBuf, part[0], part[1], part[2]);
1565 objPtr_o[0] = a_firstObj_o;
1566 objPtr_o[1] = a_secondObj_o;
1567 objPtr_o[2] = a_thirdObj_o;
1569 /* display each label justified CENTER */
1571 for (i = 0; i < 3; i++) {
1572 tmp_lightobj = (struct gator_lightobj *)objPtr_o[i]->o_data;
1574 justify_light(part[i], tmp_lightobj->label, FC_COLUMN_WIDTH,
1578 fprintf(debugFD, "[ %s ] justify_light %d failed \n", rn, i);
1584 } /* display_Server_label */
1590 /*-----------------------------------------------------------------------
1594 * Refresh the File Servers screen with the given page number starting
1595 * at the given left-column number. The appropriate contents of
1596 * prev_fsData are displayed.
1597 * First the status labels at the four corners of the screen are
1598 * updated. Next the column labels are updated and then each row
1603 * Failure: Exits afsmoitor on a severe error.
1604 *----------------------------------------------------------------------*/
1608 fs_refresh(a_pageNum, a_LcolNum)
1609 int a_pageNum; /* page to display */
1610 int a_LcolNum; /* starting (leftmost) column number */
1614 static char rn[] = "fs_refresh"; /* routine name */
1615 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
1616 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
1617 struct ServerInfo_line *tmp_fs_lines_P; /* tmp ptr to fs_lines */
1618 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
1619 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
1620 struct onode **fsLabels_o_Ptr1; /* ptr to label row 0 */
1621 struct onode **fsLabels_o_Ptr2; /* ptr to label row 1 */
1622 struct onode **fsLabels_o_Ptr3; /* ptr to label row 2 */
1623 char cmdLine[80]; /* buffer for command line */
1624 char printBuf[256]; /* buffer to print to screen */
1631 int dataIndex; /* index to the data[] field of
1632 * struct fs_Display_Data */
1635 fprintf(debugFD, "[ %s ] Called with row %d col %d \n", rn, a_pageNum,
1641 /* if the data is not yet available, ie., not one probe cycle has
1642 * completed, do nothing */
1644 if (!fs_Data_Available)
1648 /* validate the page number & column number */
1649 if (a_pageNum < 1 || a_pageNum > fs_numPages) {
1651 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
1657 if (a_LcolNum < 0 || a_LcolNum > fs_numCols) {
1659 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
1668 /* update the fixed labels */
1670 /* we reuse the ovw version lable and hence do not have to do anything
1673 /* page number label */
1674 tmp_lightobj = (struct gator_lightobj *)fs_pageNum_o->o_data;
1675 sprintf(printBuf, "[File Servers, p. %d of %d, c. %d of %d]", a_pageNum,
1676 fs_numPages, a_LcolNum + 1, fs_numCols);
1677 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
1679 gator_light_set(fs_pageNum_o, 1);
1681 /* file servers monitored label */
1682 tmp_lightobj = (struct gator_lightobj *)fs_numFS_o->o_data;
1683 sprintf(printBuf, "%d File Servers monitored, %d alerts on %d machines",
1684 numFS, num_fs_alerts, numHosts_onfs_alerts);
1685 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
1691 /* figure out what we need to show in the prompt & set the page type */
1692 /* the fs_pageType variable is in turn used by the keyboard handler
1693 * routines to call fs_refresh() with the correct parameters */
1695 fs_pageType = resolve_CmdLine(cmdLine, 1 /* fs frame */ , a_pageNum,
1696 fs_numPages, fs_numCols, a_LcolNum,
1699 /* display the command line */
1700 tmp_lightobj = (struct gator_lightobj *)fs_cmd_o->o_data;
1701 sprintf(printBuf, "%s", cmdLine);
1702 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
1704 gator_light_set(fs_cmd_o, 1);
1706 /* update the probe number label */
1707 tmp_lightobj = (struct gator_lightobj *)fs_probeNum_o->o_data;
1708 sprintf(printBuf, "[FS probes %d, freq=%d sec]", afsmon_fs_prev_probeNum,
1710 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
1712 gator_light_set(fs_probeNum_o, 1);
1714 /* update "columns on left" signal */
1715 tmp_lightobj = (struct gator_lightobj *)fs_leftArrows_o->o_data;
1716 if (fs_pageType & CMD_LEFT)
1717 strcpy(printBuf, "<<<");
1719 strcpy(printBuf, "");
1720 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1722 gator_light_set(fs_leftArrows_o, 0);
1724 /* update "columns on right" signal */
1725 tmp_lightobj = (struct gator_lightobj *)fs_rightArrows_o->o_data;
1726 if (fs_pageType & CMD_RIGHT)
1727 strcpy(printBuf, ">>>");
1729 strcpy(printBuf, "");
1730 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1732 gator_light_set(fs_rightArrows_o, 0);
1736 /* UPDATE THE COLUMN LABELS */
1738 /* the column index is also used to index the label arrays */
1739 labelIdx = a_LcolNum;
1741 /* get the pointers to the three arrays of label onodes */
1742 fsLabels_o_Ptr1 = fsLabels_o[0];
1743 fsLabels_o_Ptr2 = fsLabels_o[1];
1744 fsLabels_o_Ptr3 = fsLabels_o[2];
1746 for (k = 0; k < fs_cols_perPage; k++) {
1748 if (labelIdx < fs_numCols) {
1749 dataIndex = fs_Display_map[labelIdx];
1751 display_Server_label(fs_labels[dataIndex], *fsLabels_o_Ptr1,
1752 *fsLabels_o_Ptr2, *fsLabels_o_Ptr3);
1754 labelIdx++; /* next label */
1757 display_Server_label("//", *fsLabels_o_Ptr1, *fsLabels_o_Ptr2,
1761 fsLabels_o_Ptr1++; /* next onode in label row 1 */
1762 fsLabels_o_Ptr2++; /* next onode in label row 2 */
1763 fsLabels_o_Ptr3++; /* next onode in label row 3 */
1765 } /* labels for each column */
1768 /* UPDATE THE FILE SERVER STATISTICS */
1770 /* move to the right spot in the FS display data array */
1771 fsDataP = prev_fsData;
1773 for (i = 0; i < ((a_pageNum - 1) * fs_numHosts_perPage); i++) {
1778 if (fsIdx >= numFS) { /* whoops! screwed up */
1779 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
1783 /* get the pointer to the first line of onodes of the file server frame */
1784 tmp_fs_lines_P = fs_lines;
1786 for (i = 0; i < fs_numHosts_perPage; i++) {
1789 /* if this is the last page we may not have file servers to fill up
1790 * the page, so check the index */
1791 if (fsIdx < numFS) {
1793 if (fsDataP->hostName[0] == '\0') {
1794 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
1798 /* display the hostname , first names only please! */
1800 sprintf(printBuf, fsDataP->hostName);
1801 for (j = 0; j < strlen(printBuf); j++) {
1802 if (printBuf[j] == '.') {
1809 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1811 justify_light(printBuf, tmp_lightobj->label,
1812 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
1814 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1819 /* use the current column value to index into the fs_Display_map
1820 * array to obtain the index of the item to display. check if its
1821 * overflow flag is set and highlight if so. if the probe had failed
1822 * enter "--" is all columns */
1824 /* each host has two rows of slots for datums. get the pointers to
1825 * both the arrays */
1827 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1828 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1829 fs_curr_RCol = a_LcolNum; /* starting column number from which
1830 * we are asked to display data */
1832 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
1834 /* if there is another column of data */
1835 if (fs_curr_RCol < fs_numCols) {
1837 dataIndex = fs_Display_map[fs_curr_RCol];
1840 display_Server_datum(fsDataP->data[dataIndex],
1843 fsDataP->probeOK, RIGHT_JUSTIFY,
1844 fsDataP->threshOvf[dataIndex]);
1847 } else { /* no more data, blank out columns */
1848 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
1849 RIGHT_JUSTIFY, 0); /* no overflow */
1853 firstSlot_o_Ptr++; /* onode of next column */
1854 secondSlot_o_Ptr++; /* onode of next column */
1856 } /* for each column */
1858 /* the loop could have taken the right-column-index one over,
1860 if (fs_curr_RCol == fs_numCols)
1868 /* if fdIdx < numFS */
1869 /* if fsIdx >= numFS , blank out all succeding rows */
1870 if (fsIdx >= numFS) {
1872 /* blank out host name object */
1874 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1876 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
1879 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1884 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1885 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1887 for (k = 0; k < fs_cols_perPage; k++) {
1888 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
1889 RIGHT_JUSTIFY, 0); /* dont highlight */
1897 /* fsIDx >= numFS */
1898 tmp_fs_lines_P++; /* pointer to next line in the frame */
1899 fsDataP++; /* next host's data */
1900 fsIdx++; /* host index */
1903 } /* for each row in the File Servers frame */
1905 /* redraw the display if the File Servers screen is currently displayed */
1906 if (afsmon_win->w_frame == fsFrame)
1907 WOP_DISPLAY(afsmon_win);
1909 /* update the global page & column numbers to reflect the changes */
1910 fs_currPage = a_pageNum;
1911 fs_curr_LCol = a_LcolNum;;
1920 /*-----------------------------------------------------------------------
1924 * Switch from the File Server screen to the Overview Screen
1925 *----------------------------------------------------------------------*/
1929 /* bind the overview frame to the window */
1930 gtxframe_SetFrame(afsmon_win, ovwFrame);
1934 /*-----------------------------------------------------------------------
1938 * Switch from the File Server screen to the Cache Managers screen.
1939 *----------------------------------------------------------------------*/
1943 if (fs_pageType & CMD_CM) {
1944 /* bind the overview Cache Managers to the window */
1945 gtxframe_SetFrame(afsmon_win, cmFrame);
1950 /*-----------------------------------------------------------------------
1954 * Switch to next page of file server screen
1955 *----------------------------------------------------------------------*/
1959 static char rn[] = "Switch_fs_next";
1961 if (fs_pageType & CMD_NEXT) {
1962 /* we have a next page, refresh with next page number */
1963 fs_refresh(fs_currPage + 1, fs_curr_LCol);
1969 /*-----------------------------------------------------------------------
1973 * Switch to last page of file server screen
1974 *----------------------------------------------------------------------*/
1978 static char rn[] = "Switch_fs_last";
1981 if (fs_pageType & CMD_NEXT) {
1982 /* we have a next page, refresh with the last page number */
1983 fs_refresh(fs_numPages, fs_curr_LCol);
1989 /*-----------------------------------------------------------------------
1993 * Switch to previous page of file server screen
1994 *----------------------------------------------------------------------*/
1998 static char rn[] = "Switch_fs_prev";
2000 if (fs_pageType & CMD_PREV) {
2001 /* we have a previous page, refresh with the rpevious page number */
2002 fs_refresh(fs_currPage - 1, fs_curr_LCol);
2007 /*-----------------------------------------------------------------------
2011 * Switch to first page of file server screen
2012 *----------------------------------------------------------------------*/
2016 static char rn[] = "Switch_fs_first";
2018 if (fs_pageType & CMD_PREV) {
2019 /* we have a previous page, got to first page */
2020 fs_refresh(1, fs_curr_LCol);
2025 /*-----------------------------------------------------------------------
2029 * Scroll left on the file server screen
2030 *----------------------------------------------------------------------*/
2034 static char rn[] = "Switch_fs_left";
2036 if (fs_pageType & CMD_LEFT) {
2037 /* we have columns on left, refresh with new column number */
2038 fs_refresh(fs_currPage, fs_curr_LCol - fs_cols_perPage);
2044 /*-----------------------------------------------------------------------
2045 * Switch_fs_leftmost()
2048 * Scroll to first column on the file server screen
2049 *----------------------------------------------------------------------*/
2051 Switch_fs_leftmost()
2053 static char rn[] = "Switch_fs_leftmost";
2055 if (fs_pageType & CMD_LEFT) {
2056 /* we have columns on left, go to the first */
2057 fs_refresh(fs_currPage, 0);
2062 /*-----------------------------------------------------------------------
2066 * Scroll right on the file server screen
2067 *----------------------------------------------------------------------*/
2071 static char rn[] = "Switch_fs_right";
2073 if (fs_pageType & CMD_RIGHT) {
2074 /* we have columns on right, refresh with new column number */
2075 fs_refresh(fs_currPage, fs_curr_LCol + fs_cols_perPage);
2080 /*-----------------------------------------------------------------------
2081 * Switch_fs_rightmost()
2084 * Scroll to last column on the file server screen
2085 *----------------------------------------------------------------------*/
2087 Switch_fs_rightmost()
2089 static char rn[] = "Switch_fs_rightmost";
2093 if (fs_pageType & CMD_RIGHT) {
2094 /* we have columns on right, go to the last column */
2095 if (fs_numCols % fs_cols_perPage)
2096 curr_LCol = (fs_numCols / fs_cols_perPage) * fs_cols_perPage;
2099 ((fs_numCols / fs_cols_perPage) - 1) * fs_cols_perPage;
2101 fs_refresh(fs_currPage, curr_LCol);
2107 /*-----------------------------------------------------------------------
2108 * create_FSframe_objects()
2111 * Create the gtx objects (onodes) for the Fileservers frame and setup
2112 * the keyboard bindings.
2113 * Only as many objects as can fit on the display are created. The
2114 * positions and lengths of all these objects are fixed at creation.
2115 * These objects are updated with new data at the end of each probe
2120 * Failure: Exits afsmonitor.
2121 *----------------------------------------------------------------------*/
2124 create_FSframe_objects()
2125 { /* create_FSframe_objects */
2126 static char rn[] = "create_FSframe_objects";
2127 struct ServerInfo_line *fs_lines_Ptr;
2128 struct onode **fs_data_o_Ptr;
2129 struct onode **fsLabels_o_Ptr;
2140 fprintf(debugFD, "[ %s ] Called\n", rn);
2144 /* create the command line object */
2146 initLightObject("Command [oview, cm, prev, next, left, right] ? ", 0,
2147 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2148 if (fs_cmd_o == NULL) {
2149 sprintf(errMsg, "[ %s ] Failed to create fs command onode\n", rn);
2152 code = gtxframe_AddToList(fsFrame, fs_cmd_o);
2153 code = gator_light_set(fs_cmd_o, HIGHLIGHT);
2155 /* we already have the dimensions for the frame - same as the ovw frame */
2156 /* use the ovw program name object for the fs screen too */
2158 code = gtxframe_AddToList(fsFrame, ovw_progName_o);
2161 /* create the page number object */
2163 initLightObject("[File Servers, p. X of X, c. Y of Y]",
2164 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2166 if (fs_pageNum_o == NULL) {
2167 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2170 code = gtxframe_AddToList(fsFrame, fs_pageNum_o);
2171 code = gator_light_set(fs_pageNum_o, HIGHLIGHT);
2173 /* create the probe number object */
2175 initLightObject("[FS probes 1, freq=30 sec]",
2176 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2177 FC_PROBENUM_O_WIDTH, afsmon_win);
2178 if (fs_probeNum_o == NULL) {
2179 sprintf(errMsg, "[ %s ] Failed to create fs probeNum onode\n", rn);
2182 code = gtxframe_AddToList(fsFrame, fs_probeNum_o);
2183 code = gator_light_set(fs_probeNum_o, HIGHLIGHT);
2186 /* create the numFS monitored object */
2189 (" 0 File Servers monitored, 0 alerts on 0 machines", 4, 2,
2190 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2191 if (fs_numFS_o == NULL) {
2193 "[ %s ] Failed to create numFS onode for the fs frame\n", rn);
2196 code = gtxframe_AddToList(fsFrame, fs_numFS_o);
2198 /* create the "more columns to left" indicator */
2200 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
2201 if (fs_leftArrows_o == NULL) {
2203 "[ %s ] Failed to create leftArrows onode for the fs frame\n",
2207 code = gtxframe_AddToList(fsFrame, fs_leftArrows_o);
2209 /* create the "more columns to right" indicator */
2211 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
2213 if (fs_rightArrows_o == NULL) {
2215 "[ %s ] Failed to create rightArrows onode for the fs frame\n",
2219 code = gtxframe_AddToList(fsFrame, fs_rightArrows_o);
2224 /* calculate the maximum number of hosts per page (2 rows per host) */
2225 fs_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
2227 /* determine the number of data columns that can fit in a page */
2228 fs_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
2231 fprintf(debugFD, "[ %s ] fs_numHosts_perPage=%d fs_cols_perPage=%d\n",
2232 rn, fs_numHosts_perPage, fs_cols_perPage);
2236 /* the above two variables give us the information needed to create
2237 * the objects for displaying the file server information */
2239 /* allocate memory for all the onode pointers required to display
2240 * the file server statistics */
2242 numBytes = fs_numHosts_perPage * sizeof(struct ServerInfo_line);
2243 fs_lines = (struct ServerInfo_line *)malloc(numBytes);
2244 if (fs_lines == (struct ServerInfo_line *)0) {
2246 "[ %s ] Failed to allocate %d bytes for FS data lines\n", rn,
2251 /* for each line of server statistics allocate memory to store two arrays
2254 fs_lines_Ptr = fs_lines;
2255 for (i = 0; i < fs_numHosts_perPage; i++) {
2256 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
2257 numBytes = fs_cols_perPage * sizeof(struct onode *);
2258 fs_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes);
2259 if (fs_lines_Ptr->data_o[arrIdx] == NULL) {
2261 "[ %s ] Failed to allocate %d bytes for FS data onodes\n",
2269 /* now allocate the onodes itself */
2271 fs_lines_Ptr = fs_lines;
2272 for (i = 0; i < fs_numHosts_perPage; i++) {
2274 /* initialize host name onode */
2275 fs_lines_Ptr->host_o =
2276 initLightObject("FSHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
2277 FC_HOSTNAME_O_WIDTH, afsmon_win);
2278 if (fs_lines_Ptr->host_o == NULL) {
2279 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
2282 code = gtxframe_AddToList(fsFrame, fs_lines_Ptr->host_o);
2284 /* if (afsmon_debug) {
2285 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
2286 * rn,fs_lines_Ptr->host_o,i);
2290 /* initialize data onodes for this host */
2292 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
2294 fs_data_o_Ptr = fs_lines_Ptr->data_o[arrIdx];
2295 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
2299 /* determine x & y coordinate for this data object */
2300 /* the 1's are for leaving a blank after each column */
2301 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
2302 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
2304 sprintf(tmpBuf, "-FSData %d-", arrIdx);
2306 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
2308 if (*fs_data_o_Ptr == NULL) {
2310 "[ %s ] Failed to create an FS data onode\n", rn);
2313 code = gtxframe_AddToList(fsFrame, *fs_data_o_Ptr);
2316 } /* for each column */
2317 } /* for each onode array index */
2320 } /* for each host slot */
2323 /* INITIALIZE COLUMN LABELS */
2326 /* allocate memory for two arrays of onode pointers for file server column
2328 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
2330 fsLabels_o[arrIdx] =
2331 (struct onode **)malloc(sizeof(struct onode *) * fs_cols_perPage);
2332 if (fsLabels_o[arrIdx] == NULL) {
2334 "[ %s ] Failed to allocate memory for FS label onodes\n",
2339 /* create cache manager name objects */
2340 fsLabels_o_Ptr = fsLabels_o[arrIdx];
2341 for (i = 0; i < fs_cols_perPage; i++) {
2343 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
2344 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
2347 if (*fsLabels_o_Ptr == NULL) {
2348 sprintf(errMsg, "[ %s ] Failed to create a FS label onode\n",
2352 code = gtxframe_AddToList(fsFrame, *fsLabels_o_Ptr);
2359 /* initialize the column & page counters */
2362 fs_numCols = fs_DisplayItems_count;
2363 fs_numPages = numFS / fs_numHosts_perPage;
2364 if (numFS % fs_numHosts_perPage)
2366 fs_curr_LCol = 0; /* leftmost col */
2367 fs_curr_RCol = 0; /* rightmost col */
2369 /* create keyboard bindings */
2370 /* bind Q and
\ 3 to exit */
2371 keymap_BindToString(fsFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
2372 keymap_BindToString(fsFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
2374 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
2375 * N = last page, P = first page, L = leftmost col, R = rightmost col */
2377 keymap_BindToString(fsFrame->keymap, "o", Switch_fs_2_ovw, NULL, NULL);
2378 keymap_BindToString(fsFrame->keymap, "c", Switch_fs_2_cm, NULL, NULL);
2379 keymap_BindToString(fsFrame->keymap, "n", Switch_fs_next, NULL, NULL);
2380 keymap_BindToString(fsFrame->keymap, "N", Switch_fs_last, NULL, NULL);
2381 keymap_BindToString(fsFrame->keymap, "p", Switch_fs_prev, NULL, NULL);
2382 keymap_BindToString(fsFrame->keymap, "P", Switch_fs_first, NULL, NULL);
2383 keymap_BindToString(fsFrame->keymap, "l", Switch_fs_left, NULL, NULL);
2384 keymap_BindToString(fsFrame->keymap, "L", Switch_fs_leftmost, NULL, NULL);
2385 keymap_BindToString(fsFrame->keymap, "r", Switch_fs_right, NULL, NULL);
2386 keymap_BindToString(fsFrame->keymap, "R", Switch_fs_rightmost, NULL,
2390 } /* create_FSframe_objects */
2393 /*-----------------------------------------------------------------------
2394 * Function: cm_refresh()
2397 * Refresh the Cache Managers screen with the given page number starting
2398 * at the given left-column number. The appropriate contents of
2399 * prev_cmData are displayed.
2400 * First the status labels at the four corners of the screen are
2401 * updated. Next the column labels are updated and then each row
2406 * Failure: Exits afsmoitor on a severe error.
2407 *----------------------------------------------------------------------*/
2410 cm_refresh(a_pageNum, a_LcolNum)
2411 int a_pageNum; /* page to display */
2412 int a_LcolNum; /* starting (leftmost) column number */
2416 static char rn[] = "cm_refresh"; /* routine name */
2417 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
2418 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
2419 struct ServerInfo_line *tmp_cm_lines_P; /* tmp ptr to cm_lines */
2420 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
2421 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
2422 struct onode **cmLabels_o_Ptr1; /* ptr to label row 0 */
2423 struct onode **cmLabels_o_Ptr2; /* ptr to label row 1 */
2424 struct onode **cmLabels_o_Ptr3; /* ptr to label row 2 */
2425 char cmdLine[80]; /* buffer for command line */
2426 char printBuf[256]; /* buffer to print to screen */
2433 int dataIndex; /* index to the data[] field of
2434 * struct cm_Display_Data */
2437 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_LcolNum= %d \n", rn,
2438 a_pageNum, a_LcolNum);
2443 /* if the data is not yet available, ie., not one probe cycle has
2444 * completed, do nothing */
2446 if (!cm_Data_Available)
2450 /* validate the page number & column number */
2451 if (a_pageNum < 1 || a_pageNum > cm_numPages) {
2453 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
2459 if (a_LcolNum < 0 || a_LcolNum > cm_numCols) {
2461 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
2470 /* update the fixed labels */
2472 /* we reuse the ovw version lable and hence do not have to do anything
2475 /* page number label */
2476 tmp_lightobj = (struct gator_lightobj *)cm_pageNum_o->o_data;
2477 sprintf(printBuf, "[Cache Managers, p.%d of %d, c.%d of %d]", a_pageNum,
2478 cm_numPages, a_LcolNum + 1, cm_numCols);
2479 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
2481 gator_light_set(cm_pageNum_o, 1);
2483 /* file servers monitored label */
2484 tmp_lightobj = (struct gator_lightobj *)cm_numCM_o->o_data;
2485 sprintf(printBuf, "%d Cache Managers monitored, %d alerts on %d machines",
2486 numCM, num_cm_alerts, numHosts_oncm_alerts);
2487 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
2493 /* figure out what we need to show in the prompt & set the page type */
2494 /* the cm_pageType variable is in turn used by the keyboard handler
2495 * routines to call cm_refresh() with the correct parameters */
2497 cm_pageType = resolve_CmdLine(cmdLine, 2 /* cm frame */ , a_pageNum,
2498 cm_numPages, cm_numCols, a_LcolNum,
2501 /* display the command line */
2502 tmp_lightobj = (struct gator_lightobj *)cm_cmd_o->o_data;
2503 sprintf(printBuf, "%s", cmdLine);
2504 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
2506 gator_light_set(cm_cmd_o, 1);
2508 /* update the probe number label */
2509 tmp_lightobj = (struct gator_lightobj *)cm_probeNum_o->o_data;
2510 sprintf(printBuf, "[CM probes %d, freq=%d sec]", afsmon_cm_prev_probeNum,
2512 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
2514 gator_light_set(cm_cmd_o, 1);
2516 /* update "columns on left" signal */
2517 tmp_lightobj = (struct gator_lightobj *)cm_leftArrows_o->o_data;
2518 if (cm_pageType & CMD_LEFT)
2519 strcpy(printBuf, "<<<");
2521 strcpy(printBuf, "");
2522 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2524 gator_light_set(cm_leftArrows_o, 0);
2526 /* update "columns on right" signal */
2527 tmp_lightobj = (struct gator_lightobj *)cm_rightArrows_o->o_data;
2528 if (cm_pageType & CMD_RIGHT)
2529 strcpy(printBuf, ">>>");
2531 strcpy(printBuf, "");
2532 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2534 gator_light_set(cm_rightArrows_o, 0);
2538 /* UPDATE THE COLUMN LABELS */
2540 /* the column index is also used to index the label arrays */
2541 labelIdx = a_LcolNum;
2543 /* get the pointers to the three arrays of label onodes */
2544 cmLabels_o_Ptr1 = cmLabels_o[0];
2545 cmLabels_o_Ptr2 = cmLabels_o[1];
2546 cmLabels_o_Ptr3 = cmLabels_o[2];
2548 for (k = 0; k < cm_cols_perPage; k++) {
2550 if (labelIdx < cm_numCols) {
2551 dataIndex = cm_Display_map[labelIdx];
2553 display_Server_label(cm_labels[dataIndex], *cmLabels_o_Ptr1,
2554 *cmLabels_o_Ptr2, *cmLabels_o_Ptr3);
2556 labelIdx++; /* next label */
2559 display_Server_label("//", *cmLabels_o_Ptr1, *cmLabels_o_Ptr2,
2563 cmLabels_o_Ptr1++; /* next onode in label row 1 */
2564 cmLabels_o_Ptr2++; /* next onode in label row 2 */
2565 cmLabels_o_Ptr3++; /* next onode in label row 3 */
2567 } /* labels for each column */
2570 /* UPDATE THE FILE SERVER STATISTICS */
2572 /* move to the right spot in the CM display data array */
2573 cmDataP = prev_cmData;
2575 for (i = 0; i < ((a_pageNum - 1) * cm_numHosts_perPage); i++) {
2580 if (cmIdx >= numCM) { /* whoops! screwed up */
2581 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
2585 /* get the pointer to the first line of onodes of the file server frame */
2586 tmp_cm_lines_P = cm_lines;
2588 for (i = 0; i < cm_numHosts_perPage; i++) {
2591 /* if this is the last page we may not have file servers to fill up
2592 * the page, so check the index */
2593 if (cmIdx < numCM) {
2595 if (cmDataP->hostName[0] == '\0') {
2596 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
2600 /* display the hostname , first names only please! */
2602 sprintf(printBuf, cmDataP->hostName);
2603 for (j = 0; j < strlen(printBuf); j++) {
2604 if (printBuf[j] == '.') {
2611 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2613 justify_light(printBuf, tmp_lightobj->label,
2614 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
2616 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2621 /* use the current column value to index into the cm_Display_map
2622 * array to obtain the index of the item to display. check if its
2623 * overflow flag is set and highlight if so. if the probe had failed
2624 * enter "--" is all columns */
2626 /* each host has two rows of slots for datums. get the pointers to
2627 * both the arrays */
2629 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2630 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2631 cm_curr_RCol = a_LcolNum; /* starting column number from which
2632 * we are asked to display data */
2634 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
2636 /* if there is another column of data */
2637 if (cm_curr_RCol < cm_numCols) {
2639 dataIndex = cm_Display_map[cm_curr_RCol];
2642 display_Server_datum(cmDataP->data[dataIndex],
2645 cmDataP->probeOK, RIGHT_JUSTIFY,
2646 cmDataP->threshOvf[dataIndex]);
2649 } else { /* no more data, blank out columns */
2650 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
2651 RIGHT_JUSTIFY, 0); /* no overflow */
2655 firstSlot_o_Ptr++; /* onode of next column */
2656 secondSlot_o_Ptr++; /* onode of next column */
2658 } /* for each column */
2660 /* the loop could have taken the right-column-index one over,
2662 if (cm_curr_RCol == cm_numCols)
2670 /* if fdIdx < numCM */
2671 /* if cmIdx >= numCM , blank out all succeding rows */
2672 if (cmIdx >= numCM) {
2674 /* blank out host name object */
2676 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2678 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
2681 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2686 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2687 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2689 for (k = 0; k < cm_cols_perPage; k++) {
2690 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
2691 RIGHT_JUSTIFY, 0); /* dont highlight */
2699 /* cmIDx >= numCM */
2700 tmp_cm_lines_P++; /* pointer to next line in the frame */
2701 cmDataP++; /* next host's data */
2702 cmIdx++; /* host index */
2705 } /* for each row in the Cache Manager frame */
2707 /* redraw the display if the Cache Managers screen is currently displayed */
2708 if (afsmon_win->w_frame == cmFrame)
2709 WOP_DISPLAY(afsmon_win);
2711 /* update the global page & column numbers to reflect the changes */
2712 cm_currPage = a_pageNum;
2713 cm_curr_LCol = a_LcolNum;;
2721 /*-----------------------------------------------------------------------
2725 * Switch from the Cache Manager screen to the Overview Screen
2726 *----------------------------------------------------------------------*/
2730 /* bind the overview frame to the window */
2731 gtxframe_SetFrame(afsmon_win, ovwFrame);
2735 /*-----------------------------------------------------------------------
2739 * Switch from the Cache Manager screen to the File Servers screen
2740 *----------------------------------------------------------------------*/
2744 if (cm_pageType & CMD_FS) {
2745 /* bind the file servers frame to the window */
2746 gtxframe_SetFrame(afsmon_win, fsFrame);
2751 /*-----------------------------------------------------------------------
2755 * Switch to next page of cache managers screen
2756 *----------------------------------------------------------------------*/
2760 static char rn[] = "Switch_cm_next";
2762 if (cm_pageType & CMD_NEXT) {
2763 /* we have a next page, refresh with next page number */
2764 cm_refresh(cm_currPage + 1, cm_curr_LCol);
2770 /*-----------------------------------------------------------------------
2774 * Switch to last page of file server screen
2775 *----------------------------------------------------------------------*/
2779 static char rn[] = "Switch_cm_last";
2782 if (cm_pageType & CMD_NEXT) {
2783 /* we have a next page, refresh with last page number */
2784 cm_refresh(cm_numPages, cm_curr_LCol);
2790 /*-----------------------------------------------------------------------
2794 * Switch to previous page of cache managers screen
2795 *----------------------------------------------------------------------*/
2799 static char rn[] = "Switch_cm_prev";
2801 if (cm_pageType & CMD_PREV) {
2802 /* we have a previous page, refresh to previous page */
2803 cm_refresh(cm_currPage - 1, cm_curr_LCol);
2808 /*-----------------------------------------------------------------------
2812 * Switch to first page of cache managers screen
2813 *----------------------------------------------------------------------*/
2817 static char rn[] = "Switch_cm_first";
2819 if (cm_pageType & CMD_PREV) {
2820 /* we have a previous page, refresh to first page */
2821 cm_refresh(1, cm_curr_LCol);
2826 /*-----------------------------------------------------------------------
2830 * Scroll left on the cache managers screen
2831 *----------------------------------------------------------------------*/
2835 static char rn[] = "Switch_cm_left";
2837 if (cm_pageType & CMD_LEFT) {
2838 /* we have columns on left, refresh with new column number */
2839 cm_refresh(cm_currPage, cm_curr_LCol - cm_cols_perPage);
2845 /*-----------------------------------------------------------------------
2846 * Switch_cm_leftmost()
2849 * Scroll to first column on the cache managers screen
2850 *----------------------------------------------------------------------*/
2852 Switch_cm_leftmost()
2854 static char rn[] = "Switch_cm_leftmost";
2856 if (cm_pageType & CMD_LEFT) {
2857 /* we have columns on left, go to the first column */
2858 cm_refresh(cm_currPage, 0);
2863 /*-----------------------------------------------------------------------
2867 * Scroll right on the cache managers screen
2868 *----------------------------------------------------------------------*/
2872 static char rn[] = "Switch_cm_right";
2874 if (cm_pageType & CMD_RIGHT) {
2875 /* we have columns on right, refresh with new column number */
2876 cm_refresh(cm_currPage, cm_curr_LCol + cm_cols_perPage);
2881 /*-----------------------------------------------------------------------
2882 * Switch_cm_rightmost()
2885 * Scroll to last column on the cache managers screen
2886 *----------------------------------------------------------------------*/
2888 Switch_cm_rightmost()
2890 static char rn[] = "Switch_cm_rightmost";
2894 if (cm_pageType & CMD_RIGHT) {
2895 /* we have columns on right, go to the last column */
2896 if (cm_numCols % cm_cols_perPage)
2897 curr_LCol = (cm_numCols / cm_cols_perPage) * cm_cols_perPage;
2900 ((cm_numCols / cm_cols_perPage) - 1) * cm_cols_perPage;
2901 cm_refresh(cm_currPage, curr_LCol);
2907 /*-----------------------------------------------------------------------
2908 * create_CMframe_objects()
2911 * Create the gtx objects (onodes) for the Cache Managers frame and setup
2912 * the keyboard bindings.
2913 * Only as many objects as can fit on the display are created. The
2914 * positions and lengths of all these objects are fixed at creation.
2915 * These objects are updated with new data at the end of each probe
2920 * Failure: Exits afsmonitor.
2921 *----------------------------------------------------------------------*/
2924 create_CMframe_objects()
2925 { /* create_CMframe_objects */
2926 static char rn[] = "create_CMframe_objects";
2927 struct ServerInfo_line *cm_lines_Ptr;
2928 struct onode **cm_data_o_Ptr;
2929 struct onode **cmLabels_o_Ptr;
2939 fprintf(debugFD, "[ %s ] Called\n", rn);
2945 /* create the command line object */
2947 initLightObject("Command [oview, fs, prev, next, left, right] ? ", 0,
2948 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2949 if (cm_cmd_o == NULL) {
2950 sprintf(errMsg, "[ %s ] Failed to create cm command onode\n", rn);
2953 code = gtxframe_AddToList(cmFrame, cm_cmd_o);
2954 code = gator_light_set(cm_cmd_o, HIGHLIGHT);
2957 /* we already have the dimensions for the frame - same as the ovw frame */
2958 /* use the ovw program name object for the cm screen too */
2960 code = gtxframe_AddToList(cmFrame, ovw_progName_o);
2963 /* create the page number object */
2965 initLightObject("[Cache Managers, p. X of X, c. Y of Y]",
2966 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2968 if (cm_pageNum_o == NULL) {
2969 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2972 code = gtxframe_AddToList(cmFrame, cm_pageNum_o);
2973 code = gator_light_set(cm_pageNum_o, HIGHLIGHT);
2975 /* create the probe number object */
2977 initLightObject("[CM probes 1, freq=30 sec]",
2978 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2979 FC_PROBENUM_O_WIDTH, afsmon_win);
2980 if (cm_probeNum_o == NULL) {
2981 sprintf(errMsg, "[ %s ] Failed to create cm probeNum onode\n", rn);
2984 code = gtxframe_AddToList(cmFrame, cm_probeNum_o);
2985 code = gator_light_set(cm_probeNum_o, HIGHLIGHT);
2988 /* create the numCM monitored object */
2991 (" 0 Cache Mangers monitored, 0 alerts on 0 machines", 4, 2,
2992 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2993 if (cm_numCM_o == NULL) {
2995 "[ %s ] Failed to create numCM onode for the cm frame\n", rn);
2998 code = gtxframe_AddToList(cmFrame, cm_numCM_o);
3000 /* create the "more columns to left" indicator */
3002 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
3003 if (cm_leftArrows_o == NULL) {
3005 "[ %s ] Failed to create leftArrows onode for the cm frame\n",
3009 code = gtxframe_AddToList(cmFrame, cm_leftArrows_o);
3011 /* create the "more columns to right" indicator */
3013 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
3015 if (cm_rightArrows_o == NULL) {
3017 "[ %s ] Failed to create rightArrows onode for the cm frame\n",
3021 code = gtxframe_AddToList(cmFrame, cm_rightArrows_o);
3026 /* calculate the maximum number of hosts per page (2 rows per host) */
3027 cm_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
3029 /* determine the number of data columns that can fit in a page */
3030 cm_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
3033 fprintf(debugFD, "[ %s ] cm_numHosts_perPage=%d cm_cols_perPage=%d\n",
3034 rn, cm_numHosts_perPage, cm_cols_perPage);
3038 /* the above two variables give us the information needed to create
3039 * the objects for displaying the file server information */
3041 /* allocate memory for all the onode pointers required to display
3042 * the file server statistics */
3044 numBytes = cm_numHosts_perPage * sizeof(struct ServerInfo_line);
3045 cm_lines = (struct ServerInfo_line *)malloc(numBytes);
3046 if (cm_lines == (struct ServerInfo_line *)0) {
3048 "[ %s ] Failed to allocate %d bytes for CM data lines\n", rn,
3053 /* for each line of server statistics allocate memory to store two arrays
3056 cm_lines_Ptr = cm_lines;
3057 for (i = 0; i < cm_numHosts_perPage; i++) {
3058 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
3059 numBytes = cm_cols_perPage * sizeof(struct onode *);
3060 cm_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes);
3061 if (cm_lines_Ptr->data_o[arrIdx] == NULL) {
3063 "[ %s ] Failed to allocate %d bytes for CM data onodes\n",
3071 /* now allocate the onodes itself */
3073 cm_lines_Ptr = cm_lines;
3074 for (i = 0; i < cm_numHosts_perPage; i++) {
3076 /* initialize host name onode */
3077 cm_lines_Ptr->host_o =
3078 initLightObject("CMHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
3079 FC_HOSTNAME_O_WIDTH, afsmon_win);
3080 if (cm_lines_Ptr->host_o == NULL) {
3081 sprintf(errMsg, "[ %s ] Failed to create an CM name onode\n", rn);
3084 code = gtxframe_AddToList(cmFrame, cm_lines_Ptr->host_o);
3086 /* if (afsmon_debug) {
3087 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
3088 * rn,cm_lines_Ptr->host_o,i);
3092 /* initialize data onodes for this host */
3094 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
3096 cm_data_o_Ptr = cm_lines_Ptr->data_o[arrIdx];
3097 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
3101 /* determine x & y coordinate for this data object */
3102 /* the 1's are for leaving a blank after each column */
3103 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
3104 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
3106 sprintf(tmpBuf, "-CMData %d-", arrIdx);
3108 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
3110 if (*cm_data_o_Ptr == NULL) {
3112 "[ %s ] Failed to create an CM data onode\n", rn);
3115 code = gtxframe_AddToList(cmFrame, *cm_data_o_Ptr);
3118 } /* for each column */
3119 } /* for each onode array index */
3122 } /* for each host slot */
3125 /* INITIALIZE COLUMN LABELS */
3128 /* allocate memory for two arrays of onode pointers for file server column
3130 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
3132 cmLabels_o[arrIdx] =
3133 (struct onode **)malloc(sizeof(struct onode *) * cm_cols_perPage);
3134 if (cmLabels_o[arrIdx] == NULL) {
3136 "[ %s ] Failed to allocate memory for CM label onodes\n",
3141 /* create cache manager name objects */
3142 cmLabels_o_Ptr = cmLabels_o[arrIdx];
3143 for (i = 0; i < cm_cols_perPage; i++) {
3145 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
3146 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
3149 if (*cmLabels_o_Ptr == NULL) {
3150 sprintf(errMsg, "[ %s ] Failed to create a CM label onode\n",
3154 code = gtxframe_AddToList(cmFrame, *cmLabels_o_Ptr);
3165 /* initialize the column & page counters */
3168 cm_numCols = cm_DisplayItems_count;
3169 cm_numPages = numCM / cm_numHosts_perPage;
3170 if (numCM % cm_numHosts_perPage)
3172 cm_curr_LCol = 0; /* leftmost col */
3173 cm_curr_RCol = 0; /* rightmost col */
3175 /* create keyboard bindings */
3176 /* bind Q and
\ 3 to exit */
3177 keymap_BindToString(cmFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
3178 keymap_BindToString(cmFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
3180 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
3181 * N = last page, P = first page, L = leftmost col, R = rightmost col */
3183 keymap_BindToString(cmFrame->keymap, "o", Switch_cm_2_ovw, NULL, NULL);
3184 keymap_BindToString(cmFrame->keymap, "f", Switch_cm_2_fs, NULL, NULL);
3185 keymap_BindToString(cmFrame->keymap, "n", Switch_cm_next, NULL, NULL);
3186 keymap_BindToString(cmFrame->keymap, "N", Switch_cm_last, NULL, NULL);
3187 keymap_BindToString(cmFrame->keymap, "p", Switch_cm_prev, NULL, NULL);
3188 keymap_BindToString(cmFrame->keymap, "P", Switch_cm_first, NULL, NULL);
3189 keymap_BindToString(cmFrame->keymap, "l", Switch_cm_left, NULL, NULL);
3190 keymap_BindToString(cmFrame->keymap, "L", Switch_cm_leftmost, NULL, NULL);
3191 keymap_BindToString(cmFrame->keymap, "r", Switch_cm_right, NULL, NULL);
3192 keymap_BindToString(cmFrame->keymap, "R", Switch_cm_rightmost, NULL,
3196 } /* create_CMframe_objects */
3200 /*-----------------------------------------------------------------------
3204 * Initialize the gtx package and call routines to create the objects
3205 * for the overview, File Servers & Cache Managers screens.
3206 *----------------------------------------------------------------------*/
3209 { /* gtx_initialize */
3210 static char rn[] = "gtx_initialize"; /* routine name */
3214 fprintf(debugFD, "[ %s ] Called\n", rn);
3218 afsmon_win = gtx_Init(0, -1); /* 0 => dont start input server,
3219 * 1 => use curses */
3220 if (afsmon_win == NULL) {
3221 sprintf(errMsg, "[ %s ] gtx initialization failed\n", rn);
3224 gtx_initialized = 1;
3226 /* Create the Overview frame */
3228 ovwFrame = gtxframe_Create();
3229 if (ovwFrame == (struct gtx_frame *)0) {
3230 sprintf(errMsg, "[ %s ] Failed to create overview frame\n", rn);
3234 /* bind the overview frame to the window */
3235 gtxframe_SetFrame(afsmon_win, ovwFrame);
3237 /* create overview frame objects */
3238 code = create_ovwFrame_objects();
3240 sprintf(errMsg, "[ %s ] Error in creating ovw frame objects\n", rn);
3245 /* Create the File Server frame */
3246 fsFrame = gtxframe_Create();
3247 if (fsFrame == (struct gtx_frame *)0) {
3248 sprintf(errMsg, "[ %s ] Failed to create file server frame\n", rn);
3253 /* Create File Server frame objects */
3254 code = create_FSframe_objects();
3256 sprintf(errMsg, "[ %s ] Error in creating FS frame objects\n", rn);
3260 /* Create the Cache Managers frame */
3261 cmFrame = gtxframe_Create();
3262 if (cmFrame == (struct gtx_frame *)0) {
3263 sprintf(errMsg, "[ %s ] Failed to create Cache Managers frame\n", rn);
3267 /* Create Cache Managers frame objects */
3268 code = create_CMframe_objects();
3270 sprintf(errMsg, "[ %s ] Error in creating CM frame objects\n", rn);
3274 /* misc initializations */
3275 sprintf(blankline, "%255s", " ");
3278 } /* gtx_initialize */