/usr/bin/polygraph-pmix3-ips is in polygraph 4.3.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | #!/usr/bin/perl -w
# Web Polygraph http://www.web-polygraph.org/
# Copyright 2003-2011 The Measurement Factory
# Licensed under the Apache License, Version 2.0
require 5.003;
use strict;
use POSIX;
if (@ARGV == 1 && $ARGV[0] eq '--help') {
print usage();
exit;
}
&web2term();
die(&usage()) unless 2 <= @ARGV && @ARGV <= 3;
$SIG{__WARN__} = sub { print(STDERR &usage()); die $_[0] };
my $Quiet = @ARGV == 3;
my ($Bench, $RR, $Id) = @ARGV;
my $Pairs;
exit(&main());
sub main {
$Pairs = xceil($RR, 400);
my $Robots = xceil($RR, 0.4);
$Robots = $Pairs*xceil($Robots, $Pairs);
my $Servers = ceil($Robots*0.1 + 500);
$Servers = $Pairs*xceil($Servers, $Pairs);
my ($rbtX, $rbtY) = &countToB($Robots);
my ($srvX, $srvY) = &countToB($Servers);
# must recalc (adjust) again!
$Robots = $rbtX * $rbtY;
$Servers = $srvX * $srvY;
my ($r, $s) = ($Robots/$Pairs, $Servers/$Pairs);
if (!$Quiet) {
xprintf("bench: %6d\n", $Bench);
xprintf("req.rate: %6d/sec (actual: %8.2f/sec)\n",
$RR, $Robots*0.4);
xprintf("PCs: %6dpairs\n", $Pairs);
xprintf("robots: %6d (%4d/machine)\n",
$Robots, $r);
xprintf("servers: %6d (%4d/machine)\n",
$Servers, $s);
xprintf("\n");
xprintf("rbt_ips: %20s\n",
ipRange2Str(1, $rbtX, $rbtY));
for (my $id=1; $id<=$Pairs; $id++) {
my $step = $rbtX/$Pairs;
xprintf("\t machine_%d_ips:\t %20s\n",
$id, ipRange2Str(($id-1)*$step+1, $id*$step, $rbtY));
}
xprintf("srv_ips: %20s\n",
ipRange2Str(128+1, 128+$srvX, $srvY));
for (my $id=1; $id<=$Pairs; $id++) {
my $step = $srvX/$Pairs;
xprintf("\t machine_%d_ips:\t %20s\n",
$id, ipRange2Str(128+($id-1)*$step+1, 128+$id*$step, $srvY));
}
}
die("$0: math went wrong for robots\n") if $r != int($Robots/$Pairs);
die("$0: math went wrong for servers\n") if $s != int($Servers/$Pairs);
return 0 unless defined $Id;
if ($Id =~ /^clts$/) {
print(ipRange2Str(1, $rbtX, $rbtY));
}
elsif ($Id =~ /^srvs$/) {
print(ipRange2Str(129, 128+$srvX, $srvY));
}
elsif ($Id =~ /^clt(\d+)$/) {
my $id = $1;
die("there are only $Pairs clients, cannot have $Id client\n") if $id > $Pairs;
my $step = $rbtX/$Pairs;
print(ipRange2Str(($id-1)*$step+1, $id*$step, $rbtY));
}
elsif ($Id =~ /^srv(\d+)$/) {
my $id = $1;
die("there are only $Pairs servers, cannot have $Id server\n") if $id > $Pairs;
my $step = $srvX/$Pairs;
print(ipRange2Str(128+($id-1)*$step+1, 128+$id*$step, $srvY));
} else {
die("$0: cannot parse `$Id'; expected something like clt1 or srv4\n");
}
print("\n"); # if -t STDOUT;
return 0;
}
sub countToB {
my ($countTot) = @_;
my $rangeX = xceil($countTot, 250);
$rangeX = $Pairs*xceil($rangeX, $Pairs);
my $rangeY = xceil($countTot, $rangeX);
return ($rangeX, $rangeY);
}
sub ipRange2Str {
my ($minX, $maxX, $maxY) = @_;
return "10.$Bench.$minX-$maxX.1-$maxY";
}
sub xprintf {
my $fmt = shift;
#printf(STDERR "$0: $fmt", @_);
printf("\t$fmt", @_);
}
# try "ceil(700/0.7)" to see why xceil is needed
sub xceil {
my ($large, $small) = @_;
my $c = ceil($large/$small);
return ($c-1)*$small >= $large ? $c-1 : $c;
}
sub web2term {
my $query = $ENV{QUERY_STRING};
return unless defined $query;
open(STDERR, ">&STDOUT");
print("Content-type: text/plain\r\n\r\n");
@ARGV = ($query =~ /=([^&]+)/g);
printf("./pmix2-ips.pl %s\n\n", join(' ', @ARGV));
}
sub usage {
return "Usage: $0 <bench_id> <requests/sec> [cltId|srvId]\n";
}
sub suffix {
my ($ord) = @_;
return 'st' if $ord == 1;
return 'nd' if $ord == 2;
return 'rd' if $ord == 3;
return 'th';
}
|