2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * Afsmon-win: Curses interface for the Afsmonitor using the gtx library.
13 *-------------------------------------------------------------------------*/
15 #include <afsconfig.h>
16 #include <afs/param.h>
27 #include <afs/gtxwindows.h> /*Generic window package */
28 #include <afs/gtxobjects.h> /*Object definitions */
29 #include <afs/gtxkeymap.h>
30 #include <afs/gtxlightobj.h> /*Light object interface */
31 #include <afs/gtxcurseswin.h> /*Curses window package */
32 #include <afs/gtxdumbwin.h> /*Dumb terminal window package */
33 #include <afs/gtxX11win.h> /*X11 window package */
34 #include <afs/gtxframe.h> /*Frame package */
36 #include <afs/xstat_fs.h>
37 #include <afs/xstat_cm.h>
40 #include "afsmonitor.h"
41 #include "afsmon-labels.h"
44 /* afsmonitor version number */
45 static char afsmon_version[] = "1.0";
47 /* EXTERNAL VARIABLES (from afsmonitor.c) */
49 extern int afsmon_debug; /* debug info to file ? */
50 extern FILE *debugFD; /* debugging file descriptor */
51 extern char errMsg[256]; /* buffers used to print error messages after */
52 extern char errMsg1[256]; /* gtx is initialized (stderr/stdout gone !) */
54 /* number of fileservers and cache managers to monitor */
58 /* number of FS alerts and number of hosts on FS alerts */
59 extern int num_fs_alerts;
60 extern int numHosts_onfs_alerts;
62 /* number of CM alerts and number of hosts on FS alerts */
63 extern int num_cm_alerts;
64 extern int numHosts_oncm_alerts;
66 /* ptr to array holding the results of FS probes in ascii format */
67 extern struct fs_Display_Data *prev_fsData;
69 /* ptr to array holding the results of CM probes in ascii format */
70 extern struct cm_Display_Data *prev_cmData;
72 extern int afsmon_fs_curr_probeNum; /* current fs probe number */
73 extern int afsmon_fs_prev_probeNum; /* previous fs probe number */
74 extern int afsmon_cm_curr_probeNum; /* current cm probe number */
75 extern int afsmon_cm_prev_probeNum; /* previous cm probe number */
77 extern int afsmon_probefreq; /* probe frequency */
79 /* map of fs results items we must display. This array contains indices to
80 the fs_varNames[] array corresponding to the stats we want to display. It is
81 initialized while processing the config file */
83 extern short fs_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN];
84 extern int fs_DisplayItems_count; /* number of items to display */
86 extern short cm_Display_map[XSTAT_FS_FULLPERF_RESULTS_LEN];
87 extern int cm_DisplayItems_count; /* number of items to display */
92 /* minimum window size */
97 #define RIGHT_JUSTIFY 0
98 #define LEFT_JUSTIFY 1
101 /* width of overview frame objects */
102 /* field widths include the terminating null character */
104 #define PROGNAME_O_WIDTH (maxX/2) /* program name object */
105 #define OVW_PAGENUM_O_WIDTH 29 /* page number object */
106 #define OVW_PROBENUM_O_WIDTH 39 /* probe number object */
107 #define OVW_CMD_O_WIDTH (maxX/2) /* cmd line object */
108 #define OVW_NUMFS_O_WIDTH 40 /* num FSs monitored */
109 #define OVW_NUMCM_O_WIDTH 40 /* num CMs monitored */
110 #define OVW_FSALERTS_O_WIDTH 40 /* num FS alerts */
111 #define OVW_CMALERTS_O_WIDTH 40 /* num CM alerts */
112 #define OVW_HOSTNAME_O_WIDTH (maxX / 2) /* FS & CM host names */
113 #define OVW_HOSTNAME_O_WIDTH_HGL 30 /* cosmetic, atleast this many chars
114 * will be highlightned */
116 /* widths of FS and CM frame objects */
117 #define FC_NUMHOSTS_O_WIDTH (maxX - 8) /* number of fs monitored. leave 4
118 * chars on either side for '<<','>>' */
119 #define FC_PAGENUM_O_WIDTH 43
120 #define FC_HOSTNAME_O_WIDTH 11 /* width of FS hostnames column */
121 #define FC_CMD_O_WIDTH 55 /* width of cmd line */
122 #define FC_PROBENUM_O_WIDTH 30 /* width of probe number object */
123 #define FC_ARROWS_O_WIDTH 4 /* width of arrow indicators */
124 #define FC_COLUMN_WIDTH 11 /* width of data columns */
126 /* bit definitions for use in resolving command line */
127 /* these bits are set in the xx_pageType variables to indicate what commands
130 #define CMD_NEXT 1 /* next page ? */
131 #define CMD_PREV 2 /* previous page ? */
132 #define CMD_LEFT 4 /* left scroll ? */
133 #define CMD_RIGHT 8 /* right scroll ? */
134 #define CMD_FS 16 /* file servers frame exists ? */
135 #define CMD_CM 32 /* cache managers frame exists ? */
138 #define FC_NUM_FIXED_LINES 10 /* number of fixed lines */
139 #define FC_FIRST_HOST_ROW 8 /* first host entry row number */
140 #define FC_FIRST_LABEL_ROW 4 /* first label row number */
142 /* number of fixed lines (that dont change) on the overview screen */
143 #define OVW_NUM_FIXED_LINES 7
144 #define OVW_FIRST_HOST_ROW 5 /* row index of first host entry in ovw frame */
146 #define HIGHLIGHT 1 /* highlight object? */
148 static char blankline[256]; /* blank line */
150 /* maximum X & Y coordinates of the frames */
154 struct gwin *afsmon_win; /* afsmonitor window */
155 int gtx_initialized = 0;
157 /* Overview screen related definitions */
159 struct gtx_frame *ovwFrame; /* overview screen frame */
160 struct gwin_sizeparams frameDims; /* frame dimensions. all frames have
163 /* overview frame object names */
164 struct onode *ovw_progName_o; /* program name object */
165 struct onode *ovw_pageNum_o; /* page number onject */
166 struct onode *ovw_cmd_o; /* command line object */
167 struct onode *ovw_probeNum_o; /* probe number object */
168 struct onode *ovw_numFS_o; /* num FS monitored */
169 struct onode *ovw_numCM_o; /* num CM monitored */
170 struct onode *ovw_FSalerts_o; /* nunber of FS alerts */
171 struct onode *ovw_CMalerts_o; /* nunber of CM alerts */
172 struct onode *initMsg_o; /* initialization message */
174 /* number of pages of data for the overview frame */
175 int ovw_numPages = 0;
176 int ovw_currPage = 1; /* current page number */
178 static int ovw_pageType = 0; /* one of the above types */
180 /* number of rows of server names that can be displayed on one overview page*/
181 int ovw_numHosts_perPage;
183 /* ptr to a block of ovw_numHosts_perPage number of objects for file servers */
184 struct onode **ovw_fsNames_o;
185 /*ptr to a block of ovw_numHosts_perPage number of objects for cache managers */
186 struct onode **ovw_cmNames_o;
188 /* When the ovw_refresh routine is called by the keyboard handlers the
189 following variable is used to determine if fs/cm/fs&cm info must be updated */
190 int ovw_update_info = 0;
192 /* Variables needed to display an intialization message on startup */
193 static char *initMsg = "AFSMonitor Collecting Statistics ...";
194 static int initMsg_on = 0; /* message on ? */
196 /* FILE SERVER Screen related definitions */
198 struct gtx_frame *fsFrame; /* File Server screen frame */
200 struct onode *fs_pageNum_o; /* fs page number object */
201 struct onode *fs_cmd_o; /* fs command line object */
202 struct onode *fs_probeNum_o; /* fs probe number object */
203 struct onode *fs_numFS_o; /* fs number of FSs object */
204 struct onode *fs_leftArrows_o; /* fs cols on left signal object */
205 struct onode *fs_rightArrows_o; /* fs cols on right signal object */
206 struct onode **fs_hostNames_o; /* ptr to host names objects */
208 /* bit-map to characterize page type and contents of command prompt */
209 static int fs_pageType = 0;
211 /* coordinates for the File Servers screen */
213 /* we use page numbers to navigate vertically (ie, across hosts) and column
214 numbers to navigate horizontally */
216 int fs_numHosts_perPage; /* number of file servers per page */
217 int fs_cols_perPage; /* number of data columns per file server page */
218 int fs_currPage; /* current FS page number */
219 int fs_numPages; /* number of FS pages */
221 /* column numbers are index to the mapping structure fs_Display_map. this
222 map contains the indices of datums that should be displayed */
224 int fs_numCols; /* number of columns of FS data (excluding hostname) */
225 /* this is the same as fs_DisplayItems_count */
226 /* following column indices run from 1 to (fs_numCols -1) */
227 int fs_curr_LCol = 0; /* column number of leftmost column on display */
228 int fs_curr_RCol = 0; /* column number of rightmost column on display */
229 int fs_Data_Available = 0; /* atleast one fs probe cycle completed ? */
232 /* structure that defines a line of data in the fs/cm frames */
234 /* we store each datum value in two objects, one below the other. The reason
235 for doing this is to conserve screen area. most of the datums are just longs
236 and will fit into one object. some of them are timing values and require 13
237 characters to be displayed - such fields may overflow to the second object
238 placed below the first one. */
240 struct ServerInfo_line {
241 struct onode *host_o; /* hostname object */
242 struct onode **data_o[2]; /* ptrs to two arrays of data objects. */
246 struct ServerInfo_line *fs_lines; /* ptr to the file server data objects */
248 /* file server label onodes - three rows of them */
249 struct onode **fsLabels_o[3];
251 /* CACHE MANAGER Screen related definitions */
253 struct gtx_frame *cmFrame; /* Cache Manager screen frame */
255 struct onode *cm_pageNum_o; /* cm page number object */
256 struct onode *cm_cmd_o; /* cm command line object */
257 struct onode *cm_probeNum_o; /* cm probe number object */
258 struct onode *cm_numCM_o; /* cm number of FSs object */
259 struct onode *cm_leftArrows_o; /* fs cols on left signal object */
260 struct onode *cm_rightArrows_o; /* fs cols on right signal object */
262 struct onode **cm_hostNames_o; /* ptr to host names objects */
264 /* bit-map to characterize page type and contents of command prompt */
265 static int cm_pageType = 0;
267 /* coordinates for the Cache Managers screen */
269 /* we use page numbers to navigate vertically (ie, across hosts) and column
270 numbers to navigate horizontally */
272 int cm_numHosts_perPage; /* number of cache managers per page */
273 int cm_cols_perPage; /* number of data columns per file server page */
274 int cm_currPage; /* current CM page number */
275 int cm_numPages; /* number of CM pages */
277 /* column numbers are index to the mapping structure cm_Display_map. this
278 map contains the indices of datums that should be displayed */
280 int cm_numCols; /* number of columns of FS data (excluding hostname) */
281 /* this is the same as cm_DisplayItems_count */
282 /* following column indices run from 1 to (cm_numCols -1) */
283 int cm_curr_LCol = 0; /* column number of leftmost column on display */
284 int cm_curr_RCol = 0; /* column number of rightmost column on display */
285 int cm_Data_Available = 0; /* atleast one cm probe cycle completed ? */
288 /* structure that defines a line of data in the fs/cm frames */
289 struct ServerInfo_line *cm_lines; /* ptr to the file server data objects */
291 /* file server label onodes - three rows of them */
292 struct onode **cmLabels_o[3];
296 /*------------------------------------------------------------------------
300 * Create and initialize a light onode according to the given
302 * ( Borrowed from scout.c )
305 * char *a_name : Ptr to the light's string name.
306 * int a_x : X offset.
307 * int a_y : Y offset.
308 * int a_width : Width in chars.
309 * struct gwin *a_win : Ptr to window structure.
312 * Ptr to new light onode on success,
313 * A null pointer otherwise.
320 *------------------------------------------------------------------------*/
322 static struct onode *
323 initLightObject(char *a_name, int a_x, int a_y, int a_width,
325 { /*initLightObject */
326 struct onode *newlightp; /*Ptr to new light onode */
327 struct gator_light_crparams light_crparams; /*Light creation params */
328 char *truncname; /*Truncated name, if needed */
329 int name_len; /*True length of name */
331 /* the following debug statement floods the debug file */
332 #ifdef DEBUG_DETAILED
335 "[ %s ] Called, a_name= %s, a_x= %d, a_y= %d, a_width= %d, a_win= %d\n",
336 rn, a_name, a_x, a_y, a_width, a_win);
344 * Set up the creation parameters according to the information we've
347 light_crparams.onode_params.cr_type = GATOR_OBJ_LIGHT;
348 name_len = strlen(a_name);
350 if (name_len <= a_width)
351 sprintf(light_crparams.onode_params.cr_name, "%s", a_name);
354 * We need to truncate the given name, leaving a `*' at the end to
355 * show us it's been truncated.
357 truncname = light_crparams.onode_params.cr_name;
358 strncpy(truncname, a_name, a_width - 1);
359 truncname[a_width - 1] = '*';
360 truncname[a_width] = 0;
362 light_crparams.onode_params.cr_x = a_x;
363 light_crparams.onode_params.cr_y = a_y;
364 light_crparams.onode_params.cr_width = a_width;
365 light_crparams.onode_params.cr_height = 1;
366 light_crparams.onode_params.cr_window = a_win;
367 light_crparams.onode_params.cr_home_obj = NULL;
368 light_crparams.onode_params.cr_prev_obj = NULL;
369 light_crparams.onode_params.cr_parent_obj = NULL;
370 light_crparams.onode_params.cr_helpstring = NULL;
372 light_crparams.appearance = 0;
373 light_crparams.flashfreq = 0;
374 sprintf(light_crparams.label, "%s", a_name);
375 light_crparams.label_x = 0;
376 light_crparams.label_y = 0;
379 gator_objects_create((struct onode_createparams *)(&light_crparams));
382 * Return the news, happy or not.
386 } /*initLightObject */
390 /*------------------------------------------------------------------------
394 * Place the chars in the source buffer into the target buffer
395 * with the desired justification, either centered, left-justified
396 * or right-justified. Also, support inidication of truncation
397 * with a star (*), either on the left or right of the string,
398 * and whether we're justifying a labeled disk quantity.
400 * (derived from mini_justify() in scout.c)
403 * char *a_srcbuff : Ptr to source char buffer.
404 * char *a_dstbuff : Ptr to dest char buffer.
405 * int a_dstwidth : Width of dest buffer in chars.
406 * int a_justification : Kind of justification.
407 * int a_rightTrunc : If non-zero, place the truncation char
408 * on the right of the string. Otherwise,
409 * place it on the left.
415 *------------------------------------------------------------------------*/
418 justify_light(char *a_srcbuff, char *a_dstbuff, int a_dstwidth,
419 int a_justification, int a_rightTrunc)
422 static char rn[] = "justify_light"; /*Routine name */
423 int leftpad_chars; /*# of chars for left-padding */
424 int num_src_chars; /*# of chars in source */
425 int true_num_src_chars; /*# src chars before truncation */
426 int trunc_needed; /*Is truncation needed? */
429 /* the following debug statement floods the debug file */
430 #ifdef DEBUG_DETAILED
433 "[ %s ] Called, a_srcbuff= %s, a_dstbuff= %d, a_dstwidth= %d, a_justification= %d, a_rightTrunc= %d\n",
434 rn, a_srcbuff, a_dstbuff, a_dstwidth, a_justification,
442 * If the destination width will overrun the gtx string storage,
443 * we automatically shorten up.
445 if (a_dstwidth > GATOR_LABEL_CHARS) {
447 * if (afsmon_debug) {
449 * "[%s] Dest width (%d) > gtx buflen (%d), shrinking dest width\n",
450 * rn, a_dstwidth, GATOR_LABEL_CHARS);
454 a_dstwidth = GATOR_LABEL_CHARS;
458 * If our source string is too long, prepare for truncation.
460 true_num_src_chars = strlen(a_srcbuff);
461 if (true_num_src_chars >= a_dstwidth) {
463 num_src_chars = a_dstwidth - 1;
466 a_srcbuff += (true_num_src_chars - num_src_chars);
469 num_src_chars = true_num_src_chars;
472 * Compute the necessary left-padding.
474 switch (a_justification) {
477 leftpad_chars = (a_dstwidth - 1) - num_src_chars;
482 * This is the really easy one.
488 leftpad_chars = ((a_dstwidth - 1) - num_src_chars) / 2;
493 fprintf(debugFD, "[%s] Illegal justification command: %d", rn,
495 fprintf(debugFD, "[%s] Called with '%s', dest width=%d\n", rn,
496 a_srcbuff, a_dstwidth);
500 } /*Switch on justification type */
504 * Clear out the dest buffer, then place the source string at the
505 * appropriate padding location. Remember to place a string
506 * terminator at the end of the dest buffer, plus whatever truncation
507 * may be needed. If we're left-truncating, we've already shifted
508 * the src buffer appropriately.
510 strncpy(a_dstbuff, blankline, a_dstwidth);
511 strncpy(a_dstbuff + leftpad_chars, a_srcbuff, num_src_chars);
512 *(a_dstbuff + a_dstwidth - 1) = '\0';
515 *(a_dstbuff + a_dstwidth - 2) = '*'; /*Truncate on the right */
517 *a_dstbuff = '*'; /*Truncate on the left, non-disk */
521 /*Handle truncations */
523 * Return the good news.
531 /*-----------------------------------------------------------------------
535 * Call the exit routine. This function is mapped
536 * to the keys Q and
\ 3 in all the frames and is called by the
538 *----------------------------------------------------------------------*/
541 afsmonExit_gtx(void *d1, void *d2)
543 static char rn[] = "afsmonExit_gtx";
546 fprintf(debugFD, "[ %s ] Called\n", rn);
551 return 0; /* not reached */
555 /*-----------------------------------------------------------------------
559 * Refresh the overview screen with the contents of the specified page.
560 * There are two parts to the overview screen - the file server column
561 * and the cache manager column and each of them is independent of the
562 * other. Hence it takes as an argumnet the "type" of update to be
567 * Failure: Exits afsmonitor.
568 *----------------------------------------------------------------------*/
571 ovw_refresh(int a_pageNum, /* page to refresh overview display */
572 int a_updateType) /* OVW_UPDATE_FS = update fs column only,
573 * OVW_UPDATE_CM = update cm column only,
574 * OVW_UPDATE_BOTH = update fs & cm columns. Note that
575 * we do not want to update a column until the
576 * corresponding probe cycle has completed */
579 static char rn[] = "ovw_refresh"; /* routine name */
580 struct onode **tmp_fsNames_o; /* ptr to fsNames onodes */
581 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
582 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
583 struct onode **tmp_cmNames_o; /* ptr to fsNames onodes */
584 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
585 int fsIdx; /* for counting # of CM hosts */
586 int cmIdx; /* for counting # of CM hosts */
587 char cmdLine[80]; /* buffer for command line */
588 char printBuf[256]; /* buffer to print to screen */
594 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_updateType= %d\n",
595 rn, a_pageNum, a_updateType);
599 /* if the data is not yet available ie., not one probe cycle has
600 * completed, do nothing */
602 if ((a_updateType & OVW_UPDATE_FS) && !fs_Data_Available)
604 if ((a_updateType & OVW_UPDATE_CM) && !cm_Data_Available)
608 /* validate page number */
609 if (a_pageNum < 1 || a_pageNum > ovw_numPages) {
610 sprintf(errMsg, "[ %s ] called with incorrect page number %d\n", rn,
615 /* set the current page number */
616 ovw_currPage = a_pageNum;
618 /* turn off init message */
621 gtxframe_RemoveFromList(ovwFrame, initMsg_o);
624 /* update the labels */
627 tmp_lightobj = (struct gator_lightobj *)ovw_progName_o->o_data;
628 sprintf(printBuf, "AFSMonitor [Version %s]", afsmon_version);
629 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
631 gator_light_set(ovw_progName_o, 1);
633 /* page number label */
634 tmp_lightobj = (struct gator_lightobj *)ovw_pageNum_o->o_data;
635 sprintf(printBuf, "[System Overview, p. %d of %d]", ovw_currPage,
637 justify_light(printBuf, tmp_lightobj->label, OVW_PAGENUM_O_WIDTH,
639 gator_light_set(ovw_pageNum_o, 1);
641 /* file servers monitored label */
642 tmp_lightobj = (struct gator_lightobj *)ovw_numFS_o->o_data;
643 sprintf(printBuf, " %d File Servers monitored", numFS);
644 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
647 /* cache managers monitored label */
648 tmp_lightobj = (struct gator_lightobj *)ovw_numCM_o->o_data;
649 sprintf(printBuf, " %d Cache Managers monitored", numCM);
650 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
654 /* no. of fs alerts label */
655 tmp_lightobj = (struct gator_lightobj *)ovw_FSalerts_o->o_data;
656 sprintf(printBuf, " %d alerts on %d machines", num_fs_alerts,
657 numHosts_onfs_alerts);
658 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
661 /* no. of cm alerts label */
662 tmp_lightobj = (struct gator_lightobj *)ovw_CMalerts_o->o_data;
663 sprintf(printBuf, " %d alerts on %d machines", num_cm_alerts,
664 numHosts_oncm_alerts);
665 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
669 /* determine if we have fs/cm, more/previous pages of data to display */
672 if (numFS && fs_Data_Available)
673 ovw_pageType |= CMD_FS; /* we have an fs frame & data avail. */
674 if (numCM && cm_Data_Available)
675 ovw_pageType |= CMD_CM; /* we have a cm frame & data avail. */
676 if (ovw_currPage > 1)
677 ovw_pageType |= CMD_PREV; /* got a previous page */
678 if (ovw_currPage < ovw_numPages)
679 ovw_pageType |= CMD_NEXT; /* got a next page */
681 strcpy(cmdLine, "Command [");
682 if ((ovw_pageType & CMD_FS) && (ovw_pageType & CMD_CM))
683 strcat(cmdLine, "fs, cm");
684 else if (ovw_pageType & CMD_FS)
685 strcat(cmdLine, "fs");
686 else if (ovw_pageType & CMD_CM)
687 strcat(cmdLine, "cm");
689 if (ovw_pageType & CMD_PREV)
690 strcat(cmdLine, ", prev");
691 if (ovw_pageType & CMD_NEXT)
692 strcat(cmdLine, ", next");
694 strcat(cmdLine, "]? ");
696 /* display the command line */
697 tmp_lightobj = (struct gator_lightobj *)ovw_cmd_o->o_data;
698 sprintf(printBuf, "%s", cmdLine);
699 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
701 gator_light_set(ovw_cmd_o, 1);
703 /* display probe numbers line */
704 tmp_lightobj = (struct gator_lightobj *)ovw_probeNum_o->o_data;
705 sprintf(printBuf, "[probes %d(fs) %d(cm), freq=%d sec]",
706 afsmon_fs_prev_probeNum, afsmon_cm_prev_probeNum,
708 justify_light(printBuf, tmp_lightobj->label, OVW_PROBENUM_O_WIDTH,
710 gator_light_set(ovw_probeNum_o, 1);
712 /* update the file server names column if we are asked to */
714 if (numFS && (a_updateType & OVW_UPDATE_FS)) {
716 /* move to the right spot in the FS display data array */
717 fsDataP = prev_fsData;
719 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
724 /* get the address to the first FS name */
725 tmp_fsNames_o = ovw_fsNames_o;
727 for (i = 0; i < ovw_numHosts_perPage; i++) {
728 if (fsIdx < numFS) { /* this could be the last & partial page */
730 if (fsDataP->hostName[0] == '\0') {
731 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
735 /* check if the probe succeeded. if it did check for thresholds
736 * overflow. A failed probe is indicated by "PF" */
738 if (!fsDataP->probeOK) {
739 sprintf(printBuf, "[ PF] %s", fsDataP->hostName);
740 } else if (fsDataP->ovfCount) /* thresholds overflow */
741 sprintf(printBuf, "[%3d] %s", fsDataP->ovfCount,
744 sprintf(printBuf, " %s", fsDataP->hostName);
748 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
751 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
753 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
754 len = OVW_HOSTNAME_O_WIDTH_HGL;
756 len = strlen(printBuf) + 1;
759 justify_light(printBuf, tmp_lightobj->label, len,
763 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
768 /* highlighten if overflowed or probe failed */
770 if (fsDataP->ovfCount || !fsDataP->probeOK)
771 gator_light_set(*tmp_fsNames_o, 1);
773 gator_light_set(*tmp_fsNames_o, 0);
776 } else { /* no more hosts, blank the rest of the entries */
778 (struct gator_lightobj *)(*tmp_fsNames_o)->o_data;
779 sprintf(tmp_lightobj->label, "%s", "");
782 tmp_fsNames_o++; /* next onode */
783 fsDataP++; /* next host's data */
784 fsIdx++; /* host index */
789 /* if we have any cache managers, update them if we are asked to */
790 if (numCM && (a_updateType & OVW_UPDATE_CM)) {
792 /* move to the right spot in the CM display data array */
793 cmDataP = prev_cmData;
795 for (i = 0; i < ((a_pageNum - 1) * ovw_numHosts_perPage); i++) {
800 /* get the address to the first CM name */
801 tmp_cmNames_o = ovw_cmNames_o;
803 for (i = 0; i < ovw_numHosts_perPage; i++) {
804 if (cmIdx < numCM) { /* this could be the last & partial page */
806 if (cmDataP->hostName[0] == '\0') {
807 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
811 /* check if the probe succeeded. if it did check for thresholds
812 * overflow. A failed probe is indicated by "PF" */
814 if (!cmDataP->probeOK) {
815 sprintf(printBuf, "[ PF] %s", cmDataP->hostName);
816 } else if (cmDataP->ovfCount) { /* thresholds overflow */
817 sprintf(printBuf, "[%3d] %s", cmDataP->ovfCount,
820 sprintf(printBuf, " %s", cmDataP->hostName);
823 fprintf(debugFD, "[ %s ] to display %s\n", rn, printBuf);
826 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
828 if (strlen(printBuf) + 1 < OVW_HOSTNAME_O_WIDTH_HGL)
829 len = OVW_HOSTNAME_O_WIDTH_HGL;
831 len = strlen(printBuf) + 1;
834 justify_light(printBuf, tmp_lightobj->label, len,
838 fprintf(debugFD, "[ %s ] justify_code returned %d\n",
843 /* highlighten if overflow or if probe failed */
844 if (cmDataP->ovfCount || !cmDataP->probeOK)
845 gator_light_set(*tmp_cmNames_o, 1);
847 gator_light_set(*tmp_cmNames_o, 0);
850 } else { /* no more hosts, blank the rest of the entries */
852 (struct gator_lightobj *)(*tmp_cmNames_o)->o_data;
853 sprintf(tmp_lightobj->label, "%s", "");
856 tmp_cmNames_o++; /* next onode */
857 cmDataP++; /* next host's data */
858 cmIdx++; /* host index */
863 /* redraw the display if the overview screen is currently displayed */
864 if (afsmon_win->w_frame == ovwFrame)
865 WOP_DISPLAY(afsmon_win);
873 /*-----------------------------------------------------------------------
877 * Switch from the overview screen to the FS screen
878 *----------------------------------------------------------------------*/
880 Switch_ovw_2_fs(void *d1, void *d2)
882 static char rn[] = "Switch_ovw_2_fs";
885 fprintf(debugFD, "[ %s ] Called\n", rn);
889 /* bind the File Server frame to the window */
890 if (ovw_pageType & CMD_FS)
891 gtxframe_SetFrame(afsmon_win, fsFrame);
895 /*-----------------------------------------------------------------------
899 * Switch from the overview screen to the CM screen
900 *----------------------------------------------------------------------*/
902 Switch_ovw_2_cm(void *d1, void *d2)
904 static char rn[] = "Switch_ovw_2_cm";
907 fprintf(debugFD, "[ %s ] Called\n", rn);
911 /* bind the Cache Managers frame to the window */
912 if (ovw_pageType & CMD_CM)
913 gtxframe_SetFrame(afsmon_win, cmFrame);
917 /*-----------------------------------------------------------------------
921 * Switch to the next page in overview screen
922 *----------------------------------------------------------------------*/
924 Switch_ovw_next(void *d1, void *d2)
926 static char rn[] = "Switch_ovw_next";
929 fprintf(debugFD, "[ %s ] Called\n", rn);
933 if (ovw_pageType & CMD_NEXT) {
934 /* call refresh with the next page number */
935 ovw_refresh(ovw_currPage + 1, ovw_update_info);
941 /*-----------------------------------------------------------------------
945 * Switch to the last page in the overview screen
946 *----------------------------------------------------------------------*/
948 Switch_ovw_last(void *d1, void *d2)
950 static char rn[] = "Switch_ovw_last";
953 fprintf(debugFD, "[ %s ] Called\n", rn);
957 if (ovw_pageType & CMD_NEXT) {
958 /* call refresh with the last page number */
959 ovw_refresh(ovw_numPages, ovw_update_info);
965 /*-----------------------------------------------------------------------
969 * Switch to the previous page in the overview screen
970 *----------------------------------------------------------------------*/
972 Switch_ovw_prev(void *d1, void *d2)
974 static char rn[] = "Switch_ovw_prev";
977 fprintf(debugFD, "[ %s ] Called\n", rn);
981 if (ovw_pageType & CMD_PREV) {
982 /* call refresh with the previous page number */
983 ovw_refresh(ovw_currPage - 1, ovw_update_info);
988 /*-----------------------------------------------------------------------
992 * Switch to the first page in the overview screen
993 *----------------------------------------------------------------------*/
995 Switch_ovw_first(void *d1, void *d2)
997 static char rn[] = "Switch_ovw_first";
1000 fprintf(debugFD, "[ %s ] Called\n", rn);
1004 if (ovw_pageType & CMD_PREV) {
1005 /* refresh with the first page number */
1006 ovw_refresh(1, ovw_update_info);
1011 /*-----------------------------------------------------------------------
1012 * create_ovwFrame_objects()
1015 * Create the gtx objects (onodes) for the overview frame and setup
1016 * the keyboard bindings.
1017 * Only as many objects as can fit on the display are created. The
1018 * positions and lengths of all these objects are fixed at creation.
1019 * These objects are updated with new data at the end of each probe
1024 * Failure: Exits afsmonitor.
1025 *----------------------------------------------------------------------*/
1028 create_ovwFrame_objects(void)
1029 { /* create_ovwFrame_objects */
1031 static char rn[] = "create_ovwFrame_objects";
1032 int hostLines; /* number of lines of host names to display */
1033 struct onode **ovw_fsNames_o_Ptr; /* index to list of fs names onodes */
1034 struct onode **ovw_cmNames_o_Ptr; /* index to list of cm names onodes */
1038 fprintf(debugFD, "[ %s ] Called\n", rn);
1042 /* get frame dimensions, it must be atleast MINXxMINY for any sensible output */
1043 WOP_GETDIMENSIONS(ovwFrame->window, &frameDims);
1044 maxX = frameDims.maxx;
1045 maxY = frameDims.maxy;
1046 if (maxX + 1 < MINX || maxY + 1 < MINY) {
1047 sprintf(errMsg1, "[ %s ] Window size %dx%d; must be at least %dx%d\n",
1048 rn, maxX + 1, maxY + 1, MINX, MINY);
1052 fprintf(debugFD, "maxX = %d maxY = %d\n", maxX, maxY);
1055 /* Print an Intial message to the screen. The init message is 36 chars
1058 initLightObject(initMsg, maxX / 2 - 18, maxY / 3, sizeof(initMsg),
1060 if (initMsg_o == NULL) {
1061 sprintf(errMsg, "[ %s ] Failed to create initMsg_o onode\n", rn);
1064 gtxframe_AddToList(ovwFrame, initMsg_o);
1065 gator_light_set(initMsg_o, HIGHLIGHT);
1070 /* create the command line object */
1072 ovw_cmd_o = initLightObject("", 0, maxY - 1, OVW_CMD_O_WIDTH, afsmon_win);
1073 if (ovw_cmd_o == NULL) {
1074 sprintf(errMsg, "[ %s ] Failed to create command onode\n", rn);
1077 gtxframe_AddToList(ovwFrame, ovw_cmd_o);
1078 gator_light_set(ovw_cmd_o, HIGHLIGHT);
1080 /* create the program name object */
1082 ovw_progName_o = initLightObject("", 0, 0, PROGNAME_O_WIDTH, afsmon_win);
1083 if (ovw_progName_o == NULL) {
1084 sprintf(errMsg, "[ %s ] Failed to create programName onode\n", rn);
1087 gtxframe_AddToList(ovwFrame, ovw_progName_o);
1088 gator_light_set(ovw_progName_o, HIGHLIGHT);
1090 /* create the page number object */
1093 initLightObject("", maxX - OVW_PAGENUM_O_WIDTH, 0,
1094 OVW_PAGENUM_O_WIDTH, afsmon_win);
1095 if (ovw_pageNum_o == NULL) {
1096 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
1099 gtxframe_AddToList(ovwFrame, ovw_pageNum_o);
1100 gator_light_set(ovw_pageNum_o, HIGHLIGHT);
1102 /* create the probe number object */
1104 initLightObject("", maxX - OVW_PROBENUM_O_WIDTH, maxY - 1,
1105 OVW_PROBENUM_O_WIDTH, afsmon_win);
1106 if (ovw_probeNum_o == NULL) {
1107 sprintf(errMsg, "[ %s ] Failed to create probe number onode\n", rn);
1110 gtxframe_AddToList(ovwFrame, ovw_probeNum_o);
1111 gator_light_set(ovw_probeNum_o, HIGHLIGHT);
1113 /* create the numFS monitored object */
1114 ovw_numFS_o = initLightObject("", 0, 2, FC_NUMHOSTS_O_WIDTH, afsmon_win);
1115 if (ovw_numFS_o == NULL) {
1116 sprintf(errMsg, "[ %s ] Failed to create numFS onode\n", rn);
1119 gtxframe_AddToList(ovwFrame, ovw_numFS_o);
1121 /* create the numCM monitored object */
1123 initLightObject("", maxX / 2, 2, OVW_NUMCM_O_WIDTH, afsmon_win);
1124 if (ovw_numCM_o == NULL) {
1125 sprintf(errMsg, "[ %s ] Failed to create numCM_o onode\n", rn);
1128 gtxframe_AddToList(ovwFrame, ovw_numCM_o);
1130 /* create the number-of-FS-alerts object */
1132 initLightObject("", 0, 3, OVW_FSALERTS_O_WIDTH, afsmon_win);
1133 if (ovw_FSalerts_o == NULL) {
1134 sprintf(errMsg, "[ %s ] Failed to create FSalerts_o onode\n", rn);
1137 gtxframe_AddToList(ovwFrame, ovw_FSalerts_o);
1139 /* create the number-of-CM-alerts object */
1141 initLightObject("", maxX / 2, 3, OVW_CMALERTS_O_WIDTH, afsmon_win);
1142 if (ovw_CMalerts_o == NULL) {
1143 sprintf(errMsg, "[ %s ] Failed to create CMalerts_o onode\n", rn);
1146 gtxframe_AddToList(ovwFrame, ovw_CMalerts_o);
1148 /* create file-server-name and cache-manager-names objects */
1149 ovw_numHosts_perPage = maxY - OVW_NUM_FIXED_LINES;
1151 /* allocate memory for a list of onode pointers for file server names */
1152 ovw_fsNames_o = malloc(sizeof(struct onode *) * ovw_numHosts_perPage);
1153 if (ovw_fsNames_o == NULL) {
1154 sprintf(errMsg, "[ %s ] Failed to allocate memory for FS onodes\n",
1159 /* create file server name objects */
1160 ovw_fsNames_o_Ptr = ovw_fsNames_o;
1161 for (i = 0; i < ovw_numHosts_perPage; i++) {
1162 *ovw_fsNames_o_Ptr =
1163 initLightObject("", 0, OVW_FIRST_HOST_ROW + i,
1164 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1165 if (*ovw_fsNames_o_Ptr == NULL) {
1166 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
1170 * if (afsmon_debug) {
1171 * fprintf(debugFD,"[ %s ] fsName_o %d: %d\n",
1172 * rn,i,*ovw_fsNames_o_Ptr);
1176 gtxframe_AddToList(ovwFrame, *ovw_fsNames_o_Ptr);
1177 ovw_fsNames_o_Ptr++;
1182 /* allocate memory for a list of onode pointers for cache manager names */
1183 ovw_cmNames_o = malloc(sizeof(struct onode *) * ovw_numHosts_perPage);
1184 if (ovw_cmNames_o == NULL) {
1185 sprintf(errMsg, "[ %s ] Failed to allocate memory for CM onodes\n",
1190 /* create cache manager name objects */
1191 ovw_cmNames_o_Ptr = ovw_cmNames_o;
1192 for (i = 0; i < ovw_numHosts_perPage; i++) {
1193 *ovw_cmNames_o_Ptr =
1194 initLightObject("", maxX / 2, OVW_FIRST_HOST_ROW + i,
1195 OVW_HOSTNAME_O_WIDTH, afsmon_win);
1196 if (*ovw_cmNames_o_Ptr == NULL) {
1197 sprintf(errMsg, "[ %s ] Failed to create a CM name onode\n", rn);
1200 gtxframe_AddToList(ovwFrame, *ovw_cmNames_o_Ptr);
1201 ovw_cmNames_o_Ptr++;
1205 /* Calculate the number of pages of overview data to display */
1206 /* host information starts at the 6th line from top and stops at 3rd
1207 * line from bottom of screen */
1214 ovw_numPages = hostLines / (maxY - OVW_NUM_FIXED_LINES);
1215 if (hostLines % (maxY - OVW_NUM_FIXED_LINES))
1219 fprintf(debugFD, "[ %s ] number of ovw pages = %d\n", rn,
1222 /* When the ovw_refresh() routine is called by the keyboard handlers the
1223 * following variable is used to determine if fs/cm/fs&cm info must be
1225 ovw_update_info = 0;
1227 ovw_update_info |= OVW_UPDATE_FS;
1229 ovw_update_info |= OVW_UPDATE_CM;
1231 /* bind the overview frame to a keyboard input handler */
1233 /* bind Q and
\ 3 to exit */
1234 keymap_BindToString(ovwFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
1235 keymap_BindToString(ovwFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
1237 /* f -> switch of fs frame */
1238 keymap_BindToString(ovwFrame->keymap, "f", Switch_ovw_2_fs, NULL, NULL);
1239 /* c -> switch of cm frame */
1240 keymap_BindToString(ovwFrame->keymap, "c", Switch_ovw_2_cm, NULL, NULL);
1241 /* n -> switch to next overview page */
1242 keymap_BindToString(ovwFrame->keymap, "n", Switch_ovw_next, NULL, NULL);
1243 /* N -> switch to last overview page */
1244 keymap_BindToString(ovwFrame->keymap, "N", Switch_ovw_last, NULL, NULL);
1245 /* p -> switch to previous overview page */
1246 keymap_BindToString(ovwFrame->keymap, "p", Switch_ovw_prev, NULL, NULL);
1247 /* P -> switch to first overview page */
1248 keymap_BindToString(ovwFrame->keymap, "P", Switch_ovw_first, NULL, NULL);
1252 } /* create_ovwFrame_objects */
1255 /*-----------------------------------------------------------------------
1259 * This function is called to determine the permissible keyboard
1260 * operations on the FS and CM frames. This information is used
1261 * to create an appropriate command line prompt. It also generates
1262 * a bit map of the permissible operations on this page which is
1263 * used by the keyboard-input handler routines.
1266 * Success: page-type (bit map of permissible operations)
1268 *----------------------------------------------------------------------*/
1271 resolve_CmdLine(char *a_buffer, /* buffer to copy command line */
1272 int a_currFrame, /* current frame ovw, fs or cm? */
1273 int a_currPage, /* current page number */
1274 int a_numPages, /* number of pages of data */
1275 int a_numCols, /* number of columns of data to display */
1276 int a_curr_LCol, /* current number of leftmost column */
1277 int a_cols_perPage, /* number of columns per page */
1278 int a_Data_Available)
1279 { /* resolve_CmdLine */
1280 static char rn[] = "resolve_CmdLine";
1285 "[ %s ] Called, a_buffer= %p, a_currFrame= %d, a_currPage= %d, a_numPages= %d, a_numCols= %d, a_curr_LCol= %d, a_cols_perPage= %d\n",
1286 rn, a_buffer, a_currFrame, a_currPage, a_numPages, a_numCols,
1287 a_curr_LCol, a_cols_perPage);
1293 /* determine if we have fs/cm frames. If we do, note that we should not
1294 * let the user seen the initial junk we have there until the probe
1295 * results are available */
1296 if (a_currFrame == 1) { /* in the fs frame */
1297 if (numCM && cm_Data_Available)
1299 } else if (a_currFrame == 2) { /* in the cm frame */
1300 if (numFS && fs_Data_Available)
1304 fprintf(debugFD, "[ %s ] Wrong frame type %d\n", rn, a_currFrame);
1310 /* do we have next/previous pages */
1311 if (a_currPage < a_numPages)
1312 pageType |= CMD_NEXT; /* have a next page */
1314 pageType |= CMD_PREV; /* have a previous page */
1316 if (a_numCols > a_cols_perPage) {
1317 if (a_curr_LCol > 0)
1318 pageType |= CMD_LEFT; /* have columns on left */
1319 if ((a_curr_LCol + a_cols_perPage) < a_numCols)
1320 pageType |= CMD_RIGHT; /* have columns on right */
1323 /* now build the command line */
1325 strcpy(a_buffer, "Command [oview");
1326 if (pageType & CMD_FS)
1327 strcat(a_buffer, ", fs");
1328 if (pageType & CMD_CM)
1329 strcat(a_buffer, ", cm");
1330 if (pageType & CMD_PREV)
1331 strcat(a_buffer, ", prev");
1332 if (pageType & CMD_NEXT)
1333 strcat(a_buffer, ", next");
1334 if (pageType & CMD_LEFT)
1335 strcat(a_buffer, ", left");
1336 if (pageType & CMD_RIGHT)
1337 strcat(a_buffer, ", right");
1338 strcat(a_buffer, "]? ");
1342 } /* resolve_CmdLine */
1344 /*-----------------------------------------------------------------------
1345 * display_Server_datum()
1348 * The data in the file server & cache manager frames are displayed
1349 * in two objects, one below the other. If the data is too long to
1350 * fit in the first object it will overflow into the next. This is
1351 * to conserve real estate on the screen. This function copies the
1352 * contents of the source buffer adjusted to the two objects if the
1353 * probe had succeded. Otherwise it enters "--" in the first object
1354 * blanks out the second. If the object needs to be highlightned
1355 * (due to a threshold crossing) it is done.
1359 *----------------------------------------------------------------------*/
1361 display_Server_datum(char *a_srcBuf, /* source buffer */
1362 struct onode *a_firstObj_o, /* first object */
1363 struct onode *a_secondObj_o, /* second object */
1364 int a_probeOK, /* probe OK ? */
1365 int a_just, /* justification */
1366 int a_highlight) /* highlight object ? */
1367 { /* display_Server_datum */
1369 static char rn[] = "display_Server_datum";
1370 struct gator_lightobj *tmp_lightobj1;
1371 struct gator_lightobj *tmp_lightobj2;
1372 char part1[FC_COLUMN_WIDTH + 2];
1373 char part2[FC_COLUMN_WIDTH + 2];
1379 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %p, a_secondObj_o= %p, a_probeOK= %d, a_just= %d, a_highlight= %d\n",
1380 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_probeOK,
1381 a_just, a_highlight);
1386 tmp_lightobj1 = (struct gator_lightobj *)a_firstObj_o->o_data;
1387 tmp_lightobj2 = (struct gator_lightobj *)a_secondObj_o->o_data;
1389 if (a_probeOK) { /* probe is ok so fill in the data */
1391 /* check if it would fit in one object */
1392 if (strlen(a_srcBuf) < FC_COLUMN_WIDTH) {
1393 strcpy(part1, a_srcBuf);
1396 /* break up the src string into 2 parts */
1397 /* note that column width includes terminator */
1398 strncpy(part1, a_srcBuf, FC_COLUMN_WIDTH - 1);
1399 part1[FC_COLUMN_WIDTH - 1] = '\0';
1400 strncpy(part2, a_srcBuf + FC_COLUMN_WIDTH - 1,
1401 FC_COLUMN_WIDTH - 1);
1405 } else { /* probe failed, enter "--"s */
1406 strcpy(part1, "--");
1410 /* if (afsmon_debug) {
1411 * fprintf(debugFD,"[ %s ] %s split to %s & %s\n",rn,a_srcBuf,part1,part2);
1415 /* initialize both the objects */
1418 justify_light(part1, tmp_lightobj1->label, FC_COLUMN_WIDTH, a_just,
1422 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1428 justify_light(part2, tmp_lightobj2->label, FC_COLUMN_WIDTH, a_just,
1432 fprintf(debugFD, "[ %s ] justify_light failed 1 \n", rn);
1437 /* highlight them */
1438 if (a_highlight && (part1[0] != '-'))
1439 gator_light_set(a_firstObj_o, 1);
1441 gator_light_set(a_firstObj_o, 0);
1442 if (a_highlight && (part2[0] != '\0'))
1443 gator_light_set(a_secondObj_o, 1);
1445 gator_light_set(a_secondObj_o, 0);
1451 } /* display_Server_datum */
1454 /*-----------------------------------------------------------------------
1455 * display_Server_label()
1458 * Display the given server label in three objects. The label is
1459 * partitioned into three parts by '/'s and each part is copied
1460 * into each label object.
1464 *----------------------------------------------------------------------*/
1467 display_Server_label(char *a_srcBuf,
1468 struct onode *a_firstObj_o, /* first object */
1469 struct onode *a_secondObj_o, /* second object */
1470 struct onode *a_thirdObj_o) /* third object */
1471 { /* display_Server_label */
1472 static char rn[] = "display_Server_label";
1473 char part[3][20]; /* buffer for three parts of label */
1475 struct gator_lightobj *tmp_lightobj;
1476 struct onode *objPtr_o[3];
1483 /* the following debug statement floods the debug file */
1484 #ifdef DEBUG_DETAILED
1487 "[ %s ] Called, a_srcBuf= %s, a_firstObj_o= %d, a_secondObj_o= %d, a_thirdObj_o= %d\n",
1488 rn, a_srcBuf, a_firstObj_o, a_secondObj_o, a_thirdObj_o);
1494 /* break the label string into three parts */
1499 /* now for a dumb precaution */
1501 strLen = strlen(a_srcBuf);
1504 for (i = 0; i < 3; i++) {
1506 while (*strPtr != '\0' && (len++ <= strLen)) {
1507 if (*strPtr == '/') {
1511 part[i][j] = *strPtr;
1519 * if (afsmon_debug) {
1520 * fprintf(debugFD,"[ %s ] LABELS %s -> %s %s %s\n",
1521 * rn, a_srcBuf, part[0], part[1], part[2]);
1526 objPtr_o[0] = a_firstObj_o;
1527 objPtr_o[1] = a_secondObj_o;
1528 objPtr_o[2] = a_thirdObj_o;
1530 /* display each label justified CENTER */
1532 for (i = 0; i < 3; i++) {
1533 tmp_lightobj = (struct gator_lightobj *)objPtr_o[i]->o_data;
1535 justify_light(part[i], tmp_lightobj->label, FC_COLUMN_WIDTH,
1539 fprintf(debugFD, "[ %s ] justify_light %d failed \n", rn, i);
1545 } /* display_Server_label */
1551 /*-----------------------------------------------------------------------
1555 * Refresh the File Servers screen with the given page number starting
1556 * at the given left-column number. The appropriate contents of
1557 * prev_fsData are displayed.
1558 * First the status labels at the four corners of the screen are
1559 * updated. Next the column labels are updated and then each row
1564 * Failure: Exits afsmoitor on a severe error.
1565 *----------------------------------------------------------------------*/
1569 fs_refresh(int a_pageNum, /* page to display */
1570 int a_LcolNum) /* starting (leftmost) column number */
1573 static char rn[] = "fs_refresh"; /* routine name */
1574 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
1575 struct fs_Display_Data *fsDataP; /* ptr to FS display data array */
1576 struct ServerInfo_line *tmp_fs_lines_P; /* tmp ptr to fs_lines */
1577 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
1578 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
1579 struct onode **fsLabels_o_Ptr1; /* ptr to label row 0 */
1580 struct onode **fsLabels_o_Ptr2; /* ptr to label row 1 */
1581 struct onode **fsLabels_o_Ptr3; /* ptr to label row 2 */
1582 char cmdLine[80]; /* buffer for command line */
1583 char printBuf[256]; /* buffer to print to screen */
1590 int dataIndex; /* index to the data[] field of
1591 * struct fs_Display_Data */
1594 fprintf(debugFD, "[ %s ] Called with row %d col %d \n", rn, a_pageNum,
1600 /* if the data is not yet available, ie., not one probe cycle has
1601 * completed, do nothing */
1603 if (!fs_Data_Available)
1607 /* validate the page number & column number */
1608 if (a_pageNum < 1 || a_pageNum > fs_numPages) {
1610 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
1616 if (a_LcolNum < 0 || a_LcolNum > fs_numCols) {
1618 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
1627 /* update the fixed labels */
1629 /* we reuse the ovw version lable and hence do not have to do anything
1632 /* page number label */
1633 tmp_lightobj = (struct gator_lightobj *)fs_pageNum_o->o_data;
1634 sprintf(printBuf, "[File Servers, p. %d of %d, c. %d of %d]", a_pageNum,
1635 fs_numPages, a_LcolNum + 1, fs_numCols);
1636 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
1638 gator_light_set(fs_pageNum_o, 1);
1640 /* file servers monitored label */
1641 tmp_lightobj = (struct gator_lightobj *)fs_numFS_o->o_data;
1642 sprintf(printBuf, "%d File Servers monitored, %d alerts on %d machines",
1643 numFS, num_fs_alerts, numHosts_onfs_alerts);
1644 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
1650 /* figure out what we need to show in the prompt & set the page type */
1651 /* the fs_pageType variable is in turn used by the keyboard handler
1652 * routines to call fs_refresh() with the correct parameters */
1654 fs_pageType = resolve_CmdLine(cmdLine, 1 /* fs frame */ , a_pageNum,
1655 fs_numPages, fs_numCols, a_LcolNum,
1656 fs_cols_perPage, 0);
1658 /* display the command line */
1659 tmp_lightobj = (struct gator_lightobj *)fs_cmd_o->o_data;
1660 sprintf(printBuf, "%s", cmdLine);
1661 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
1663 gator_light_set(fs_cmd_o, 1);
1665 /* update the probe number label */
1666 tmp_lightobj = (struct gator_lightobj *)fs_probeNum_o->o_data;
1667 sprintf(printBuf, "[FS probes %d, freq=%d sec]", afsmon_fs_prev_probeNum,
1669 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
1671 gator_light_set(fs_probeNum_o, 1);
1673 /* update "columns on left" signal */
1674 tmp_lightobj = (struct gator_lightobj *)fs_leftArrows_o->o_data;
1675 if (fs_pageType & CMD_LEFT)
1676 strcpy(printBuf, "<<<");
1678 strcpy(printBuf, "");
1679 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1681 gator_light_set(fs_leftArrows_o, 0);
1683 /* update "columns on right" signal */
1684 tmp_lightobj = (struct gator_lightobj *)fs_rightArrows_o->o_data;
1685 if (fs_pageType & CMD_RIGHT)
1686 strcpy(printBuf, ">>>");
1688 strcpy(printBuf, "");
1689 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
1691 gator_light_set(fs_rightArrows_o, 0);
1695 /* UPDATE THE COLUMN LABELS */
1697 /* the column index is also used to index the label arrays */
1698 labelIdx = a_LcolNum;
1700 /* get the pointers to the three arrays of label onodes */
1701 fsLabels_o_Ptr1 = fsLabels_o[0];
1702 fsLabels_o_Ptr2 = fsLabels_o[1];
1703 fsLabels_o_Ptr3 = fsLabels_o[2];
1705 for (k = 0; k < fs_cols_perPage; k++) {
1707 if (labelIdx < fs_numCols) {
1708 dataIndex = fs_Display_map[labelIdx];
1709 display_Server_label(fs_labels[dataIndex], *fsLabels_o_Ptr1,
1710 *fsLabels_o_Ptr2, *fsLabels_o_Ptr3);
1712 labelIdx++; /* next label */
1714 display_Server_label("//", *fsLabels_o_Ptr1, *fsLabels_o_Ptr2,
1718 fsLabels_o_Ptr1++; /* next onode in label row 1 */
1719 fsLabels_o_Ptr2++; /* next onode in label row 2 */
1720 fsLabels_o_Ptr3++; /* next onode in label row 3 */
1722 } /* labels for each column */
1725 /* UPDATE THE FILE SERVER STATISTICS */
1727 /* move to the right spot in the FS display data array */
1728 fsDataP = prev_fsData;
1730 for (i = 0; i < ((a_pageNum - 1) * fs_numHosts_perPage); i++) {
1735 if (fsIdx >= numFS) { /* whoops! screwed up */
1736 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
1740 /* get the pointer to the first line of onodes of the file server frame */
1741 tmp_fs_lines_P = fs_lines;
1743 for (i = 0; i < fs_numHosts_perPage; i++) {
1746 /* if this is the last page we may not have file servers to fill up
1747 * the page, so check the index */
1748 if (fsIdx < numFS) {
1750 if (fsDataP->hostName[0] == '\0') {
1751 sprintf(errMsg, "[ %s ] empty fs display entry \n", rn);
1755 /* display the hostname , first names only please! */
1757 sprintf(printBuf, "%s", fsDataP->hostName);
1758 for (j = 0; j < strlen(printBuf); j++) {
1759 if (printBuf[j] == '.') {
1766 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1768 justify_light(printBuf, tmp_lightobj->label,
1769 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
1771 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1776 /* use the current column value to index into the fs_Display_map
1777 * array to obtain the index of the item to display. check if its
1778 * overflow flag is set and highlight if so. if the probe had failed
1779 * enter "--" is all columns */
1781 /* each host has two rows of slots for datums. get the pointers to
1782 * both the arrays */
1784 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1785 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1786 fs_curr_RCol = a_LcolNum; /* starting column number from which
1787 * we are asked to display data */
1789 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
1791 /* if there is another column of data */
1792 if (fs_curr_RCol < fs_numCols) {
1794 dataIndex = fs_Display_map[fs_curr_RCol];
1796 display_Server_datum(fsDataP->data[dataIndex],
1799 fsDataP->probeOK, RIGHT_JUSTIFY,
1800 fsDataP->threshOvf[dataIndex]);
1803 } else { /* no more data, blank out columns */
1804 display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
1805 RIGHT_JUSTIFY, 0); /* no overflow */
1809 firstSlot_o_Ptr++; /* onode of next column */
1810 secondSlot_o_Ptr++; /* onode of next column */
1812 } /* for each column */
1814 /* the loop could have taken the right-column-index one over,
1816 if (fs_curr_RCol == fs_numCols)
1824 /* if fdIdx < numFS */
1825 /* if fsIdx >= numFS , blank out all succeding rows */
1826 if (fsIdx >= numFS) {
1828 /* blank out host name object */
1830 (struct gator_lightobj *)tmp_fs_lines_P->host_o->o_data;
1832 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
1835 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
1840 firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
1841 secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
1843 for (k = 0; k < fs_cols_perPage; k++) {
1844 display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
1845 RIGHT_JUSTIFY, 0); /* dont highlight */
1853 /* fsIDx >= numFS */
1854 tmp_fs_lines_P++; /* pointer to next line in the frame */
1855 fsDataP++; /* next host's data */
1856 fsIdx++; /* host index */
1859 } /* for each row in the File Servers frame */
1861 /* redraw the display if the File Servers screen is currently displayed */
1862 if (afsmon_win->w_frame == fsFrame)
1863 WOP_DISPLAY(afsmon_win);
1865 /* update the global page & column numbers to reflect the changes */
1866 fs_currPage = a_pageNum;
1867 fs_curr_LCol = a_LcolNum;;
1876 /*-----------------------------------------------------------------------
1880 * Switch from the File Server screen to the Overview Screen
1881 *----------------------------------------------------------------------*/
1883 Switch_fs_2_ovw(void *d1, void *d2)
1885 /* bind the overview frame to the window */
1886 gtxframe_SetFrame(afsmon_win, ovwFrame);
1890 /*-----------------------------------------------------------------------
1894 * Switch from the File Server screen to the Cache Managers screen.
1895 *----------------------------------------------------------------------*/
1897 Switch_fs_2_cm(void *d1, void *d2)
1899 if (fs_pageType & CMD_CM) {
1900 /* bind the overview Cache Managers to the window */
1901 gtxframe_SetFrame(afsmon_win, cmFrame);
1906 /*-----------------------------------------------------------------------
1910 * Switch to next page of file server screen
1911 *----------------------------------------------------------------------*/
1913 Switch_fs_next(void *d1, void *d2)
1915 if (fs_pageType & CMD_NEXT) {
1916 /* we have a next page, refresh with next page number */
1917 fs_refresh(fs_currPage + 1, fs_curr_LCol);
1923 /*-----------------------------------------------------------------------
1927 * Switch to last page of file server screen
1928 *----------------------------------------------------------------------*/
1930 Switch_fs_last(void *d1, void *d2)
1932 if (fs_pageType & CMD_NEXT) {
1933 /* we have a next page, refresh with the last page number */
1934 fs_refresh(fs_numPages, fs_curr_LCol);
1940 /*-----------------------------------------------------------------------
1944 * Switch to previous page of file server screen
1945 *----------------------------------------------------------------------*/
1947 Switch_fs_prev(void *d1, void *d2)
1949 if (fs_pageType & CMD_PREV) {
1950 /* we have a previous page, refresh with the rpevious page number */
1951 fs_refresh(fs_currPage - 1, fs_curr_LCol);
1956 /*-----------------------------------------------------------------------
1960 * Switch to first page of file server screen
1961 *----------------------------------------------------------------------*/
1963 Switch_fs_first(void *d1, void *d2)
1965 if (fs_pageType & CMD_PREV) {
1966 /* we have a previous page, got to first page */
1967 fs_refresh(1, fs_curr_LCol);
1972 /*-----------------------------------------------------------------------
1976 * Scroll left on the file server screen
1977 *----------------------------------------------------------------------*/
1979 Switch_fs_left(void *d1, void *d2)
1981 if (fs_pageType & CMD_LEFT) {
1982 /* we have columns on left, refresh with new column number */
1983 fs_refresh(fs_currPage, fs_curr_LCol - fs_cols_perPage);
1989 /*-----------------------------------------------------------------------
1990 * Switch_fs_leftmost()
1993 * Scroll to first column on the file server screen
1994 *----------------------------------------------------------------------*/
1996 Switch_fs_leftmost(void *d1, void *d2)
1998 if (fs_pageType & CMD_LEFT) {
1999 /* we have columns on left, go to the first */
2000 fs_refresh(fs_currPage, 0);
2005 /*-----------------------------------------------------------------------
2009 * Scroll right on the file server screen
2010 *----------------------------------------------------------------------*/
2012 Switch_fs_right(void *d1, void *d2)
2014 if (fs_pageType & CMD_RIGHT) {
2015 /* we have columns on right, refresh with new column number */
2016 fs_refresh(fs_currPage, fs_curr_LCol + fs_cols_perPage);
2021 /*-----------------------------------------------------------------------
2022 * Switch_fs_rightmost()
2025 * Scroll to last column on the file server screen
2026 *----------------------------------------------------------------------*/
2028 Switch_fs_rightmost(void *d1, void *d2)
2032 if (fs_pageType & CMD_RIGHT) {
2033 /* we have columns on right, go to the last column */
2034 if (fs_numCols % fs_cols_perPage)
2035 curr_LCol = (fs_numCols / fs_cols_perPage) * fs_cols_perPage;
2038 ((fs_numCols / fs_cols_perPage) - 1) * fs_cols_perPage;
2040 fs_refresh(fs_currPage, curr_LCol);
2046 /*-----------------------------------------------------------------------
2047 * create_FSframe_objects()
2050 * Create the gtx objects (onodes) for the Fileservers frame and setup
2051 * the keyboard bindings.
2052 * Only as many objects as can fit on the display are created. The
2053 * positions and lengths of all these objects are fixed at creation.
2054 * These objects are updated with new data at the end of each probe
2059 * Failure: Exits afsmonitor.
2060 *----------------------------------------------------------------------*/
2063 create_FSframe_objects(void)
2064 { /* create_FSframe_objects */
2065 static char rn[] = "create_FSframe_objects";
2066 struct ServerInfo_line *fs_lines_Ptr;
2067 struct onode **fs_data_o_Ptr;
2068 struct onode **fsLabels_o_Ptr;
2078 fprintf(debugFD, "[ %s ] Called\n", rn);
2082 /* create the command line object */
2084 initLightObject("Command [oview, cm, prev, next, left, right] ? ", 0,
2085 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2086 if (fs_cmd_o == NULL) {
2087 sprintf(errMsg, "[ %s ] Failed to create fs command onode\n", rn);
2090 gtxframe_AddToList(fsFrame, fs_cmd_o);
2091 gator_light_set(fs_cmd_o, HIGHLIGHT);
2093 /* we already have the dimensions for the frame - same as the ovw frame */
2094 /* use the ovw program name object for the fs screen too */
2096 gtxframe_AddToList(fsFrame, ovw_progName_o);
2099 /* create the page number object */
2101 initLightObject("[File Servers, p. X of X, c. Y of Y]",
2102 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2104 if (fs_pageNum_o == NULL) {
2105 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2108 gtxframe_AddToList(fsFrame, fs_pageNum_o);
2109 gator_light_set(fs_pageNum_o, HIGHLIGHT);
2111 /* create the probe number object */
2113 initLightObject("[FS probes 1, freq=30 sec]",
2114 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2115 FC_PROBENUM_O_WIDTH, afsmon_win);
2116 if (fs_probeNum_o == NULL) {
2117 sprintf(errMsg, "[ %s ] Failed to create fs probeNum onode\n", rn);
2120 gtxframe_AddToList(fsFrame, fs_probeNum_o);
2121 gator_light_set(fs_probeNum_o, HIGHLIGHT);
2124 /* create the numFS monitored object */
2127 (" 0 File Servers monitored, 0 alerts on 0 machines", 4, 2,
2128 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2129 if (fs_numFS_o == NULL) {
2131 "[ %s ] Failed to create numFS onode for the fs frame\n", rn);
2134 gtxframe_AddToList(fsFrame, fs_numFS_o);
2136 /* create the "more columns to left" indicator */
2138 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
2139 if (fs_leftArrows_o == NULL) {
2141 "[ %s ] Failed to create leftArrows onode for the fs frame\n",
2145 gtxframe_AddToList(fsFrame, fs_leftArrows_o);
2147 /* create the "more columns to right" indicator */
2149 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
2151 if (fs_rightArrows_o == NULL) {
2153 "[ %s ] Failed to create rightArrows onode for the fs frame\n",
2157 gtxframe_AddToList(fsFrame, fs_rightArrows_o);
2162 /* calculate the maximum number of hosts per page (2 rows per host) */
2163 fs_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
2165 /* determine the number of data columns that can fit in a page */
2166 fs_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
2169 fprintf(debugFD, "[ %s ] fs_numHosts_perPage=%d fs_cols_perPage=%d\n",
2170 rn, fs_numHosts_perPage, fs_cols_perPage);
2174 /* the above two variables give us the information needed to create
2175 * the objects for displaying the file server information */
2177 /* allocate memory for all the onode pointers required to display
2178 * the file server statistics */
2180 numBytes = fs_numHosts_perPage * sizeof(struct ServerInfo_line);
2181 fs_lines = malloc(numBytes);
2182 if (fs_lines == (struct ServerInfo_line *)0) {
2184 "[ %s ] Failed to allocate %d bytes for FS data lines\n", rn,
2189 /* for each line of server statistics allocate memory to store two arrays
2192 fs_lines_Ptr = fs_lines;
2193 for (i = 0; i < fs_numHosts_perPage; i++) {
2194 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
2195 numBytes = fs_cols_perPage * sizeof(struct onode *);
2196 fs_lines_Ptr->data_o[arrIdx] = malloc(numBytes);
2197 if (fs_lines_Ptr->data_o[arrIdx] == NULL) {
2199 "[ %s ] Failed to allocate %d bytes for FS data onodes\n",
2207 /* now allocate the onodes itself */
2209 fs_lines_Ptr = fs_lines;
2210 for (i = 0; i < fs_numHosts_perPage; i++) {
2212 /* initialize host name onode */
2213 fs_lines_Ptr->host_o =
2214 initLightObject("FSHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
2215 FC_HOSTNAME_O_WIDTH, afsmon_win);
2216 if (fs_lines_Ptr->host_o == NULL) {
2217 sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
2220 gtxframe_AddToList(fsFrame, fs_lines_Ptr->host_o);
2222 /* if (afsmon_debug) {
2223 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
2224 * rn,fs_lines_Ptr->host_o,i);
2228 /* initialize data onodes for this host */
2230 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
2232 fs_data_o_Ptr = fs_lines_Ptr->data_o[arrIdx];
2233 for (j = 0; j < fs_cols_perPage; j++) { /* for each column */
2237 /* determine x & y coordinate for this data object */
2238 /* the 1's are for leaving a blank after each column */
2239 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
2240 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
2242 sprintf(tmpBuf, "-FSData %d-", arrIdx);
2244 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
2246 if (*fs_data_o_Ptr == NULL) {
2248 "[ %s ] Failed to create an FS data onode\n", rn);
2251 gtxframe_AddToList(fsFrame, *fs_data_o_Ptr);
2254 } /* for each column */
2255 } /* for each onode array index */
2258 } /* for each host slot */
2261 /* INITIALIZE COLUMN LABELS */
2264 /* allocate memory for two arrays of onode pointers for file server column
2266 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
2268 fsLabels_o[arrIdx] = malloc(sizeof(struct onode *) * fs_cols_perPage);
2269 if (fsLabels_o[arrIdx] == NULL) {
2271 "[ %s ] Failed to allocate memory for FS label onodes\n",
2276 /* create cache manager name objects */
2277 fsLabels_o_Ptr = fsLabels_o[arrIdx];
2278 for (i = 0; i < fs_cols_perPage; i++) {
2280 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
2281 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
2284 if (*fsLabels_o_Ptr == NULL) {
2285 sprintf(errMsg, "[ %s ] Failed to create a FS label onode\n",
2289 gtxframe_AddToList(fsFrame, *fsLabels_o_Ptr);
2296 /* initialize the column & page counters */
2299 fs_numCols = fs_DisplayItems_count;
2300 fs_numPages = numFS / fs_numHosts_perPage;
2301 if (numFS % fs_numHosts_perPage)
2303 fs_curr_LCol = 0; /* leftmost col */
2304 fs_curr_RCol = 0; /* rightmost col */
2306 /* create keyboard bindings */
2307 /* bind Q and
\ 3 to exit */
2308 keymap_BindToString(fsFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
2309 keymap_BindToString(fsFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
2311 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
2312 * N = last page, P = first page, L = leftmost col, R = rightmost col */
2314 keymap_BindToString(fsFrame->keymap, "o", Switch_fs_2_ovw, NULL, NULL);
2315 keymap_BindToString(fsFrame->keymap, "c", Switch_fs_2_cm, NULL, NULL);
2316 keymap_BindToString(fsFrame->keymap, "n", Switch_fs_next, NULL, NULL);
2317 keymap_BindToString(fsFrame->keymap, "N", Switch_fs_last, NULL, NULL);
2318 keymap_BindToString(fsFrame->keymap, "p", Switch_fs_prev, NULL, NULL);
2319 keymap_BindToString(fsFrame->keymap, "P", Switch_fs_first, NULL, NULL);
2320 keymap_BindToString(fsFrame->keymap, "l", Switch_fs_left, NULL, NULL);
2321 keymap_BindToString(fsFrame->keymap, "L", Switch_fs_leftmost, NULL, NULL);
2322 keymap_BindToString(fsFrame->keymap, "r", Switch_fs_right, NULL, NULL);
2323 keymap_BindToString(fsFrame->keymap, "R", Switch_fs_rightmost, NULL,
2327 } /* create_FSframe_objects */
2330 /*-----------------------------------------------------------------------
2331 * Function: cm_refresh()
2334 * Refresh the Cache Managers screen with the given page number starting
2335 * at the given left-column number. The appropriate contents of
2336 * prev_cmData are displayed.
2337 * First the status labels at the four corners of the screen are
2338 * updated. Next the column labels are updated and then each row
2343 * Failure: Exits afsmoitor on a severe error.
2344 *----------------------------------------------------------------------*/
2347 cm_refresh(int a_pageNum, /* page to display */
2348 int a_LcolNum) /* starting (leftmost) column number */
2351 static char rn[] = "cm_refresh"; /* routine name */
2352 struct gator_lightobj *tmp_lightobj; /* ptr for object's display data */
2353 struct cm_Display_Data *cmDataP; /* ptr to CM display data array */
2354 struct ServerInfo_line *tmp_cm_lines_P; /* tmp ptr to cm_lines */
2355 struct onode **firstSlot_o_Ptr; /* ptr to first data slot of a datum */
2356 struct onode **secondSlot_o_Ptr; /* ptr to second data slot of a datum */
2357 struct onode **cmLabels_o_Ptr1; /* ptr to label row 0 */
2358 struct onode **cmLabels_o_Ptr2; /* ptr to label row 1 */
2359 struct onode **cmLabels_o_Ptr3; /* ptr to label row 2 */
2360 char cmdLine[80]; /* buffer for command line */
2361 char printBuf[256]; /* buffer to print to screen */
2368 int dataIndex; /* index to the data[] field of
2369 * struct cm_Display_Data */
2372 fprintf(debugFD, "[ %s ] Called, a_pageNum= %d, a_LcolNum= %d \n", rn,
2373 a_pageNum, a_LcolNum);
2378 /* if the data is not yet available, ie., not one probe cycle has
2379 * completed, do nothing */
2381 if (!cm_Data_Available)
2385 /* validate the page number & column number */
2386 if (a_pageNum < 1 || a_pageNum > cm_numPages) {
2388 fprintf(debugFD, "[ %s ] Called with wrong page # %d \n", rn,
2394 if (a_LcolNum < 0 || a_LcolNum > cm_numCols) {
2396 fprintf(debugFD, "[ %s ] Called with wrong column #%d\n", rn,
2405 /* update the fixed labels */
2407 /* we reuse the ovw version lable and hence do not have to do anything
2410 /* page number label */
2411 tmp_lightobj = (struct gator_lightobj *)cm_pageNum_o->o_data;
2412 sprintf(printBuf, "[Cache Managers, p.%d of %d, c.%d of %d]", a_pageNum,
2413 cm_numPages, a_LcolNum + 1, cm_numCols);
2414 justify_light(printBuf, tmp_lightobj->label, FC_PAGENUM_O_WIDTH,
2416 gator_light_set(cm_pageNum_o, 1);
2418 /* file servers monitored label */
2419 tmp_lightobj = (struct gator_lightobj *)cm_numCM_o->o_data;
2420 sprintf(printBuf, "%d Cache Managers monitored, %d alerts on %d machines",
2421 numCM, num_cm_alerts, numHosts_oncm_alerts);
2422 justify_light(printBuf, tmp_lightobj->label, FC_NUMHOSTS_O_WIDTH, CENTER,
2428 /* figure out what we need to show in the prompt & set the page type */
2429 /* the cm_pageType variable is in turn used by the keyboard handler
2430 * routines to call cm_refresh() with the correct parameters */
2432 cm_pageType = resolve_CmdLine(cmdLine, 2 /* cm frame */ , a_pageNum,
2433 cm_numPages, cm_numCols, a_LcolNum,
2434 cm_cols_perPage, 0);
2436 /* display the command line */
2437 tmp_lightobj = (struct gator_lightobj *)cm_cmd_o->o_data;
2438 sprintf(printBuf, "%s", cmdLine);
2439 justify_light(printBuf, tmp_lightobj->label, strlen(printBuf) + 1,
2441 gator_light_set(cm_cmd_o, 1);
2443 /* update the probe number label */
2444 tmp_lightobj = (struct gator_lightobj *)cm_probeNum_o->o_data;
2445 sprintf(printBuf, "[CM probes %d, freq=%d sec]", afsmon_cm_prev_probeNum,
2447 justify_light(printBuf, tmp_lightobj->label, FC_PROBENUM_O_WIDTH,
2449 gator_light_set(cm_cmd_o, 1);
2451 /* update "columns on left" signal */
2452 tmp_lightobj = (struct gator_lightobj *)cm_leftArrows_o->o_data;
2453 if (cm_pageType & CMD_LEFT)
2454 strcpy(printBuf, "<<<");
2456 strcpy(printBuf, "");
2457 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2459 gator_light_set(cm_leftArrows_o, 0);
2461 /* update "columns on right" signal */
2462 tmp_lightobj = (struct gator_lightobj *)cm_rightArrows_o->o_data;
2463 if (cm_pageType & CMD_RIGHT)
2464 strcpy(printBuf, ">>>");
2466 strcpy(printBuf, "");
2467 justify_light(printBuf, tmp_lightobj->label, FC_ARROWS_O_WIDTH,
2469 gator_light_set(cm_rightArrows_o, 0);
2473 /* UPDATE THE COLUMN LABELS */
2475 /* the column index is also used to index the label arrays */
2476 labelIdx = a_LcolNum;
2478 /* get the pointers to the three arrays of label onodes */
2479 cmLabels_o_Ptr1 = cmLabels_o[0];
2480 cmLabels_o_Ptr2 = cmLabels_o[1];
2481 cmLabels_o_Ptr3 = cmLabels_o[2];
2483 for (k = 0; k < cm_cols_perPage; k++) {
2485 if (labelIdx < cm_numCols) {
2486 dataIndex = cm_Display_map[labelIdx];
2487 display_Server_label(cm_labels[dataIndex], *cmLabels_o_Ptr1,
2488 *cmLabels_o_Ptr2, *cmLabels_o_Ptr3);
2490 labelIdx++; /* next label */
2492 display_Server_label("//", *cmLabels_o_Ptr1, *cmLabels_o_Ptr2,
2496 cmLabels_o_Ptr1++; /* next onode in label row 1 */
2497 cmLabels_o_Ptr2++; /* next onode in label row 2 */
2498 cmLabels_o_Ptr3++; /* next onode in label row 3 */
2500 } /* labels for each column */
2503 /* UPDATE THE FILE SERVER STATISTICS */
2505 /* move to the right spot in the CM display data array */
2506 cmDataP = prev_cmData;
2508 for (i = 0; i < ((a_pageNum - 1) * cm_numHosts_perPage); i++) {
2513 if (cmIdx >= numCM) { /* whoops! screwed up */
2514 sprintf(errMsg, "[ %s ] Programming error 1\n", rn);
2518 /* get the pointer to the first line of onodes of the file server frame */
2519 tmp_cm_lines_P = cm_lines;
2521 for (i = 0; i < cm_numHosts_perPage; i++) {
2524 /* if this is the last page we may not have file servers to fill up
2525 * the page, so check the index */
2526 if (cmIdx < numCM) {
2528 if (cmDataP->hostName[0] == '\0') {
2529 sprintf(errMsg, "[ %s ] empty cm display entry \n", rn);
2533 /* display the hostname , first names only please! */
2535 sprintf(printBuf, "%s", cmDataP->hostName);
2536 for (j = 0; j < strlen(printBuf); j++) {
2537 if (printBuf[j] == '.') {
2544 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2546 justify_light(printBuf, tmp_lightobj->label,
2547 FC_HOSTNAME_O_WIDTH, LEFT_JUSTIFY, 1);
2549 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2554 /* use the current column value to index into the cm_Display_map
2555 * array to obtain the index of the item to display. check if its
2556 * overflow flag is set and highlight if so. if the probe had failed
2557 * enter "--" is all columns */
2559 /* each host has two rows of slots for datums. get the pointers to
2560 * both the arrays */
2562 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2563 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2564 cm_curr_RCol = a_LcolNum; /* starting column number from which
2565 * we are asked to display data */
2567 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
2569 /* if there is another column of data */
2570 if (cm_curr_RCol < cm_numCols) {
2572 dataIndex = cm_Display_map[cm_curr_RCol];
2574 display_Server_datum(cmDataP->data[dataIndex],
2577 cmDataP->probeOK, RIGHT_JUSTIFY,
2578 cmDataP->threshOvf[dataIndex]);
2581 } else { /* no more data, blank out columns */
2582 display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe ok */
2583 RIGHT_JUSTIFY, 0); /* no overflow */
2587 firstSlot_o_Ptr++; /* onode of next column */
2588 secondSlot_o_Ptr++; /* onode of next column */
2590 } /* for each column */
2592 /* the loop could have taken the right-column-index one over,
2594 if (cm_curr_RCol == cm_numCols)
2602 /* if fdIdx < numCM */
2603 /* if cmIdx >= numCM , blank out all succeding rows */
2604 if (cmIdx >= numCM) {
2606 /* blank out host name object */
2608 (struct gator_lightobj *)tmp_cm_lines_P->host_o->o_data;
2610 justify_light("", tmp_lightobj->label, FC_HOSTNAME_O_WIDTH,
2613 fprintf(debugFD, "[ %s ] justify_code returned %d\n", rn,
2618 firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
2619 secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
2621 for (k = 0; k < cm_cols_perPage; k++) {
2622 display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
2623 RIGHT_JUSTIFY, 0); /* dont highlight */
2631 /* cmIDx >= numCM */
2632 tmp_cm_lines_P++; /* pointer to next line in the frame */
2633 cmDataP++; /* next host's data */
2634 cmIdx++; /* host index */
2637 } /* for each row in the Cache Manager frame */
2639 /* redraw the display if the Cache Managers screen is currently displayed */
2640 if (afsmon_win->w_frame == cmFrame)
2641 WOP_DISPLAY(afsmon_win);
2643 /* update the global page & column numbers to reflect the changes */
2644 cm_currPage = a_pageNum;
2645 cm_curr_LCol = a_LcolNum;;
2653 /*-----------------------------------------------------------------------
2657 * Switch from the Cache Manager screen to the Overview Screen
2658 *----------------------------------------------------------------------*/
2660 Switch_cm_2_ovw(void *d1, void *d2)
2662 /* bind the overview frame to the window */
2663 gtxframe_SetFrame(afsmon_win, ovwFrame);
2667 /*-----------------------------------------------------------------------
2671 * Switch from the Cache Manager screen to the File Servers screen
2672 *----------------------------------------------------------------------*/
2674 Switch_cm_2_fs(void *d1, void *d2)
2676 if (cm_pageType & CMD_FS) {
2677 /* bind the file servers frame to the window */
2678 gtxframe_SetFrame(afsmon_win, fsFrame);
2683 /*-----------------------------------------------------------------------
2687 * Switch to next page of cache managers screen
2688 *----------------------------------------------------------------------*/
2690 Switch_cm_next(void *d1, void *d2)
2692 if (cm_pageType & CMD_NEXT) {
2693 /* we have a next page, refresh with next page number */
2694 cm_refresh(cm_currPage + 1, cm_curr_LCol);
2700 /*-----------------------------------------------------------------------
2704 * Switch to last page of file server screen
2705 *----------------------------------------------------------------------*/
2707 Switch_cm_last(void *d1, void *d2)
2709 if (cm_pageType & CMD_NEXT) {
2710 /* we have a next page, refresh with last page number */
2711 cm_refresh(cm_numPages, cm_curr_LCol);
2717 /*-----------------------------------------------------------------------
2721 * Switch to previous page of cache managers screen
2722 *----------------------------------------------------------------------*/
2724 Switch_cm_prev(void *d1, void *d2)
2726 if (cm_pageType & CMD_PREV) {
2727 /* we have a previous page, refresh to previous page */
2728 cm_refresh(cm_currPage - 1, cm_curr_LCol);
2733 /*-----------------------------------------------------------------------
2737 * Switch to first page of cache managers screen
2738 *----------------------------------------------------------------------*/
2740 Switch_cm_first(void *d1, void *d2)
2742 if (cm_pageType & CMD_PREV) {
2743 /* we have a previous page, refresh to first page */
2744 cm_refresh(1, cm_curr_LCol);
2749 /*-----------------------------------------------------------------------
2753 * Scroll left on the cache managers screen
2754 *----------------------------------------------------------------------*/
2756 Switch_cm_left(void *d1, void *d2)
2758 if (cm_pageType & CMD_LEFT) {
2759 /* we have columns on left, refresh with new column number */
2760 cm_refresh(cm_currPage, cm_curr_LCol - cm_cols_perPage);
2766 /*-----------------------------------------------------------------------
2767 * Switch_cm_leftmost()
2770 * Scroll to first column on the cache managers screen
2771 *----------------------------------------------------------------------*/
2773 Switch_cm_leftmost(void *d1, void *d2)
2775 if (cm_pageType & CMD_LEFT) {
2776 /* we have columns on left, go to the first column */
2777 cm_refresh(cm_currPage, 0);
2782 /*-----------------------------------------------------------------------
2786 * Scroll right on the cache managers screen
2787 *----------------------------------------------------------------------*/
2789 Switch_cm_right(void *d1, void *d2)
2791 if (cm_pageType & CMD_RIGHT) {
2792 /* we have columns on right, refresh with new column number */
2793 cm_refresh(cm_currPage, cm_curr_LCol + cm_cols_perPage);
2798 /*-----------------------------------------------------------------------
2799 * Switch_cm_rightmost()
2802 * Scroll to last column on the cache managers screen
2803 *----------------------------------------------------------------------*/
2805 Switch_cm_rightmost(void *d1, void *d2)
2809 if (cm_pageType & CMD_RIGHT) {
2810 /* we have columns on right, go to the last column */
2811 if (cm_numCols % cm_cols_perPage)
2812 curr_LCol = (cm_numCols / cm_cols_perPage) * cm_cols_perPage;
2815 ((cm_numCols / cm_cols_perPage) - 1) * cm_cols_perPage;
2816 cm_refresh(cm_currPage, curr_LCol);
2822 /*-----------------------------------------------------------------------
2823 * create_CMframe_objects()
2826 * Create the gtx objects (onodes) for the Cache Managers frame and setup
2827 * the keyboard bindings.
2828 * Only as many objects as can fit on the display are created. The
2829 * positions and lengths of all these objects are fixed at creation.
2830 * These objects are updated with new data at the end of each probe
2835 * Failure: Exits afsmonitor.
2836 *----------------------------------------------------------------------*/
2839 create_CMframe_objects(void)
2840 { /* create_CMframe_objects */
2841 static char rn[] = "create_CMframe_objects";
2842 struct ServerInfo_line *cm_lines_Ptr;
2843 struct onode **cm_data_o_Ptr;
2844 struct onode **cmLabels_o_Ptr;
2853 fprintf(debugFD, "[ %s ] Called\n", rn);
2859 /* create the command line object */
2861 initLightObject("Command [oview, fs, prev, next, left, right] ? ", 0,
2862 maxY - 1, FC_CMD_O_WIDTH, afsmon_win);
2863 if (cm_cmd_o == NULL) {
2864 sprintf(errMsg, "[ %s ] Failed to create cm command onode\n", rn);
2867 gtxframe_AddToList(cmFrame, cm_cmd_o);
2868 gator_light_set(cm_cmd_o, HIGHLIGHT);
2871 /* we already have the dimensions for the frame - same as the ovw frame */
2872 /* use the ovw program name object for the cm screen too */
2874 gtxframe_AddToList(cmFrame, ovw_progName_o);
2877 /* create the page number object */
2879 initLightObject("[Cache Managers, p. X of X, c. Y of Y]",
2880 maxX - FC_PAGENUM_O_WIDTH, 0, FC_PAGENUM_O_WIDTH,
2882 if (cm_pageNum_o == NULL) {
2883 sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
2886 gtxframe_AddToList(cmFrame, cm_pageNum_o);
2887 gator_light_set(cm_pageNum_o, HIGHLIGHT);
2889 /* create the probe number object */
2891 initLightObject("[CM probes 1, freq=30 sec]",
2892 maxX - FC_PROBENUM_O_WIDTH, maxY - 1,
2893 FC_PROBENUM_O_WIDTH, afsmon_win);
2894 if (cm_probeNum_o == NULL) {
2895 sprintf(errMsg, "[ %s ] Failed to create cm probeNum onode\n", rn);
2898 gtxframe_AddToList(cmFrame, cm_probeNum_o);
2899 gator_light_set(cm_probeNum_o, HIGHLIGHT);
2902 /* create the numCM monitored object */
2905 (" 0 Cache Mangers monitored, 0 alerts on 0 machines", 4, 2,
2906 FC_NUMHOSTS_O_WIDTH, afsmon_win);
2907 if (cm_numCM_o == NULL) {
2909 "[ %s ] Failed to create numCM onode for the cm frame\n", rn);
2912 gtxframe_AddToList(cmFrame, cm_numCM_o);
2914 /* create the "more columns to left" indicator */
2916 initLightObject("<<<", 0, 2, FC_ARROWS_O_WIDTH, afsmon_win);
2917 if (cm_leftArrows_o == NULL) {
2919 "[ %s ] Failed to create leftArrows onode for the cm frame\n",
2923 gtxframe_AddToList(cmFrame, cm_leftArrows_o);
2925 /* create the "more columns to right" indicator */
2927 initLightObject(">>>", maxX - FC_ARROWS_O_WIDTH, 2, FC_ARROWS_O_WIDTH,
2929 if (cm_rightArrows_o == NULL) {
2931 "[ %s ] Failed to create rightArrows onode for the cm frame\n",
2935 gtxframe_AddToList(cmFrame, cm_rightArrows_o);
2940 /* calculate the maximum number of hosts per page (2 rows per host) */
2941 cm_numHosts_perPage = (maxY - FC_NUM_FIXED_LINES) / 2;
2943 /* determine the number of data columns that can fit in a page */
2944 cm_cols_perPage = (maxX - FC_HOSTNAME_O_WIDTH) / (FC_COLUMN_WIDTH);
2947 fprintf(debugFD, "[ %s ] cm_numHosts_perPage=%d cm_cols_perPage=%d\n",
2948 rn, cm_numHosts_perPage, cm_cols_perPage);
2952 /* the above two variables give us the information needed to create
2953 * the objects for displaying the file server information */
2955 /* allocate memory for all the onode pointers required to display
2956 * the file server statistics */
2958 numBytes = cm_numHosts_perPage * sizeof(struct ServerInfo_line);
2959 cm_lines = malloc(numBytes);
2960 if (cm_lines == (struct ServerInfo_line *)0) {
2962 "[ %s ] Failed to allocate %d bytes for CM data lines\n", rn,
2967 /* for each line of server statistics allocate memory to store two arrays
2970 cm_lines_Ptr = cm_lines;
2971 for (i = 0; i < cm_numHosts_perPage; i++) {
2972 for (arrIdx = 0; arrIdx < 2; arrIdx++) {
2973 numBytes = cm_cols_perPage * sizeof(struct onode *);
2974 cm_lines_Ptr->data_o[arrIdx] = malloc(numBytes);
2975 if (cm_lines_Ptr->data_o[arrIdx] == NULL) {
2977 "[ %s ] Failed to allocate %d bytes for CM data onodes\n",
2985 /* now allocate the onodes itself */
2987 cm_lines_Ptr = cm_lines;
2988 for (i = 0; i < cm_numHosts_perPage; i++) {
2990 /* initialize host name onode */
2991 cm_lines_Ptr->host_o =
2992 initLightObject("CMHostName", 0, FC_FIRST_HOST_ROW + 2 * i,
2993 FC_HOSTNAME_O_WIDTH, afsmon_win);
2994 if (cm_lines_Ptr->host_o == NULL) {
2995 sprintf(errMsg, "[ %s ] Failed to create an CM name onode\n", rn);
2998 gtxframe_AddToList(cmFrame, cm_lines_Ptr->host_o);
3000 /* if (afsmon_debug) {
3001 * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
3002 * rn,cm_lines_Ptr->host_o,i);
3006 /* initialize data onodes for this host */
3008 for (arrIdx = 0; arrIdx < 2; arrIdx++) { /* for each array index */
3010 cm_data_o_Ptr = cm_lines_Ptr->data_o[arrIdx];
3011 for (j = 0; j < cm_cols_perPage; j++) { /* for each column */
3015 /* determine x & y coordinate for this data object */
3016 /* the 1's are for leaving a blank after each column */
3017 x_pos = FC_HOSTNAME_O_WIDTH + (j * (FC_COLUMN_WIDTH));
3018 y_pos = FC_FIRST_HOST_ROW + 2 * i + arrIdx;
3020 sprintf(tmpBuf, "-CMData %d-", arrIdx);
3022 initLightObject(tmpBuf, x_pos, y_pos, FC_COLUMN_WIDTH,
3024 if (*cm_data_o_Ptr == NULL) {
3026 "[ %s ] Failed to create an CM data onode\n", rn);
3029 gtxframe_AddToList(cmFrame, *cm_data_o_Ptr);
3032 } /* for each column */
3033 } /* for each onode array index */
3036 } /* for each host slot */
3039 /* INITIALIZE COLUMN LABELS */
3042 /* allocate memory for two arrays of onode pointers for file server column
3044 for (arrIdx = 0; arrIdx < 3; arrIdx++) {
3046 cmLabels_o[arrIdx] = malloc(sizeof(struct onode *) * cm_cols_perPage);
3047 if (cmLabels_o[arrIdx] == NULL) {
3049 "[ %s ] Failed to allocate memory for CM label onodes\n",
3054 /* create cache manager name objects */
3055 cmLabels_o_Ptr = cmLabels_o[arrIdx];
3056 for (i = 0; i < cm_cols_perPage; i++) {
3058 initLightObject("", FC_HOSTNAME_O_WIDTH + i * FC_COLUMN_WIDTH,
3059 FC_FIRST_LABEL_ROW + arrIdx, FC_COLUMN_WIDTH,
3062 if (*cmLabels_o_Ptr == NULL) {
3063 sprintf(errMsg, "[ %s ] Failed to create a CM label onode\n",
3067 gtxframe_AddToList(cmFrame, *cmLabels_o_Ptr);
3073 /* initialize the column & page counters */
3076 cm_numCols = cm_DisplayItems_count;
3077 cm_numPages = numCM / cm_numHosts_perPage;
3078 if (numCM % cm_numHosts_perPage)
3080 cm_curr_LCol = 0; /* leftmost col */
3081 cm_curr_RCol = 0; /* rightmost col */
3083 /* create keyboard bindings */
3084 /* bind Q and
\ 3 to exit */
3085 keymap_BindToString(cmFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
3086 keymap_BindToString(cmFrame->keymap, "
\ 3", afsmonExit_gtx, NULL, NULL);
3088 /* o = overview, c = cm, n = next, p = prev, l = left, r = right
3089 * N = last page, P = first page, L = leftmost col, R = rightmost col */
3091 keymap_BindToString(cmFrame->keymap, "o", Switch_cm_2_ovw, NULL, NULL);
3092 keymap_BindToString(cmFrame->keymap, "f", Switch_cm_2_fs, NULL, NULL);
3093 keymap_BindToString(cmFrame->keymap, "n", Switch_cm_next, NULL, NULL);
3094 keymap_BindToString(cmFrame->keymap, "N", Switch_cm_last, NULL, NULL);
3095 keymap_BindToString(cmFrame->keymap, "p", Switch_cm_prev, NULL, NULL);
3096 keymap_BindToString(cmFrame->keymap, "P", Switch_cm_first, NULL, NULL);
3097 keymap_BindToString(cmFrame->keymap, "l", Switch_cm_left, NULL, NULL);
3098 keymap_BindToString(cmFrame->keymap, "L", Switch_cm_leftmost, NULL, NULL);
3099 keymap_BindToString(cmFrame->keymap, "r", Switch_cm_right, NULL, NULL);
3100 keymap_BindToString(cmFrame->keymap, "R", Switch_cm_rightmost, NULL,
3104 } /* create_CMframe_objects */
3108 /*-----------------------------------------------------------------------
3112 * Initialize the gtx package and call routines to create the objects
3113 * for the overview, File Servers & Cache Managers screens.
3114 *----------------------------------------------------------------------*/
3116 gtx_initialize(void)
3117 { /* gtx_initialize */
3118 static char rn[] = "gtx_initialize"; /* routine name */
3122 fprintf(debugFD, "[ %s ] Called\n", rn);
3126 afsmon_win = gtx_Init(0, -1); /* 0 => dont start input server,
3127 * 1 => use curses */
3128 if (afsmon_win == NULL) {
3129 sprintf(errMsg, "[ %s ] gtx initialization failed\n", rn);
3132 gtx_initialized = 1;
3134 /* Create the Overview frame */
3136 ovwFrame = gtxframe_Create();
3137 if (ovwFrame == (struct gtx_frame *)0) {
3138 sprintf(errMsg, "[ %s ] Failed to create overview frame\n", rn);
3142 /* bind the overview frame to the window */
3143 gtxframe_SetFrame(afsmon_win, ovwFrame);
3145 /* create overview frame objects */
3146 code = create_ovwFrame_objects();
3148 sprintf(errMsg, "[ %s ] Error in creating ovw frame objects\n", rn);
3153 /* Create the File Server frame */
3154 fsFrame = gtxframe_Create();
3155 if (fsFrame == (struct gtx_frame *)0) {
3156 sprintf(errMsg, "[ %s ] Failed to create file server frame\n", rn);
3161 /* Create File Server frame objects */
3162 code = create_FSframe_objects();
3164 sprintf(errMsg, "[ %s ] Error in creating FS frame objects\n", rn);
3168 /* Create the Cache Managers frame */
3169 cmFrame = gtxframe_Create();
3170 if (cmFrame == (struct gtx_frame *)0) {
3171 sprintf(errMsg, "[ %s ] Failed to create Cache Managers frame\n", rn);
3175 /* Create Cache Managers frame objects */
3176 code = create_CMframe_objects();
3178 sprintf(errMsg, "[ %s ] Error in creating CM frame objects\n", rn);
3182 /* misc initializations */
3183 sprintf(blankline, "%255s", " ");
3186 } /* gtx_initialize */