| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | #include <afsconfig.h> |
| 15 | #include <afs/param.h> |
| 16 | |
| 17 | #include <roken.h> |
| 18 | |
| 19 | #undef IN |
| 20 | #include <afs/gtxwindows.h> /*Generic window package */ |
| 21 | #include <afs/gtxobjects.h> /*Object definitions */ |
| 22 | #include <afs/gtxtextobj.h> /*Text object interface */ |
| 23 | #include <afs/gtxlightobj.h> /*Light object interface */ |
| 24 | #include <afs/gtxcurseswin.h> /*Curses window package */ |
| 25 | #include <afs/gtxdumbwin.h> /*Dumb terminal window package */ |
| 26 | #include <afs/gtxX11win.h> /*X11 window package */ |
| 27 | #include <afs/gtxframe.h> /*Frame package */ |
| 28 | #include <afs/gtxinput.h> |
| 29 | #include <afs/cmd.h> /*Command interpretation library */ |
| 30 | #include <afs/fsprobe.h> /*Interface for fsprobe module */ |
| 31 | #include <afs/afsutil.h> |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | #define P_SERVER0 0 |
| 37 | #define P_BASE1 1 |
| 38 | #if 0 |
| 39 | #define P_PACKAGE 2 |
| 40 | #endif /* 0 */ |
| 41 | #define P_FREQ2 2 |
| 42 | #define P_HOST3 3 |
| 43 | #define P_ATTENTION4 4 |
| 44 | #define P_DEBUG5 5 |
| 45 | #define P_WIDTHS6 6 |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | #define LIGHTOBJ_CONN_WIDTH5 5 |
| 51 | #define LIGHTOBJ_FETCH_WIDTH10 10 |
| 52 | #define LIGHTOBJ_STORE_WIDTH10 10 |
| 53 | #define LIGHTOBJ_WK_WIDTH5 5 |
| 54 | #define LIGHTOBJ_SRVNAME_WIDTH13 13 |
| 55 | #define LIGHTOBJ_DISK_WIDTH12 12 |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | #define COL_CONN0 0 |
| 61 | #define COL_FETCH1 1 |
| 62 | #define COL_STORE2 2 |
| 63 | #define COL_WK3 3 |
| 64 | #define COL_SRVNAME4 4 |
| 65 | #define COL_DISK5 5 |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | #define SCOUT_RIGHT_JUSTIFY0 0 |
| 71 | #define SCOUT_LEFT_JUSTIFY1 1 |
| 72 | #define SCOUT_CENTER2 2 |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | #define SCOUT_LEFT_TRUNC0 0 |
| 78 | #define SCOUT_RIGHT_TRUNC1 1 |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | #define SCOUT_ISNT_LDISK0 0 |
| 84 | #define SCOUT_IS_LDISK1 1 |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | #define SCOUT_NIL(-1) (-1) |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | struct scout_disk { |
| 97 | int prev; |
| 98 | int next; |
| 99 | int active; |
| 100 | char *name; |
| 101 | struct onode *disk_lp; |
| 102 | }; |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | struct mini_line { |
| 110 | |
| 111 | |
| 112 | |
| 113 | struct sockaddr_in skt; |
| 114 | int numDisks; |
| 115 | |
| 116 | |
| 117 | |
| 118 | int base_line; |
| 119 | int num_lines; |
| 120 | |
| 121 | |
| 122 | |
| 123 | struct onode *currConns_lp; |
| 124 | struct onode *fetches_lp; |
| 125 | struct onode *stores_lp; |
| 126 | struct onode *workstations_lp; |
| 127 | struct onode *srvName_lp; |
| 128 | struct scout_disk disks[VOLMAXPARTS255]; |
| 129 | int used_head; |
| 130 | int used_tail; |
| 131 | int free_head; |
| 132 | int free_tail; |
| 133 | }; |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | struct mini_screen { |
| 139 | int numServers; |
| 140 | int base_line_num; |
| 141 | struct mini_line *line; |
| 142 | }; |
| 143 | |
| 144 | static char pn[] = "scout"; |
| 145 | static int scout_debug = 0; |
| 146 | static FILE *scout_debugfd; |
| 147 | static int scout_gtx_initialized = 0; |
| 148 | static struct mini_screen scout_screen; |
| 149 | static int scout_probefreq; |
| 150 | static char scout_basename[64]; |
| 151 | static char scout_hostname[128]; |
| 152 | static int scout_showhostname = 0; |
| 153 | static char scout_blankline[256]; |
| 154 | static struct gwin *scout_gwin; |
| 155 | static struct gtx_frame *scout_frame; |
| 156 | static struct onode *scout_banner0_lp; |
| 157 | static struct onode *scout_banner1_lp; |
| 158 | static struct onode *scout_banner2_lp; |
| 159 | static int scout_DiskLightLeftCol = 0; |
| 160 | static struct gwin_sizeparams scout_frameDims; |
| 161 | |
| 162 | static int scout_col_width[] = { LIGHTOBJ_CONN_WIDTH5, |
| 163 | LIGHTOBJ_FETCH_WIDTH10, |
| 164 | LIGHTOBJ_STORE_WIDTH10, |
| 165 | LIGHTOBJ_WK_WIDTH5, |
| 166 | LIGHTOBJ_SRVNAME_WIDTH13, |
| 167 | LIGHTOBJ_DISK_WIDTH12 |
| 168 | }; |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | #define SCOUT_ATTN_NOTUSED(-1) (-1) |
| 174 | #define SCOUT_DISKM_PCUSED0 0 |
| 175 | #define SCOUT_DISKM_MINFREE1 1 |
| 176 | |
| 177 | static int scout_attn_conn = SCOUT_ATTN_NOTUSED(-1); |
| 178 | static int scout_attn_fetch = SCOUT_ATTN_NOTUSED(-1); |
| 179 | static int scout_attn_store = SCOUT_ATTN_NOTUSED(-1); |
| 180 | static int scout_attn_workstations = SCOUT_ATTN_NOTUSED(-1); |
| 181 | static int scout_attn_disk_mode = SCOUT_DISKM_PCUSED0; |
| 182 | static int scout_attn_disk_minfree = 1000; |
| 183 | static float scout_attn_disk_pcused = 0.95; |
| 184 | static char scout_attn_disk_pcusedstr[8] = "95"; |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | static char scout_Banner[256]; |
| 190 | static const char *scout_label[] = |
| 191 | { "Conn", "Fetch", "Store", "Ws", "", "Disk attn" }; |
| 192 | static const char *scout_underline[] = |
| 193 | { "----", "--------", "--------", "-----", "", "----------" }; |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | static void |
| 220 | scout_CleanExit(int a_exitval) |
| 221 | { |
| 222 | |
| 223 | static char rn[] = "scout_CleanExit"; |
| 224 | |
| 225 | if (scout_debugfd != (FILE *) 0) { |
| 226 | fprintf(scout_debugfd, "[%s] Closing debugging file\n", rn); |
| 227 | fclose(scout_debugfd); |
| 228 | } |
| 229 | |
| 230 | if (scout_gtx_initialized) { |
| 231 | gtxframe_exitValue = a_exitval; |
| 232 | gtxframe_ExitCmd((void *)(>xframe_exitValue), NULL((void *)0)); |
| 233 | } else |
| 234 | exit(a_exitval); |
| 235 | |
| 236 | } |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | static struct onode * |
| 264 | mini_initLightObject(char *a_name, int a_x, int a_y, int a_width, struct gwin *a_win) |
| 265 | { |
| 266 | |
| 267 | static char rn[] = "mini_initLightObject"; |
| 268 | struct onode *newlightp; |
| 269 | |
| 270 | struct gator_light_crparams light_crparams; |
| 271 | char *truncname; |
| 272 | int name_len; |
| 273 | |
| 274 | if (scout_debug) { |
| 275 | fprintf(scout_debugfd, |
| 276 | "[%s] Called for name '%s', [%d, %d], %d-char field\n", rn, |
| 277 | a_name, a_x, a_y, a_width); |
| 278 | fflush(scout_debugfd); |
| 279 | } |
| 280 | newlightp = NULL((void *)0); |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | light_crparams.onode_params.cr_type = GATOR_OBJ_LIGHT1; |
| 287 | name_len = strlen(a_name); |
| 288 | if (scout_debug) |
| 289 | fprintf(scout_debugfd, "[%s] Name '%s' has %d chars\n", rn, a_name, |
| 290 | name_len); |
| 291 | if (name_len <= a_width) |
| 292 | sprintf(light_crparams.onode_params.cr_name, "%s", a_name); |
| 293 | else { |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | truncname = light_crparams.onode_params.cr_name; |
| 299 | strncpy(truncname, a_name, a_width - 1); |
| 300 | truncname[a_width - 1] = '*'; |
| 301 | truncname[a_width] = 0; |
| 302 | } |
| 303 | light_crparams.onode_params.cr_x = a_x; |
| 304 | light_crparams.onode_params.cr_y = a_y; |
| 305 | light_crparams.onode_params.cr_width = a_width; |
| 306 | light_crparams.onode_params.cr_height = 1; |
| 307 | light_crparams.onode_params.cr_window = a_win; |
| 308 | light_crparams.onode_params.cr_home_obj = NULL((void *)0); |
| 309 | light_crparams.onode_params.cr_prev_obj = NULL((void *)0); |
| 310 | light_crparams.onode_params.cr_parent_obj = NULL((void *)0); |
| 311 | light_crparams.onode_params.cr_helpstring = NULL((void *)0); |
| 312 | |
| 313 | light_crparams.appearance = 0; |
| 314 | light_crparams.flashfreq = 0; |
| 315 | sprintf(light_crparams.label, "%s", a_name); |
| 316 | light_crparams.label_x = 0; |
| 317 | light_crparams.label_y = 0; |
| 318 | |
| 319 | newlightp = |
| 320 | gator_objects_create((struct onode_createparams *)(&light_crparams)); |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | return (newlightp); |
| 326 | |
| 327 | } |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | |
| 351 | static int |
| 352 | scout_initDiskLightObjects(struct mini_line *a_line, struct gwin *a_win) |
| 353 | { |
| 354 | |
| 355 | static char rn[] = "scout_initDiskLightObjects"; |
| 356 | struct scout_disk *curr_disk; |
| 357 | int i; |
| 358 | |
| 359 | if (scout_debug) { |
| 360 | fprintf(scout_debugfd, "[%s] Called\n", rn); |
| 361 | fflush(scout_debugfd); |
| 362 | } |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | a_line->used_head = SCOUT_NIL(-1); |
| 368 | a_line->used_tail = SCOUT_NIL(-1); |
| 369 | a_line->free_head = 0; |
| 370 | a_line->free_tail = VOLMAXPARTS255 - 1; |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | curr_disk = a_line->disks; |
| 377 | for (i = 0; i < VOLMAXPARTS255; i++) { |
| 378 | |
| 379 | |
| 380 | |
| 381 | if ((curr_disk->disk_lp = mini_initLightObject("Disk", |
| 382 | 0, |
| 383 | 0, |
| 384 | scout_col_width[COL_DISK5], |
| 385 | a_win)) |
| 386 | == NULL((void *)0)) { |
| 387 | fprintf(stderr__stderrp, "[%s:%s] Can't create disk %d light object\n", pn, |
| 388 | rn, i); |
| 389 | return (-1); |
| 390 | } |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | curr_disk->prev = i - 1; |
| 398 | curr_disk->next = i + 1; |
| 399 | curr_disk->active = 0; |
| 400 | curr_disk->name = '\0'; |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | curr_disk++; |
| 406 | |
| 407 | } |
| 408 | |
| 409 | |
| 410 | |
| 411 | |
| 412 | |
| 413 | a_line->disks[0].prev = SCOUT_NIL(-1); |
| 414 | a_line->disks[VOLMAXPARTS255 - 1].next = SCOUT_NIL(-1); |
| 415 | |
| 416 | return (0); |
| 417 | |
| 418 | } |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | int |
| 454 | mini_justify(char *a_srcbuff, char *a_dstbuff, int a_dstwidth, |
| 455 | int a_justification, int a_rightTrunc, |
| 456 | int a_isLabeledDisk) |
| 457 | { |
| 458 | |
| 459 | static char rn[] = "mini_justify"; |
| 460 | int leftpad_chars; |
| 461 | int num_src_chars; |
| 462 | int true_num_src_chars; |
| 463 | int trunc_needed; |
| 464 | char diskChar = 0; |
| 465 | |
| 466 | if (scout_debug) { |
| 467 | fprintf(scout_debugfd, "[%s] Called with '%s', dest width=%d\n", rn, |
| 468 | a_srcbuff, a_dstwidth); |
| 469 | fflush(scout_debugfd); |
| 470 | } |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | if (a_isLabeledDisk) |
| 476 | diskChar = *a_srcbuff; |
| 477 | |
| 478 | |
| 479 | |
| 480 | |
| 481 | |
| 482 | if (a_dstwidth > GATOR_LABEL_CHARS128) { |
| 483 | if (scout_debug) { |
| 484 | fprintf(scout_debugfd, |
| 485 | "[%s] Dest width (%d) > gtx buflen (%d), shrinking dest width\n", |
| 486 | rn, a_dstwidth, GATOR_LABEL_CHARS128); |
| 487 | fflush(scout_debugfd); |
| 488 | } |
| 489 | a_dstwidth = GATOR_LABEL_CHARS128; |
| 490 | } |
| 491 | |
| 492 | |
| 493 | |
| 494 | |
| 495 | true_num_src_chars = strlen(a_srcbuff); |
| 496 | if (true_num_src_chars >= a_dstwidth) { |
| 497 | trunc_needed = 1; |
| 498 | num_src_chars = a_dstwidth - 1; |
| 499 | leftpad_chars = 0; |
| 500 | if (!a_rightTrunc) |
| 501 | a_srcbuff += (true_num_src_chars - num_src_chars); |
| 502 | } else { |
| 503 | trunc_needed = 0; |
| 504 | num_src_chars = true_num_src_chars; |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | switch (a_justification) { |
| 510 | |
| 511 | case SCOUT_RIGHT_JUSTIFY0: |
| 512 | leftpad_chars = (a_dstwidth - 1) - num_src_chars; |
| 513 | break; |
| 514 | |
| 515 | case SCOUT_LEFT_JUSTIFY1: |
| 516 | |
| 517 | |
| 518 | |
| 519 | leftpad_chars = 0; |
| 520 | break; |
| 521 | |
| 522 | case SCOUT_CENTER2: |
| 523 | leftpad_chars = ((a_dstwidth - 1) - num_src_chars) / 2; |
| 524 | break; |
| 525 | |
| 526 | default: |
| 527 | fprintf(stderr__stderrp, "[%s] Illegal justification command: %d", rn, |
| 528 | a_justification); |
| 529 | return (-1); |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | strncpy(a_dstbuff, scout_blankline, a_dstwidth); |
| 541 | strncpy(a_dstbuff + leftpad_chars, a_srcbuff, num_src_chars); |
| 542 | *(a_dstbuff + a_dstwidth - 1) = '\0'; |
| 543 | if (trunc_needed) { |
| 544 | if (a_rightTrunc) |
| 545 | *(a_dstbuff + a_dstwidth - 2) = '*'; |
| 546 | else { |
| 547 | if (a_isLabeledDisk) { |
| 548 | *a_dstbuff = diskChar; |
| 549 | *(a_dstbuff + 1) = ':'; |
| 550 | *(a_dstbuff + 2) = '*'; |
| 551 | } else |
| 552 | *a_dstbuff = '*'; |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | |
| 557 | |
| 558 | |
| 559 | |
| 560 | return (0); |
| 561 | |
| 562 | } |
| 563 | |
| 564 | |
| 565 | |
| 566 | |
| 567 | |
| 568 | |
| 569 | |
| 570 | |
| 571 | |
| 572 | |
| 573 | |
| 574 | |
| 575 | |
| 576 | |
| 577 | |
| 578 | |
| 579 | |
| 580 | |
| 581 | |
| 582 | |
| 583 | |
| 584 | |
| 585 | |
| 586 | static void |
| 587 | scout_SetNonDiskLightLine(struct mini_line *a_srvline, int a_linenum) |
| 588 | { |
| 589 | |
| 590 | struct gator_lightobj *nondisk_lightdata; |
| 591 | struct gwin_strparams *nondisk_strparams; |
| 592 | |
| 593 | |
| 594 | |
| 595 | |
| 596 | a_srvline->currConns_lp->o_y = a_linenum; |
| 597 | nondisk_lightdata = |
| 598 | (struct gator_lightobj *)(a_srvline->currConns_lp->o_data); |
| 599 | nondisk_strparams = (struct gwin_strparams *)(nondisk_lightdata->llrock); |
| 600 | nondisk_strparams->y = a_linenum; |
| 601 | |
| 602 | a_srvline->fetches_lp->o_y = a_linenum; |
| 603 | nondisk_lightdata = |
| 604 | (struct gator_lightobj *)(a_srvline->fetches_lp->o_data); |
| 605 | nondisk_strparams = (struct gwin_strparams *)(nondisk_lightdata->llrock); |
| 606 | nondisk_strparams->y = a_linenum; |
| 607 | |
| 608 | a_srvline->stores_lp->o_y = a_linenum; |
| 609 | nondisk_lightdata = |
| 610 | (struct gator_lightobj *)(a_srvline->stores_lp->o_data); |
| 611 | nondisk_strparams = (struct gwin_strparams *)(nondisk_lightdata->llrock); |
| 612 | nondisk_strparams->y = a_linenum; |
| 613 | |
| 614 | a_srvline->workstations_lp->o_y = a_linenum; |
| 615 | nondisk_lightdata = |
| 616 | (struct gator_lightobj *)(a_srvline->workstations_lp->o_data); |
| 617 | nondisk_strparams = (struct gwin_strparams *)(nondisk_lightdata->llrock); |
| 618 | nondisk_strparams->y = a_linenum; |
| 619 | |
| 620 | a_srvline->srvName_lp->o_y = a_linenum; |
| 621 | nondisk_lightdata = |
| 622 | (struct gator_lightobj *)(a_srvline->srvName_lp->o_data); |
| 623 | nondisk_strparams = (struct gwin_strparams *)(nondisk_lightdata->llrock); |
| 624 | nondisk_strparams->y = a_linenum; |
| 625 | |
| 626 | } |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 | |
| 641 | |
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | |
| 649 | |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| 654 | static int |
| 655 | scout_RecomputeLightLocs(struct mini_line *a_srvline) |
| 656 | { |
| 657 | |
| 658 | static char rn[] = "scout_RecomputeLightLocs"; |
| 659 | int lights_per_line; |
| 660 | int lights_this_line; |
| 661 | int curr_idx; |
| 662 | struct scout_disk *sc_disk; |
| 663 | int lines_for_server; |
| 664 | int curr_line; |
| 665 | int curr_x; |
| 666 | struct gator_lightobj *disk_lightdata; |
| 667 | struct gwin_strparams *disk_strparams; |
| 668 | |
| 669 | if (scout_debug) { |
| 670 | fprintf(scout_debugfd, "[%s] Called\n", rn); |
| 671 | fflush(scout_debugfd); |
| 672 | } |
| 673 | |
| 674 | |
| 675 | |
| 676 | |
| 677 | |
| 678 | if (scout_DiskLightLeftCol == 0) { |
| 679 | int i; |
| 680 | int num_cols = sizeof(scout_col_width) / sizeof(*scout_col_width); |
| 681 | scout_DiskLightLeftCol = 0; |
| 682 | for (i = 0; i < (num_cols - 1); i++) { |
| 683 | scout_DiskLightLeftCol += scout_col_width[i] + 1; |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | lights_per_line = |
| 691 | (scout_frameDims.maxx - |
| 692 | scout_DiskLightLeftCol) / (scout_col_width[COL_DISK5] + 1); |
| 693 | if (scout_debug) { |
| 694 | fprintf(scout_debugfd, "[%s] %d lights per line\n", rn, |
| 695 | lights_per_line); |
| 696 | fflush(scout_debugfd); |
| 697 | } |
| 698 | |
| 699 | |
| 700 | |
| 701 | |
| 702 | |
| 703 | lights_this_line = 0; |
| 704 | curr_idx = a_srvline->used_head; |
| 705 | lines_for_server = 1; |
| 706 | curr_line = a_srvline->base_line; |
| 707 | curr_x = scout_DiskLightLeftCol; |
| 708 | |
| 709 | while (curr_idx != SCOUT_NIL(-1)) { |
| 710 | |
| 711 | |
| 712 | |
| 713 | |
| 714 | if (lights_this_line >= lights_per_line) { |
| 715 | lights_this_line = 0; |
| 716 | lines_for_server++; |
| 717 | curr_line++; |
| 718 | curr_x = scout_DiskLightLeftCol; |
| 719 | } |
| 720 | |
| 721 | |
| 722 | |
| 723 | |
| 724 | |
| 725 | sc_disk = a_srvline->disks; |
| 726 | sc_disk[curr_idx].disk_lp->o_x = curr_x; |
| 727 | sc_disk[curr_idx].disk_lp->o_y = curr_line; |
| 728 | disk_lightdata = |
| 729 | (struct gator_lightobj *)(sc_disk[curr_idx].disk_lp->o_data); |
| 730 | disk_strparams = (struct gwin_strparams *)(disk_lightdata->llrock); |
| 731 | disk_strparams->x = curr_x; |
| 732 | disk_strparams->y = curr_line; |
| 733 | if (scout_debug) { |
| 734 | fprintf(scout_debugfd, |
| 735 | "[%s] Disk light at index %d located at [%d, %d]\n", rn, |
| 736 | curr_idx, curr_x, curr_line); |
| 737 | fflush(scout_debugfd); |
| 738 | } |
| 739 | |
| 740 | |
| 741 | |
| 742 | |
| 743 | |
| 744 | lights_this_line++; |
| 745 | curr_x += scout_col_width[COL_DISK5] + 1; |
| 746 | curr_idx = sc_disk[curr_idx].next; |
| 747 | |
| 748 | } |
| 749 | |
| 750 | |
| 751 | |
| 752 | |
| 753 | |
| 754 | if (a_srvline->num_lines != lines_for_server) { |
| 755 | if (scout_debug) { |
| 756 | fprintf(scout_debugfd, |
| 757 | "[%s] Server previously had %d screen lines; now changed\n", |
| 758 | rn, a_srvline->num_lines); |
| 759 | fflush(scout_debugfd); |
| 760 | } |
| 761 | a_srvline->num_lines = lines_for_server; |
| 762 | } |
| 763 | |
| 764 | if (scout_debug) { |
| 765 | fprintf(scout_debugfd, "[%s] Server has %d screen lines\n", rn, |
| 766 | a_srvline->num_lines); |
| 767 | fflush(scout_debugfd); |
| 768 | } |
| 769 | return (a_srvline->num_lines); |
| 770 | |
| 771 | } |
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 | |
| 783 | |
| 784 | |
| 785 | |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 | |
| 797 | |
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | static int |
| 806 | scout_FindUsedDisk(char *a_diskname, struct mini_line *a_srvline, int *a_record_added) |
| 807 | { |
| 808 | |
| 809 | static char rn[] = "scout_FindUsedDisk"; |
| 810 | int curr_idx; |
| 811 | int append_idx; |
| 812 | int new_idx; |
| 813 | struct scout_disk *sc_disk; |
| 814 | int code; |
| 815 | |
| 816 | if (scout_debug) { |
| 817 | fprintf(scout_debugfd, "[%s] Called\n", rn); |
| 818 | fflush(scout_debugfd); |
| 819 | } |
| 820 | |
| 821 | |
| 822 | |
| 823 | |
| 824 | curr_idx = a_srvline->used_head; |
| 825 | append_idx = SCOUT_NIL(-1); |
| 826 | sc_disk = a_srvline->disks; |
| 827 | if (scout_debug) { |
| 828 | fprintf(scout_debugfd, |
| 829 | "[%s] Scanning existing used disk entries for disk '%s'\n", |
| 830 | rn, a_diskname); |
| 831 | fflush(scout_debugfd); |
| 832 | } |
| 833 | while (curr_idx != SCOUT_NIL(-1)) { |
| 834 | if (scout_debug) { |
| 835 | fprintf(scout_debugfd, "[%s] Disk %d is named '%s'\n", rn, |
| 836 | curr_idx, sc_disk[curr_idx].name); |
| 837 | fflush(scout_debugfd); |
| 838 | } |
| 839 | if (strcmp(sc_disk[curr_idx].name, a_diskname) == 0) { |
| 840 | |
| 841 | |
| 842 | |
| 843 | if (scout_debug) { |
| 844 | fprintf(scout_debugfd, "[%s] Match found\n", rn); |
| 845 | fflush(scout_debugfd); |
| 846 | } |
| 847 | return (curr_idx); |
| 848 | } |
| 849 | |
| 850 | |
| 851 | |
| 852 | |
| 853 | |
| 854 | |
| 855 | if (strcmp(a_diskname, sc_disk[curr_idx].name) < 0) { |
| 856 | if (scout_debug) { |
| 857 | fprintf(scout_debugfd, "[%s] Disk '%s' can't be here\n", rn, |
| 858 | a_diskname); |
| 859 | fflush(scout_debugfd); |
| 860 | } |
| 861 | break; |
| 862 | } |
| 863 | |
| 864 | |
| 865 | |
| 866 | |
| 867 | |
| 868 | |
| 869 | append_idx = curr_idx; |
| 870 | curr_idx = sc_disk[curr_idx].next; |
| 871 | } |
| 872 | |
| 873 | |
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | if (a_srvline->free_head == SCOUT_NIL(-1)) |
| 879 | return (SCOUT_NIL(-1)); |
| 880 | *a_record_added = 1; |
| 881 | new_idx = a_srvline->free_head; |
| 882 | if (scout_debug) { |
| 883 | fprintf(scout_debugfd, "[%s] Choosing free index %d for new entry\n", |
| 884 | rn, new_idx); |
| 885 | fflush(scout_debugfd); |
| 886 | } |
| 887 | a_srvline->free_head = sc_disk[new_idx].next; |
| 888 | if (a_srvline->free_head == SCOUT_NIL(-1)) |
| 889 | a_srvline->free_tail = SCOUT_NIL(-1); |
| 890 | |
| 891 | |
| 892 | |
| 893 | |
| 894 | sc_disk[new_idx].active = 0; |
| 895 | sc_disk[new_idx].name = a_diskname; |
| 896 | |
| 897 | |
| 898 | |
| 899 | |
| 900 | if (append_idx == SCOUT_NIL(-1)) { |
| 901 | |
| 902 | |
| 903 | |
| 904 | if (scout_debug) { |
| 905 | fprintf(scout_debugfd, "[%s] Inserted at used disk head\n", rn); |
| 906 | fflush(scout_debugfd); |
| 907 | } |
| 908 | sc_disk[new_idx].next = a_srvline->used_head; |
| 909 | sc_disk[new_idx].prev = SCOUT_NIL(-1); |
| 910 | a_srvline->used_head = new_idx; |
| 911 | if (a_srvline->used_tail == SCOUT_NIL(-1)) |
| 912 | a_srvline->used_tail = new_idx; |
| 913 | } else { |
| 914 | if (scout_debug) { |
| 915 | fprintf(scout_debugfd, "[%s] Entry appended after index %d\n", rn, |
| 916 | append_idx); |
| 917 | fflush(scout_debugfd); |
| 918 | } |
| 919 | sc_disk[new_idx].prev = append_idx; |
| 920 | sc_disk[new_idx].next = sc_disk[append_idx].next; |
| 921 | sc_disk[append_idx].next = new_idx; |
| 922 | if (sc_disk[new_idx].next == SCOUT_NIL(-1)) |
| 923 | a_srvline->used_tail = new_idx; |
| 924 | else |
| 925 | sc_disk[sc_disk[new_idx].next].prev = new_idx; |
| 926 | }; |
| 927 | |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | if (scout_debug) { |
| 933 | fprintf(scout_debugfd, |
| 934 | "[%s] Adding disk light at index %d to display list\n", rn, |
| 935 | new_idx); |
| 936 | fflush(scout_debugfd); |
| 937 | } |
| 938 | code = gtxframe_AddToList(scout_frame, sc_disk[new_idx].disk_lp); |
| 939 | if (code) { |
| 940 | if (scout_debug) { |
| 941 | fprintf(scout_debugfd, |
| 942 | "[%s] Can't add to display list, code is %d\n", rn, code); |
| 943 | fflush(scout_debugfd); |
| 944 | } |
| 945 | } |
| 946 | return (new_idx); |
| 947 | |
| 948 | } |
| 949 | |
| 950 | |
| 951 | |
| 952 | |
| 953 | |
| 954 | |
| 955 | |
| 956 | |
| 957 | |
| 958 | |
| 959 | |
| 960 | |
| 961 | |
| 962 | |
| 963 | |
| 964 | |
| 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | |
| 974 | static void |
| 975 | scout_RemoveInactiveDisk(struct mini_line *a_srvline, int a_used_idx) |
| 976 | { |
| 977 | |
| 978 | static char rn[] = "scout_RemoveInactiveDisk"; |
| 979 | |
| 980 | if (scout_debug) { |
| 981 | fprintf(scout_debugfd, "[%s] Called\n", rn); |
| 982 | fflush(scout_debugfd); |
| 983 | } |
| 984 | |
| 985 | |
| 986 | |
| 987 | } |
| 988 | |
| 989 | |
| 990 | |
| 991 | |
| 992 | |
| 993 | |
| 994 | |
| 995 | |
| 996 | |
| 997 | |
| 998 | |
| 999 | |
| 1000 | |
| 1001 | |
| 1002 | |
| 1003 | |
| 1004 | |
| 1005 | |
| 1006 | |
| 1007 | |
| 1008 | |
| 1009 | |
| 1010 | |
| 1011 | |
| 1012 | |
| 1013 | |
| 1014 | |
| 1015 | |
| 1016 | static int |
| 1017 | mini_PrintDiskStats(struct mini_line *a_srvline, |
| 1018 | struct ProbeViceStatistics *a_stats, |
| 1019 | int a_probeOK, int a_width_changed, |
| 1020 | int a_fix_line_num, int a_delta_line_num) |
| 1021 | { |
| 1022 | |
| 1023 | static char rn[] = "mini_PrintDiskStats"; |
| 1024 | char s[128]; |
| 1025 | struct onode *curr_disklight; |
| 1026 | struct onode *srvname_light; |
| 1027 | ViceDisk *curr_diskstat; |
| 1028 | int curr_disk; |
| 1029 | int used_disk_idx; |
| 1030 | int next_used_idx; |
| 1031 | int pastthreshold; |
| 1032 | struct gator_lightobj *diskdata; |
| 1033 | struct gwin_strparams *disk_strparams; |
| 1034 | char *diskname = 0; |
| 1035 | int found_idx; |
| 1036 | char *srv_name; |
| 1037 | struct scout_disk *sc_disk; |
| 1038 | int fix_light_locs; |
| 1039 | |
| 1040 | if (scout_debug) { |
| 1041 | fprintf(scout_debugfd, "[%s] Called\n", rn); |
| 1042 | fflush(scout_debugfd); |
| 1043 | } |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | |
| 1048 | |
| 1049 | srvname_light = a_srvline->srvName_lp; |
| 1050 | srv_name = ((struct gator_lightobj *)(srvname_light->o_data))->label; |
| 1051 | fix_light_locs = 0; |
| 1052 | if (scout_debug) { |
| 1053 | fprintf(scout_debugfd, "[%s] Value of a_delta_line_num is %d\n", rn, |
| 1054 | a_delta_line_num); |
| 1055 | fflush(scout_debugfd); |
| 1056 | } |
| 1057 | |
| 1058 | |
| 1059 | |
| 1060 | |
| 1061 | |
| 1062 | if (a_probeOK) { |
| 1063 | used_disk_idx = a_srvline->used_head; |
| 1064 | while (used_disk_idx != SCOUT_NIL(-1)) { |
| 1065 | |
| 1066 | |
| 1067 | |
| 1068 | |
| 1069 | |
| 1070 | |
| 1071 | curr_disklight = a_srvline->disks[used_disk_idx].disk_lp; |
| 1072 | diskdata = (struct gator_lightobj *)(curr_disklight->o_data); |
| 1073 | if (scout_debug) { |
| 1074 | fprintf(scout_debugfd, |
| 1075 | "[%s] Prev value of disk light %d: '%s'\n", rn, |
| 1076 | used_disk_idx, diskdata->label); |
| 1077 | fflush(scout_debugfd); |
| 1078 | } |
| 1079 | mini_justify(" ", |
| 1080 | diskdata->label, |
| 1081 | scout_col_width[COL_DISK5], |
| 1082 | SCOUT_RIGHT_JUSTIFY0, |
| 1083 | SCOUT_LEFT_TRUNC0, |
| 1084 | SCOUT_ISNT_LDISK0); |
| 1085 | gator_light_set(curr_disklight, 0); |
| 1086 | if (a_fix_line_num) { |
| 1087 | curr_disklight->o_y += a_delta_line_num; |
| 1088 | disk_strparams = (struct gwin_strparams *)(diskdata->llrock); |
| 1089 | disk_strparams->y += a_delta_line_num; |
| 1090 | } |
| 1091 | |
| 1092 | |
| 1093 | |
| 1094 | |
| 1095 | used_disk_idx = a_srvline->disks[used_disk_idx].next; |
| 1096 | |
| 1097 | } |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | |
| 1103 | |
| 1104 | if (a_width_changed) |
| 1105 | scout_RecomputeLightLocs(a_srvline); |
| 1106 | |
| 1107 | return (a_srvline->num_lines); |
| 1108 | |
| 1109 | } |
| 1110 | |
| 1111 | |
| 1112 | |
| 1113 | |
| 1114 | |
| 1115 | |
| 1116 | |
| 1117 | |
| 1118 | sc_disk = a_srvline->disks; |
| 1119 | used_disk_idx = a_srvline->used_head; |
| 1120 | while (used_disk_idx != SCOUT_NIL(-1)) { |
| 1121 | if (scout_debug) { |
| 1122 | fprintf(scout_debugfd, "[%s] Marking used disk %d inactive\n", rn, |
| 1123 | used_disk_idx); |
| 1124 | fflush(scout_debugfd); |
| 1125 | } |
| 1126 | sc_disk = (a_srvline->disks) + used_disk_idx; |
| 1127 | sc_disk->active = 0; |
| 1128 | used_disk_idx = sc_disk->next; |
| 1129 | if (a_fix_line_num) { |
| 1130 | sc_disk->disk_lp->o_y += a_delta_line_num; |
| 1131 | diskdata = (struct gator_lightobj *)(sc_disk->disk_lp->o_data); |
| 1132 | disk_strparams = (struct gwin_strparams *)(diskdata->llrock); |
| 1133 | disk_strparams->y += a_delta_line_num; |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | curr_diskstat = (ViceDisk *) a_stats->Disk; |
| 1138 | for (curr_disk = 0; curr_disk < VOLMAXPARTS255; curr_disk++) { |
| 1139 | |
| 1140 | |
| 1141 | |
| 1142 | if (scout_debug) { |
| 1143 | fprintf(scout_debugfd, "[%s] Disk stats at %p for disk '%s'\n", |
| 1144 | rn, curr_diskstat, curr_diskstat->Name); |
| 1145 | fflush(scout_debugfd); |
| 1146 | } |
| 1147 | if (strncmp("/vice", curr_diskstat->Name, 5) == 0) { |
| 1148 | |
| 1149 | |
| 1150 | |
| 1151 | |
| 1152 | diskname = &curr_diskstat->Name[6]; |
| 1153 | found_idx = scout_FindUsedDisk(diskname, |
| 1154 | a_srvline, |
| 1155 | &fix_light_locs); |
| 1156 | if (found_idx == SCOUT_NIL(-1)) { |
| 1157 | fprintf(stderr__stderrp, |
| 1158 | "[%s] Can't display /vicep%s on server '%s'\n", rn, |
| 1159 | diskname, srv_name); |
| 1160 | } else { |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | |
| 1165 | |
| 1166 | |
| 1167 | sprintf(s, "%s:%d", diskname, curr_diskstat->BlocksAvailable); |
| 1168 | if (scout_attn_disk_mode == SCOUT_DISKM_PCUSED0) { |
| 1169 | if ((float) |
| 1170 | (curr_diskstat->TotalBlocks - |
| 1171 | curr_diskstat->BlocksAvailable) / |
| 1172 | (float)(curr_diskstat->TotalBlocks) > |
| 1173 | scout_attn_disk_pcused) |
| 1174 | pastthreshold = 1; |
| 1175 | else |
| 1176 | pastthreshold = 0; |
| 1177 | } else |
| 1178 | pastthreshold = |
| 1179 | (curr_diskstat->BlocksAvailable < |
| 1180 | scout_attn_disk_minfree) ? 1 : 0; |
| 1181 | sc_disk = (a_srvline->disks) + found_idx; |
| 1182 | sc_disk->active = 1; |
| 1183 | diskdata = |
| 1184 | (struct gator_lightobj *)(sc_disk->disk_lp->o_data); |
| 1185 | if (scout_debug) { |
| 1186 | fprintf(scout_debugfd, |
| 1187 | "[%s] Justifying %s for disk idx %d (prev value: '%s')\n", |
| 1188 | rn, s, found_idx, diskdata->label); |
| 1189 | fflush(scout_debugfd); |
| 1190 | } |
| 1191 | mini_justify(s, |
| 1192 | diskdata->label, |
| 1193 | scout_col_width[COL_DISK5], |
| 1194 | SCOUT_LEFT_JUSTIFY1, |
| 1195 | SCOUT_LEFT_TRUNC0, |
| 1196 | SCOUT_IS_LDISK1); |
| 1197 | |
| 1198 | gator_light_set(sc_disk->disk_lp, pastthreshold); |
| 1199 | |
| 1200 | } |
| 1201 | } |
| 1202 | |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | |
| 1207 | curr_diskstat++; |
| 1208 | } |
| 1209 | |
| 1210 | |
| 1211 | |
| 1212 | |
| 1213 | |
| 1214 | |
| 1215 | if (scout_debug) { |
| 1216 | fprintf(scout_debugfd, |
| 1217 | "[%s] Scanning used disk records for inactive entries\n", rn); |
| 1218 | fflush(scout_debugfd); |
| 1219 | } |
| 1220 | used_disk_idx = a_srvline->used_head; |
| 1221 | while (used_disk_idx != SCOUT_NIL(-1)) { |
| 1222 | if (scout_debug) { |
| 1223 | fprintf(scout_debugfd, "[%s] Examining entry at index %d\n", rn, |
| 1224 | used_disk_idx); |
| 1225 | fflush(scout_debugfd); |
| 1226 | } |
| 1227 | sc_disk = (a_srvline->disks) + used_disk_idx; |
| 1228 | next_used_idx = sc_disk->next; |
| 1229 | if (!(sc_disk->active)) { |
| 1230 | scout_RemoveInactiveDisk(a_srvline, |
| 1231 | used_disk_idx); |
| 1232 | fix_light_locs = 1; |
| 1233 | } |
| 1234 | used_disk_idx = next_used_idx; |
| 1235 | |
| 1236 | } |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | |
| 1241 | |
| 1242 | |
| 1243 | if (fix_light_locs || a_width_changed) |
| 1244 | scout_RecomputeLightLocs(a_srvline); |
| 1245 | |
| 1246 | |
| 1247 | |
| 1248 | |
| 1249 | return (a_srvline->num_lines); |
| 1250 | |
| 1251 | } |
| 1252 | |
| 1253 | |
| 1254 | |
| 1255 | |
| 1256 | |
| 1257 | |
| 1258 | |
| 1259 | |
| 1260 | |
| 1261 | |
| 1262 | |
| 1263 | |
| 1264 | |
| 1265 | |
| 1266 | |
| 1267 | |
| 1268 | |
| 1269 | |
| 1270 | |
| 1271 | |
| 1272 | |
| 1273 | |
| 1274 | |
| 1275 | |
| 1276 | |
| 1277 | |
| 1278 | |
| 1279 | int |
| 1280 | FS_Handler(void) |
| 1281 | { |
| 1282 | |
| 1283 | static char rn[] = "FS_Handler"; |
| 1284 | int code; |
| 1285 | struct ProbeViceStatistics *curr_stats; |
| 1286 | int *curr_probeOK; |
| 1287 | int curr_srvidx; |
| 1288 | char s[128]; |
| 1289 | static char sblank[] = " "; |
| 1290 | char *sp; |
| 1291 | struct mini_line *curr_line; |
| 1292 | int curr_line_num; |
| 1293 | struct gator_lightobj *lightdata; |
| 1294 | int setting; |
| 1295 | int old_width; |
| 1296 | int width_changed; |
| 1297 | int fix_line_num; |
| 1298 | int delta_line_num; |
| 1299 | |
| 1300 | |
| 1301 | |
| 1302 | |
| 1303 | |
| 1304 | old_width = scout_frameDims.maxx; |
| 1305 | if (scout_debug) { |
| 1306 | fprintf(scout_debugfd, "[%s] Calling wop_getdimensions\n", rn); |
| 1307 | fflush(scout_debugfd); |
| 1308 | } |
| 1309 | WOP_GETDIMENSIONS(scout_frame->window, &scout_frameDims)(scout_frame->window)->w_op->gw_getdimensions(scout_frame ->window, &scout_frameDims); |
| 1310 | width_changed = (old_width == scout_frameDims.maxx) ? 0 : 1; |
| 1311 | if (scout_debug) { |
| 1312 | fprintf(scout_debugfd, |
| 1313 | "[%s] Frame dimensions are %d rows, %d columns\n", rn, |
| 1314 | scout_frameDims.maxy, scout_frameDims.maxx); |
| 1315 | if (width_changed) |
| 1316 | fprintf(scout_debugfd, "[%s] Width has changed from %d columns\n", |
| 1317 | rn, old_width); |
| 1318 | fflush(scout_debugfd); |
| 1319 | } |
| 1320 | |
| 1321 | |
| 1322 | |
| 1323 | |
| 1324 | |
| 1325 | curr_line = scout_screen.line; |
| 1326 | curr_stats = fsprobe_Results.stats; |
| 1327 | curr_probeOK = fsprobe_Results.probeOK; |
| 1328 | curr_line_num = curr_line->base_line; |
| 1329 | |
| 1330 | setting = 0; |
| 1331 | for (curr_srvidx = 0; curr_srvidx < scout_screen.numServers; |
| 1332 | curr_srvidx++) { |
| 1333 | |
| 1334 | |
| 1335 | |
| 1336 | |
| 1337 | |
| 1338 | if (curr_line->base_line != curr_line_num) { |
| 1339 | fix_line_num = 1; |
| 1340 | delta_line_num = curr_line_num - curr_line->base_line; |
| 1341 | curr_line->base_line = curr_line_num; |
| 1342 | scout_SetNonDiskLightLine(curr_line, curr_line_num); |
| 1343 | } else { |
| 1344 | fix_line_num = 0; |
| 1345 | delta_line_num = 0; |
| 1346 | } |
| 1347 | |
| 1348 | lightdata = |
| 1349 | (struct gator_lightobj *)(curr_line->currConns_lp->o_data); |
| 1350 | if (*curr_probeOK == 0) { |
| 1351 | sp = s; |
| 1352 | sprintf(sp, "%d", curr_stats->CurrentConnections); |
| 1353 | } else |
| 1354 | sp = sblank; |
| 1355 | code = mini_justify(sp, |
| 1356 | lightdata->label, |
| 1357 | scout_col_width[COL_CONN0], |
| 1358 | SCOUT_RIGHT_JUSTIFY0, |
| 1359 | SCOUT_LEFT_TRUNC0, |
| 1360 | SCOUT_ISNT_LDISK0); |
| 1361 | if (scout_attn_conn != SCOUT_ATTN_NOTUSED(-1) |
| 1362 | && curr_stats->CurrentConnections >= scout_attn_conn) |
| 1363 | setting = 1; |
| 1364 | else |
| 1365 | setting = 0; |
| 1366 | code = gator_light_set(curr_line->currConns_lp, setting); |
| 1367 | |
| 1368 | lightdata = (struct gator_lightobj *)(curr_line->fetches_lp->o_data); |
| 1369 | if (*curr_probeOK == 0) { |
| 1370 | sp = s; |
| 1371 | sprintf(sp, "%u", curr_stats->TotalFetchs); |
| 1372 | } else |
| 1373 | sp = sblank; |
| 1374 | code = mini_justify(sp, |
| 1375 | lightdata->label, |
| 1376 | scout_col_width[COL_FETCH1], |
| 1377 | SCOUT_RIGHT_JUSTIFY0, |
| 1378 | SCOUT_LEFT_TRUNC0, |
| 1379 | SCOUT_ISNT_LDISK0); |
| 1380 | if (scout_attn_fetch != SCOUT_ATTN_NOTUSED(-1) |
| 1381 | && curr_stats->TotalFetchs >= scout_attn_fetch) |
| 1382 | setting = 1; |
| 1383 | else |
| 1384 | setting = 0; |
| 1385 | code = gator_light_set(curr_line->fetches_lp, setting); |
| 1386 | |
| 1387 | lightdata = (struct gator_lightobj *)(curr_line->stores_lp->o_data); |
| 1388 | if (*curr_probeOK == 0) { |
| 1389 | sp = s; |
| 1390 | sprintf(sp, "%u", curr_stats->TotalStores); |
| 1391 | } else |
| 1392 | sp = sblank; |
| 1393 | code = mini_justify(sp, |
| 1394 | lightdata->label, |
| 1395 | scout_col_width[COL_STORE2], |
| 1396 | SCOUT_RIGHT_JUSTIFY0, |
| 1397 | SCOUT_LEFT_TRUNC0, |
| 1398 | SCOUT_ISNT_LDISK0); |
| 1399 | if (scout_attn_store != SCOUT_ATTN_NOTUSED(-1) |
| 1400 | && curr_stats->TotalStores >= scout_attn_store) |
| 1401 | setting = 1; |
| 1402 | else |
| 1403 | setting = 0; |
| 1404 | code = gator_light_set(curr_line->stores_lp, setting); |
| 1405 | |
| 1406 | lightdata = |
| 1407 | (struct gator_lightobj *)(curr_line->workstations_lp->o_data); |
| 1408 | if (*curr_probeOK == 0) { |
| 1409 | sp = s; |
| 1410 | sprintf(sp, "%d", curr_stats->WorkStations); |
| 1411 | } else |
| 1412 | sp = sblank; |
| 1413 | code = mini_justify(sp, |
| 1414 | lightdata->label, |
| 1415 | scout_col_width[COL_WK3], |
| 1416 | SCOUT_RIGHT_JUSTIFY0, |
| 1417 | SCOUT_LEFT_TRUNC0, |
| 1418 | SCOUT_ISNT_LDISK0); |
| 1419 | if (scout_attn_workstations != SCOUT_ATTN_NOTUSED(-1) |
| 1420 | && curr_stats->WorkStations >= scout_attn_workstations) |
| 1421 | setting = 1; |
| 1422 | else |
| 1423 | setting = 0; |
| 1424 | code = gator_light_set(curr_line->workstations_lp, setting); |
| 1425 | |
| 1426 | |
| 1427 | |
| 1428 | |
| 1429 | |
| 1430 | |
| 1431 | setting = (*curr_probeOK) ? 1 : 0; |
| 1432 | code = gator_light_set(curr_line->srvName_lp, setting); |
| 1433 | |
| 1434 | |
| 1435 | |
| 1436 | |
| 1437 | |
| 1438 | |
| 1439 | code = mini_PrintDiskStats(curr_line, |
| 1440 | curr_stats, |
| 1441 | *curr_probeOK, |
| 1442 | width_changed, |
| 1443 | fix_line_num, |
| 1444 | delta_line_num); |
| 1445 | if (code == 0) { |
| 1446 | fprintf(stderr__stderrp, "[%s] Error in printing out disk statistics\n", |
| 1447 | rn); |
| 1448 | return (-1); |
| 1449 | } else |
| 1450 | curr_line_num += code; |
| 1451 | |
| 1452 | |
| 1453 | |
| 1454 | |
| 1455 | |
| 1456 | curr_line++; |
| 1457 | curr_stats++; |
| 1458 | curr_probeOK++; |
| 1459 | |
| 1460 | } |
| 1461 | |
| 1462 | |
| 1463 | |
| 1464 | |
| 1465 | sprintf(s, "Probe %d results", fsprobe_Results.probeNum); |
| 1466 | gtxframe_DisplayString(scout_frame, s); |
| 1467 | WOP_DISPLAY(scout_gwin)(scout_gwin)->w_op->gw_display(scout_gwin); |
| 1468 | |
| 1469 | |
| 1470 | |
| 1471 | |
| 1472 | return (0); |
| 1473 | |
| 1474 | } |
| 1475 | |
| 1476 | |
| 1477 | |
| 1478 | |
| 1479 | |
| 1480 | |
| 1481 | |
| 1482 | |
| 1483 | |
| 1484 | |
| 1485 | |
| 1486 | |
| 1487 | |
| 1488 | |
| 1489 | |
| 1490 | |
| 1491 | |
| 1492 | |
| 1493 | |
| 1494 | |
| 1495 | |
| 1496 | |
| 1497 | |
| 1498 | |
| 1499 | static int |
| 1500 | init_mini_line(struct sockaddr_in *a_skt, int a_lineNum, |
| 1501 | struct mini_line *a_line, char *a_srvname) |
| 1502 | { |
| 1503 | |
| 1504 | static char rn[] = "init_mini_line"; |
| 1505 | int curr_x; |
| 1506 | int curr_y; |
| 1507 | char s[128]; |
| 1508 | int code; |
| 1509 | struct gator_lightobj *lightdata; |
| 1510 | |
| 1511 | if (scout_debug) { |
| 1512 | fprintf(scout_debugfd, "[%s] Called for base line %d\n", rn, |
| 1513 | a_lineNum); |
| 1514 | fflush(scout_debugfd); |
| 1515 | } |
| 1516 | |
| 1517 | |
| 1518 | |
| 1519 | |
| 1520 | |
| 1521 | memcpy((char *)&(a_line->skt), (char *)a_skt, sizeof(struct sockaddr_in)); |
| 1522 | a_line->numDisks = 0; |
| 1523 | a_line->base_line = a_lineNum + scout_screen.base_line_num; |
| 1524 | a_line->num_lines = 1; |
| 1525 | |
| 1526 | curr_x = 1; |
| 1527 | curr_y = a_line->base_line; |
| 1528 | if ((a_line->currConns_lp = |
| 1529 | mini_initLightObject("Conns", curr_x, curr_y, scout_col_width[COL_CONN0], |
| 1530 | scout_gwin)) |
| 1531 | == NULL((void *)0)) { |
| 1532 | fprintf(stderr__stderrp, "[%s:%s] Can't create currConns light object\n", pn, |
| 1533 | rn); |
| 1534 | return (-1); |
| 1535 | } |
| 1536 | curr_x += scout_col_width[COL_CONN0] + 1; |
| 1537 | |
| 1538 | if ((a_line->fetches_lp = |
| 1539 | mini_initLightObject("Fetches", curr_x, curr_y, scout_col_width[COL_FETCH1], |
| 1540 | scout_frame->window)) |
| 1541 | == NULL((void *)0)) { |
| 1542 | fprintf(stderr__stderrp, "[%s:%s] Can't create fetches light object\n", pn, |
| 1543 | rn); |
| 1544 | return (-1); |
| 1545 | } |
| 1546 | curr_x += scout_col_width[COL_FETCH1] + 1; |
| 1547 | |
| 1548 | if ((a_line->stores_lp = |
| 1549 | mini_initLightObject("Stores", curr_x, curr_y, scout_col_width[COL_STORE2], |
| 1550 | scout_frame->window)) |
| 1551 | == NULL((void *)0)) { |
| 1552 | fprintf(stderr__stderrp, "[%s:%s] Can't create stores light object\n", pn, rn); |
| 1553 | return (-1); |
| 1554 | } |
| 1555 | curr_x += scout_col_width[COL_STORE2] + 1; |
| 1556 | |
| 1557 | if ((a_line->workstations_lp = |
| 1558 | mini_initLightObject("WrkStn", curr_x, curr_y, scout_col_width[COL_WK3], |
| 1559 | scout_frame->window)) |
| 1560 | == NULL((void *)0)) { |
| 1561 | fprintf(stderr__stderrp, "[%s:%s] Can't create workstations light object\n", |
| 1562 | pn, rn); |
| 1563 | return (-1); |
| 1564 | } |
| 1565 | curr_x += scout_col_width[COL_WK3] + 1; |
| 1566 | |
| 1567 | if ((a_line->srvName_lp = |
| 1568 | mini_initLightObject(a_srvname, curr_x, curr_y, |
| 1569 | scout_col_width[COL_SRVNAME4], scout_frame->window)) |
| 1570 | == NULL((void *)0)) { |
| 1571 | fprintf(stderr__stderrp, "[%s:%s] Can't create server name light object\n", pn, |
| 1572 | rn); |
| 1573 | return (-1); |
| 1574 | } |
| 1575 | sprintf(s, "%s", a_srvname); |
| 1576 | lightdata = (struct gator_lightobj *)(a_line->srvName_lp->o_data); |
| 1577 | code = mini_justify(s, |
| 1578 | lightdata->label, |
| 1579 | scout_col_width[COL_SRVNAME4], |
| 1580 | SCOUT_CENTER2, |
| 1581 | SCOUT_RIGHT_TRUNC1, |
| 1582 | SCOUT_ISNT_LDISK0); |
| 1583 | if (code) { |
| 1584 | fprintf(stderr__stderrp, |
| 1585 | "[%s] Can't center server name inside of light object\n", rn); |
| 1586 | return (code); |
| 1587 | } |
| 1588 | curr_x += scout_col_width[COL_SRVNAME4] + 1; |
| 1589 | |
| 1590 | if (scout_initDiskLightObjects(a_line, scout_frame->window)) { |
| 1591 | fprintf(stderr__stderrp, "[%s:%s] Can't create disk light objects\n", pn, rn); |
| 1592 | return (-1); |
| 1593 | } |
| 1594 | |
| 1595 | |
| 1596 | |
| 1597 | |
| 1598 | return (0); |
| 1599 | |
| 1600 | } |
| 1601 | |
| 1602 | |
| 1603 | |
| 1604 | |
| 1605 | |
| 1606 | |
| 1607 | |
| 1608 | |
| 1609 | |
| 1610 | |
| 1611 | |
| 1612 | |
| 1613 | |
| 1614 | |
| 1615 | |
| 1616 | |
| 1617 | |
| 1618 | |
| 1619 | |
| 1620 | |
| 1621 | |
| 1622 | |
| 1623 | |
| 1624 | |
| 1625 | static int |
| 1626 | execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg) |
| 1627 | { |
| 1628 | |
| 1629 | static char rn[] = "execute_scout"; |
| 1630 | static char fullsrvname[128]; |
| 1631 | int code; |
| 1632 | struct sockaddr_in *FSSktArray; |
| 1633 | int sktbytes; |
| 1634 | struct sockaddr_in *curr_skt; |
| 1635 | struct cmd_item *curr_item; |
| 1636 | struct hostent *he; |
| 1637 | struct mini_line *mini_lines; |
| 1638 | struct mini_line *curr_line; |
| 1639 | int i; |
| 1640 | int mini_line_bytes; |
| 1641 | struct timeval tv; |
| 1642 | int linenum; |
| 1643 | #if 0 |
| 1644 | PROCESS pid; |
| 1645 | PROCESS gxlistener_ID; |
| 1646 | #endif /* 0 */ |
| 1647 | struct gator_lightobj *lightdata; |
| 1648 | |
| 1649 | if (scout_debug) { |
| |
| 1650 | fprintf(scout_debugfd, "[%s] Called\n", rn); |
| 1651 | fflush(scout_debugfd); |
| 1652 | } |
| 1653 | |
| 1654 | |
| 1655 | |
| 1656 | |
| 1657 | |
| 1658 | #if 0 |
| 1659 | code = LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY(4 -2), &pid); |
| 1660 | if (code) { |
| 1661 | fprintf(stderr__stderrp, "[%s:%s] Can't initialize LWP\n", pn, rn); |
| 1662 | scout_CleanExit(code); |
| 1663 | } |
| 1664 | #endif /* 0 */ |
| 1665 | |
| 1666 | |
| 1667 | |
| 1668 | |
| 1669 | #if 0 |
| 1670 | fprintf(stderr__stderrp, "[%s:%s] Starting up gtx package\n", pn, rn); |
| 1671 | #endif /* 0 */ |
| 1672 | scout_gwin = gtx_Init(0, |
| 1673 | -1); |
| 1674 | if (scout_gwin == NULL((void *)0)) { |
| |
| 1675 | fprintf(stderr__stderrp, "[%s:%s] Call to gtx_Init() failed!\n", pn, rn); |
| 1676 | return (-1); |
| 1677 | } |
| 1678 | |
| 1679 | |
| 1680 | |
| 1681 | |
| 1682 | scout_gtx_initialized = 1; |
| 1683 | |
| 1684 | |
| 1685 | |
| 1686 | |
| 1687 | |
| 1688 | scout_frame = gtxframe_Create(); |
| 1689 | if (scout_frame == (struct gtx_frame *)0) { |
| |
| 1690 | fprintf(stderr__stderrp, "[%s:%s] Call to gtxframe_Create() failed!\n", pn, |
| 1691 | rn); |
| 1692 | return (-1); |
| 1693 | } |
| 1694 | gtxframe_SetFrame(scout_gwin, scout_frame); |
| 1695 | WOP_GETDIMENSIONS(scout_frame->window, &scout_frameDims)(scout_frame->window)->w_op->gw_getdimensions(scout_frame ->window, &scout_frameDims); |
| 1696 | |
| 1697 | |
| 1698 | |
| 1699 | |
| 1700 | |
| 1701 | sktbytes = a_numservers * sizeof(struct sockaddr_in); |
| 1702 | FSSktArray = (struct sockaddr_in *)malloc(sktbytes); |
| 1703 | if (FSSktArray == (struct sockaddr_in *)0) { |
| |
| 1704 | fprintf(stderr__stderrp, |
| 1705 | "[%s] Can't malloc() %d sockaddrs (%d bytes) for the given servers\n", |
| 1706 | rn, a_numservers, sktbytes); |
| 1707 | scout_CleanExit(-1); |
| 1708 | } |
| 1709 | memset(FSSktArray, 0, sktbytes); |
| 1710 | |
| 1711 | |
| 1712 | |
| 1713 | |
| 1714 | |
| 1715 | |
| 1716 | curr_item = a_srvname; |
| 1717 | curr_skt = FSSktArray; |
| 1718 | while (curr_item) { |
| 5 | Loop condition is false. Execution continues on line 1744 |
|
| 1719 | if (*scout_basename == '\0') |
| 1720 | sprintf(fullsrvname, "%s", curr_item->data); |
| 1721 | else |
| 1722 | sprintf(fullsrvname, "%s.%s", curr_item->data, scout_basename); |
| 1723 | he = hostutil_GetHostByName(fullsrvname); |
| 1724 | if (he == NULL((void *)0)) { |
| 1725 | fprintf(stderr__stderrp, "[%s] Can't get host info for '%s'\n", rn, |
| 1726 | fullsrvname); |
| 1727 | return (-1); |
| 1728 | } |
| 1729 | memcpy(&(curr_skt->sin_addr.s_addr), he->h_addrh_addr_list[0], 4); |
| 1730 | curr_skt->sin_family = AF_INET2; |
| 1731 | curr_skt->sin_port = htons(7000)(__builtin_constant_p(7000) ? (__uint16_t)(((__uint16_t)(7000 )) << 8 | ((__uint16_t)(7000)) >> 8) : __bswap16_var (7000)); |
| 1732 | |
| 1733 | |
| 1734 | |
| 1735 | |
| 1736 | curr_item = curr_item->next; |
| 1737 | curr_skt++; |
| 1738 | |
| 1739 | } |
| 1740 | |
| 1741 | |
| 1742 | |
| 1743 | |
| 1744 | mini_line_bytes = a_numservers * sizeof(struct mini_line); |
| 1745 | mini_lines = (struct mini_line *)malloc(mini_line_bytes); |
| 1746 | if (mini_lines == (struct mini_line *)0) { |
| |
| 1747 | fprintf(stderr__stderrp, "[%s] Can't malloc() %d bytes for %d screen lines\n", |
| 1748 | rn, mini_line_bytes, a_numservers); |
| 1749 | return (-1); |
| 1750 | } |
| 1751 | memset(mini_lines, 0, mini_line_bytes); |
| 1752 | |
| 1753 | |
| 1754 | |
| 1755 | |
| 1756 | |
| 1757 | scout_screen.base_line_num = 4; |
| 1758 | curr_line = mini_lines; |
| 1759 | curr_skt = FSSktArray; |
| 1760 | linenum = 0; |
| 1761 | curr_item = a_srvname; |
| 1762 | gtxframe_ClearList(scout_frame); |
| 1763 | |
| 1764 | |
| 1765 | |
| 1766 | |
| 1767 | |
| 1768 | |
| 1769 | if (scout_showhostname) { |
| |
| 1770 | if (*scout_basename == '\0') |
| 1771 | sprintf(scout_Banner, "[%s] %s", scout_hostname, "Scout"); |
| 1772 | else |
| 1773 | sprintf(scout_Banner, "[%s] Scout for %s", scout_hostname, |
| 1774 | scout_basename); |
| 1775 | } else { |
| 1776 | if (*scout_basename == '\0') |
| |
| 1777 | sprintf(scout_Banner, "%s", " Scout"); |
| 1778 | else |
| 1779 | sprintf(scout_Banner, " Scout for %s", scout_basename); |
| 1780 | } |
| 1781 | scout_banner0_lp = mini_initLightObject("Banner 0", |
| 1782 | 0, 0, scout_frameDims.maxx, |
| 1783 | scout_gwin); |
| 1784 | if (scout_banner0_lp != NULL((void *)0)) { |
| |
| 1785 | lightdata = (struct gator_lightobj *)(scout_banner0_lp->o_data); |
| 1786 | code = |
| 1787 | mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx, |
| 1788 | SCOUT_CENTER2, SCOUT_RIGHT_TRUNC1, SCOUT_ISNT_LDISK0); |
| 1789 | code = gator_light_set(scout_banner0_lp, 1); |
| 1790 | code = gtxframe_AddToList(scout_frame, scout_banner0_lp); |
| 1791 | |
| 1792 | |
| 1793 | if (scout_debug) |
| 1794 | fprintf(scout_debugfd, "[%s] Scout label is '%s', %" AFS_SIZET_FMT"zu" " chars\n", rn, |
| 1795 | lightdata->label, strlen(lightdata->label)); |
| 1796 | } |
| 1797 | |
| 1798 | scout_banner1_lp = mini_initLightObject("Banner 1", |
| 1799 | 0, 2, scout_frameDims.maxx, |
| 1800 | scout_gwin); |
| 1801 | if (scout_banner1_lp != NULL((void *)0)) { |
| |
| 1802 | char attn_label[256]; |
| 1803 | if (scout_attn_disk_mode == SCOUT_DISKM_PCUSED0) { |
| 1804 | snprintf(attn_label, sizeof(attn_label), "%s: > %s%% used", |
| 1805 | scout_label[5], scout_attn_disk_pcusedstr); |
| 1806 | } else { |
| 1807 | snprintf(attn_label, sizeof(attn_label), "%s: < %d blocks free", |
| 1808 | scout_label[5], scout_attn_disk_minfree); |
| 1809 | } |
| 1810 | snprintf(scout_Banner, sizeof(scout_Banner), |
| 1811 | "%*s %*s %*s %*s %*s %s", |
| 1812 | scout_col_width[0], scout_label[0], |
| 1813 | scout_col_width[1], scout_label[1], |
| 1814 | scout_col_width[2], scout_label[2], |
| 1815 | scout_col_width[3], scout_label[3], |
| 1816 | scout_col_width[4], scout_label[4], |
| 1817 | attn_label); |
| 1818 | |
| 1819 | lightdata = (struct gator_lightobj *)(scout_banner1_lp->o_data); |
| 1820 | code = |
| 1821 | mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx, |
| 1822 | SCOUT_LEFT_JUSTIFY1, SCOUT_RIGHT_TRUNC1, |
| 1823 | SCOUT_ISNT_LDISK0); |
| 1824 | |
| 1825 | code = gtxframe_AddToList(scout_frame, scout_banner1_lp); |
| 1826 | } |
| 1827 | |
| 1828 | scout_banner2_lp = mini_initLightObject("Banner 2", |
| 1829 | 0, 3, scout_frameDims.maxx, |
| 1830 | scout_gwin); |
| 1831 | if (scout_banner2_lp != NULL((void *)0)) { |
| |
| 1832 | snprintf(scout_Banner, sizeof(scout_Banner), |
| 1833 | "%*s %*s %*s %*s %*s %s", |
| 1834 | scout_col_width[0], scout_underline[0], |
| 1835 | scout_col_width[1], scout_underline[1], |
| 1836 | scout_col_width[2], scout_underline[2], |
| 1837 | scout_col_width[3], scout_underline[3], |
| 1838 | scout_col_width[4], scout_underline[4], |
| 1839 | scout_underline[5]); |
| 1840 | |
| 1841 | lightdata = (struct gator_lightobj *)(scout_banner2_lp->o_data); |
| 1842 | code = |
| 1843 | mini_justify(scout_Banner, lightdata->label, |
| 1844 | scout_frameDims.maxx, SCOUT_LEFT_JUSTIFY1, |
| 1845 | SCOUT_RIGHT_TRUNC1, SCOUT_ISNT_LDISK0); |
| 1846 | code = gtxframe_AddToList(scout_frame, scout_banner2_lp); |
| 1847 | } |
| 1848 | |
| 1849 | for (i = 0; i < a_numservers; i++) { |
| 12 | Loop condition is true. Entering loop body |
|
| 1850 | code = init_mini_line(curr_skt, linenum, curr_line, curr_item->data); |
| 13 | Access to field 'data' results in a dereference of a null pointer (loaded from variable 'curr_item') |
|
| 1851 | if (code) { |
| 1852 | fprintf(stderr__stderrp, "[%s] Can't initialize line for server %d\n", rn, |
| 1853 | i); |
| 1854 | return (-1); |
| 1855 | } |
| 1856 | curr_skt++; |
| 1857 | curr_line++; |
| 1858 | linenum++; |
| 1859 | curr_item = curr_item->next; |
| 1860 | } |
| 1861 | |
| 1862 | |
| 1863 | |
| 1864 | |
| 1865 | |
| 1866 | |
| 1867 | curr_line = mini_lines; |
| 1868 | for (i = 0; i < a_numservers; i++) { |
| 1869 | code = gtxframe_AddToList(scout_frame, curr_line->currConns_lp); |
| 1870 | if (code) { |
| 1871 | fprintf(stderr__stderrp, |
| 1872 | "[%s] Can't add client connections light to display list\n", |
| 1873 | rn); |
| 1874 | return (code); |
| 1875 | } |
| 1876 | |
| 1877 | code = gtxframe_AddToList(scout_frame, curr_line->fetches_lp); |
| 1878 | if (code) { |
| 1879 | fprintf(stderr__stderrp, |
| 1880 | "[%s] Can't add fetches light to frame display list\n", |
| 1881 | rn); |
| 1882 | return (code); |
| 1883 | } |
| 1884 | |
| 1885 | code = gtxframe_AddToList(scout_frame, curr_line->stores_lp); |
| 1886 | if (code) { |
| 1887 | fprintf(stderr__stderrp, |
| 1888 | "[%s] Can't add stores light to frame display list\n", |
| 1889 | rn); |
| 1890 | return (code); |
| 1891 | } |
| 1892 | |
| 1893 | code = gtxframe_AddToList(scout_frame, curr_line->workstations_lp); |
| 1894 | if (code) { |
| 1895 | fprintf(stderr__stderrp, |
| 1896 | "[%s] Can't add workstation light to display list\n", rn); |
| 1897 | return (code); |
| 1898 | } |
| 1899 | |
| 1900 | code = gtxframe_AddToList(scout_frame, curr_line->srvName_lp); |
| 1901 | if (code) { |
| 1902 | fprintf(stderr__stderrp, |
| 1903 | "[%s] Can't add server name light to display list\n", rn); |
| 1904 | return (code); |
| 1905 | } |
| 1906 | |
| 1907 | |
| 1908 | |
| 1909 | |
| 1910 | curr_line++; |
| 1911 | |
| 1912 | } |
| 1913 | |
| 1914 | #if 0 |
| 1915 | |
| 1916 | |
| 1917 | |
| 1918 | code = keymap_BindToString(scout_frame->keymap, |
| 1919 | "e", |
| 1920 | ExitCmd, |
| 1921 | NULL((void *)0), |
| 1922 | NULL((void *)0)); |
| 1923 | if (code) { |
| 1924 | fprintf(stderr__stderrp, "[%s] Can't bind key `e', code is %d\n", rn, code); |
| 1925 | return (code); |
| 1926 | } |
| 1927 | #endif /* 0 */ |
| 1928 | |
| 1929 | |
| 1930 | |
| 1931 | |
| 1932 | scout_screen.numServers = a_numservers; |
| 1933 | scout_screen.line = mini_lines; |
| 1934 | WOP_GETDIMENSIONS(scout_frame->window, &scout_frameDims)(scout_frame->window)->w_op->gw_getdimensions(scout_frame ->window, &scout_frameDims); |
| 1935 | |
| 1936 | |
| 1937 | |
| 1938 | |
| 1939 | |
| 1940 | gtxframe_DisplayString(scout_frame, |
| 1941 | "Establishing File Server connection(s)..."); |
| 1942 | code = fsprobe_Init(a_numservers, |
| 1943 | FSSktArray, |
| 1944 | scout_probefreq, |
| 1945 | FS_Handler, |
| 1946 | 0); |
| 1947 | #if 0 |
| 1948 | scout_debug); |
| 1949 | #endif /* 0 */ |
| 1950 | if (code) { |
| 1951 | fprintf(stderr__stderrp, "[%s] Error returned by fsprobe_Init: %d\n", rn, |
| 1952 | code); |
| 1953 | return (-1); |
| 1954 | } |
| 1955 | |
| 1956 | |
| 1957 | |
| 1958 | |
| 1959 | |
| 1960 | #if 0 |
| 1961 | code = LWP_CreateProcess(gtx_InputServer, |
| 1962 | 8192, |
| 1963 | LWP_NORMAL_PRIORITY(4 -2), |
| 1964 | (void *)scout_gwin, |
| 1965 | "gx-listener", |
| 1966 | &gxlistener_ID); |
| 1967 | #endif /* 0 */ |
| 1968 | |
| 1969 | code = (int)(intptr_t)gtx_InputServer(scout_gwin); |
| 1970 | if (code) { |
| 1971 | fprintf(stderr__stderrp, |
| 1972 | "[%s] Error exit from gtx_InputServer(), error is %d\n", rn, |
| 1973 | code); |
| 1974 | scout_CleanExit(code); |
| 1975 | } |
| 1976 | |
| 1977 | |
| 1978 | |
| 1979 | |
| 1980 | while (1) { |
| 1981 | tv.tv_sec = 60 * 60; |
| 1982 | tv.tv_usec = 0; |
| 1983 | code = select(0, |
| 1984 | 0, |
| 1985 | 0, |
| 1986 | 0, |
| 1987 | &tv); |
| 1988 | } |
| 1989 | |
| 1990 | #if 0 |
| 1991 | |
| 1992 | |
| 1993 | |
| 1994 | |
| 1995 | WOP_CLEANUP(&scout_gwin)((*(gwinbops.gw_cleanup))(&scout_gwin)); |
| 1996 | return (0); |
| 1997 | #endif /* 0 */ |
| 1998 | |
| 1999 | } |
| 2000 | |
| 2001 | |
| 2002 | |
| 2003 | |
| 2004 | |
| 2005 | |
| 2006 | |
| 2007 | |
| 2008 | |
| 2009 | |
| 2010 | |
| 2011 | |
| 2012 | |
| 2013 | |
| 2014 | |
| 2015 | |
| 2016 | |
| 2017 | |
| 2018 | |
| 2019 | |
| 2020 | |
| 2021 | static int countServers(struct cmd_item *a_firstItem) |
| 2022 | { |
| 2023 | |
| 2024 | int list_len; |
| 2025 | struct cmd_item *curr_item; |
| 2026 | |
| 2027 | list_len = 0; |
| 2028 | curr_item = a_firstItem; |
| 2029 | |
| 2030 | |
| 2031 | |
| 2032 | |
| 2033 | while (curr_item) { |
| 2034 | list_len++; |
| 2035 | curr_item = curr_item->next; |
| 2036 | } |
| 2037 | |
| 2038 | |
| 2039 | |
| 2040 | |
| 2041 | return (list_len); |
| 2042 | |
| 2043 | } |
| 2044 | |
| 2045 | |
| 2046 | |
| 2047 | |
| 2048 | |
| 2049 | |
| 2050 | |
| 2051 | |
| 2052 | |
| 2053 | |
| 2054 | |
| 2055 | |
| 2056 | |
| 2057 | |
| 2058 | |
| 2059 | |
| 2060 | |
| 2061 | |
| 2062 | |
| 2063 | |
| 2064 | |
| 2065 | |
| 2066 | |
| 2067 | |
| 2068 | |
| 2069 | |
| 2070 | |
| 2071 | static void scout_AdoptThresholds(struct cmd_item *a_thresh_item) |
| 2072 | { |
| 2073 | |
| 2074 | static char rn[] = "scout_AdoptThresholds"; |
| 2075 | struct cmd_item *curr_item; |
| 2076 | char *curr_name; |
| 2077 | char *curr_value; |
| 2078 | int diskval_len; |
| 2079 | |
| 2080 | curr_item = a_thresh_item; |
| 2081 | while (curr_item) { |
| 2082 | |
| 2083 | |
| 2084 | |
| 2085 | |
| 2086 | if (curr_item->next == (struct cmd_item *)0) { |
| 2087 | printf("[%s] No threshold value given for '%s'\n", rn, |
| 2088 | curr_item->data); |
| 2089 | scout_CleanExit(-1); |
| 2090 | } |
| 2091 | |
| 2092 | curr_name = curr_item->data; |
| 2093 | curr_value = curr_item->next->data; |
| 2094 | |
| 2095 | if (strcmp(curr_name, "conn") == 0) { |
| 2096 | if (scout_debug) { |
| 2097 | fprintf(scout_debugfd, |
| 2098 | "[%s] Setting conn attn value to %d (default %d)\n", |
| 2099 | rn, atoi(curr_value), scout_attn_conn); |
| 2100 | fflush(scout_debugfd); |
| 2101 | } |
| 2102 | scout_attn_conn = atoi(curr_value); |
| 2103 | } else if (strcmp(curr_name, "disk") == 0) { |
| 2104 | |
| 2105 | |
| 2106 | |
| 2107 | |
| 2108 | diskval_len = strlen(curr_value); |
| 2109 | if (curr_value[diskval_len - 1] == '%') { |
| 2110 | curr_value[diskval_len - 1] = '\0'; |
| 2111 | if (scout_debug) { |
| 2112 | fprintf(scout_debugfd, |
| 2113 | "[%s] New disk attn value: 0.%s used (default %f)\n", |
| 2114 | rn, curr_value, scout_attn_disk_pcused); |
| 2115 | fflush(scout_debugfd); |
| 2116 | } |
| 2117 | sprintf(scout_attn_disk_pcusedstr, "%s", curr_value); |
| 2118 | scout_attn_disk_pcused = |
| 2119 | ((float)(atoi(curr_value))) / ((float)(100)); |
| 2120 | } |
| 2121 | else { |
| 2122 | if (scout_debug) { |
| 2123 | fprintf(scout_debugfd, |
| 2124 | "[%s] New disk attn value: %s min free (default %f)\n", |
| 2125 | rn, curr_value, scout_attn_disk_pcused); |
| 2126 | fflush(scout_debugfd); |
| 2127 | } |
| 2128 | scout_attn_disk_mode = SCOUT_DISKM_MINFREE1; |
| 2129 | scout_attn_disk_minfree = atoi(curr_value); |
| 2130 | } |
| 2131 | } else if (strcmp(curr_name, "fetch") == 0) { |
| 2132 | if (scout_debug) { |
| 2133 | fprintf(scout_debugfd, |
| 2134 | "[%s] Setting fetch attn value to %d (default %d)\n", |
| 2135 | rn, atoi(curr_value), scout_attn_fetch); |
| 2136 | fflush(scout_debugfd); |
| 2137 | } |
| 2138 | scout_attn_fetch = atoi(curr_value); |
| 2139 | } else if (strcmp(curr_name, "store") == 0) { |
| 2140 | if (scout_debug) { |
| 2141 | fprintf(scout_debugfd, |
| 2142 | "[%s] Setting store attn value to %d (default %d)\n", |
| 2143 | rn, atoi(curr_value), scout_attn_store); |
| 2144 | fflush(scout_debugfd); |
| 2145 | } |
| 2146 | scout_attn_store = atoi(curr_value); |
| 2147 | } else if (strcmp(curr_name, "ws") == 0) { |
| 2148 | if (scout_debug) { |
| 2149 | fprintf(scout_debugfd, |
| 2150 | "[%s] Setting workstation attn value to %d (default %d)\n", |
| 2151 | rn, atoi(curr_value), scout_attn_workstations); |
| 2152 | fflush(scout_debugfd); |
| 2153 | } |
| 2154 | scout_attn_workstations = atoi(curr_value); |
| 2155 | } else { |
| 2156 | printf("[%s] Unknown attention item: '%s'\n", rn, |
| 2157 | curr_item->data); |
| 2158 | scout_CleanExit(-1); |
| 2159 | } |
| 2160 | |
| 2161 | |
| 2162 | |
| 2163 | |
| 2164 | curr_item = curr_item->next->next; |
| 2165 | |
| 2166 | } |
| 2167 | |
| 2168 | } |
| 2169 | |
| 2170 | |
| 2171 | |
| 2172 | |
| 2173 | |
| 2174 | |
| 2175 | |
| 2176 | |
| 2177 | |
| 2178 | |
| 2179 | |
| 2180 | |
| 2181 | |
| 2182 | |
| 2183 | void |
| 2184 | scout_SetColumnWidths(struct cmd_item *a_width_item) |
| 2185 | { |
| 2186 | int i; |
| 2187 | int width; |
| 2188 | int num_cols = sizeof(scout_col_width) / sizeof(*scout_col_width); |
| 2189 | |
| 2190 | for (i = 0; a_width_item && i < num_cols; i++) { |
| 2191 | width = atoi(a_width_item->data); |
| 2192 | if (width > 0) { |
| 2193 | int min_width = strlen(scout_underline[i]); |
| 2194 | if (min_width) { |
| 2195 | width = max(width, min_width)((width) < (min_width) ? (min_width) : (width)); |
| 2196 | } |
| 2197 | scout_col_width[i] = width + 1; |
| 2198 | } |
| 2199 | a_width_item = a_width_item->next; |
| 2200 | } |
| 2201 | if (a_width_item) { |
| 2202 | fprintf(stderr__stderrp, "Too many values given for -columnwidths\n"); |
| 2203 | scout_CleanExit(1); |
| 2204 | } |
| 2205 | } |
| 2206 | |
| 2207 | |
| 2208 | |
| 2209 | |
| 2210 | |
| 2211 | |
| 2212 | |
| 2213 | |
| 2214 | |
| 2215 | |
| 2216 | |
| 2217 | |
| 2218 | |
| 2219 | |
| 2220 | |
| 2221 | |
| 2222 | |
| 2223 | |
| 2224 | |
| 2225 | |
| 2226 | |
| 2227 | |
| 2228 | |
| 2229 | static int scoutInit(struct cmd_syndesc *as, void *arock) |
| 2230 | { |
| 2231 | |
| 2232 | static char rn[] = "scoutInit"; |
| 2233 | int code; |
| 2234 | int wpkg_to_use; |
| 2235 | int server_count; |
| 2236 | char *debug_filename; |
| 2237 | |
| 2238 | if (scout_debug) { |
| 2239 | fprintf(scout_debugfd, "[%s] Called\n", rn); |
| 2240 | fflush(scout_debugfd); |
| 2241 | } |
| 2242 | |
| 2243 | if (as->parms[P_DEBUG5].items != 0) { |
| 2244 | scout_debug = 1; |
| 2245 | debug_filename = as->parms[P_DEBUG5].items->data; |
| 2246 | scout_debugfd = fopen(debug_filename, "w"); |
| 2247 | if (scout_debugfd == (FILE *) 0) { |
| 2248 | printf("[%s] Can't open debugging file '%s'!\n", rn, |
| 2249 | debug_filename); |
| 2250 | scout_CleanExit(-1); |
| 2251 | } |
| 2252 | fprintf(scout_debugfd, "[%s] Writing to Scout debugging file '%s'\n", |
| 2253 | rn, debug_filename); |
| 2254 | } |
| 2255 | #if 0 |
| 2256 | wpkg_to_use = atoi(as->parms[P_PACKAGE].items->data); |
| 2257 | #endif /* 0 */ |
| 2258 | wpkg_to_use = 2; |
| 2259 | #if 0 |
| 2260 | fprintf(stderr__stderrp, "[%s:%s] Using graphics package %d: ", pn, rn, |
| 2261 | wpkg_to_use); |
| 2262 | switch (wpkg_to_use) { |
| 2263 | case GATOR_WIN_CURSES2: |
| 2264 | fprintf(stderr__stderrp, "curses\n"); |
| 2265 | break; |
| 2266 | case GATOR_WIN_DUMB1: |
| 2267 | fprintf(stderr__stderrp, "dumb terminal\n"); |
| 2268 | break; |
| 2269 | case GATOR_WIN_X113: |
| 2270 | fprintf(stderr__stderrp, "X11\n"); |
| 2271 | break; |
| 2272 | default: |
| 2273 | fprintf(stderr__stderrp, "Illegal graphics package: %d\n", wpkg_to_use); |
| 2274 | scout_CleanExit(-1); |
| 2275 | } |
| 2276 | #endif /* 0 */ |
| 2277 | |
| 2278 | if (as->parms[P_FREQ2].items != 0) |
| 2279 | scout_probefreq = atoi(as->parms[P_FREQ2].items->data); |
| 2280 | else |
| 2281 | scout_probefreq = 60; |
| 2282 | |
| 2283 | |
| 2284 | |
| 2285 | |
| 2286 | if (as->parms[P_BASE1].items != 0) |
| 2287 | sprintf(scout_basename, "%s", as->parms[P_BASE1].items->data); |
| 2288 | else |
| 2289 | *scout_basename = '\0'; |
| 2290 | |
| 2291 | |
| 2292 | |
| 2293 | |
| 2294 | server_count = countServers(as->parms[P_SERVER0].items); |
| 2295 | |
| 2296 | |
| 2297 | |
| 2298 | |
| 2299 | sprintf(scout_blankline, "%255s", " "); |
| 2300 | |
| 2301 | |
| 2302 | |
| 2303 | |
| 2304 | |
| 2305 | if (as->parms[P_HOST3].items != 0) { |
| 2306 | scout_showhostname = 1; |
| 2307 | *scout_hostname = '\0'; |
| 2308 | code = gethostname(scout_hostname, 128); |
| 2309 | if (code) |
| 2310 | sprintf(scout_hostname, "%s", "*No Hostname*"); |
| 2311 | } |
| 2312 | |
| 2313 | |
| 2314 | |
| 2315 | |
| 2316 | if (as->parms[P_ATTENTION4].items != 0) |
| 2317 | scout_AdoptThresholds(as->parms[P_ATTENTION4].items); |
| 2318 | |
| 2319 | if (as->parms[P_WIDTHS6].items != 0) { |
| 2320 | scout_SetColumnWidths(as->parms[P_WIDTHS6].items); |
| 2321 | } |
| 2322 | |
| 2323 | |
| 2324 | |
| 2325 | |
| 2326 | code = execute_scout(server_count, |
| 2327 | as->parms[P_SERVER0].items, |
| 2328 | wpkg_to_use); |
| 2329 | if (code) { |
| 2330 | fprintf(stderr__stderrp, "[%s] Error executing scout: %d\n", rn, code); |
| 2331 | scout_CleanExit(-1); |
| 2332 | } |
| 2333 | |
| 2334 | |
| 2335 | |
| 2336 | |
| 2337 | return (0); |
| 2338 | |
| 2339 | } |
| 2340 | |
| 2341 | #include "AFS_component_version_number.c" |
| 2342 | |
| 2343 | int |
| 2344 | main(int argc, char **argv) |
| 2345 | { |
| 2346 | |
| 2347 | afs_int32 code; |
| 2348 | struct cmd_syndesc *ts; |
| 2349 | |
| 2350 | #ifdef AFS_AIX32_ENV |
| 2351 | |
| 2352 | |
| 2353 | |
| 2354 | |
| 2355 | |
| 2356 | |
| 2357 | struct sigaction nsa; |
| 2358 | |
| 2359 | sigemptyset(&nsa.sa_mask); |
| 2360 | nsa.sa_handler__sigaction_u.__sa_handler = SIG_DFL((__sighandler_t *)0); |
| 2361 | nsa.sa_flags = SA_FULLDUMP; |
| 2362 | sigaction(SIGSEGV11, &nsa, NULL((void *)0)); |
| 2363 | #endif |
| 2364 | |
| 2365 | |
| 2366 | |
| 2367 | ts = cmd_CreateSyntax("initcmd", scoutInit, NULL((void *)0), "initialize the program"); |
| 2368 | cmd_AddParm(ts, "-server", CMD_LIST3, CMD_REQUIRED0, |
| 2369 | "FileServer name(s) to monitor"); |
| 2370 | cmd_AddParm(ts, "-basename", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2371 | "base server name"); |
| 2372 | #if 0 |
| 2373 | cmd_AddParm(ts, "-package", CMD_SINGLE2, CMD_REQUIRED0, |
| 2374 | "Graphics package to use"); |
| 2375 | #endif /* 0 */ |
| 2376 | cmd_AddParm(ts, "-frequency", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2377 | "poll frequency, in seconds"); |
| 2378 | cmd_AddParm(ts, "-host", CMD_FLAG1, CMD_OPTIONAL1, |
| 2379 | "show name of host you're running on"); |
| 2380 | cmd_AddParm(ts, "-attention", CMD_LIST3, CMD_OPTIONAL1, |
| 2381 | "specify attention (highlighting) level"); |
| 2382 | cmd_AddParm(ts, "-debug", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2383 | "turn debugging output on to the named file"); |
| 2384 | cmd_AddParm(ts, "-columnwidths", CMD_LIST3, CMD_OPTIONAL1, |
| 2385 | "specify column widths"); |
| 2386 | |
| 2387 | |
| 2388 | |
| 2389 | |
| 2390 | |
| 2391 | code = cmd_Dispatch(argc, argv); |
| 2392 | if (code) { |
| 2393 | #if 0 |
| 2394 | fprintf(stderr__stderrp, "[%s:%s] Call to cmd_Dispatch() failed; code is %d\n", |
| 2395 | pn, rn, code); |
| 2396 | #endif /* 0 */ |
| 2397 | scout_CleanExit(1); |
| 2398 | } else |
| 2399 | scout_CleanExit(0); |
| 2400 | |
| 2401 | return 0; |
| 2402 | } |