/** * @covers NginxStatus::getActiveConnections * @covers NginxStatus::getAcceptedRequests * @covers NginxStatus::getHandledRequests * @covers NginxStatus::getStatusReading * @covers NginxStatus::getStatusWriting * @covers NginxStatus::getStatusWaiting * @covers NginxStatus::getRequestsPerConnection */ public function testGetter() { $this->assertEquals(1, self::$status->getActiveConnections()); $this->assertEquals(2, self::$status->getAcceptedRequests()); $this->assertEquals(3, self::$status->getHandledRequests()); $this->assertEquals(4, self::$status->getStatusReading()); $this->assertEquals(5, self::$status->getStatusWriting()); $this->assertEquals(6, self::$status->getStatusWaiting()); $this->assertEquals(7.123, self::$status->getRequestsPerConnection()); }
/** * @return NginxStatus * @throws NginxStatusException */ public function parse() { $result = new NginxStatus(); if (!count($this->statusPageContent) == 4) { throw new NginxStatusException("Result seems to be invalid!", 2); } $tmpRow = array(); for ($i = 0; $i < count($this->statusPageContent); $i++) { preg_match($this->getRegex()[$i], $this->statusPageContent[$i], $tmpRow[$i]); } $result->setActiveConnections($tmpRow[0][1]); $result->setAcceptedRequests($tmpRow[2][1]); $result->setHandledRequests($tmpRow[2][3]); $result->setRequestsPerConnection($tmpRow[2][1] / $tmpRow[2][3]); $result->setStatusReading($tmpRow[3][1]); $result->setStatusWriting($tmpRow[3][2]); $result->setStatusWaiting($tmpRow[3][3]); return $result; }