예제 #1
0
 public function get($path = null)
 {
     // header("Refresh: 60");
     $servers = \Koshatul\Config\Config::Get('haproxyweb/server');
     $stats = new \Koshatul\HAProxyWeb\Helper\GetStats($servers);
     $stats->process();
     $output = "";
     $output .= $this->_head();
     $output .= $this->body($stats->getData());
     $output .= $this->_foot();
     echo $output;
 }
예제 #2
0
 public function process()
 {
     $this->_data = array();
     foreach ($this->_uri as $servername => $server) {
         $this->_api = new HAProxyAPI\API($server, \Koshatul\Config\Config::Get('haproxyweb/username'), \Koshatul\Config\Config::Get('haproxyweb/password'));
         try {
             $stats = $this->_api->execute('stats', array('grouping' => HAProxyAPI\Command\StatsCommand::GROUPING_BACKEND));
             foreach ($stats as $group => $services) {
                 if (!array_key_exists($group, $this->_data)) {
                     $this->_data[$group] = array();
                 }
                 foreach ($services as $service) {
                     $backend = new \Koshatul\HAProxyWeb\Types\Backend($servername, $server, $group, $service);
                     //echo "[".$group."] ".$backend->getProxyName()."/".$backend->getServiceName()." (".$backend->getServer().")".PHP_EOL;
                     $this->_data[$group][] = $backend;
                 }
             }
         } catch (HAProxyAPI\Client\Exception $e) {
             // Server error
         } catch (HAProxyAPI\Command\Exception $e) {
             // Data error
         }
     }
 }
예제 #3
0
 public function testConfigSetup()
 {
     $this->assertEquals('testdatavalue', Config::Get('testsection/test'), 'Return Known Config Value');
     $this->assertEquals(null, Config::Get('testsection/doesnotexixt'), 'Return Known Config Value');
     $this->assertEquals('differentvalue', Config::Get('anothersection/test'), 'Return Known Config Value');
 }