Exemplo n.º 1
0
 public function render()
 {
     try {
         ob_start();
         $reactor = \Amp\getReactor();
         $client = new Client($reactor);
         $url = sprintf("http://%s/www-status?full&json", $this->domain->getCanonicalDomain());
         $promise = $client->request($url);
         $response = \Amp\wait($promise);
         $headers = ["pool" => "Pool name", "process manager" => "Process manager", "start time" => "Start time", "start since" => "Uptime", "accepted conn" => "Accepted connections", "listen queue" => "Listen queue", "max listen queue" => "Max listen queue", "listen queue len" => "Listen queue length", "idle processes" => "Idle processes", "active processes" => "Active processes", "total processes" => "Total processes", "max active processes" => "Max active processes", "max children reached" => "Max children reached", "slow requests" => "Slow requests"];
         $json = json_decode($response->getBody(), true);
         echo "<table class='table-serverSettings'>";
         echo "<tr><th colspan='2'>Pool info</th></tr>";
         foreach ($headers as $header => $display) {
             echo "<tr><td>";
             echo $display;
             echo "</td><td>";
             echo $json[$header];
             echo "</td></tr>";
         }
         echo "</table>";
         echo "<div style='height: 20px;'></div>";
         echo "<table class='table-serverSettings'>";
         $processHeaders = ["pid", "state", "start since", "requests", "request URI", "content length", "script", "last request cpu", "last request memory"];
         foreach ($processHeaders as $processHeader) {
             echo "<th>";
             echo $processHeader;
             echo "</th>";
         }
         if (isset($json['processes']) && is_array($json['processes'])) {
             foreach ($json['processes'] as $process) {
                 echo "<tr>";
                 foreach ($processHeaders as $processHeader) {
                     echo "<td align='right'>";
                     if (array_key_exists($processHeader, $process)) {
                         $text = $process[$processHeader];
                         $text = str_replace(['/home/github/imagick-demos//imagick-demos', '/home/github/imagick-demos/imagick-demos'], '', $text);
                         $text = ltrim($text, '/');
                         echo $text;
                     } else {
                         echo "-";
                     }
                     echo "</td>";
                 }
                 echo "</tr>";
             }
         }
         echo "</table>";
         echo "<br/>";
         echo "<a href='http://127.0.0.1:9002'>SupervisorD</a>";
         $output = ob_get_contents();
         ob_end_clean();
         return $output;
     } catch (\Exception $e) {
         while (ob_get_level() > 0) {
             ob_end_clean();
         }
         return "Error fetch FPM status: " . $e->getMessage();
     }
 }
Exemplo n.º 2
0
 function createResponse()
 {
     ob_start();
     $reactor = \Amp\getReactor();
     $client = new Client($reactor);
     $url = "http://phpimagick.com/www-status?full&json";
     $promise = $client->request($url);
     $response = \Amp\wait($promise);
     //$response = $promise->wait();
     $headers = ["pool" => "Pool name", "process manager" => "Process manager", "start time" => "Start time", "start since" => "Uptime", "accepted conn" => "Accepted connections", "listen queue" => "Listen queue", "max listen queue" => "Max listen queue", "listen queue len" => "Listen queue length", "idle processes" => "Idle processes", "active processes" => "Active processes", "total processes" => "Total processes", "max active processes" => "Max active processes", "max children reached" => "Max children reached", "slow requests" => "Slow requests"];
     $json = json_decode($response->getBody(), true);
     echo "<table>";
     foreach ($headers as $header => $display) {
         echo "<tr><td>";
         echo $display;
         echo "</td><td>";
         echo $json[$header];
         echo "</td></tr>";
     }
     echo "</table>";
     echo "<table>";
     $processHeaders = ["pid", "state", "start time", "start since", "requests", "request duration", "request URI", "content length", "script", "last request cpu", "last request memory"];
     foreach ($processHeaders as $processHeader) {
         echo "<th>";
         echo $processHeader;
         echo "</th>";
     }
     if (isset($json['processes']) && is_array($json['processes'])) {
         foreach ($json['processes'] as $process) {
             echo "<tr>";
             foreach ($processHeaders as $processHeader) {
                 echo "<td align='right'>";
                 if (array_key_exists($processHeader, $process)) {
                     $text = $process[$processHeader];
                     $text = str_replace(['/home/github/imagick-demos//imagick-demos', '/home/github/imagick-demos/imagick-demos'], '', $text);
                     $text = ltrim($text, '/');
                     echo $text;
                 } else {
                     echo "-";
                 }
                 echo "</td>";
             }
             echo "</tr>";
         }
     }
     echo "</table>";
     echo "<br/>";
     echo "<a href='http://127.0.0.1:9002'>SupervisorD</a>";
     $output = ob_get_contents();
     ob_end_clean();
     return new TextResponse($output);
 }
Exemplo n.º 3
0
 public function __construct(Reactor $reactor = null, CookieJar $cookieJar = null, HttpSocketPool $socketPool = null, Encryptor $encryptor = null, WriterFactory $writerFactory = null)
 {
     $reactor = $reactor ?: \Amp\getReactor();
     $this->reactor = $reactor;
     $this->cookieJar = $cookieJar ?: new ArrayCookieJar();
     $this->socketPool = $socketPool ?: new HttpSocketPool($reactor);
     $this->encryptor = $encryptor ?: new Encryptor($reactor);
     $this->writerFactory = $writerFactory ?: new WriterFactory();
     $this->hasZlib = extension_loaded('zlib');
     $this->dequeuer = function () {
         if ($this->queue) {
             $this->dequeueNextRequest();
         }
     };
     /*
     $this->reactor->repeat(function() {
         printf("outstanding requests: %s\n", self::$outstandingRequests);
     }, 1000);
     */
 }
Exemplo n.º 4
0
            $this->urlsChecked[] = new URLResult($path, 500, "Error getting {$path} - " . $e->getMessage() . " Exception type is " . get_class($e));
        }
        if ($ok != true) {
            $this->errors++;
        }
    }
    /**
     * @return URLResult[]
     */
    function getResults()
    {
        return $this->urlsChecked;
    }
}
$site = "http://imagick.test";
$site = "http://phpimagick.com";
$site = "http://phpimagick.test";
$reactor = Amp\getReactor();
$client = new ArtaxClient();
$client->setOption(\Amp\Artax\Client::OP_MS_CONNECT_TIMEOUT, 2500);
$client->setOption(ArtaxClient::OP_HOST_CONNECTION_LIMIT, 4);
$siteChecker = new SiteChecker($site, $client);
$start = new URLToCheck('/', '/');
$siteChecker->checkURL($start);
$reactor->run();
echo "fin";
$printer = new HTMLPrinter($siteChecker->getResults(), $site);
$outputStream = fopen("./checkResults.html", "w");
$printer->output($outputStream);
fclose($outputStream);
echo "Check complete. Found " . $siteChecker->getURLCount() . " URIs with " . $siteChecker->getErrorCount() . " errors.";