create system services dashboard item (#7231)
* create system services dashboard item * update internationalization language file used in system_services
This commit is contained in:
parent
88b35835b0
commit
96da9967e0
|
|
@ -243,6 +243,112 @@ $text['message-unavailable']['zh-cn'] = "不可用";
|
|||
$text['message-unavailable']['ja-jp'] = "利用不可";
|
||||
$text['message-unavailable']['ko-kr'] = "없는";
|
||||
|
||||
$text['label-service']['en-us'] = 'Service';
|
||||
$text['label-service']['en-gb'] = 'Service';
|
||||
$text['label-service']['ar-eg'] = 'خدمة';
|
||||
$text['label-service']['de-at'] = 'Service';
|
||||
$text['label-service']['de-ch'] = 'Service';
|
||||
$text['label-service']['de-de'] = 'Service';
|
||||
$text['label-service']['el-gr'] = 'Υπηρεσία';
|
||||
$text['label-service']['es-cl'] = 'Servicio';
|
||||
$text['label-service']['es-mx'] = 'Servicio';
|
||||
$text['label-service']['fr-ca'] = 'Service';
|
||||
$text['label-service']['fr-fr'] = 'Service';
|
||||
$text['label-service']['he-il'] = 'שֵׁרוּת';
|
||||
$text['label-service']['it-it'] = 'Servizio';
|
||||
$text['label-service']['ka-ge'] = 'სერვისი';
|
||||
$text['label-service']['nl-nl'] = 'Dienst';
|
||||
$text['label-service']['pl-pl'] = 'Praca';
|
||||
$text['label-service']['pt-br'] = 'Serviço';
|
||||
$text['label-service']['pt-pt'] = 'Serviço';
|
||||
$text['label-service']['ro-ro'] = 'Serviciu';
|
||||
$text['label-service']['ru-ru'] = 'Услуга';
|
||||
$text['label-service']['sv-se'] = 'Service';
|
||||
$text['label-service']['uk-ua'] = 'Сервіс';
|
||||
$text['label-service']['tr-tr'] = 'Hizmet';
|
||||
$text['label-service']['zh-cn'] = '服务';
|
||||
$text['label-service']['ja-jp'] = 'サービス';
|
||||
$text['label-service']['ko-kr'] = '서비스';
|
||||
|
||||
$text['label-running']['en-us'] = "Running";
|
||||
$text['label-running']['en-gb'] = "Running";
|
||||
$text['label-running']['ar-eg'] = "فعال";
|
||||
$text['label-running']['de-at'] = "Aktiv";
|
||||
$text['label-running']['de-ch'] = "Aktiv";
|
||||
$text['label-running']['de-de'] = "Aktiv";
|
||||
$text['label-running']['el-gr'] = "Τρέξιμο";
|
||||
$text['label-running']['es-cl'] = "Corriendo";
|
||||
$text['label-running']['es-mx'] = "Corriendo";
|
||||
$text['label-running']['fr-ca'] = "Actif";
|
||||
$text['label-running']['fr-fr'] = "Actif";
|
||||
$text['label-running']['he-il'] = "ריצה";
|
||||
$text['label-running']['it-it'] = "Attivo";
|
||||
$text['label-running']['ka-ge'] = "გაშვებულია";
|
||||
$text['label-running']['nl-nl'] = "Aktief";
|
||||
$text['label-running']['pl-pl'] = "Uruchomiony";
|
||||
$text['label-running']['pt-br'] = "Em execução";
|
||||
$text['label-running']['pt-pt'] = "Em execução";
|
||||
$text['label-running']['ro-ro'] = "Alergare";
|
||||
$text['label-running']['ru-ru'] = "Запущено";
|
||||
$text['label-running']['sv-se'] = "Löpning";
|
||||
$text['label-running']['uk-ua'] = "Запущено";
|
||||
$text['label-running']['tr-tr'] = "Koşma";
|
||||
$text['label-running']['zh-cn'] = "跑步";
|
||||
$text['label-running']['ja-jp'] = "ランニング";
|
||||
$text['label-running']['ko-kr'] = "달리기";
|
||||
|
||||
$text['label-yes']['en-us'] = "Yes";
|
||||
$text['label-yes']['en-gb'] = "Yes";
|
||||
$text['label-yes']['ar-eg'] = "نعم";
|
||||
$text['label-yes']['de-at'] = "Ja";
|
||||
$text['label-yes']['de-ch'] = "Ja";
|
||||
$text['label-yes']['de-de'] = "Ja";
|
||||
$text['label-yes']['el-gr'] = "Ναί";
|
||||
$text['label-yes']['es-cl'] = "Si";
|
||||
$text['label-yes']['es-mx'] = "Si";
|
||||
$text['label-yes']['fr-ca'] = "Oui";
|
||||
$text['label-yes']['fr-fr'] = "Oui";
|
||||
$text['label-yes']['he-il'] = "כן";
|
||||
$text['label-yes']['it-it'] = "Si";
|
||||
$text['label-yes']['nl-nl'] = "Ja";
|
||||
$text['label-yes']['pl-pl'] = "Tak";
|
||||
$text['label-yes']['pt-br'] = "Sim";
|
||||
$text['label-yes']['pt-pt'] = "Sim";
|
||||
$text['label-yes']['ro-ro'] = "da";
|
||||
$text['label-yes']['ru-ru'] = "Да";
|
||||
$text['label-yes']['sv-se'] = "Ja";
|
||||
$text['label-yes']['uk-ua'] = "Так";
|
||||
$text['label-yes']['tr-tr'] = "Evet";
|
||||
$text['label-yes']['zh-cn'] = "是的";
|
||||
$text['label-yes']['ja-jp'] = "はい";
|
||||
$text['label-yes']['ko-kr'] = "예";
|
||||
|
||||
$text['label-no']['en-us'] = "No";
|
||||
$text['label-no']['en-gb'] = "No";
|
||||
$text['label-no']['ar-eg'] = "لا";
|
||||
$text['label-no']['de-at'] = "Nein";
|
||||
$text['label-no']['de-ch'] = "Nein";
|
||||
$text['label-no']['de-de'] = "Nein";
|
||||
$text['label-no']['el-gr'] = "Οχι";
|
||||
$text['label-no']['es-cl'] = "No";
|
||||
$text['label-no']['es-mx'] = "No";
|
||||
$text['label-no']['fr-ca'] = "Non";
|
||||
$text['label-no']['fr-fr'] = "Non";
|
||||
$text['label-no']['he-il'] = "לא";
|
||||
$text['label-no']['it-it'] = "No";
|
||||
$text['label-no']['nl-nl'] = "Nee";
|
||||
$text['label-no']['pl-pl'] = "Nie";
|
||||
$text['label-no']['pt-br'] = "Não ";
|
||||
$text['label-no']['pt-pt'] = "Não";
|
||||
$text['label-no']['ro-ro'] = "Nu";
|
||||
$text['label-no']['ru-ru'] = "Нет";
|
||||
$text['label-no']['sv-se'] = "Nej";
|
||||
$text['label-no']['uk-ua'] = "Ні";
|
||||
$text['label-no']['tr-tr'] = "HAYIR";
|
||||
$text['label-no']['zh-cn'] = "不";
|
||||
$text['label-no']['ja-jp'] = "いいえ";
|
||||
$text['label-no']['ko-kr'] = "아니요";
|
||||
|
||||
$text['label-os']['en-us'] = "Operating System";
|
||||
$text['label-os']['en-gb'] = "Operating System";
|
||||
$text['label-os']['ar-eg'] = "מערכת הפעלה";
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ $y = 0;
|
|||
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = '41befc82-c65a-499e-9e29-513a3dd7974a';
|
||||
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = 'beade936-846b-4f02-986c-a2de6fa762c2';
|
||||
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'superadmin';
|
||||
$x++;
|
||||
|
||||
$x++;
|
||||
$array['dashboard'][$x]['dashboard_uuid'] = 'bb76f7fc-669f-41dd-a636-6ddaee5deae1';
|
||||
$array['dashboard'][$x]['dashboard_name'] = 'System Counts';
|
||||
$array['dashboard'][$x]['dashboard_path'] = 'system/system_counts';
|
||||
|
|
@ -61,6 +61,21 @@ $y = 0;
|
|||
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = 'a772d2a8-7c1f-4453-b77b-2e15b510a78d';
|
||||
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = 'bb76f7fc-669f-41dd-a636-6ddaee5deae1';
|
||||
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'superadmin';
|
||||
|
||||
$x++;
|
||||
$array['dashboard'][$x]['dashboard_uuid'] = '2a0a6742-bd2d-449a-88ac-b3ed255c9f8e';
|
||||
$array['dashboard'][$x]['dashboard_name'] = 'System Services';
|
||||
$array['dashboard'][$x]['dashboard_path'] = 'system/system_services';
|
||||
$array['dashboard'][$x]['dashboard_column_span'] = '1';
|
||||
$array['dashboard'][$x]['dashboard_row_span'] = '2';
|
||||
$array['dashboard'][$x]['dashboard_details_state'] = 'hidden';
|
||||
$array['dashboard'][$x]['dashboard_order'] = '110';
|
||||
$array['dashboard'][$x]['dashboard_enabled'] = 'true';
|
||||
$array['dashboard'][$x]['dashboard_description'] = 'A list of showing the count of active and inactive services';
|
||||
$y = 0;
|
||||
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = '719d8a56-00b2-437e-83c0-a9e5005a53c5';
|
||||
$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = '4bd3e11d-f4cd-4e37-8e7b-445e1e4aa7d5';
|
||||
$array['dashboard'][$x]['dashboard_groups'][$y]['group_name'] = 'superadmin';
|
||||
//$y++;
|
||||
//$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_group_uuid'] = '127382ae-0dd1-45eb-869c-56a708220de5';
|
||||
//$array['dashboard'][$x]['dashboard_groups'][$y]['dashboard_uuid'] = 'bb76f7fc-669f-41dd-a636-6ddaee5deae1';
|
||||
|
|
|
|||
|
|
@ -0,0 +1,175 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* FusionPBX
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FusionPBX
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mark J Crane <markjcrane@fusionpbx.com>
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008-2024
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mark J Crane <markjcrane@fusionpbx.com>
|
||||
* Tim Fry <tim@fusionpbx.com>
|
||||
*/
|
||||
|
||||
//includes files
|
||||
require_once dirname(__DIR__, 4) . "/resources/require.php";
|
||||
|
||||
//check permissions
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('xml_cdr_view')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
$dashboard_name = "System Services";
|
||||
|
||||
//function to parse a FusionPBX service from a .service file
|
||||
if (!function_exists('get_classname')) {
|
||||
function get_classname(string $file) {
|
||||
$parsed = parse_ini_file($file);
|
||||
$exec_cmd = $parsed['ExecStart'];
|
||||
$parts = explode(' ', $exec_cmd);
|
||||
$php_file = $parts[1] ?? '';
|
||||
if (!empty($php_file)) {
|
||||
return $php_file;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
//function to check for running process
|
||||
if (!function_exists('is_running')) {
|
||||
function is_running(string $name) {
|
||||
$output = '';
|
||||
|
||||
//escape for better safety
|
||||
$name = escapeshellarg($name);
|
||||
|
||||
// Use pgrep to search for the program by its name
|
||||
$output = shell_exec("ps -aux | grep $name | grep -v grep");
|
||||
|
||||
// If there is a process id then the program is running
|
||||
return ($output !== null && strlen($output) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
//load installed services
|
||||
$files = glob(PROJECT_ROOT . '/*/*/resources/service/*.service');
|
||||
$services = [];
|
||||
$total_running = 0;
|
||||
foreach ($files as $file) {
|
||||
$service = get_classname($file);
|
||||
//check if the service name was found
|
||||
if (!empty($service)) {
|
||||
$basename = basename($service, '.php');
|
||||
//clean up the name
|
||||
//$basename = ucwords(str_replace('_', ' ', $basename));
|
||||
//check if service is running
|
||||
$services[$basename] = is_running($service);
|
||||
//keep total count for charts
|
||||
if ($services[$basename]) {
|
||||
++$total_running;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//track total installed services for charts
|
||||
$total_services = count($services);
|
||||
|
||||
//add multi-lingual support
|
||||
$text = (new text())->get($settings->get('domain','language','en-us'), 'core/user_settings');
|
||||
|
||||
//show the results
|
||||
echo "<div class='hud_box'>\n";
|
||||
echo " <div class='hud_content' ".($dashboard_details_state == 'disabled' ?: "onclick=\"$('#hud_system_services_details').slideToggle('fast'); toggle_grid_row_end('$dashboard_name')\""). ">\n";
|
||||
echo " <span class='hud_title'>System Services</span>\n";
|
||||
echo " <div class='hud_chart' style='width: 250px;'><canvas id='system_services_chart'></canvas></div>\n";
|
||||
echo " </div>\n";
|
||||
echo " <script>\n";
|
||||
echo " const system_services_chart = new Chart (\n";
|
||||
echo " document.getElementById('system_services_chart').getContext('2d'),\n";
|
||||
echo " {\n";
|
||||
echo " type: 'doughnut',\n";
|
||||
echo " data: {\n";
|
||||
echo " labels: ['Active: $total_running' , 'Inactive: ".$total_services-$total_running."'],\n";
|
||||
echo " datasets: [{\n";
|
||||
echo " data: ['5','".$total_services-$total_running."'],\n";
|
||||
echo " backgroundColor: [\n";
|
||||
echo " '".$settings->get('theme', 'dashboard_system_counts_chart_main_color','#2a9df4')."',\n";
|
||||
echo " '".$settings->get('theme', 'dashboard_system_counts_chart_sub_color','#d4d4d4')."'\n";
|
||||
echo " ],\n";
|
||||
echo " borderColor: '".$settings->get('theme', 'dashboard_chart_border_color')."',\n";
|
||||
echo " borderWidth: '".$settings->get('theme', 'dashboard_chart_border_width')."'\n";
|
||||
echo " }]\n";
|
||||
echo " },\n";
|
||||
echo " options: {\n";
|
||||
echo " plugins: {\n";
|
||||
echo " chart_number: {\n";
|
||||
echo " text: '$total_services'\n";
|
||||
echo " },\n";
|
||||
echo " legend: {\n";
|
||||
echo " display: true,\n";
|
||||
echo " position: 'right',\n";
|
||||
echo " labels: {\n";
|
||||
echo " usePointStyle: true,\n";
|
||||
echo " pointStyle: 'rect',\n";
|
||||
echo " color: '$dashboard_heading_text_color'\n";
|
||||
echo " }\n";
|
||||
echo " }\n";
|
||||
echo " }\n";
|
||||
echo " },\n";
|
||||
echo " plugins: [{\n";
|
||||
echo " id: 'chart_number',\n";
|
||||
echo " beforeDraw(chart, args, options) {\n";
|
||||
echo " const {ctx, chartArea: {top, right, bottom, left, width, height} } = chart;\n";
|
||||
echo " ctx.font = chart_text_size + ' ' + chart_text_font;\n";
|
||||
echo " ctx.textBaseline = 'middle';\n";
|
||||
echo " ctx.textAlign = 'center';\n";
|
||||
echo " ctx.fillStyle = '$dashboard_number_text_color';\n";
|
||||
echo " ctx.fillText(options.text, width / 2, top + (height / 2));\n";
|
||||
echo " ctx.save();\n";
|
||||
echo " }\n";
|
||||
echo " }]\n";
|
||||
echo " }\n";
|
||||
echo " );\n";
|
||||
echo " </script>\n";
|
||||
|
||||
if ($dashboard_details_state != 'disabled') {
|
||||
echo " <div class='hud_details hud_box' id='hud_system_services_details'>\n";
|
||||
echo " <table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <th class='hud_heading' width='50%'>".($text['label-service'] ?? 'Service')."</th>\n";
|
||||
echo " <th class='hud_heading' width='50%' style='text-align: center; padding-left: 0; padding-right: 0;'>".($text['label-running'] ?? 'Running')."</th>\n";
|
||||
echo " </tr>\n";
|
||||
$row_style[false] = "row_style0";
|
||||
$row_style[true] = "row_style1";
|
||||
$c = true;
|
||||
foreach ($services as $name => $enabled) {
|
||||
echo " <tr>\n";
|
||||
echo " <td valign='top' class='{$row_style[$c]}' hud_text>$name</td>\n";
|
||||
echo " <td valign='top' class='{$row_style[$c]}' hud_text style='text-align: center;'>" . ($enabled ? $text['label-yes'] ?? 'Yes' : $text['label-no'] ?? 'No') . "</td>\n";
|
||||
echo " </tr>\n";
|
||||
$c = !$c;
|
||||
}
|
||||
echo " </table>\n";
|
||||
echo " </div>\n";
|
||||
}
|
||||
echo "</div>\n";
|
||||
Loading…
Reference in New Issue