diff --git a/Dockerfile b/Dockerfile index 0004f2ec..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 -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 \ @@ -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 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) {
  • -
  • +
  • + +
  • +
  • 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 + 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 +} 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 +} diff --git a/front/systeminfo.php b/front/systeminfo.php new file mode 100644 index 00000000..d62ece1e --- /dev/null +++ b/front/systeminfo.php @@ -0,0 +1,420 @@ + + +
    + + +
    + +

    + +

    +
    + + +
    + +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'); +//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}'"); +$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)); +//USB devices +$usb_result = shell_exec("lsusb"); +$usb_devices_mount = explode("\n", trim($usb_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 ---------------------------------------------------------- +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 '
    +
    +

    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 '
    +
    '; + +// 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 query:
    +
    ' . $_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 '
    +
    +

    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 '
    +
    +

    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 '
    '; + +?> + +
    + + + + + + + +