| 503 | } |
| 504 | |
| 505 | static void usage(char *cmd) |
| 506 | { |
| 507 | fprintf(stderr, "%s [OPTIONS]\n", cmd); |
| 508 | fprintf(stderr, "\n"); |
| 509 | fprintf(stderr, "%s sends CPG messages to all registered users of the CPG.\n", cmd); |
| 510 | fprintf(stderr, "The messages have a sequence number and a CRC so that missing or\n"); |
| 511 | fprintf(stderr, "corrupted messages will be detected and reported.\n"); |
| 512 | fprintf(stderr, "\n"); |
| 513 | fprintf(stderr, "%s can also be asked to simply listen for (and check) packets\n", cmd); |
| 514 | fprintf(stderr, "so that there is another node in the cluster connected to the CPG.\n"); |
| 515 | fprintf(stderr, "\n"); |
| 516 | fprintf(stderr, "Multiple copies, in different CPGs, can also be run on the same or\n"); |
| 517 | fprintf(stderr, "different nodes by using the -n option.\n"); |
| 518 | fprintf(stderr, "\n"); |
| 519 | fprintf(stderr, "%s can handle more than 1 sender in the same CPG provided they are on\n", cmd); |
| 520 | fprintf(stderr, "different nodes.\n"); |
| 521 | fprintf(stderr, "\n"); |
| 522 | fprintf(stderr, " -w<num>, --size-bytes Write size in Kbytes, default 4\n"); |
| 523 | fprintf(stderr, " -W<num>, --size-kb Write size in bytes, default 4096\n"); |
| 524 | fprintf(stderr, " -n<name>, --name CPG name to use, default 'cpghum'\n"); |
| 525 | fprintf(stderr, " -M Write machine-readable results\n"); |
| 526 | fprintf(stderr, " -D<char> Delimiter for machine-readable results (default ',')\n"); |
| 527 | fprintf(stderr, " -E Send normal output to stderr instead of stdout\n"); |
| 528 | fprintf(stderr, " -d<num>, --delay Delay between sending packets (mS), default 1000\n"); |
| 529 | fprintf(stderr, " -r<num> Number of repetitions, default 100\n"); |
| 530 | fprintf(stderr, " -p<num> Delay between printing output (seconds), default 10s\n"); |
| 531 | fprintf(stderr, " -l, --listen Listen and check CRCs only, don't send (^C to quit)\n"); |
| 532 | fprintf(stderr, " -t, --rtt Report Round Trip Times for each packet.\n"); |
| 533 | fprintf(stderr, " -m<num> cpg_initialise() model. Default 1.\n"); |
| 534 | fprintf(stderr, " -s Also send errors to syslog.\n"); |
| 535 | fprintf(stderr, " -f, --flood Flood test CPG (cpgbench). see --flood-* long options\n"); |
| 536 | fprintf(stderr, " -a Abort on crc/length/sequence error\n"); |
| 537 | fprintf(stderr, " -q, --quiet Quiet. Don't print messages every 10s (see also -p)\n"); |
| 538 | fprintf(stderr, " -qq Very quiet. Don't print stats at the end\n"); |
| 539 | fprintf(stderr, " --flood-start=bytes Start value for --flood\n"); |
| 540 | fprintf(stderr, " --flood-mult=value Packet size multiplier value for --flood\n"); |
| 541 | fprintf(stderr, " --flood-max=bytes Maximum packet size for --flood\n"); |
| 542 | fprintf(stderr, "\n"); |
| 543 | fprintf(stderr, " values for --flood* and -W can have K or M suffixes to indicate\n"); |
| 544 | fprintf(stderr, " Kilobytes or Megabytes\n"); |
| 545 | fprintf(stderr, "\n"); |
| 546 | fprintf(stderr, "%s exit code is 0 if no error happened, 1 on generic error and 2 on\n", cmd); |
| 547 | fprintf(stderr, "send/crc/length/sequence error"); |
| 548 | fprintf(stderr, "\n"); |
| 549 | } |
| 550 | |
| 551 | /* Parse a size, optionally ending in 'K', 'M' */ |
| 552 | static long parse_bytes(const char *valstring) |