added functions
parent
0e8943f762
commit
afddd91e27
|
@ -444,7 +444,7 @@ actions:
|
|||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- php /home/litespeed/mbmanager/scripts/check_opcache.php
|
||||
- php /home/litespeed/mbmanager/scripts/check_opcache.php --simple
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
|
|
@ -9,32 +9,60 @@ if (php_sapi_name() !== 'cli') {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
// Check PHP version and path
|
||||
echo "PHP Version: " . PHP_VERSION . "\n";
|
||||
echo "PHP Binary: " . PHP_BINARY . "\n";
|
||||
echo "PHP SAPI: " . php_sapi_name() . "\n";
|
||||
// Check for simple status flag
|
||||
$simpleStatus = isset($argv[1]) && $argv[1] === '--simple';
|
||||
|
||||
// Check PHP version and path (only if not simple mode)
|
||||
if (!$simpleStatus) {
|
||||
echo "PHP Version: " . PHP_VERSION . "\n";
|
||||
echo "PHP Binary: " . PHP_BINARY . "\n";
|
||||
echo "PHP SAPI: " . php_sapi_name() . "\n";
|
||||
}
|
||||
|
||||
// Check if OPCache is enabled
|
||||
if (!function_exists('opcache_get_status')) {
|
||||
if ($simpleStatus) {
|
||||
echo "OPcache status: Disabled - OPcache is not installed";
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => 'OPCache is not installed']);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Get OPCache status
|
||||
$status = opcache_get_status(false);
|
||||
if ($status === false) {
|
||||
if ($simpleStatus) {
|
||||
echo "OPcache status: Error - Failed to get OPcache status";
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Failed to get OPCache status']);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Get OPCache configuration
|
||||
$config = opcache_get_configuration();
|
||||
if ($config === false) {
|
||||
if ($simpleStatus) {
|
||||
echo "OPcache status: Error - Failed to get OPcache configuration";
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Failed to get OPCache configuration']);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Format the response
|
||||
// If simple status requested, just return enabled/disabled
|
||||
if ($simpleStatus) {
|
||||
$enabled = $config['directives']['opcache.enable'];
|
||||
if ($enabled) {
|
||||
echo "OPcache status: Enabled";
|
||||
} else {
|
||||
echo "OPcache status: Disabled";
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Format the full response (original functionality)
|
||||
$response = [
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
|
|
Loading…
Reference in New Issue