Fixes the status checks
							parent
							
								
									813a9594fb
								
							
						
					
					
						commit
						f78ef4fe40
					
				| 
						 | 
				
			
			@ -23,6 +23,14 @@ function getJicofoStatus() {
 | 
			
		|||
    $status = trim(shell_exec('systemctl is-active jicofo'));
 | 
			
		||||
    return ($status === 'active') ? 'running' : 'not running';
 | 
			
		||||
}
 | 
			
		||||
function getJicofoStats($command) {
 | 
			
		||||
    $data = shell_exec($command);
 | 
			
		||||
    $decodedData = json_decode($data, true);
 | 
			
		||||
    if (json_last_error() !== JSON_ERROR_NONE) {
 | 
			
		||||
        return ['error' => 'Failed to decode the JSON reply from the service.'];
 | 
			
		||||
    }
 | 
			
		||||
    return $decodedData;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// get JVB data
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,8 +25,11 @@ if ($request === '/nginx' || $request === "/$scriptname/nginx") {
 | 
			
		|||
 | 
			
		||||
// jicofo status
 | 
			
		||||
} elseif ($request === '/jicofo' || $request === "/$scriptname/jicofo") {
 | 
			
		||||
    $jicofoStatsCommand = 'curl -s http://localhost:8888/stats';
 | 
			
		||||
    $jicofoStatsData = getJicofoStats($jicofoStatsCommand);
 | 
			
		||||
    $data = [
 | 
			
		||||
        'jicofo_status'		=> getJicofoStatus(),
 | 
			
		||||
        'jicofo_API_stats'	=> $jicofoStatsData;
 | 
			
		||||
    ];
 | 
			
		||||
    echo json_encode($data, JSON_PRETTY_PRINT) . "\n";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue