| 
									
										
										
										
											2024-09-01 13:29:59 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // get nginx data
 | 
					
						
							|  |  |  | function getNginxStatus() { | 
					
						
							|  |  |  |     $status = trim(shell_exec('systemctl is-active nginx')); | 
					
						
							|  |  |  |     return ($status === 'active') ? 'running' : 'not running'; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | function getNginxConnections() { | 
					
						
							| 
									
										
										
										
											2024-09-01 13:57:57 +00:00
										 |  |  |     $connections = shell_exec("netstat -an | grep ':$nginxPort' | wc -l"); | 
					
						
							| 
									
										
										
										
											2024-09-01 13:29:59 +00:00
										 |  |  |     return intval(trim($connections)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-01 13:40:47 +00:00
										 |  |  | // get prosody data
 | 
					
						
							| 
									
										
										
										
											2024-09-01 13:29:59 +00:00
										 |  |  | function getProsodyStatus() { | 
					
						
							|  |  |  |     $status = trim(shell_exec('systemctl is-active prosody')); | 
					
						
							|  |  |  |     return ($status === 'active') ? 'running' : 'not running'; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-09-01 13:40:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // get jicofo data
 | 
					
						
							| 
									
										
										
										
											2024-09-01 13:29:59 +00:00
										 |  |  | function getJicofoStatus() { | 
					
						
							|  |  |  |     $status = trim(shell_exec('systemctl is-active jicofo')); | 
					
						
							|  |  |  |     return ($status === 'active') ? 'running' : 'not running'; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-09-01 13:49:43 +00:00
										 |  |  | 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; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-09-01 13:29:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-01 13:40:47 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // get JVB data
 | 
					
						
							|  |  |  | function getJVBStatus() { | 
					
						
							| 
									
										
										
										
											2024-09-01 13:53:12 +00:00
										 |  |  |     $status = trim(shell_exec('systemctl is-active jitsi-videobridge2')); | 
					
						
							| 
									
										
										
										
											2024-09-01 13:40:47 +00:00
										 |  |  |     return ($status === 'active') ? 'running' : 'not running'; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-09-01 13:53:12 +00:00
										 |  |  | function getJVBStats($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; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-09-01 13:40:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-01 13:29:59 +00:00
										 |  |  | ?>
 |