From 87212bb25f6ee6ebf9d7587eeb207615acbc9133 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 13:34:37 +0200 Subject: [PATCH 01/20] Update header.php Add new menu System Info --- front/php/templates/header.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/front/php/templates/header.php b/front/php/templates/header.php index a4c66292..60007e85 100755 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -252,7 +252,10 @@ if ($ENABLED_DARKMODE === True) {
  • -
  • +
  • + +
  • +
  • From 5d53f1f605650da14d5f3717d973680e29400d37 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:03:06 +0200 Subject: [PATCH 02/20] Create systeminfo.php Create page for the new "System Information" menu --- front/systeminfo.php | 215 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 front/systeminfo.php diff --git a/front/systeminfo.php b/front/systeminfo.php new file mode 100644 index 00000000..4e6e966c --- /dev/null +++ b/front/systeminfo.php @@ -0,0 +1,215 @@ + + + +
    + + +
    + +

    + +

    +
    + + +
    + +format('l, F j, Y H:i:s'); +$formatted_date2 = $date->format('d/m/Y H:i:s'); +$formatted_date3 = $date->format('Y/m/d H:i:s'); +//hdd stat +$hdd_result = shell_exec("df | awk '{print $1}'"); +$hdd_devices = explode("\n", trim($hdd_result)); +$hdd_result = shell_exec("df | awk '{print $2}'"); +$hdd_devices_total = explode("\n", trim($hdd_result)); +$hdd_result = shell_exec("df | awk '{print $3}'"); +$hdd_devices_used = explode("\n", trim($hdd_result)); +$hdd_result = shell_exec("df | awk '{print $4}'"); +$hdd_devices_free = explode("\n", trim($hdd_result)); +$hdd_result = shell_exec("df | awk '{print $5}'"); +$hdd_devices_percent = explode("\n", trim($hdd_result)); +$hdd_result = shell_exec("df | awk '{print $6}'"); +$hdd_devices_mount = explode("\n", trim($hdd_result)); + +// Client ---------------------------------------------------------- +echo '
    +
    +

    This Client

    +
    +
    +
    +
    User Agent
    +
    ' . $_SERVER['HTTP_USER_AGENT'] . '
    +
    +
    +
    Browser Resolution:
    +
    +
    +
    +
    '; + +// General ---------------------------------------------------------- +echo '
    +
    +

    General

    +
    +
    +
    +
    Full Date
    +
    ' . $formatted_date . '
    +
    +
    +
    Date
    +
    ' . $formatted_date2 . '
    +
    +
    +
    Date2
    +
    ' . $formatted_date3 . '
    +
    +
    +
    Timezone
    +
    ' . $timeZone . '
    +
    +
    +
    Uptime
    +
    ' . $stat['uptime'] . '
    +
    +
    +
    Operating System
    +
    ' . $stat['os_version'] . '
    +
    +
    +
    CPU Name:
    +
    ' . $stat['cpu_model'] . '
    +
    +
    +
    CPU Cores:
    +
    ' . $stat['cpu'] . ' @ ' . $stat['cpu_frequ'] . ' MHz
    +
    +
    +
    Memory:
    +
    ' . $stat['mem_used'] . ' MB / ' . $stat['mem_total'] . ' MB
    +
    +
    +
    Memory %:
    +
    ' . $memory_usage_percent . ' %
    +
    +
    +
    Total memory:
    +
    ' . $total_memory . ' MB
    +
    +
    +
    Load AVG:
    +
    '. $load_average[0] .' '. $load_average[1] .' '. $load_average[2] .'
    +
    +
    +
    '; + +echo ''; + +// Storage usage ---------------------------------------------------------- +echo '
    +
    +

    Storage usage

    +
    +
    '; +for ($x = 0; $x < sizeof($hdd_devices); $x++) { + if (stristr($hdd_devices[$x], '/dev/')) { + if ($hdd_devices_total[$x] == 0) {$temp_total = 0;} else { $temp_total = number_format(round(($hdd_devices_total[$x] / 1024 / 1024), 2), 2, ',', '.');} + if ($hdd_devices_used[$x] == 0) {$temp_used = 0;} else { $temp_used = number_format(round(($hdd_devices_used[$x] / 1024 / 1024), 2), 2, ',', '.');} + if ($hdd_devices_free[$x] == 0) {$temp_free = 0;} else { $temp_free = number_format(round(($hdd_devices_free[$x] / 1024 / 1024), 2), 2, ',', '.');} + echo '
    '; + echo '
    Mount point "' . $hdd_devices_mount[$x] . '"
    '; + echo '
    Total: ' . $temp_total . ' GB
    '; + echo '
    Used: ' . $temp_used . ' GB (' . number_format($hdd_devices_percent[$x], 1, ',', '.') . '%)
    '; + echo '
    Free: ' . $temp_free . ' GB
    '; + echo '
    '; + } +} +echo '
    ' . $pia_lang['SysInfo_storage_note']; +echo '
    +
    '; +?> + +
    + + + + + + + + From 293e00932132f6c61113be755d481140d73715aa Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:06:06 +0200 Subject: [PATCH 03/20] Update systeminfo.php Updated blanks Updated OS-Version comment --- front/systeminfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index 4e6e966c..f082327e 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -9,7 +9,7 @@ // Puche 2021 pi.alert.application@gmail.com GNU GPLv3 // jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 // leiweibau 2022 https://github.com/leiweibau GNU GPLv3 -// cvc90 2023 https://github.com/cvc90 GNU GPLv3 +// cvc90 2023 https://github.com/cvc90 GNU GPLv3 //------------------------------------------------------------------------------ ?> @@ -32,7 +32,7 @@
    Date: Sat, 5 Aug 2023 14:15:25 +0200 Subject: [PATCH 04/20] Update es_es.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added new translation to Spanish, variable Navigation_SystemInfo" : "Información del sistema" Added new translation to Spanish, variable "SYSTEM_TITLE" : "Información del sistema" --- front/php/templates/language/es_es.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json index 609da9d5..fe0cb40d 100755 --- a/front/php/templates/language/es_es.json +++ b/front/php/templates/language/es_es.json @@ -41,6 +41,7 @@ "Navigation_Plugins" : "Plugins", "Navigation_Maintenance" : "Mantenimiento", "Navigation_Settings" : "Configuración", + "Navigation_SystemInfo" : "Información del sistema", "Navigation_HelpFAQ" : "Ayuda / Preguntas frecuentes", "Device_Title" : "Dispositivos", "Device_Shortcut_AllDevices" : "Todos", @@ -451,6 +452,7 @@ "SMTP_SKIP_TLS_description" : "Deshabilite TLS cuando se conecte a su servidor SMTP.", "SMTP_FORCE_SSL_name" : "Forzar SSL", "SMTP_FORCE_SSL_description" : "Forzar SSL al conectarse a su servidor SMTP", + "SYSTEM_TITLE" : "Información del sistema", "REPORT_TO_name" : "Enviar el email a", "REPORT_TO_description" : "Dirección de correo electrónico a la que se enviará la notificación.", "REPORT_FROM_name" : "Asunto del email", @@ -560,4 +562,4 @@ "API_CUSTOM_SQL_name" : "Endpoint personalizado", "API_CUSTOM_SQL_description" : "Puede especificar una consulta SQL personalizada que generará un archivo JSON y luego lo expondrá a través del archivo table_custom_endpoint.json." } -} \ No newline at end of file +} From d8904f7ac8240af597c72c613f9396b5e64c0b64 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:16:54 +0200 Subject: [PATCH 05/20] Update systeminfo.php Update variable lang --- front/systeminfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index f082327e..417d8a78 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -24,7 +24,7 @@

    - +

    From e8f9608372249a717ef7023b00479e92644042a3 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:21:44 +0200 Subject: [PATCH 06/20] Update en_us.json Added new translation to English, variable "Navigation_SystemInfo" : "System Information" Added new translation to English, variable "SYSTEM_TITLE" : "System Information" --- front/php/templates/language/en_us.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 45c8b541..cd9b8fbb 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -42,6 +42,7 @@ "Navigation_Plugins" : "Plugins", "Navigation_Maintenance" : "Maintenance", "Navigation_Settings" : "Settings", + "Navigation_SystemInfo" : "System Information", "Navigation_Flows" : "Flows", "Navigation_HelpFAQ" : "Help / FAQ", "Device_Title" : "Devices", @@ -475,6 +476,7 @@ "SMTP_SKIP_TLS_description" : "Disable TLS when connecting to your SMTP server.", "SMTP_FORCE_SSL_name" : "Force SSL", "SMTP_FORCE_SSL_description" : "Force SSL when connecting to your SMTP server.", + "SYSTEM_TITLE" : "System Information", "REPORT_TO_name" : "Send email to", "REPORT_TO_description" : "Email address to which the notification will be send to.", "REPORT_FROM_name" : "Email subject", @@ -586,4 +588,4 @@ "API_CUSTOM_SQL_name" : "Custom endpoint", "API_CUSTOM_SQL_description" : "You can specify a custom SQL query which will generate a JSON file and then expose it via the table_custom_endpoint.json file endpoint." } -} \ No newline at end of file +} From 1bafee59c8910ad10233a6c3e22b9ea933801295 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:26:51 +0200 Subject: [PATCH 07/20] Update de_de.json Added new translation to German, variable "Navigation_SystemInfo" : "Systeminformationen" Added new translation to German, variable "SYSTEM_TITLE" : "Systeminformationen" --- front/php/templates/language/de_de.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json index bcf3c2b4..fbb308a2 100755 --- a/front/php/templates/language/de_de.json +++ b/front/php/templates/language/de_de.json @@ -28,6 +28,7 @@ "Navigation_Events" : "Ereignisse", "Navigation_Maintenance" : "Wartung", "Navigation_Settings" : "Einstellung", + "Navigation_SystemInfo" : "Systeminformationen", "Navigation_Network" : "Netzwerk", "Navigation_HelpFAQ" : "Hilfe / FAQ", "Device_Title" : "Geräte", @@ -315,7 +316,8 @@ "HelpFAQ_Cat_Presence_401_head" : "Ein Gerät wird als Anwesend angezeigt, obwohl es \"Offline\" ist.", "HelpFAQ_Cat_Presence_401_text" : "Wenn dies geschieht hast du die Möglickeit, bei dem betreffenden Gerät (Detailsansicht) die Events zu löschen. Eine andere Möglichkeit wäre, das Gerät einzuschalten und zu warten, bis Pi.Alert mit dem nächsten Scan das Gerät als \"Online\" erkennt und anschließend das Gerät einfach wieder ausschalten. Nun sollte Pi.Alert mit dem nächsten Scan den Zustand des Gerätes ordentlich in der Datenbank vermerken.", "HelpFAQ_Cat_Network_600_head" : "Was bringt mir diese Seite?", - "HelpFAQ_Cat_Network_600_text" : "Diese Seite soll dir die Möglichkeit bieten, die Belegung deiner Netzwerkgeräte abzubilden. Dazu kannst du einen oder mehrere Switches, WLANs, Router, etc. erstellen, sie ggf. mit einer Portanzahl versehen und bereits erkannte Geräte diesen zuordnen. Diese Zuordnung erfolgt in der Detailansicht, des zuzuordnenden Gerätes. So ist es dir möglich, schnell festzustellen an welchem Port ein Host angeschlossen und ob er online ist." + "HelpFAQ_Cat_Network_600_text" : "Diese Seite soll dir die Möglichkeit bieten, die Belegung deiner Netzwerkgeräte abzubilden. Dazu kannst du einen oder mehrere Switches, WLANs, Router, etc. erstellen, sie ggf. mit einer Portanzahl versehen und bereits erkannte Geräte diesen zuordnen. Diese Zuordnung erfolgt in der Detailansicht, des zuzuordnenden Gerätes. So ist es dir möglich, schnell festzustellen an welchem Port ein Host angeschlossen und ob er online ist.", + "SYSTEM_TITLE" : "Systeminformationen" } } - \ No newline at end of file + From a4f8cfa287bc3c11031592373ac9a2f7bd60e552 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:30:03 +0200 Subject: [PATCH 08/20] Update systeminfo.php Update variable lang to --- front/systeminfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index 417d8a78..fe0b0fa0 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -24,7 +24,7 @@

    - +

    From 07c2c2b9ac63a56218afc0c52524135b49f4db85 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:39:13 +0200 Subject: [PATCH 09/20] Update Dockerfile Fixes for the new System Info menu to work in Docker, added "systemctl", "lsusb" to the installation list --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0004f2ec..369da091 100755 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ ENV USER=pi USER_ID=1000 USER_GID=1000 PORT=20211 # Todo, do we still need all these packages? I can already see sudo which isn't needed RUN apt-get update \ - && apt-get install --no-install-recommends tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools python3 iproute2 nmap python3-pip zip -y \ + && apt-get install --no-install-recommends tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools python3 iproute2 nmap python3-pip zip systemctl lsusb -y \ && pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi \ && update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \ && apt-get clean autoclean \ @@ -51,4 +51,4 @@ CMD ["/home/pi/pialert/dockerfiles/start.sh"] -## command to build docker: DOCKER_BUILDKIT=1 docker build . --iidfile dockerID \ No newline at end of file +## command to build docker: DOCKER_BUILDKIT=1 docker build . --iidfile dockerID From cab6c0cefbe5757db702b1c3a4619e81975c64f2 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:48:59 +0200 Subject: [PATCH 10/20] Update Dockerfile Change "lsusb" to "usbutils" in apt-get install --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 369da091..f1ebf974 100755 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ ENV USER=pi USER_ID=1000 USER_GID=1000 PORT=20211 # Todo, do we still need all these packages? I can already see sudo which isn't needed RUN apt-get update \ - && apt-get install --no-install-recommends tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools python3 iproute2 nmap python3-pip zip systemctl lsusb -y \ + && apt-get install --no-install-recommends tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools python3 iproute2 nmap python3-pip zip systemctl usbutils -y \ && pip3 install requests paho-mqtt scapy cron-converter pytz json2table dhcp-leases pyunifi \ && update-alternatives --install /usr/bin/python python /usr/bin/python3 10 \ && apt-get clean autoclean \ From 8fe10e63142f87aa21b83aafc033148c9aae3e45 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:56:05 +0200 Subject: [PATCH 11/20] Update systeminfo.php Fix variable 'mem_used' --- front/systeminfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index fe0b0fa0..8906de46 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -70,7 +70,7 @@ if (file_exists('/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq')) { $total_memory = shell_exec("cat /proc/meminfo | grep MemTotal | cut -d' ' -f2-") / 1024 | bc; $mem_result = shell_exec("cat /proc/meminfo | grep MemTotal"); $stat['mem_total'] = round(preg_replace("#[^0-9]+(?:\.[0-9]*)?#", "", $mem_result) / 1024 / 1024, 3); -$stat['mem_used'] = round(memory_get_usage() / 1048576, 2); +$stat['mem_used'] = round(memory_get_usage() / 1048576 * 100, 2); $memory_usage_percent = round($mem_used * 100, 2); //Load System $load_average = sys_getloadavg(); From 43a2c4870e8a8a9f92a04bb5eb2674e73c19284d Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:09:47 +0200 Subject: [PATCH 12/20] Update systeminfo.php Fix variable $memory_usage_percent --- front/systeminfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index 8906de46..b65941df 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -71,7 +71,7 @@ $total_memory = shell_exec("cat /proc/meminfo | grep MemTotal | cut -d' ' -f2-") $mem_result = shell_exec("cat /proc/meminfo | grep MemTotal"); $stat['mem_total'] = round(preg_replace("#[^0-9]+(?:\.[0-9]*)?#", "", $mem_result) / 1024 / 1024, 3); $stat['mem_used'] = round(memory_get_usage() / 1048576 * 100, 2); -$memory_usage_percent = round($mem_used * 100, 2); +$memory_usage_percent = round(($stat['mem_used'] / $stat['mem_total']), 2); //Load System $load_average = sys_getloadavg(); //Date & Time From 012589b8481e3cffb9d053e5d8959d8b0fba1d4f Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:19:23 +0200 Subject: [PATCH 13/20] Update systeminfo.php Add new content to the "USB" variables submenu Add new content to the "USB" submenu Add new content to the "Services" submenu --- front/systeminfo.php | 62 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index b65941df..4e00ef9f 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -9,7 +9,7 @@ // Puche 2021 pi.alert.application@gmail.com GNU GPLv3 // jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 // leiweibau 2022 https://github.com/leiweibau GNU GPLv3 -// cvc90 2023 https://github.com/cvc90 GNU GPLv3 +// cvc90 2023 https://github.com/cvc90 GNU GPLv3 //------------------------------------------------------------------------------ ?> @@ -92,6 +92,9 @@ $hdd_result = shell_exec("df | awk '{print $5}'"); $hdd_devices_percent = explode("\n", trim($hdd_result)); $hdd_result = shell_exec("df | awk '{print $6}'"); $hdd_devices_mount = explode("\n", trim($hdd_result)); +//usb devices +$usb_result = shell_exec("lsusb"); +$usb_devices_mount = explode("\n", trim($usb_result)); // Client ---------------------------------------------------------- echo '
    @@ -200,6 +203,63 @@ for ($x = 0; $x < sizeof($hdd_devices); $x++) { echo '
    ' . $pia_lang['SysInfo_storage_note']; echo '
    '; + +// Services ---------------------------------------------------------- +echo '
    +
    +

    Services (running)

    +
    +
    '; +echo '
    '; +exec('systemctl --type=service --state=running', $running_services); +echo ''; +echo ' + + + + + '; +$table_color = 'odd'; +for ($x = 0; $x < sizeof($running_services); $x++) { + if (stristr($running_services[$x], '.service')) { + $temp_services_arr = array_values(array_filter(explode(' ', trim($running_services[$x])))); + $servives_name = $temp_services_arr[0]; + unset($temp_services_arr[0], $temp_services_arr[1], $temp_services_arr[2], $temp_services_arr[3]); + $servives_description = implode(" ", $temp_services_arr); + if ($table_color == 'odd') {$table_color = 'even';} else { $table_color = 'odd';} + + echo ''; + } +} +echo ''; +echo '
    '; +echo '
    +
    '; + +// USB ---------------------------------------------------------- +echo '
    +
    +

    USB Devices

    +
    +
    '; +echo ' '; + +$table_color = 'odd'; +sort($usb_devices_mount); +for ($x = 0; $x < sizeof($usb_devices_mount); $x++) { + $cut_pos = strpos($usb_devices_mount[$x], ':'); + $usb_bus = substr($usb_devices_mount[$x], 0, $cut_pos); + $usb_dev = substr($usb_devices_mount[$x], $cut_pos + 1); + + if ($table_color == 'odd') {$table_color = 'even';} else { $table_color = 'odd';} + echo ''; +} +echo ' '; +echo '
    +
    '; +echo '
    '; + + ?> From e5eb3ab2975baca1083054ed84be7c014b6c3d3e Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:21:16 +0200 Subject: [PATCH 14/20] Update systeminfo.php Fixed comment space located in variable error_reporting(0); // Turn off php errors --- front/systeminfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index 4e00ef9f..6c446477 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -14,7 +14,7 @@ ?> From e06fe9146c763deafd10d7193a01b491496413d2 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:27:24 +0200 Subject: [PATCH 15/20] Update systeminfo.php Add new content to the "Storage" submenu --- front/systeminfo.php | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index 6c446477..0fa8cfe8 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -14,7 +14,7 @@ ?> @@ -181,6 +181,43 @@ echo ''; +// Storage ---------------------------------------------------------- +echo '
    +
    +

    Storage

    +
    +
    '; + +$storage_lsblk = shell_exec("lsblk -io NAME,SIZE,TYPE,MOUNTPOINT,MODEL --list | tail -n +2 | awk '{print $1\"#\"$2\"#\"$3\"#\"$4\"#\"$5}'"); +$storage_lsblk_line = explode("\n", $storage_lsblk); +$storage_lsblk_line = array_filter($storage_lsblk_line); + +for ($x = 0; $x < sizeof($storage_lsblk_line); $x++) { + $temp = array(); + $temp = explode("#", $storage_lsblk_line[$x]); + $storage_lsblk_line[$x] = $temp; +} +// echo '
    ';
    +// print_r($storage_lsblk_line);
    +// echo '
    '; + +for ($x = 0; $x < sizeof($storage_lsblk_line); $x++) { + //if (stristr($hdd_devices[$x], '/dev/')) { + echo '
    '; + if (preg_match('~[0-9]+~', $storage_lsblk_line[$x][0])) { + echo '
    Mount point "' . $storage_lsblk_line[$x][3] . '"
    '; + } else { + echo '
    "' . str_replace('_', ' ', $storage_lsblk_line[$x][3]) . '"
    '; + } + echo '
    Device: /dev/' . $storage_lsblk_line[$x][0] . '
    '; + echo '
    Size: ' . $storage_lsblk_line[$x][1] . '
    '; + echo '
    Type: ' . $storage_lsblk_line[$x][2] . '
    '; + echo '
    '; + //} +} +echo '
    +
    '; + // Storage usage ---------------------------------------------------------- echo '
    From da0d387ae047ba45e2fef0cc03c5eb94af45d7c4 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:38:14 +0200 Subject: [PATCH 16/20] Update systeminfo.php Updated some comments of variable sections Added new section of variables "Network Hardware stat" Add new content to the "Network Hardware" submenu --- front/systeminfo.php | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index 0fa8cfe8..e306f85e 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -9,7 +9,7 @@ // Puche 2021 pi.alert.application@gmail.com GNU GPLv3 // jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 // leiweibau 2022 https://github.com/leiweibau GNU GPLv3 -// cvc90 2023 https://github.com/cvc90 GNU GPLv3 +// cvc90 2023 https://github.com/cvc90 GNU GPLv3 //------------------------------------------------------------------------------ ?> @@ -41,7 +41,7 @@ if ($os_version == '') {$os_version = exec('uname -o');} //$os_version_arr = explode("\n", trim($os_version)); $stat['os_version'] = str_replace('"', '', str_replace('PRETTY_NAME=', '', $os_version)); $stat['uptime'] = str_replace('up ', '', shell_exec("uptime -p")); -//cpu stat +//CPU stat $prevVal = shell_exec("cat /proc/cpuinfo | grep processor"); $prevArr = explode("\n", trim($prevVal)); $stat['cpu'] = sizeof($prevArr); @@ -66,7 +66,7 @@ if (file_exists('/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq')) { // Fallback $stat['cpu_frequ'] = "unknown"; } -//memory stat +//Memory stats $total_memory = shell_exec("cat /proc/meminfo | grep MemTotal | cut -d' ' -f2-") / 1024 | bc; $mem_result = shell_exec("cat /proc/meminfo | grep MemTotal"); $stat['mem_total'] = round(preg_replace("#[^0-9]+(?:\.[0-9]*)?#", "", $mem_result) / 1024 / 1024, 3); @@ -79,7 +79,14 @@ $date = new DateTime(); $formatted_date = $date->format('l, F j, Y H:i:s'); $formatted_date2 = $date->format('d/m/Y H:i:s'); $formatted_date3 = $date->format('Y/m/d H:i:s'); -//hdd stat +//Network Hardware stat +$network_result = shell_exec("cat /proc/net/dev | tail -n +3 | awk '{print $1}'"); +$net_interfaces = explode("\n", trim($network_result)); +$network_result = shell_exec("cat /proc/net/dev | tail -n +3 | awk '{print $2}'"); +$net_interfaces_rx = explode("\n", trim($network_result)); +$network_result = shell_exec("cat /proc/net/dev | tail -n +3 | awk '{print $10}'"); +$net_interfaces_tx = explode("\n", trim($network_result)); +//HDD stats $hdd_result = shell_exec("df | awk '{print $1}'"); $hdd_devices = explode("\n", trim($hdd_result)); $hdd_result = shell_exec("df | awk '{print $2}'"); @@ -92,7 +99,7 @@ $hdd_result = shell_exec("df | awk '{print $5}'"); $hdd_devices_percent = explode("\n", trim($hdd_result)); $hdd_result = shell_exec("df | awk '{print $6}'"); $hdd_devices_mount = explode("\n", trim($hdd_result)); -//usb devices +//USB devices $usb_result = shell_exec("lsusb"); $usb_devices_mount = explode("\n", trim($usb_result)); @@ -241,6 +248,33 @@ echo '
    ' . $pia_lang['SysInfo_storage_note']; echo '
    '; +// Network Hardware ---------------------------------------------------------- +echo '
    +
    +

    Network Hardware

    +
    +
    '; + +for ($x = 0; $x < sizeof($net_interfaces); $x++) { + $interface_name = str_replace(':', '', $net_interfaces[$x]); + $interface_ip_temp = exec('ip addr show ' . $interface_name . ' | grep inet'); + $interface_ip_arr = explode(' ', trim($interface_ip_temp)); + + if (!isset($interface_ip_arr[1])) {$interface_ip_arr[1] = '--';} + + if ($net_interfaces_rx[$x] == 0) {$temp_rx = 0;} else { $temp_rx = number_format(round(($net_interfaces_rx[$x] / 1024 / 1024), 2), 2, ',', '.');} + if ($net_interfaces_tx[$x] == 0) {$temp_tx = 0;} else { $temp_tx = number_format(round(($net_interfaces_tx[$x] / 1024 / 1024), 2), 2, ',', '.');} + echo '
    '; + echo '
    ' . $interface_name . '
    '; + echo '
    ' . $interface_ip_arr[1] . '
    '; + echo '
    RX:
    ' . $temp_rx . ' MB
    '; + echo '
    TX:
    ' . $temp_tx . ' MB
    '; + echo '
    '; + +} +echo '
    +
    '; + // Services ---------------------------------------------------------- echo '
    From 72ccaf754fc304b656fe273de56d57073db30f5f Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:42:41 +0200 Subject: [PATCH 17/20] Update systeminfo.php Add new content to the "Network" submenu --- front/systeminfo.php | 74 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/front/systeminfo.php b/front/systeminfo.php index e306f85e..2a1567fc 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -248,6 +248,80 @@ echo '
    ' . $pia_lang['SysInfo_storage_note']; echo '
    '; +// Network ---------------------------------------------------------- +echo '
    +
    +

    Network

    +
    +
    +
    +
    IP Internet:
    +
    ' . shell_exec("curl https://ifconfig.co") . '
    +
    +
    +
    IP connection:
    +
    ' . $_SERVER['REMOTE_ADDR'] . '
    +
    +
    +
    Server IP:
    +
    ' . $_SERVER['SERVER_ADDR'] . '
    +
    +
    +
    Server name:
    +
    ' . $_SERVER['SERVER_NAME'] . '
    +
    +
    +
    Connection port:
    +
    ' . $_SERVER['REMOTE_PORT'] . '
    +
    +
    +
    Secure connection:
    +
    ' . $_SERVER['HTTPS'] . '
    +
    +
    +
    Server Version:
    +
    ' . $_SERVER['SERVER_SOFTWARE'] . '
    +
    +
    +
    Request URI:
    +
    ' . $_SERVER['REQUEST_URI'] . '
    +
    +
    +
    Server Version:
    +
    ' . $_SERVER['QUERY_STRING'] . '
    +
    +
    +
    HTTP_host:
    +
    ' . $_SERVER['HTTP_HOST'] . '
    +
    +
    +
    HTTP_referer:
    +
    ' . $_SERVER['HTTP_REFERER'] . '
    +
    +
    +
    MIME:
    +
    ' . $_SERVER['HTTP_ACCEPT'] . '
    +
    +
    +
    Accept language:
    +
    ' . $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '
    +
    +
    +
    Accept encoding:
    +
    ' . $_SERVER['HTTP_ACCEPT_ENCODING'] . '
    +
    +
    +
    Request_Method:
    +
    ' . $_SERVER['REQUEST_METHOD'] . '
    +
    +
    +
    Request_time:
    +
    ' . $_SERVER['REQUEST_TIME'] . '
    +
    +
    +
    '; + + // Network Hardware ---------------------------------------------------------- echo '
    From c2676f9fdaec24142b9637cee617c7b535150590 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:49:32 +0200 Subject: [PATCH 18/20] Update systeminfo.php Added final section separator Fixed end of submenu section --- front/systeminfo.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index 2a1567fc..460b7b8a 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -402,8 +402,10 @@ for ($x = 0; $x < sizeof($usb_devices_mount); $x++) { echo ' '; echo '
    '; -echo '
    '; +// ---------------------------------------------------------- + +echo '
    '; ?> From a4984dc477b27ebb712fe4e802c2a6bc8b0f9620 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:54:13 +0200 Subject: [PATCH 19/20] Update systeminfo.php Fixed Server name query --- front/systeminfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index 460b7b8a..5b0fb774 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -287,7 +287,7 @@ echo '
    ' . $_SERVER['REQUEST_URI'] . '
    -
    Server Version:
    +
    Server query:
    ' . $_SERVER['QUERY_STRING'] . '
    From f26507e5402a350de2389501832b45ffc8637fc5 Mon Sep 17 00:00:00 2001 From: Carlos V <76731844+cvc90@users.noreply.github.com> Date: Sat, 5 Aug 2023 19:47:42 +0200 Subject: [PATCH 20/20] Update systeminfo.php Updated php opening at the beginning of the file --- front/systeminfo.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/front/systeminfo.php b/front/systeminfo.php index 5b0fb774..d62ece1e 100644 --- a/front/systeminfo.php +++ b/front/systeminfo.php @@ -12,8 +12,6 @@ // cvc90 2023 https://github.com/cvc90 GNU GPLv3 //------------------------------------------------------------------------------ -?> -