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>
31 #include <gtxwindows.h> /*Generic window package */
32 #include <gtxobjects.h> /*Object definitions */
34 #include <gtxtextcb.h> /*Text object circular buffer interface */
35 #include <gtxtextobj.h> /*Text object interface */
37 #include <gtxlightobj.h> /*Light object interface */
38 #include <gtxcurseswin.h> /*Curses window package */
39 #include <gtxdumbwin.h> /*Dumb terminal window package */
40 #include <gtxX11win.h> /*X11 window package */
41 #include <gtxframe.h> /*Frame package */
43 #include <afs/xstat_fs.h>
44 #include <afs/xstat_cm.h>
47 #include "afsmonitor.h"
48 #include "afsmon-labels.h"
51 /* afsmonitor version number */
52 static char afsmon_version[] = "1.0";
54 /* EXTERNAL VARIABLES (from afsmonitor.c) */
56 extern int afsmon_debug; /* debug info to file ? */
57 extern FILE *debugFD; /* debugging file descriptor */
58 extern char errMsg[256]; /* buffers used to print error messages after */
59 extern char errMsg1[256]; /* gtx is initialized (stderr/stdout gone !) */
61 /* number of fileservers and cache managers to monitor */
65 /* number of FS alerts and number of hosts on FS alerts */
66 extern int num_fs_alerts;
67 extern int numHosts_onfs_alerts;
69 /* number of CM alerts and number of hosts on FS alerts */
70 extern int num_cm_alerts;
71 extern int numHosts_oncm_alerts;
73 /* ptr to array holding the results of FS probes in ascii format */
74 extern struct fs_Display_Data *prev_fsData;
76 /* ptr to array holding the results of CM probes in ascii format */
77 extern struct cm_Display_Data *prev_cmData;
79 extern int afsmon_fs_curr_probeNum; /* current fs probe number */
80 extern int afsmon_fs_prev_probeNum; /* previous fs probe number */
81 extern int afsmon_cm_curr_probeNum; /* current cm probe number */
82 extern int afsmon_cm_prev_probeNum; /* previous cm probe number */
84 extern int afsmon_probefreq; /* probe frequency */
86 /* map of fs results items we must display. This array contains indices to
87 the fs_varNames[] array corresponding to the stats we want to display. It is
88 initialized while processing the config file */
90 extern short fs_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN];
91 extern int fs_DisplayItems_count; /* number of items to display */
93 extern short cm_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN];
94 extern int cm_DisplayItems_count; /* number of items to display */
99 /* minimum window size */
104 #define RIGHT_JUSTIFY 0
105 #define LEFT_JUSTIFY 1
108 /* width of overview frame objects */
109 /* field widths include the terminating null character */
111 #define PROGNAME_O_WIDTH (maxX/2) /* program name object */
112 #define OVW_PAGENUM_O_WIDTH 29 /* page number object */
113 #define OVW_PROBENUM_O_WIDTH 39 /* probe number object */
114 #define OVW_CMD_O_WIDTH (maxX/2) /* cmd line object */
115 #define OVW_NUMFS_O_WIDTH 40 /* num FSs monitored */
116 #define OVW_NUMCM_O_WIDTH 40 /* num CMs monitored */
117 #define OVW_FSALERTS_O_WIDTH 40 /* num FS alerts */
118 #define OVW_CMALERTS_O_WIDTH 40 /* num CM alerts */
119 #define OVW_HOSTNAME_O_WIDTH (maxX / 2) /* FS & CM host names */
120 #define OVW_HOSTNAME_O_WIDTH_HGL 30 /* cosmetic, atleast this many chars
121 * will be highlightned */
123 /* widths of FS and CM frame objects */
124 #define FC_NUMHOSTS_O_WIDTH (maxX - 8) /* number of fs monitored. leave 4
125 * chars on either side for '<<','>>' */
126 #define FC_PAGENUM_O_WIDTH 43
127 #define FC_HOSTNAME_O_WIDTH 11 /* width of FS hostnames column */
128 #define FC_CMD_O_WIDTH 55 /* width of cmd line */
129 #define FC_PROBENUM_O_WIDTH 30 /* width of probe number object */
130 #define FC_ARROWS_O_WIDTH 4 /* width of arrow indicators */
131 #define FC_COLUMN_WIDTH 11 /* width of data columns */
133 /* bit definitions for use in resolving command line */
134 /* these bits are set in the xx_pageType variables to indicate what commands
137 #define CMD_NEXT 1 /* next page ? */
138 #define CMD_PREV 2 /* previous page ? */
139 #define CMD_LEFT 4 /* left scroll ? */
140 #define CMD_RIGHT 8 /* right scroll ? */
141 #define CMD_FS 16 /* file servers frame exists ? */
142 #define CMD_CM 32 /* cache managers frame exists ? */
145 #define FC_NUM_FIXED_LINES 10 /* number of fixed lines */
146 #define FC_FIRST_HOST_ROW 8 /* first host entry row number */
147 #define FC_FIRST_LABEL_ROW 4 /* first label row number */
149 /* number of fixed lines (that dont change) on the overview screen */
150 #define OVW_NUM_FIXED_LINES 7
151 #define OVW_FIRST_HOST_ROW 5 /* row index of first host entry in ovw frame */
153 #define HIGHLIGHT 1 /* highlight object? */
155 static char blankline[256]; /* blank line */
157 /* maximum X & Y coordinates of the frames */
161 struct gwin *afsmon_win; /* afsmonitor window */
162 int gtx_initialized = 0;
164 /* Overview screen related definitions */
166 struct gtx_frame *ovwFrame; /* overview screen frame */
167 struct gwin_sizeparams frameDims; /* frame dimensions. all frames have
170 /* overview frame object names */
171 struct onode *ovw_progName_o; /* program name object */
172 struct onode *ovw_pageNum_o; /* page number onject */
173 struct onode *ovw_cmd_o; /* command line object */
174 struct onode *ovw_probeNum_o; /* probe number object */
175 struct onode *ovw_numFS_o; /* num FS monitored */
176 struct onode *ovw_numCM_o; /* num CM monitored */
177 struct onode *ovw_FSalerts_o; /* nunber of FS alerts */
178 struct onode *ovw_CMalerts_o; /* nunber of CM alerts */
179 struct onode *initMsg_o; /* initialization message */
181 /* number of pages of data for the overview frame */
182 int ovw_numPages = 0;
183 int ovw_currPage = 1; /* current page number */
185 static int ovw_pageType = 0; /* one of the above types */
187 /* number of rows of server names that can be displayed on one overview page*/
188 int ovw_numHosts_perPage;
190 /* ptr to a block of ovw_numHosts_perPage number of objects for file servers */
191 struct onode **ovw_fsNames_o;
192 /*ptr to a block of ovw_numHosts_perPage number of objects for cache managers */
193 struct onode **ovw_cmNames_o;
195 /* When the ovw_refresh routine is called by the keyboard handlers the
196 following variable is used to determine if fs/cm/fs&cm info must be updated */
197 int ovw_update_info = 0;
199 /* Variables needed to display an intialization message on startup */
200 static char *initMsg = "AFSMonitor Collecting Statistics ...";
201 static int initMsg_on = 0; /* message on ? */
203 /* FILE SERVER Screen related definitions */
205 struct gtx_frame *fsFrame; /* File Server screen frame */
207 struct onode *fs_pageNum_o; /* fs page number object */
208 struct onode *fs_cmd_o; /* fs command line object */
209 struct onode *fs_probeNum_o; /* fs probe number object */
210 struct onode *fs_numFS_o; /* fs number of FSs object */
211 struct onode *fs_leftArrows_o; /* fs cols on left signal object */
212 struct onode *fs_rightArrows_o; /* fs cols on right signal object */
213 struct onode **fs_hostNames_o; /* ptr to host names objects */
215 /* bit-map to characterize page type and contents of command prompt */
216 static int fs_pageType = 0;
218 /* coordinates for the File Servers screen */
220 /* we use page numbers to navigate vertically (ie, across hosts) and column
221 numbers to navigate horizontally */
223 int fs_numHosts_perPage; /* number of file servers per page */
224 int fs_cols_perPage; /* number of data columns per file server page */
225 int fs_currPage; /* current FS page number */
226 int fs_numPages; /* number of FS pages */
228 /* column numbers are index to the mapping structure fs_Display_map. this
229 map contains the indices of datums that should be displayed */
231 int fs_numCols; /* number of columns of FS data (excluding hostname) */
232 /* this is the same as fs_DisplayItems_count */
233 /* following column indices run from 1 to (fs_numCols -1) */
234 int fs_curr_LCol = 0; /* column number of leftmost column on display */
235 int fs_curr_RCol = 0; /* column number of rightmost column on display */
236 int fs_Data_Available = 0; /* atleast one fs probe cycle completed ? */
239 /* structure that defines a line of data in the fs/cm frames */
241 /* we store each datum value in two objects, one below the other. The reason
242 for doing this is to conserve screen area. most of the datums are just longs
243 and will fit into one object. some of them are timing values and require 13
244 characters to be displayed - such fields may overflow to the second object
245 placed below the first one. */
247 struct ServerInfo_line {
248 struct onode *host_o; /* hostname object */
249 struct onode **data_o[2]; /* ptrs to two arrays of data objects. */
253 struct ServerInfo_line *fs_lines; /* ptr to the file server data objects */
255 /* file server label onodes - three rows of them */
256 struct onode **fsLabels_o[3];
258 /* CACHE MANAGER Screen related definitions */
260 struct gtx_frame *cmFrame; /* Cache Manager screen frame */
262 struct onode *cm_pageNum_o; /* cm page number object */
263 struct onode *cm_cmd_o; /* cm command line object */
264 struct onode *cm_probeNum_o; /* cm probe number object */
265 struct onode *cm_numCM_o; /* cm number of FSs object */
266 struct onode *cm_leftArrows_o; /* fs cols on left signal object */
267 struct onode *cm_rightArrows_o; /* fs cols on right signal object */
269 struct onode **cm_hostNames_o; /* ptr to host names objects */
271 /* bit-map to characterize page type and contents of command prompt */
272 static int cm_pageType = 0;
274 /* coordinates for the Cache Managers screen */
276 /* we use page numbers to navigate vertically (ie, across hosts) and column
277 numbers to navigate horizontally */
279 int cm_numHosts_perPage; /* number of cache managers per page */
280 int cm_cols_perPage; /* number of data columns per file server page */
281 int cm_currPage; /* current CM page number */
282 int cm_numPages; /* number of CM pages */
284 /* column numbers are index to the mapping structure cm_Display_map. this
285 map contains the indices of datums that should be displayed */
287 int cm_numCols; /* number of columns of FS data (excluding hostname) */
288 /* this is the same as cm_DisplayItems_count */
289 /* following column indices run from 1 to (cm_numCols -1) */
290 int cm_curr_LCol = 0; /* column number of leftmost column on display */
291 int cm_curr_RCol = 0; /* column number of rightmost column on display */
292 int cm_Data_Available = 0; /* atleast one cm probe cycle completed ? */
295 /* structure that defines a line of data in the fs/cm frames */
296 struct ServerInfo_line *cm_lines; /* ptr to the file server data objects */
298 /* file server label onodes - three rows of them */
299 struct onode **cmLabels_o[3];
303 /*------------------------------------------------------------------------
307 * Create and initialize a light onode according to the given
309 * ( Borrowed from scout.c )
312 * char *a_name : Ptr to the light's string name.
313 * int a_x : X offset.
314 * int a_y : Y offset.
315 * int a_width : Width in chars.
316 * struct gwin *a_win : Ptr to window structure.
319 * Ptr to new light onode on success,
320 * A null pointer otherwise.
327 *------------------------------------------------------------------------*/
329 static struct onode *
330 initLightObject(a_name, a_x, a_y, a_width, a_win)
337 { /*initLightObject */
339 static char rn[] = "initLightObject"; /*Routine name */
340 struct onode *newlightp; /*Ptr to new light onode */
341 struct gator_light_crparams light_crparams; /*Light creation params */
342 char *truncname; /*Truncated name, if needed */
343 int name_len; /*True length of name */
345 /* the following debug statement floods the debug file */
346 #ifdef DEBUG_DETAILED
349 "[ %s ] Called, a_name= %s, a_x= %d, a_y= %d, a_width= %d, a_win= %d\n",
350 rn, a_name, a_x, a_y, a_width, a_win);
358 * Set up the creation parameters according to the information we've
361 light_crparams.onode_params.cr_type = GATOR_OBJ_LIGHT;
362 name_len = strlen(a_name);
364 if (name_len <= a_width)
365 sprintf(light_crparams.onode_params.cr_name, "%s", a_name);
368 * We need to truncate the given name, leaving a `*' at the end to
369 * show us it's been truncated.
371 truncname = light_crparams.onode_params.cr_name;
372 strncpy(truncname, a_name, a_width - 1);
373 truncname[a_width - 1] = '*';
374 truncname[a_width] = 0;
376 light_crparams.onode_params.cr_x = a_x;
377 light_crparams.onode_params.cr_y = a_y;
378 light_crparams.onode_params.cr_width = a_width;
379 light_crparams.onode_params.cr_height = 1;
380 light_crparams.onode_params.cr_window = a_win;
381 light_crparams.onode_params.cr_home_obj = NULL;
382 light_crparams.onode_params.cr_prev_obj = NULL;
383 light_crparams.onode_params.cr_parent_obj = NULL;
384 light_crparams.onode_params.cr_helpstring = NULL;
386 light_crparams.appearance = 0;
387 light_crparams.flashfreq = 0;
388 sprintf(light_crparams.label, "%s", a_name);
389 light_crparams.label_x = 0;
390 light_crparams.label_y = 0;
393 gator_objects_create((struct onode_createparams *)(&light_crparams));
396 * Return the news, happy or not.
400 } /*initLightObject */
404 /*------------------------------------------------------------------------
408 * Place the chars in the source buffer into the target buffer
409 * with the desired justification, either centered, left-justified
410 * or right-justified. Also, support inidication of truncation
411 * with a star (*), either on the left or right of the string,
412 * and whether we're justifying a labeled disk quantity.
414 * (derived from mini_justify() in scout.c)
417 * char *a_srcbuff : Ptr to source char buffer.
418 * char *a_dstbuff : Ptr to dest char buffer.
419 * int a_dstwidth : Width of dest buffer in chars.
420 * int a_justification : Kind of justification.
421 * int a_rightTrunc : If non-zero, place the truncation char
422 * on the right of the string. Otherwise,
423 * place it on the left.
429 *------------------------------------------------------------------------*/
432 justify_light(a_srcbuff, a_dstbuff, a_dstwidth, a_justification, a_rightTrunc)
441 static char rn[] = "justify_light"; /*Routine name */
442 int leftpad_chars; /*# of chars for left-padding */
443 int num_src_chars; /*# of chars in source */
444 int true_num_src_chars; /*# src chars before truncation */
445 int trunc_needed; /*Is truncation needed? */
448 /* the following debug statement floods the debug file */
449 #ifdef DEBUG_DETAILED
452 "[ %s ] Called, a_srcbuff= %s, a_dstbuff= %d, a_dstwidth= %d, a_justification= %d, a_rightTrunc= %d\n",
453 rn, a_srcbuff, a_dstbuff, a_dstwidth, a_justification,
461 * If the destination width will overrun the gtx string storage,
462 * we automatically shorten up.
464 if (a_dstwidth > GATOR_LABEL_CHARS) {
466 * if (afsmon_debug) {
468 * "[%s] Dest width (%d) > gtx buflen (%d), shrinking dest width\n",
469 * rn, a_dstwidth, GATOR_LABEL_CHARS);
473 a_dstwidth = GATOR_LABEL_CHARS;
477 * If our source string is too long, prepare for truncation.
479 true_num_src_chars = strlen(a_srcbuff);
480 if (true_num_src_chars >= a_dstwidth) {
482 num_src_chars = a_dstwidth - 1;
485 a_srcbuff += (true_num_src_chars - num_src_chars);
488 num_src_chars = true_num_src_chars;
491 * Compute the necessary left-padding.
493 switch (a_justification) {
496 leftpad_chars = (a_dstwidth - 1) - num_src_chars;
501 * This is the really easy one.
507 leftpad_chars = ((a_dstwidth - 1) - num_src_chars) / 2;
512 fprintf(debugFD, "[%s] Illegal justification command: %d", rn,
514 fprintf(debugFD, "[%s] Called with '%s', dest width=%d\n", rn,
515 a_srcbuff, a_dstwidth);
519 } /*Switch on justification type */
523 * Clear out the dest buffer, then place the source string at the
524 * appropriate padding location. Remember to place a string
525 * terminator at the end of the dest buffer, plus whatever truncation
526 * may be needed. If we're left-truncating, we've already shifted
527 * the src buffer appropriately.
529 strncpy(a_dstbuff, blankline, a_dstwidth);
530 strncpy(a_dstbuff + leftpad_chars, a_srcbuff, num_src_chars);
531 *(a_dstbuff + a_dstwidth - 1) = '\0';
534 *(a_dstbuff + a_dstwidth - 2) = '*'; /*Truncate on the right */
536 *a_dstbuff = '*'; /*Truncate on the left, non-disk */
540 /*Handle truncations */
542 * Return the good news.
550 /*-----------------------------------------------------------------------
554 * Call the exit routine. This function is mapped
555 * to the keys Q and
\ 3 in all the frames and is called by the
557 *----------------------------------------------------------------------*/
562 static char rn[] = "afsmonExit_gtx";
565 fprintf(debugFD, "[ %s ] Called\n", rn);
573 /*-----------------------------------------------------------------------
577 * Refresh the overview screen with the contents of the specified page.
578 * There are two parts to the overview screen - the file server column
579 * and the cache manager column and each of them is independent of the
580 * other. Hence it takes as an argumnet the "type" of update to be
585 * Failure: Exits afsmonitor.
586 *----------------------------------------------------------------------*/
589 ovw_refresh(a_pageNum, a_updateType)
590 int a_pageNum; /* page to refresh overview display */
591 int a_updateType; /* OVW_UPDATE_FS = update fs column only,
592 * OVW_UPDATE_CM = update cm column only,
593 * OVW_UPDATE_BOTH = update fs & cm columns. Note that
594 * we do not want to update a column until the
595 * corresponding probe cycle has completed */
598 static char rn[] = "ovw_refresh"; /* routine name */
599 struct onode **tmp_fsNames_o; /* ptr to fsNames onodes */
600 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
601 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
602 struct onode **tmp_cmNames_o; /* ptr to fsNames onodes */
603 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
604 int fsIdx; /* for counting # of CM hosts */
605 int cmIdx; /* for counting # of CM hosts */
606 int next_page = 0; /* is there a next ovw page ? */
607 int prev_page = 0; /* is there a previous ovw page */
608 char cmdLine[80]; /* buffer for command line */
609 char printBuf[256]; /* buffer to print to screen */
615 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_updateType= %d\n",
616 rn, a_pageNum, a_updateType);
620 /* if the data is not yet available ie., not one probe cycle has
621 * completed, do nothing */
623 if ((a_updateType & OVW_UPDATE_FS) && !fs_Data_Available)
625 if ((a_updateType & OVW_UPDATE_CM) && !cm_Data_Available)
629 /* validate page number */
630 if (a_pageNum < 1 || a_pageNum > ovw_numPages) {
631 sprintf(errMsg, "[ %s ] called with incorrect page number %d\n", rn,
636 /* set the current page number */
637 ovw_currPage = a_pageNum;
639 /* turn off init message */
642 gtxframe_RemoveFromList(ovwFrame, initMsg_o);
645 /* update the labels */
648 tmp_lightobj = (struct gator_lightobj *)ovw_progName_o->o_data;
649 sprintf(printBuf, "AFSMonitor [Version %s]", afsmon_version);
650 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
652 gator_light_set(ovw_progName_o, 1);
654 /* page number label */
655 tmp_lightobj = (struct gator_lightobj *)ovw_pageNum_o->o_data;
656 sprintf(printBuf, "[System Overview, p. %d of %d]", ovw_currPage,
658 justify_light(printBuf, tmp_lightobj->label, OVW_PAGENUM_O_WIDTH,
660 gator_light_set(ovw_pageNum_o, 1);
662 /* file servers monitored label */
663 tmp_lightobj = (struct gator_lightobj *)ovw_numFS_o->o_data;
664 sprintf(printBuf, " %d File Servers monitored", numFS);
665 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
668 /* cache managers monitored label */
669 tmp_lightobj = (struct gator_lightobj *)ovw_numCM_o->o_data;
670 sprintf(printBuf, " %d Cache Managers monitored", numCM);
671 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
675 /* no. of fs alerts label */
676 tmp_lightobj = (struct gator_lightobj *)ovw_FSalerts_o->o_data;
677 sprintf(printBuf, " %d alerts on %d machines", num_fs_alerts,
678 numHosts_onfs_alerts);
679 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
682 /* no. of cm alerts label */
683 tmp_lightobj = (struct gator_lightobj *)ovw_CMalerts_o->o_data;
684 sprintf(printBuf, " %d alerts on %d machines", num_cm_alerts,
685 numHosts_oncm_alerts);
686 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
690 /* determine if we have fs/cm, more/previous pages of data to display */
693 if (numFS && fs_Data_Available)
694 ovw_pageType |= CMD_FS; /* we have an fs frame & data avail. */
695 if (numCM && cm_Data_Available)
696 ovw_pageType |= CMD_CM; /* we have a cm frame & data avail. */
697 if (ovw_currPage > 1)
698 ovw_pageType |= CMD_PREV; /* got a previous page */
699 if (ovw_currPage < ovw_numPages)
700 ovw_pageType |= CMD_NEXT; /* got a next page */
702 strcpy(cmdLine, "Command [");
703 if ((ovw_pageType & CMD_FS) && (ovw_pageType & CMD_CM))
704 strcat(cmdLine, "fs, cm");
705 else if (ovw_pageType & CMD_FS)
706 strcat(cmdLine, "fs");
707 else if (ovw_pageType & CMD_CM)
708 strcat(cmdLine, "cm");
710 if (ovw_pageType & CMD_PREV)
711 strcat(cmdLine, ", prev");
712 if (ovw_pageType & CMD_NEXT)
713 strcat(cmdLine, ", next");
715 strcat(cmdLine, "]? ");
720 /* display the command line */
721 tmp_lightobj = (struct gator_lightobj *)ovw_cmd_o->o_data;
722 sprintf(printBuf, "%s", cmdLine);
723 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
725 gator_light_set(ovw_cmd_o, 1);
727 /* display probe numbers line */
728 tmp_lightobj = (struct gator_lightobj *)ovw_probeNum_o->o_data;
729 sprintf(printBuf, "[probes %d(fs) %d(cm), freq=%d sec]",
730 afsmon_fs_prev_probeNum, afsmon_cm_prev_probeNum,
732 justify_light(printBuf, tmp_lightobj->label, OVW_PROBENUM_O_WIDTH,
734 gator_light_set(ovw_probeNum_o, 1);
738 /* update the file server names column if we are asked to */
740 if (numFS && (a_updateType & OVW_UPDATE_FS)) {
742 /* move to the right spot in the FS display data array */
743 fsDataP = prev_fsData;
745 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
750 /* get the address to the first FS name */
751 tmp_fsNames_o = ovw_fsNames_o;
753 for (i = 0; i < ovw_numHosts_perPage; i++) {
754 if (fsIdx < numFS) { /* this could be the last & partial page */
756 if (fsDataP->hostName[0] == '\0') {
757 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
761 /* check if the probe succeeded. if it did check for thresholds
762 * overflow. A failed probe is indicated by "PF" */
764 if (!fsDataP->probeOK) {
765 sprintf(printBuf, "[ PF] %s", fsDataP->hostName);
766 } else if (fsDataP->ovfCount) /* thresholds overflow */
767 sprintf(printBuf, "[%3d] %s", fsDataP->ovfCount,
770 sprintf(printBuf, " %s", fsDataP->hostName);
774 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
777 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
779 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
780 len = OVW_HOSTNAME_O_WIDTH_HGL;
782 len = strlen(printBuf) + 1;
785 justify_light(printBuf, tmp_lightobj->label, len,
789 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
794 /* highlighten if overflowed or probe failed */
796 if (fsDataP->ovfCount || !fsDataP->probeOK)
797 code = gator_light_set(*tmp_fsNames_o, 1);
799 code = gator_light_set(*tmp_fsNames_o, 0);
802 } else { /* no more hosts, blank the rest of the entries */
804 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
805 sprintf(tmp_lightobj->label, "%s", "");
808 tmp_fsNames_o++; /* next onode */
809 fsDataP++; /* next host's data */
810 fsIdx++; /* host index */
815 /* if we have any cache managers, update them if we are asked to */
816 if (numCM && (a_updateType & OVW_UPDATE_CM)) {
818 /* move to the right spot in the CM display data array */
819 cmDataP = prev_cmData;
821 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
826 /* get the address to the first CM name */
827 tmp_cmNames_o = ovw_cmNames_o;
829 for (i = 0; i < ovw_numHosts_perPage; i++) {
830 if (cmIdx < numCM) { /* this could be the last & partial page */
832 if (cmDataP->hostName[0] == '\0') {
833 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
837 /* check if the probe succeeded. if it did check for thresholds
838 * overflow. A failed probe is indicated by "PF" */
840 if (!cmDataP->probeOK) {
841 sprintf(printBuf, "[ PF] %s", cmDataP->hostName);
842 } else if (cmDataP->ovfCount) { /* thresholds overflow */
843 sprintf(printBuf, "[%3d] %s", cmDataP->ovfCount,
846 sprintf(printBuf, " %s", cmDataP->hostName);
849 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
852 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
854 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
855 len = OVW_HOSTNAME_O_WIDTH_HGL;
857 len = strlen(printBuf) + 1;
860 justify_light(printBuf, tmp_lightobj->label, len,
864 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
869 /* highlighten if overflow or if probe failed */
870 if (cmDataP->ovfCount || !cmDataP->probeOK)
871 code = gator_light_set(*tmp_cmNames_o, 1);
873 code = gator_light_set(*tmp_cmNames_o, 0);
876 } else { /* no more hosts, blank the rest of the entries */
878 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
879 sprintf(tmp_lightobj->label, "%s", "");
882 tmp_cmNames_o++; /* next onode */
883 cmDataP++; /* next host's data */
884 cmIdx++; /* host index */
889 /* redraw the display if the overview screen is currently displayed */
890 if (afsmon_win->w_frame == ovwFrame)
891 WOP_DISPLAY(afsmon_win);
899 /*-----------------------------------------------------------------------
903 * Switch from the overview screen to the FS screen
904 *----------------------------------------------------------------------*/
908 static char rn[] = "Switch_ovw_2_fs";
911 fprintf(debugFD, "[ %s ] Called\n", rn);
915 /* bind the File Server frame to the window */
916 if (ovw_pageType & CMD_FS)
917 gtxframe_SetFrame(afsmon_win, fsFrame);
921 /*-----------------------------------------------------------------------
925 * Switch from the overview screen to the CM screen
926 *----------------------------------------------------------------------*/
930 static char rn[] = "Switch_ovw_2_cm";
933 fprintf(debugFD, "[ %s ] Called\n", rn);
937 /* bind the Cache Managers frame to the window */
938 if (ovw_pageType & CMD_CM)
939 gtxframe_SetFrame(afsmon_win, cmFrame);
943 /*-----------------------------------------------------------------------
947 * Switch to the next page in overview screen
948 *----------------------------------------------------------------------*/
952 static char rn[] = "Switch_ovw_next";
955 fprintf(debugFD, "[ %s ] Called\n", rn);
959 if (ovw_pageType & CMD_NEXT) {
960 /* call refresh with the next page number */
961 ovw_refresh(ovw_currPage + 1, ovw_update_info);
967 /*-----------------------------------------------------------------------
971 * Switch to the last page in the overview screen
972 *----------------------------------------------------------------------*/
976 static char rn[] = "Switch_ovw_last";
979 fprintf(debugFD, "[ %s ] Called\n", rn);
983 if (ovw_pageType & CMD_NEXT) {
984 /* call refresh with the last page number */
985 ovw_refresh(ovw_numPages, ovw_update_info);
991 /*-----------------------------------------------------------------------
995 * Switch to the previous page in the overview screen
996 *----------------------------------------------------------------------*/
1000 static char rn[] = "Switch_ovw_prev";
1003 fprintf(debugFD, "[ %s ] Called\n", rn);
1007 if (ovw_pageType & CMD_PREV) {
1008 /* call refresh with the previous page number */
1009 ovw_refresh(ovw_currPage - 1, ovw_update_info);
1014 /*-----------------------------------------------------------------------
1015 * Switch_ovw_first()
1018 * Switch to the first page in the overview screen
1019 *----------------------------------------------------------------------*/
1023 static char rn[] = "Switch_ovw_first";
1026 fprintf(debugFD, "[ %s ] Called\n", rn);
1030 if (ovw_pageType & CMD_PREV) {
1031 /* refresh with the first page number */
1032 ovw_refresh(1, ovw_update_info);
1037 /*-----------------------------------------------------------------------
1038 * create_ovwFrame_objects()
1041 * Create the gtx objects (onodes) for the overview frame and setup
1042 * the keyboard bindings.
1043 * Only as many objects as can fit on the display are created. The
1044 * positions and lengths of all these objects are fixed at creation.
1045 * These objects are updated with new data at the end of each probe
1050 * Failure: Exits afsmonitor.
1051 *----------------------------------------------------------------------*/
1054 create_ovwFrame_objects()
1055 { /* create_ovwFrame_objects */
1057 static char rn[] = "create_ovwFrame_objects";
1058 int hostLines; /* number of lines of host names to display */
1059 struct onode **ovw_fsNames_o_Ptr; /* index to list of fs names onodes */
1060 struct onode **ovw_cmNames_o_Ptr; /* index to list of cm names onodes */
1065 fprintf(debugFD, "[ %s ] Called\n", rn);
1069 /* get frame dimensions, it must be atleast MINXxMINY for any sensible output */
1070 WOP_GETDIMENSIONS(ovwFrame->window, &frameDims);
1071 maxX = frameDims.maxx;
1072 maxY = frameDims.maxy;
1073 if (maxX + 1 < MINX || maxY + 1 < MINY) {
1074 sprintf(errMsg1, "[ %s ] Window size %dx%d; must be at least %dx%d\n",
1075 rn, maxX + 1, maxY + 1, MINX, MINY);
1079 fprintf(debugFD, "maxX = %d maxY = %d\n", maxX, maxY);
1082 /* Print an Intial message to the screen. The init message is 36 chars
1085 initLightObject(initMsg, maxX / 2 - 18, maxY / 3, sizeof(initMsg),
1087 if (initMsg_o == NULL) {
1088 sprintf(errMsg, "[ %s ] Failed to create initMsg_o onode\n", rn);
1091 code = gtxframe_AddToList(ovwFrame, initMsg_o);
1092 code = gator_light_set(initMsg_o, HIGHLIGHT);
1097 /* create the command line object */
1099 ovw_cmd_o = initLightObject("", 0, maxY - 1, OVW_CMD_O_WIDTH, afsmon_win);
1100 if (ovw_cmd_o == NULL) {
1101 sprintf(errMsg, "[ %s ] Failed to create command onode\n", rn);
1104 code = gtxframe_AddToList(ovwFrame, ovw_cmd_o);
1105 code = gator_light_set(ovw_cmd_o, HIGHLIGHT);
1107 /* create the program name object */
1109 ovw_progName_o = initLightObject("", 0, 0, PROGNAME_O_WIDTH, afsmon_win);
1110 if (ovw_progName_o == NULL) {
1111 sprintf(errMsg, "[ %s ] Failed to create programName onode\n", rn);
1114 code = gtxframe_AddToList(ovwFrame, ovw_progName_o);
1115 code = gator_light_set(ovw_progName_o, HIGHLIGHT);
1117 /* create the page number object */
1120 initLightObject("", maxX - OVW_PAGENUM_O_WIDTH, 0,
1121 OVW_PAGENUM_O_WIDTH, afsmon_win);
1122 if (ovw_pageNum_o == NULL) {
1123 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
1126 code = gtxframe_AddToList(ovwFrame, ovw_pageNum_o);
1127 code = gator_light_set(ovw_pageNum_o, HIGHLIGHT);
1129 /* create the probe number object */
1131 initLightObject("", maxX - OVW_PROBENUM_O_WIDTH, maxY - 1,
1132 OVW_PROBENUM_O_WIDTH, afsmon_win);
1133 if (ovw_probeNum_o == NULL) {
1134 sprintf(errMsg, "[ %s ] Failed to create probe number onode\n", rn);
1137 code = gtxframe_AddToList(ovwFrame, ovw_probeNum_o);
1138 code = gator_light_set(ovw_probeNum_o, HIGHLIGHT);
1140 /* create the numFS monitored object */
1141 ovw_numFS_o = initLightObject("", 0, 2, FC_NUMHOSTS_O_WIDTH, afsmon_win);
1142 if (ovw_numFS_o == NULL) {
1143 sprintf(errMsg, "[ %s ] Failed to create numFS onode\n", rn);
1146 code = gtxframe_AddToList(ovwFrame, ovw_numFS_o);
1148 /* create the numCM monitored object */
1150 initLightObject("", maxX / 2, 2, OVW_NUMCM_O_WIDTH, afsmon_win);
1151 if (ovw_numCM_o == NULL) {
1152 sprintf(errMsg, "[ %s ] Failed to create numCM_o onode\n", rn);
1155 code = gtxframe_AddToList(ovwFrame, ovw_numCM_o);
1157 /* create the number-of-FS-alerts object */
1159 initLightObject("", 0, 3, OVW_FSALERTS_O_WIDTH, afsmon_win);
1160 if (ovw_FSalerts_o == NULL) {
1161 sprintf(errMsg, "[ %s ] Failed to create FSalerts_o onode\n", rn);
1164 code = gtxframe_AddToList(ovwFrame, ovw_FSalerts_o);
1166 /* create the number-of-CM-alerts object */
1168 initLightObject("", maxX / 2, 3, OVW_CMALERTS_O_WIDTH, afsmon_win);
1169 if (ovw_CMalerts_o == NULL) {
1170 sprintf(errMsg, "[ %s ] Failed to create CMalerts_o onode\n", rn);
1173 code = gtxframe_AddToList(ovwFrame, ovw_CMalerts_o);
1175 /* create file-server-name and cache-manager-names objects */
1176 ovw_numHosts_perPage = maxY - OVW_NUM_FIXED_LINES;
1178 /* allocate memory for a list of onode pointers for file server names */
1180 (struct onode **)malloc(sizeof(struct onode *) *
1181 ovw_numHosts_perPage);
1182 if (ovw_fsNames_o == NULL) {
1183 sprintf(errMsg, "[ %s ] Failed to allocate memory for FS onodes\n",
1188 /* create file server name objects */
1189 ovw_fsNames_o_Ptr = ovw_fsNames_o;
1190 for (i = 0; i < ovw_numHosts_perPage; i++) {
1191 *ovw_fsNames_o_Ptr =
1192 initLightObject("", 0, OVW_FIRST_HOST_ROW + i,
1193 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1194 if (*ovw_fsNames_o_Ptr == NULL) {
1195 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
1199 * if (afsmon_debug) {
1200 * fprintf(debugFD,"[ %s ] fsName_o %d: %d\n",
1201 * rn,i,*ovw_fsNames_o_Ptr);
1205 code = gtxframe_AddToList(ovwFrame, *ovw_fsNames_o_Ptr);
1206 ovw_fsNames_o_Ptr++;
1211 /* allocate memory for a list of onode pointers for cache manager names */
1213 (struct onode **)malloc(sizeof(struct onode *) *
1214 ovw_numHosts_perPage);
1215 if (ovw_cmNames_o == NULL) {
1216 sprintf(errMsg, "[ %s ] Failed to allocate memory for CM onodes\n",
1221 /* create cache manager name objects */
1222 ovw_cmNames_o_Ptr = ovw_cmNames_o;
1223 for (i = 0; i < ovw_numHosts_perPage; i++) {
1224 *ovw_cmNames_o_Ptr =
1225 initLightObject("", maxX / 2, OVW_FIRST_HOST_ROW + i,
1226 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1227 if (*ovw_cmNames_o_Ptr == NULL) {
1228 sprintf(errMsg, "[ %s ] Failed to create a CM name onode\n", rn);
1231 code = gtxframe_AddToList(ovwFrame, *ovw_cmNames_o_Ptr);
1232 ovw_cmNames_o_Ptr++;
1236 /* Calculate the number of pages of overview data to display */
1237 /* host information starts at the 6th line from top and stops at 3rd
1238 * line from bottom of screen */
1245 ovw_numPages = hostLines / (maxY - OVW_NUM_FIXED_LINES);
1246 if (hostLines % (maxY - OVW_NUM_FIXED_LINES))
1250 fprintf(debugFD, "[ %s ] number of ovw pages = %d\n", rn,
1253 /* When the ovw_refresh() routine is called by the keyboard handlers the
1254 * following variable is used to determine if fs/cm/fs&cm info must be
1256 ovw_update_info = 0;
1258 ovw_update_info |= OVW_UPDATE_FS;
1260 ovw_update_info |= OVW_UPDATE_CM;
1262 /* bind the overview frame to a keyboard input handler */
1264 /* bind Q and
\ 3 to exit */
1265 keymap_BindToString(ovwFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
1266 keymap_BindToString(ovwFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
1268 /* f -> switch of fs frame */
1269 keymap_BindToString(ovwFrame->keymap, "f", Switch_ovw_2_fs, NULL, NULL);
1270 /* c -> switch of cm frame */
1271 keymap_BindToString(ovwFrame->keymap, "c", Switch_ovw_2_cm, NULL, NULL);
1272 /* n -> switch to next overview page */
1273 keymap_BindToString(ovwFrame->keymap, "n", Switch_ovw_next, NULL, NULL);
1274 /* N -> switch to last overview page */
1275 keymap_BindToString(ovwFrame->keymap, "N", Switch_ovw_last, NULL, NULL);
1276 /* p -> switch to previous overview page */
1277 keymap_BindToString(ovwFrame->keymap, "p", Switch_ovw_prev, NULL, NULL);
1278 /* P -> switch to first overview page */
1279 keymap_BindToString(ovwFrame->keymap, "P", Switch_ovw_first, NULL, NULL);
1283 } /* create_ovwFrame_objects */
1286 /*-----------------------------------------------------------------------
1290 * This function is called to determine the permissible keyboard
1291 * operations on the FS and CM frames. This information is used
1292 * to create an appropriate command line prompt. It also generates
1293 * a bit map of the permissible operations on this page which is
1294 * used by the keyboard-input handler routines.
1297 * Success: page-type (bit map of permissible operations)
1299 *----------------------------------------------------------------------*/
1302 resolve_CmdLine(a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols,
1303 a_curr_LCol, a_cols_perPage, a_Data_Available)
1304 char *a_buffer; /* buffer to copy command line */
1305 int a_currFrame; /* current frame ovw, fs or cm? */
1306 int a_currPage; /* current page number */
1307 int a_numPages; /* number of pages of data */
1308 int a_numCols; /* number of columns of data to display */
1309 int a_curr_LCol; /* current number of leftmost column */
1310 int a_cols_perPage; /* number of columns per page */
1312 { /* resolve_CmdLine */
1313 static char rn[] = "resolve_CmdLine";
1318 "[ %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",
1319 rn, a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols,
1320 a_curr_LCol, a_cols_perPage);
1326 /* determine if we have fs/cm frames. If we do, note that we should not
1327 * let the user seen the initial junk we have there until the probe
1328 * results are available */
1329 if (a_currFrame == 1) { /* in the fs frame */
1330 if (numCM && cm_Data_Available)
1332 } else if (a_currFrame == 2) { /* in the cm frame */
1333 if (numFS && fs_Data_Available)
1337 fprintf(debugFD, "[ %s ] Wrong frame type %d\n", rn, a_currFrame);
1343 /* do we have next/previous pages */
1344 if (a_currPage < a_numPages)
1345 pageType |= CMD_NEXT; /* have a next page */
1347 pageType |= CMD_PREV; /* have a previous page */
1349 if (a_numCols > a_cols_perPage) {
1350 if (a_curr_LCol > 0)
1351 pageType |= CMD_LEFT; /* have columns on left */
1352 if ((a_curr_LCol + a_cols_perPage) < a_numCols)
1353 pageType |= CMD_RIGHT; /* have columns on right */
1356 /* now build the command line */
1358 strcpy(a_buffer, "Command [oview");
1359 if (pageType & CMD_FS)
1360 strcat(a_buffer, ", fs");
1361 if (pageType & CMD_CM)
1362 strcat(a_buffer, ", cm");
1363 if (pageType & CMD_PREV)
1364 strcat(a_buffer, ", prev");
1365 if (pageType & CMD_NEXT)
1366 strcat(a_buffer, ", next");
1367 if (pageType & CMD_LEFT)
1368 strcat(a_buffer, ", left");
1369 if (pageType & CMD_RIGHT)
1370 strcat(a_buffer, ", right");
1371 strcat(a_buffer, "]? ");
1375 } /* resolve_CmdLine */
1377 /*-----------------------------------------------------------------------
1378 * display_Server_datum()
1381 * The data in the file server & cache manager frames are displayed
1382 * in two objects, one below the other. If the data is too long to
1383 * fit in the first object it will overflow into the next. This is
1384 * to conserve real estate on the screen. This function copies the
1385 * contents of the source buffer adjusted to the two objects if the
1386 * probe had succeded. Otherwise it enters "--" in the first object
1387 * blanks out the second. If the object needs to be highlightned
1388 * (due to a threshold crossing) it is done.
1392 *----------------------------------------------------------------------*/
1394 display_Server_datum(a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK, a_just,
1397 char *a_srcBuf; /* source buffer */
1398 struct onode *a_firstObj_o; /* first object */
1399 struct onode *a_secondObj_o; /* second object */
1400 int a_probeOK; /* probe OK ? */
1401 int a_just; /* justification */
1402 int a_highlight; /* highlight object ? */
1404 { /* display_Server_datum */
1406 static char rn[] = "display_Server_datum";
1407 struct gator_lightobj *tmp_lightobj1;
1408 struct gator_lightobj *tmp_lightobj2;
1409 char part1[FC_COLUMN_WIDTH + 2];
1410 char part2[FC_COLUMN_WIDTH + 2];
1416 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_probeOK= %d, a_just= %d, a_highlight= %d\n",
1417 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK,
1418 a_just, a_highlight);
1423 tmp_lightobj1 = (struct gator_lightobj *)a_firstObj_o->o_data;
1424 tmp_lightobj2 = (struct gator_lightobj *)a_secondObj_o->o_data;
1426 if (a_probeOK) { /* probe is ok so fill in the data */
1428 /* check if it would fit in one object */
1429 if (strlen(a_srcBuf) < FC_COLUMN_WIDTH) {
1430 strcpy(part1, a_srcBuf);
1433 /* break up the src string into 2 parts */
1434 /* note that column width includes terminator */
1435 strncpy(part1, a_srcBuf, FC_COLUMN_WIDTH - 1);
1436 part1[FC_COLUMN_WIDTH - 1] = '\0';
1437 strncpy(part2, a_srcBuf + FC_COLUMN_WIDTH - 1,
1438 FC_COLUMN_WIDTH - 1);
1442 } else { /* probe failed, enter "--"s */
1443 strcpy(part1, "--");
1447 /* if (afsmon_debug) {
1448 * fprintf(debugFD,"[ %s ] %s split to %s & %s\n",rn,a_srcBuf,part1,part2);
1452 /* initialize both the objects */
1455 justify_light(part1, tmp_lightobj1->label, FC_COLUMN_WIDTH, a_just,
1459 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1465 justify_light(part2, tmp_lightobj2->label, FC_COLUMN_WIDTH, a_just,
1469 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1474 /* highlight them */
1475 if (a_highlight && (part1[0] != '-'))
1476 gator_light_set(a_firstObj_o, 1);
1478 gator_light_set(a_firstObj_o, 0);
1479 if (a_highlight && (part2[0] != '\0'))
1480 gator_light_set(a_secondObj_o, 1);
1482 gator_light_set(a_secondObj_o, 0);
1488 } /* display_Server_datum */
1491 /*-----------------------------------------------------------------------
1492 * display_Server_label()
1495 * Display the given server label in three objects. The label is
1496 * partitioned into three parts by '/'s and each part is copied
1497 * into each label object.
1501 *----------------------------------------------------------------------*/
1504 display_Server_label(a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o)
1506 struct onode *a_firstObj_o; /* first object */
1507 struct onode *a_secondObj_o; /* second object */
1508 struct onode *a_thirdObj_o; /* third object */
1510 { /* display_Server_label */
1512 static char rn[] = "display_Server_label";
1513 char part[3][20]; /* buffer for three parts of label */
1515 struct gator_lightobj *tmp_lightobj;
1516 struct onode *objPtr_o[3];
1523 /* the following debug statement floods the debug file */
1524 #ifdef DEBUG_DETAILED
1527 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_thirdObj_o= %d\n",
1528 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o);
1534 /* break the label string into three parts */
1539 /* now for a dumb precaution */
1541 strLen = strlen(a_srcBuf);
1544 for (i = 0; i < 3; i++) {
1546 while (*strPtr != '\0' && (len++ <= strLen)) {
1547 if (*strPtr == '/') {
1551 part[i][j] = *strPtr;
1559 * if (afsmon_debug) {
1560 * fprintf(debugFD,"[ %s ] LABELS %s -> %s %s %s\n",
1561 * rn, a_srcBuf, part[0], part[1], part[2]);
1566 objPtr_o[0] = a_firstObj_o;
1567 objPtr_o[1] = a_secondObj_o;
1568 objPtr_o[2] = a_thirdObj_o;
1570 /* display each label justified CENTER */
1572 for (i = 0; i < 3; i++) {
1573 tmp_lightobj = (struct gator_lightobj *)objPtr_o[i]->o_data;
1575 justify_light(part[i], tmp_lightobj->label, FC_COLUMN_WIDTH,
1579 fprintf(debugFD, "[ %s ] justify_light %d failed \n", rn, i);
1585 } /* display_Server_label */
1591 /*-----------------------------------------------------------------------
1595 * Refresh the File Servers screen with the given page number starting
1596 * at the given left-column number. The appropriate contents of
1597 * prev_fsData are displayed.
1598 * First the status labels at the four corners of the screen are
1599 * updated. Next the column labels are updated and then each row
1604 * Failure: Exits afsmoitor on a severe error.
1605 *----------------------------------------------------------------------*/
1609 fs_refresh(a_pageNum, a_LcolNum)
1610 int a_pageNum; /* page to display */
1611 int a_LcolNum; /* starting (leftmost) column number */
1615 static char rn[] = "fs_refresh"; /* routine name */
1616 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
1617 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
1618 struct ServerInfo_line *tmp_fs_lines_P; /* tmp ptr to fs_lines */
1619 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
1620 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
1621 struct onode **fsLabels_o_Ptr1; /* ptr to label row 0 */
1622 struct onode **fsLabels_o_Ptr2; /* ptr to label row 1 */
1623 struct onode **fsLabels_o_Ptr3; /* ptr to label row 2 */
1624 char cmdLine[80]; /* buffer for command line */
1625 char printBuf[256]; /* buffer to print to screen */
1632 int dataIndex; /* index to the data[] field of
1633 * struct fs_Display_Data */
1636 fprintf(debugFD, "[ %s ] Called with row %d col %d \n", rn, a_pageNum,
1642 /* if the data is not yet available, ie., not one probe cycle has
1643 * completed, do nothing */
1645 if (!fs_Data_Available)
1649 /* validate the page number & column number */
1650 if (a_pageNum < 1 || a_pageNum > fs_numPages) {
1652 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
1658 if (a_LcolNum < 0 || a_LcolNum > fs_numCols) {
1660 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
1669 /* update the fixed labels */
1671 /* we reuse the ovw version lable and hence do not have to do anything
1674 /* page number label */
1675 tmp_lightobj = (struct gator_lightobj *)fs_pageNum_o->o_data;
1676 sprintf(printBuf, "[File Servers, p. %d of %d, c. %d of %d]", a_pageNum,
1677 fs_numPages, a_LcolNum + 1, fs_numCols);
1678 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
1680 gator_light_set(fs_pageNum_o, 1);
1682 /* file servers monitored label */
1683 tmp_lightobj = (struct gator_lightobj *)fs_numFS_o->o_data;
1684 sprintf(printBuf, "%d File Servers monitored, %d alerts on %d machines",
1685 numFS, num_fs_alerts, numHosts_onfs_alerts);
1686 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
1692 /* figure out what we need to show in the prompt & set the page type */
1693 /* the fs_pageType variable is in turn used by the keyboard handler
1694 * routines to call fs_refresh() with the correct parameters */
1696 fs_pageType = resolve_CmdLine(cmdLine, 1 /* fs frame */ , a_pageNum,
1697 fs_numPages, fs_numCols, a_LcolNum,
1700 /* display the command line */
1701 tmp_lightobj = (struct gator_lightobj *)fs_cmd_o->o_data;
1702 sprintf(printBuf, "%s", cmdLine);
1703 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
1705 gator_light_set(fs_cmd_o, 1);
1707 /* update the probe number label */
1708 tmp_lightobj = (struct gator_lightobj *)fs_probeNum_o->o_data;
1709 sprintf(printBuf, "[FS probes %d, freq=%d sec]", afsmon_fs_prev_probeNum,
1711 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
1713 gator_light_set(fs_probeNum_o, 1);
1715 /* update "columns on left" signal */
1716 tmp_lightobj = (struct gator_lightobj *)fs_leftArrows_o->o_data;
1717 if (fs_pageType & CMD_LEFT)
1718 strcpy(printBuf, "<<<");
1720 strcpy(printBuf, "");
1721 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1723 gator_light_set(fs_leftArrows_o, 0);
1725 /* update "columns on right" signal */
1726 tmp_lightobj = (struct gator_lightobj *)fs_rightArrows_o->o_data;
1727 if (fs_pageType & CMD_RIGHT)
1728 strcpy(printBuf, ">>>");
1730 strcpy(printBuf, "");
1731 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1733 gator_light_set(fs_rightArrows_o, 0);
1737 /* UPDATE THE COLUMN LABELS */
1739 /* the column index is also used to index the label arrays */
1740 labelIdx = a_LcolNum;
1742 /* get the pointers to the three arrays of label onodes */
1743 fsLabels_o_Ptr1 = fsLabels_o[0];
1744 fsLabels_o_Ptr2 = fsLabels_o[1];
1745 fsLabels_o_Ptr3 = fsLabels_o[2];
1747 for (k = 0; k < fs_cols_perPage; k++) {
1749 if (labelIdx < fs_numCols) {
1750 dataIndex = fs_Display_map[labelIdx];
1752 display_Server_label(fs_labels[dataIndex], *fsLabels_o_Ptr1,
1753 *fsLabels_o_Ptr2, *fsLabels_o_Ptr3);
1755 labelIdx++; /* next label */
1758 display_Server_label("//", *fsLabels_o_Ptr1, *fsLabels_o_Ptr2,
1762 fsLabels_o_Ptr1++; /* next onode in label row 1 */
1763 fsLabels_o_Ptr2++; /* next onode in label row 2 */
1764 fsLabels_o_Ptr3++; /* next onode in label row 3 */
1766 } /* labels for each column */
1769 /* UPDATE THE FILE SERVER STATISTICS */
1771 /* move to the right spot in the FS display data array */
1772 fsDataP = prev_fsData;
1774 for (i = 0; i < ((a_pageNum - 1) * fs_numHosts_perPage); i++) {
1779 if (fsIdx >= numFS) { /* whoops! screwed up */
1780 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
1784 /* get the pointer to the first line of onodes of the file server frame */
1785 tmp_fs_lines_P = fs_lines;
1787 for (i = 0; i < fs_numHosts_perPage; i++) {
1790 /* if this is the last page we may not have file servers to fill up
1791 * the page, so check the index */
1792 if (fsIdx < numFS) {
1794 if (fsDataP->hostName[0] == '\0') {
1795 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
1799 /* display the hostname , first names only please! */
1801 sprintf(printBuf, fsDataP->hostName);
1802 for (j = 0; j < strlen(printBuf); j++) {
1803 if (printBuf[j] == '.') {
1810 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1812 justify_light(printBuf, tmp_lightobj->label,
1813 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
1815 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1820 /* use the current column value to index into the fs_Display_map
1821 * array to obtain the index of the item to display. check if its
1822 * overflow flag is set and highlight if so. if the probe had failed
1823 * enter "--" is all columns */
1825 /* each host has two rows of slots for datums. get the pointers to
1826 * both the arrays */
1828 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1829 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1830 fs_curr_RCol = a_LcolNum; /* starting column number from which
1831 * we are asked to display data */
1833 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
1835 /* if there is another column of data */
1836 if (fs_curr_RCol < fs_numCols) {
1838 dataIndex = fs_Display_map[fs_curr_RCol];
1841 display_Server_datum(fsDataP->data[dataIndex],
1844 fsDataP->probeOK, RIGHT_JUSTIFY,
1845 fsDataP->threshOvf[dataIndex]);
1848 } else { /* no more data, blank out columns */
1849 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
1850 RIGHT_JUSTIFY, 0); /* no overflow */
1854 firstSlot_o_Ptr++; /* onode of next column */
1855 secondSlot_o_Ptr++; /* onode of next column */
1857 } /* for each column */
1859 /* the loop could have taken the right-column-index one over,
1861 if (fs_curr_RCol == fs_numCols)
1869 /* if fdIdx < numFS */
1870 /* if fsIdx >= numFS , blank out all succeding rows */
1871 if (fsIdx >= numFS) {
1873 /* blank out host name object */
1875 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1877 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
1880 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1885 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1886 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1888 for (k = 0; k < fs_cols_perPage; k++) {
1889 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
1890 RIGHT_JUSTIFY, 0); /* dont highlight */
1898 /* fsIDx >= numFS */
1899 tmp_fs_lines_P++; /* pointer to next line in the frame */
1900 fsDataP++; /* next host's data */
1901 fsIdx++; /* host index */
1904 } /* for each row in the File Servers frame */
1906 /* redraw the display if the File Servers screen is currently displayed */
1907 if (afsmon_win->w_frame == fsFrame)
1908 WOP_DISPLAY(afsmon_win);
1910 /* update the global page & column numbers to reflect the changes */
1911 fs_currPage = a_pageNum;
1912 fs_curr_LCol = a_LcolNum;;
1921 /*-----------------------------------------------------------------------
1925 * Switch from the File Server screen to the Overview Screen
1926 *----------------------------------------------------------------------*/
1930 /* bind the overview frame to the window */
1931 gtxframe_SetFrame(afsmon_win, ovwFrame);
1935 /*-----------------------------------------------------------------------
1939 * Switch from the File Server screen to the Cache Managers screen.
1940 *----------------------------------------------------------------------*/
1944 if (fs_pageType & CMD_CM) {
1945 /* bind the overview Cache Managers to the window */
1946 gtxframe_SetFrame(afsmon_win, cmFrame);
1951 /*-----------------------------------------------------------------------
1955 * Switch to next page of file server screen
1956 *----------------------------------------------------------------------*/
1960 static char rn[] = "Switch_fs_next";
1962 if (fs_pageType & CMD_NEXT) {
1963 /* we have a next page, refresh with next page number */
1964 fs_refresh(fs_currPage + 1, fs_curr_LCol);
1970 /*-----------------------------------------------------------------------
1974 * Switch to last page of file server screen
1975 *----------------------------------------------------------------------*/
1979 static char rn[] = "Switch_fs_last";
1982 if (fs_pageType & CMD_NEXT) {
1983 /* we have a next page, refresh with the last page number */
1984 fs_refresh(fs_numPages, fs_curr_LCol);
1990 /*-----------------------------------------------------------------------
1994 * Switch to previous page of file server screen
1995 *----------------------------------------------------------------------*/
1999 static char rn[] = "Switch_fs_prev";
2001 if (fs_pageType & CMD_PREV) {
2002 /* we have a previous page, refresh with the rpevious page number */
2003 fs_refresh(fs_currPage - 1, fs_curr_LCol);
2008 /*-----------------------------------------------------------------------
2012 * Switch to first page of file server screen
2013 *----------------------------------------------------------------------*/
2017 static char rn[] = "Switch_fs_first";
2019 if (fs_pageType & CMD_PREV) {
2020 /* we have a previous page, got to first page */
2021 fs_refresh(1, fs_curr_LCol);
2026 /*-----------------------------------------------------------------------
2030 * Scroll left on the file server screen
2031 *----------------------------------------------------------------------*/
2035 static char rn[] = "Switch_fs_left";
2037 if (fs_pageType & CMD_LEFT) {
2038 /* we have columns on left, refresh with new column number */
2039 fs_refresh(fs_currPage, fs_curr_LCol - fs_cols_perPage);
2045 /*-----------------------------------------------------------------------
2046 * Switch_fs_leftmost()
2049 * Scroll to first column on the file server screen
2050 *----------------------------------------------------------------------*/
2052 Switch_fs_leftmost()
2054 static char rn[] = "Switch_fs_leftmost";
2056 if (fs_pageType & CMD_LEFT) {
2057 /* we have columns on left, go to the first */
2058 fs_refresh(fs_currPage, 0);
2063 /*-----------------------------------------------------------------------
2067 * Scroll right on the file server screen
2068 *----------------------------------------------------------------------*/
2072 static char rn[] = "Switch_fs_right";
2074 if (fs_pageType & CMD_RIGHT) {
2075 /* we have columns on right, refresh with new column number */
2076 fs_refresh(fs_currPage, fs_curr_LCol + fs_cols_perPage);
2081 /*-----------------------------------------------------------------------
2082 * Switch_fs_rightmost()
2085 * Scroll to last column on the file server screen
2086 *----------------------------------------------------------------------*/
2088 Switch_fs_rightmost()
2090 static char rn[] = "Switch_fs_rightmost";
2094 if (fs_pageType & CMD_RIGHT) {
2095 /* we have columns on right, go to the last column */
2096 if (fs_numCols % fs_cols_perPage)
2097 curr_LCol = (fs_numCols / fs_cols_perPage) * fs_cols_perPage;
2100 ((fs_numCols / fs_cols_perPage) - 1) * fs_cols_perPage;
2102 fs_refresh(fs_currPage, curr_LCol);
2108 /*-----------------------------------------------------------------------
2109 * create_FSframe_objects()
2112 * Create the gtx objects (onodes) for the Fileservers frame and setup
2113 * the keyboard bindings.
2114 * Only as many objects as can fit on the display are created. The
2115 * positions and lengths of all these objects are fixed at creation.
2116 * These objects are updated with new data at the end of each probe
2121 * Failure: Exits afsmonitor.
2122 *----------------------------------------------------------------------*/
2125 create_FSframe_objects()
2126 { /* create_FSframe_objects */
2127 static char rn[] = "create_FSframe_objects";
2128 struct ServerInfo_line *fs_lines_Ptr;
2129 struct onode **fs_data_o_Ptr;
2130 struct onode **fsLabels_o_Ptr;
2141 fprintf(debugFD, "[ %s ] Called\n", rn);
2145 /* create the command line object */
2147 initLightObject("Command [oview, cm, prev, next, left, right] ? ", 0,
2148 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2149 if (fs_cmd_o == NULL) {
2150 sprintf(errMsg, "[ %s ] Failed to create fs command onode\n", rn);
2153 code = gtxframe_AddToList(fsFrame, fs_cmd_o);
2154 code = gator_light_set(fs_cmd_o, HIGHLIGHT);
2156 /* we already have the dimensions for the frame - same as the ovw frame */
2157 /* use the ovw program name object for the fs screen too */
2159 code = gtxframe_AddToList(fsFrame, ovw_progName_o);
2162 /* create the page number object */
2164 initLightObject("[File Servers, p. X of X, c. Y of Y]",
2165 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2167 if (fs_pageNum_o == NULL) {
2168 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2171 code = gtxframe_AddToList(fsFrame, fs_pageNum_o);
2172 code = gator_light_set(fs_pageNum_o, HIGHLIGHT);
2174 /* create the probe number object */
2176 initLightObject("[FS probes 1, freq=30 sec]",
2177 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2178 FC_PROBENUM_O_WIDTH, afsmon_win);
2179 if (fs_probeNum_o == NULL) {
2180 sprintf(errMsg, "[ %s ] Failed to create fs probeNum onode\n", rn);
2183 code = gtxframe_AddToList(fsFrame, fs_probeNum_o);
2184 code = gator_light_set(fs_probeNum_o, HIGHLIGHT);
2187 /* create the numFS monitored object */
2190 (" 0 File Servers monitored, 0 alerts on 0 machines", 4, 2,
2191 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2192 if (fs_numFS_o == NULL) {
2194 "[ %s ] Failed to create numFS onode for the fs frame\n", rn);
2197 code = gtxframe_AddToList(fsFrame, fs_numFS_o);
2199 /* create the "more columns to left" indicator */
2201 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
2202 if (fs_leftArrows_o == NULL) {
2204 "[ %s ] Failed to create leftArrows onode for the fs frame\n",
2208 code = gtxframe_AddToList(fsFrame, fs_leftArrows_o);
2210 /* create the "more columns to right" indicator */
2212 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
2214 if (fs_rightArrows_o == NULL) {
2216 "[ %s ] Failed to create rightArrows onode for the fs frame\n",
2220 code = gtxframe_AddToList(fsFrame, fs_rightArrows_o);
2225 /* calculate the maximum number of hosts per page (2 rows per host) */
2226 fs_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
2228 /* determine the number of data columns that can fit in a page */
2229 fs_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
2232 fprintf(debugFD, "[ %s ] fs_numHosts_perPage=%d fs_cols_perPage=%d\n",
2233 rn, fs_numHosts_perPage, fs_cols_perPage);
2237 /* the above two variables give us the information needed to create
2238 * the objects for displaying the file server information */
2240 /* allocate memory for all the onode pointers required to display
2241 * the file server statistics */
2243 numBytes = fs_numHosts_perPage * sizeof(struct ServerInfo_line);
2244 fs_lines = (struct ServerInfo_line *)malloc(numBytes);
2245 if (fs_lines == (struct ServerInfo_line *)0) {
2247 "[ %s ] Failed to allocate %d bytes for FS data lines\n", rn,
2252 /* for each line of server statistics allocate memory to store two arrays
2255 fs_lines_Ptr = fs_lines;
2256 for (i = 0; i < fs_numHosts_perPage; i++) {
2257 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
2258 numBytes = fs_cols_perPage * sizeof(struct onode *);
2259 fs_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes);
2260 if (fs_lines_Ptr->data_o[arrIdx] == NULL) {
2262 "[ %s ] Failed to allocate %d bytes for FS data onodes\n",
2270 /* now allocate the onodes itself */
2272 fs_lines_Ptr = fs_lines;
2273 for (i = 0; i < fs_numHosts_perPage; i++) {
2275 /* initialize host name onode */
2276 fs_lines_Ptr->host_o =
2277 initLightObject("FSHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
2278 FC_HOSTNAME_O_WIDTH, afsmon_win);
2279 if (fs_lines_Ptr->host_o == NULL) {
2280 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
2283 code = gtxframe_AddToList(fsFrame, fs_lines_Ptr->host_o);
2285 /* if (afsmon_debug) {
2286 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
2287 * rn,fs_lines_Ptr->host_o,i);
2291 /* initialize data onodes for this host */
2293 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
2295 fs_data_o_Ptr = fs_lines_Ptr->data_o[arrIdx];
2296 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
2300 /* determine x & y coordinate for this data object */
2301 /* the 1's are for leaving a blank after each column */
2302 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
2303 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
2305 sprintf(tmpBuf, "-FSData %d-", arrIdx);
2307 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
2309 if (*fs_data_o_Ptr == NULL) {
2311 "[ %s ] Failed to create an FS data onode\n", rn);
2314 code = gtxframe_AddToList(fsFrame, *fs_data_o_Ptr);
2317 } /* for each column */
2318 } /* for each onode array index */
2321 } /* for each host slot */
2324 /* INITIALIZE COLUMN LABELS */
2327 /* allocate memory for two arrays of onode pointers for file server column
2329 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
2331 fsLabels_o[arrIdx] =
2332 (struct onode **)malloc(sizeof(struct onode *) * fs_cols_perPage);
2333 if (fsLabels_o[arrIdx] == NULL) {
2335 "[ %s ] Failed to allocate memory for FS label onodes\n",
2340 /* create cache manager name objects */
2341 fsLabels_o_Ptr = fsLabels_o[arrIdx];
2342 for (i = 0; i < fs_cols_perPage; i++) {
2344 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
2345 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
2348 if (*fsLabels_o_Ptr == NULL) {
2349 sprintf(errMsg, "[ %s ] Failed to create a FS label onode\n",
2353 code = gtxframe_AddToList(fsFrame, *fsLabels_o_Ptr);
2360 /* initialize the column & page counters */
2363 fs_numCols = fs_DisplayItems_count;
2364 fs_numPages = numFS / fs_numHosts_perPage;
2365 if (numFS % fs_numHosts_perPage)
2367 fs_curr_LCol = 0; /* leftmost col */
2368 fs_curr_RCol = 0; /* rightmost col */
2370 /* create keyboard bindings */
2371 /* bind Q and
\ 3 to exit */
2372 keymap_BindToString(fsFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
2373 keymap_BindToString(fsFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
2375 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
2376 * N = last page, P = first page, L = leftmost col, R = rightmost col */
2378 keymap_BindToString(fsFrame->keymap, "o", Switch_fs_2_ovw, NULL, NULL);
2379 keymap_BindToString(fsFrame->keymap, "c", Switch_fs_2_cm, NULL, NULL);
2380 keymap_BindToString(fsFrame->keymap, "n", Switch_fs_next, NULL, NULL);
2381 keymap_BindToString(fsFrame->keymap, "N", Switch_fs_last, NULL, NULL);
2382 keymap_BindToString(fsFrame->keymap, "p", Switch_fs_prev, NULL, NULL);
2383 keymap_BindToString(fsFrame->keymap, "P", Switch_fs_first, NULL, NULL);
2384 keymap_BindToString(fsFrame->keymap, "l", Switch_fs_left, NULL, NULL);
2385 keymap_BindToString(fsFrame->keymap, "L", Switch_fs_leftmost, NULL, NULL);
2386 keymap_BindToString(fsFrame->keymap, "r", Switch_fs_right, NULL, NULL);
2387 keymap_BindToString(fsFrame->keymap, "R", Switch_fs_rightmost, NULL,
2391 } /* create_FSframe_objects */
2394 /*-----------------------------------------------------------------------
2395 * Function: cm_refresh()
2398 * Refresh the Cache Managers screen with the given page number starting
2399 * at the given left-column number. The appropriate contents of
2400 * prev_cmData are displayed.
2401 * First the status labels at the four corners of the screen are
2402 * updated. Next the column labels are updated and then each row
2407 * Failure: Exits afsmoitor on a severe error.
2408 *----------------------------------------------------------------------*/
2411 cm_refresh(a_pageNum, a_LcolNum)
2412 int a_pageNum; /* page to display */
2413 int a_LcolNum; /* starting (leftmost) column number */
2417 static char rn[] = "cm_refresh"; /* routine name */
2418 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
2419 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
2420 struct ServerInfo_line *tmp_cm_lines_P; /* tmp ptr to cm_lines */
2421 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
2422 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
2423 struct onode **cmLabels_o_Ptr1; /* ptr to label row 0 */
2424 struct onode **cmLabels_o_Ptr2; /* ptr to label row 1 */
2425 struct onode **cmLabels_o_Ptr3; /* ptr to label row 2 */
2426 char cmdLine[80]; /* buffer for command line */
2427 char printBuf[256]; /* buffer to print to screen */
2434 int dataIndex; /* index to the data[] field of
2435 * struct cm_Display_Data */
2438 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_LcolNum= %d \n", rn,
2439 a_pageNum, a_LcolNum);
2444 /* if the data is not yet available, ie., not one probe cycle has
2445 * completed, do nothing */
2447 if (!cm_Data_Available)
2451 /* validate the page number & column number */
2452 if (a_pageNum < 1 || a_pageNum > cm_numPages) {
2454 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
2460 if (a_LcolNum < 0 || a_LcolNum > cm_numCols) {
2462 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
2471 /* update the fixed labels */
2473 /* we reuse the ovw version lable and hence do not have to do anything
2476 /* page number label */
2477 tmp_lightobj = (struct gator_lightobj *)cm_pageNum_o->o_data;
2478 sprintf(printBuf, "[Cache Managers, p.%d of %d, c.%d of %d]", a_pageNum,
2479 cm_numPages, a_LcolNum + 1, cm_numCols);
2480 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
2482 gator_light_set(cm_pageNum_o, 1);
2484 /* file servers monitored label */
2485 tmp_lightobj = (struct gator_lightobj *)cm_numCM_o->o_data;
2486 sprintf(printBuf, "%d Cache Managers monitored, %d alerts on %d machines",
2487 numCM, num_cm_alerts, numHosts_oncm_alerts);
2488 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
2494 /* figure out what we need to show in the prompt & set the page type */
2495 /* the cm_pageType variable is in turn used by the keyboard handler
2496 * routines to call cm_refresh() with the correct parameters */
2498 cm_pageType = resolve_CmdLine(cmdLine, 2 /* cm frame */ , a_pageNum,
2499 cm_numPages, cm_numCols, a_LcolNum,
2502 /* display the command line */
2503 tmp_lightobj = (struct gator_lightobj *)cm_cmd_o->o_data;
2504 sprintf(printBuf, "%s", cmdLine);
2505 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
2507 gator_light_set(cm_cmd_o, 1);
2509 /* update the probe number label */
2510 tmp_lightobj = (struct gator_lightobj *)cm_probeNum_o->o_data;
2511 sprintf(printBuf, "[CM probes %d, freq=%d sec]", afsmon_cm_prev_probeNum,
2513 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
2515 gator_light_set(cm_cmd_o, 1);
2517 /* update "columns on left" signal */
2518 tmp_lightobj = (struct gator_lightobj *)cm_leftArrows_o->o_data;
2519 if (cm_pageType & CMD_LEFT)
2520 strcpy(printBuf, "<<<");
2522 strcpy(printBuf, "");
2523 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2525 gator_light_set(cm_leftArrows_o, 0);
2527 /* update "columns on right" signal */
2528 tmp_lightobj = (struct gator_lightobj *)cm_rightArrows_o->o_data;
2529 if (cm_pageType & CMD_RIGHT)
2530 strcpy(printBuf, ">>>");
2532 strcpy(printBuf, "");
2533 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2535 gator_light_set(cm_rightArrows_o, 0);
2539 /* UPDATE THE COLUMN LABELS */
2541 /* the column index is also used to index the label arrays */
2542 labelIdx = a_LcolNum;
2544 /* get the pointers to the three arrays of label onodes */
2545 cmLabels_o_Ptr1 = cmLabels_o[0];
2546 cmLabels_o_Ptr2 = cmLabels_o[1];
2547 cmLabels_o_Ptr3 = cmLabels_o[2];
2549 for (k = 0; k < cm_cols_perPage; k++) {
2551 if (labelIdx < cm_numCols) {
2552 dataIndex = cm_Display_map[labelIdx];
2554 display_Server_label(cm_labels[dataIndex], *cmLabels_o_Ptr1,
2555 *cmLabels_o_Ptr2, *cmLabels_o_Ptr3);
2557 labelIdx++; /* next label */
2560 display_Server_label("//", *cmLabels_o_Ptr1, *cmLabels_o_Ptr2,
2564 cmLabels_o_Ptr1++; /* next onode in label row 1 */
2565 cmLabels_o_Ptr2++; /* next onode in label row 2 */
2566 cmLabels_o_Ptr3++; /* next onode in label row 3 */
2568 } /* labels for each column */
2571 /* UPDATE THE FILE SERVER STATISTICS */
2573 /* move to the right spot in the CM display data array */
2574 cmDataP = prev_cmData;
2576 for (i = 0; i < ((a_pageNum - 1) * cm_numHosts_perPage); i++) {
2581 if (cmIdx >= numCM) { /* whoops! screwed up */
2582 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
2586 /* get the pointer to the first line of onodes of the file server frame */
2587 tmp_cm_lines_P = cm_lines;
2589 for (i = 0; i < cm_numHosts_perPage; i++) {
2592 /* if this is the last page we may not have file servers to fill up
2593 * the page, so check the index */
2594 if (cmIdx < numCM) {
2596 if (cmDataP->hostName[0] == '\0') {
2597 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
2601 /* display the hostname , first names only please! */
2603 sprintf(printBuf, cmDataP->hostName);
2604 for (j = 0; j < strlen(printBuf); j++) {
2605 if (printBuf[j] == '.') {
2612 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2614 justify_light(printBuf, tmp_lightobj->label,
2615 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
2617 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2622 /* use the current column value to index into the cm_Display_map
2623 * array to obtain the index of the item to display. check if its
2624 * overflow flag is set and highlight if so. if the probe had failed
2625 * enter "--" is all columns */
2627 /* each host has two rows of slots for datums. get the pointers to
2628 * both the arrays */
2630 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2631 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2632 cm_curr_RCol = a_LcolNum; /* starting column number from which
2633 * we are asked to display data */
2635 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
2637 /* if there is another column of data */
2638 if (cm_curr_RCol < cm_numCols) {
2640 dataIndex = cm_Display_map[cm_curr_RCol];
2643 display_Server_datum(cmDataP->data[dataIndex],
2646 cmDataP->probeOK, RIGHT_JUSTIFY,
2647 cmDataP->threshOvf[dataIndex]);
2650 } else { /* no more data, blank out columns */
2651 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
2652 RIGHT_JUSTIFY, 0); /* no overflow */
2656 firstSlot_o_Ptr++; /* onode of next column */
2657 secondSlot_o_Ptr++; /* onode of next column */
2659 } /* for each column */
2661 /* the loop could have taken the right-column-index one over,
2663 if (cm_curr_RCol == cm_numCols)
2671 /* if fdIdx < numCM */
2672 /* if cmIdx >= numCM , blank out all succeding rows */
2673 if (cmIdx >= numCM) {
2675 /* blank out host name object */
2677 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2679 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
2682 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2687 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2688 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2690 for (k = 0; k < cm_cols_perPage; k++) {
2691 code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
2692 RIGHT_JUSTIFY, 0); /* dont highlight */
2700 /* cmIDx >= numCM */
2701 tmp_cm_lines_P++; /* pointer to next line in the frame */
2702 cmDataP++; /* next host's data */
2703 cmIdx++; /* host index */
2706 } /* for each row in the Cache Manager frame */
2708 /* redraw the display if the Cache Managers screen is currently displayed */
2709 if (afsmon_win->w_frame == cmFrame)
2710 WOP_DISPLAY(afsmon_win);
2712 /* update the global page & column numbers to reflect the changes */
2713 cm_currPage = a_pageNum;
2714 cm_curr_LCol = a_LcolNum;;
2722 /*-----------------------------------------------------------------------
2726 * Switch from the Cache Manager screen to the Overview Screen
2727 *----------------------------------------------------------------------*/
2731 /* bind the overview frame to the window */
2732 gtxframe_SetFrame(afsmon_win, ovwFrame);
2736 /*-----------------------------------------------------------------------
2740 * Switch from the Cache Manager screen to the File Servers screen
2741 *----------------------------------------------------------------------*/
2745 if (cm_pageType & CMD_FS) {
2746 /* bind the file servers frame to the window */
2747 gtxframe_SetFrame(afsmon_win, fsFrame);
2752 /*-----------------------------------------------------------------------
2756 * Switch to next page of cache managers screen
2757 *----------------------------------------------------------------------*/
2761 static char rn[] = "Switch_cm_next";
2763 if (cm_pageType & CMD_NEXT) {
2764 /* we have a next page, refresh with next page number */
2765 cm_refresh(cm_currPage + 1, cm_curr_LCol);
2771 /*-----------------------------------------------------------------------
2775 * Switch to last page of file server screen
2776 *----------------------------------------------------------------------*/
2780 static char rn[] = "Switch_cm_last";
2783 if (cm_pageType & CMD_NEXT) {
2784 /* we have a next page, refresh with last page number */
2785 cm_refresh(cm_numPages, cm_curr_LCol);
2791 /*-----------------------------------------------------------------------
2795 * Switch to previous page of cache managers screen
2796 *----------------------------------------------------------------------*/
2800 static char rn[] = "Switch_cm_prev";
2802 if (cm_pageType & CMD_PREV) {
2803 /* we have a previous page, refresh to previous page */
2804 cm_refresh(cm_currPage - 1, cm_curr_LCol);
2809 /*-----------------------------------------------------------------------
2813 * Switch to first page of cache managers screen
2814 *----------------------------------------------------------------------*/
2818 static char rn[] = "Switch_cm_first";
2820 if (cm_pageType & CMD_PREV) {
2821 /* we have a previous page, refresh to first page */
2822 cm_refresh(1, cm_curr_LCol);
2827 /*-----------------------------------------------------------------------
2831 * Scroll left on the cache managers screen
2832 *----------------------------------------------------------------------*/
2836 static char rn[] = "Switch_cm_left";
2838 if (cm_pageType & CMD_LEFT) {
2839 /* we have columns on left, refresh with new column number */
2840 cm_refresh(cm_currPage, cm_curr_LCol - cm_cols_perPage);
2846 /*-----------------------------------------------------------------------
2847 * Switch_cm_leftmost()
2850 * Scroll to first column on the cache managers screen
2851 *----------------------------------------------------------------------*/
2853 Switch_cm_leftmost()
2855 static char rn[] = "Switch_cm_leftmost";
2857 if (cm_pageType & CMD_LEFT) {
2858 /* we have columns on left, go to the first column */
2859 cm_refresh(cm_currPage, 0);
2864 /*-----------------------------------------------------------------------
2868 * Scroll right on the cache managers screen
2869 *----------------------------------------------------------------------*/
2873 static char rn[] = "Switch_cm_right";
2875 if (cm_pageType & CMD_RIGHT) {
2876 /* we have columns on right, refresh with new column number */
2877 cm_refresh(cm_currPage, cm_curr_LCol + cm_cols_perPage);
2882 /*-----------------------------------------------------------------------
2883 * Switch_cm_rightmost()
2886 * Scroll to last column on the cache managers screen
2887 *----------------------------------------------------------------------*/
2889 Switch_cm_rightmost()
2891 static char rn[] = "Switch_cm_rightmost";
2895 if (cm_pageType & CMD_RIGHT) {
2896 /* we have columns on right, go to the last column */
2897 if (cm_numCols % cm_cols_perPage)
2898 curr_LCol = (cm_numCols / cm_cols_perPage) * cm_cols_perPage;
2901 ((cm_numCols / cm_cols_perPage) - 1) * cm_cols_perPage;
2902 cm_refresh(cm_currPage, curr_LCol);
2908 /*-----------------------------------------------------------------------
2909 * create_CMframe_objects()
2912 * Create the gtx objects (onodes) for the Cache Managers frame and setup
2913 * the keyboard bindings.
2914 * Only as many objects as can fit on the display are created. The
2915 * positions and lengths of all these objects are fixed at creation.
2916 * These objects are updated with new data at the end of each probe
2921 * Failure: Exits afsmonitor.
2922 *----------------------------------------------------------------------*/
2925 create_CMframe_objects()
2926 { /* create_CMframe_objects */
2927 static char rn[] = "create_CMframe_objects";
2928 struct ServerInfo_line *cm_lines_Ptr;
2929 struct onode **cm_data_o_Ptr;
2930 struct onode **cmLabels_o_Ptr;
2940 fprintf(debugFD, "[ %s ] Called\n", rn);
2946 /* create the command line object */
2948 initLightObject("Command [oview, fs, prev, next, left, right] ? ", 0,
2949 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2950 if (cm_cmd_o == NULL) {
2951 sprintf(errMsg, "[ %s ] Failed to create cm command onode\n", rn);
2954 code = gtxframe_AddToList(cmFrame, cm_cmd_o);
2955 code = gator_light_set(cm_cmd_o, HIGHLIGHT);
2958 /* we already have the dimensions for the frame - same as the ovw frame */
2959 /* use the ovw program name object for the cm screen too */
2961 code = gtxframe_AddToList(cmFrame, ovw_progName_o);
2964 /* create the page number object */
2966 initLightObject("[Cache Managers, p. X of X, c. Y of Y]",
2967 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2969 if (cm_pageNum_o == NULL) {
2970 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2973 code = gtxframe_AddToList(cmFrame, cm_pageNum_o);
2974 code = gator_light_set(cm_pageNum_o, HIGHLIGHT);
2976 /* create the probe number object */
2978 initLightObject("[CM probes 1, freq=30 sec]",
2979 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2980 FC_PROBENUM_O_WIDTH, afsmon_win);
2981 if (cm_probeNum_o == NULL) {
2982 sprintf(errMsg, "[ %s ] Failed to create cm probeNum onode\n", rn);
2985 code = gtxframe_AddToList(cmFrame, cm_probeNum_o);
2986 code = gator_light_set(cm_probeNum_o, HIGHLIGHT);
2989 /* create the numCM monitored object */
2992 (" 0 Cache Mangers monitored, 0 alerts on 0 machines", 4, 2,
2993 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2994 if (cm_numCM_o == NULL) {
2996 "[ %s ] Failed to create numCM onode for the cm frame\n", rn);
2999 code = gtxframe_AddToList(cmFrame, cm_numCM_o);
3001 /* create the "more columns to left" indicator */
3003 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
3004 if (cm_leftArrows_o == NULL) {
3006 "[ %s ] Failed to create leftArrows onode for the cm frame\n",
3010 code = gtxframe_AddToList(cmFrame, cm_leftArrows_o);
3012 /* create the "more columns to right" indicator */
3014 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
3016 if (cm_rightArrows_o == NULL) {
3018 "[ %s ] Failed to create rightArrows onode for the cm frame\n",
3022 code = gtxframe_AddToList(cmFrame, cm_rightArrows_o);
3027 /* calculate the maximum number of hosts per page (2 rows per host) */
3028 cm_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
3030 /* determine the number of data columns that can fit in a page */
3031 cm_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
3034 fprintf(debugFD, "[ %s ] cm_numHosts_perPage=%d cm_cols_perPage=%d\n",
3035 rn, cm_numHosts_perPage, cm_cols_perPage);
3039 /* the above two variables give us the information needed to create
3040 * the objects for displaying the file server information */
3042 /* allocate memory for all the onode pointers required to display
3043 * the file server statistics */
3045 numBytes = cm_numHosts_perPage * sizeof(struct ServerInfo_line);
3046 cm_lines = (struct ServerInfo_line *)malloc(numBytes);
3047 if (cm_lines == (struct ServerInfo_line *)0) {
3049 "[ %s ] Failed to allocate %d bytes for CM data lines\n", rn,
3054 /* for each line of server statistics allocate memory to store two arrays
3057 cm_lines_Ptr = cm_lines;
3058 for (i = 0; i < cm_numHosts_perPage; i++) {
3059 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
3060 numBytes = cm_cols_perPage * sizeof(struct onode *);
3061 cm_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes);
3062 if (cm_lines_Ptr->data_o[arrIdx] == NULL) {
3064 "[ %s ] Failed to allocate %d bytes for CM data onodes\n",
3072 /* now allocate the onodes itself */
3074 cm_lines_Ptr = cm_lines;
3075 for (i = 0; i < cm_numHosts_perPage; i++) {
3077 /* initialize host name onode */
3078 cm_lines_Ptr->host_o =
3079 initLightObject("CMHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
3080 FC_HOSTNAME_O_WIDTH, afsmon_win);
3081 if (cm_lines_Ptr->host_o == NULL) {
3082 sprintf(errMsg, "[ %s ] Failed to create an CM name onode\n", rn);
3085 code = gtxframe_AddToList(cmFrame, cm_lines_Ptr->host_o);
3087 /* if (afsmon_debug) {
3088 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
3089 * rn,cm_lines_Ptr->host_o,i);
3093 /* initialize data onodes for this host */
3095 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
3097 cm_data_o_Ptr = cm_lines_Ptr->data_o[arrIdx];
3098 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
3102 /* determine x & y coordinate for this data object */
3103 /* the 1's are for leaving a blank after each column */
3104 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
3105 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
3107 sprintf(tmpBuf, "-CMData %d-", arrIdx);
3109 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
3111 if (*cm_data_o_Ptr == NULL) {
3113 "[ %s ] Failed to create an CM data onode\n", rn);
3116 code = gtxframe_AddToList(cmFrame, *cm_data_o_Ptr);
3119 } /* for each column */
3120 } /* for each onode array index */
3123 } /* for each host slot */
3126 /* INITIALIZE COLUMN LABELS */
3129 /* allocate memory for two arrays of onode pointers for file server column
3131 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
3133 cmLabels_o[arrIdx] =
3134 (struct onode **)malloc(sizeof(struct onode *) * cm_cols_perPage);
3135 if (cmLabels_o[arrIdx] == NULL) {
3137 "[ %s ] Failed to allocate memory for CM label onodes\n",
3142 /* create cache manager name objects */
3143 cmLabels_o_Ptr = cmLabels_o[arrIdx];
3144 for (i = 0; i < cm_cols_perPage; i++) {
3146 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
3147 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
3150 if (*cmLabels_o_Ptr == NULL) {
3151 sprintf(errMsg, "[ %s ] Failed to create a CM label onode\n",
3155 code = gtxframe_AddToList(cmFrame, *cmLabels_o_Ptr);
3166 /* initialize the column & page counters */
3169 cm_numCols = cm_DisplayItems_count;
3170 cm_numPages = numCM / cm_numHosts_perPage;
3171 if (numCM % cm_numHosts_perPage)
3173 cm_curr_LCol = 0; /* leftmost col */
3174 cm_curr_RCol = 0; /* rightmost col */
3176 /* create keyboard bindings */
3177 /* bind Q and
\ 3 to exit */
3178 keymap_BindToString(cmFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
3179 keymap_BindToString(cmFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
3181 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
3182 * N = last page, P = first page, L = leftmost col, R = rightmost col */
3184 keymap_BindToString(cmFrame->keymap, "o", Switch_cm_2_ovw, NULL, NULL);
3185 keymap_BindToString(cmFrame->keymap, "f", Switch_cm_2_fs, NULL, NULL);
3186 keymap_BindToString(cmFrame->keymap, "n", Switch_cm_next, NULL, NULL);
3187 keymap_BindToString(cmFrame->keymap, "N", Switch_cm_last, NULL, NULL);
3188 keymap_BindToString(cmFrame->keymap, "p", Switch_cm_prev, NULL, NULL);
3189 keymap_BindToString(cmFrame->keymap, "P", Switch_cm_first, NULL, NULL);
3190 keymap_BindToString(cmFrame->keymap, "l", Switch_cm_left, NULL, NULL);
3191 keymap_BindToString(cmFrame->keymap, "L", Switch_cm_leftmost, NULL, NULL);
3192 keymap_BindToString(cmFrame->keymap, "r", Switch_cm_right, NULL, NULL);
3193 keymap_BindToString(cmFrame->keymap, "R", Switch_cm_rightmost, NULL,
3197 } /* create_CMframe_objects */
3201 /*-----------------------------------------------------------------------
3205 * Initialize the gtx package and call routines to create the objects
3206 * for the overview, File Servers & Cache Managers screens.
3207 *----------------------------------------------------------------------*/
3210 { /* gtx_initialize */
3211 static char rn[] = "gtx_initialize"; /* routine name */
3215 fprintf(debugFD, "[ %s ] Called\n", rn);
3219 afsmon_win = gtx_Init(0, -1); /* 0 => dont start input server,
3220 * 1 => use curses */
3221 if (afsmon_win == NULL) {
3222 sprintf(errMsg, "[ %s ] gtx initialization failed\n", rn);
3225 gtx_initialized = 1;
3227 /* Create the Overview frame */
3229 ovwFrame = gtxframe_Create();
3230 if (ovwFrame == (struct gtx_frame *)0) {
3231 sprintf(errMsg, "[ %s ] Failed to create overview frame\n", rn);
3235 /* bind the overview frame to the window */
3236 gtxframe_SetFrame(afsmon_win, ovwFrame);
3238 /* create overview frame objects */
3239 code = create_ovwFrame_objects();
3241 sprintf(errMsg, "[ %s ] Error in creating ovw frame objects\n", rn);
3246 /* Create the File Server frame */
3247 fsFrame = gtxframe_Create();
3248 if (fsFrame == (struct gtx_frame *)0) {
3249 sprintf(errMsg, "[ %s ] Failed to create file server frame\n", rn);
3254 /* Create File Server frame objects */
3255 code = create_FSframe_objects();
3257 sprintf(errMsg, "[ %s ] Error in creating FS frame objects\n", rn);
3261 /* Create the Cache Managers frame */
3262 cmFrame = gtxframe_Create();
3263 if (cmFrame == (struct gtx_frame *)0) {
3264 sprintf(errMsg, "[ %s ] Failed to create Cache Managers frame\n", rn);
3268 /* Create Cache Managers frame objects */
3269 code = create_CMframe_objects();
3271 sprintf(errMsg, "[ %s ] Error in creating CM frame objects\n", rn);
3275 /* misc initializations */
3276 sprintf(blankline, "%255s", " ");
3279 } /* gtx_initialize */