wallacebrf / Synology-SMART-test-scheduler

Scheduler of Synology SMART tests
10 stars 1 forks source link

How to open the php file in a web browser? #14

Closed 007revad closed 2 weeks ago

007revad commented 2 weeks ago

using a browser go to the "smart_scheduler_config.php" page

That's kind of vague. Can you explain this in more detail?

Did you setup something in Web Station?

I've tried the following which gives the "Synology. Sorry, the page you are looking for is not found" http://192.168.20.20:5070/web/synology_smart/smart_scheduler_config.php

And with https chrome says "This site can’t provide a secure connection. 192.168.20.20 sent an invalid response"

From Windows I can browse to the php file, right-click and select open with Chrome - which opens it as a text page (showing the source code). Webber is the NAS' hostname. file://webber/web/synology_smart/smart_scheduler_config.php

Changing "file;//" to "https://" or "http://" both result in error 500. http://webber/web/synology_smart/smart_scheduler_config.php https://webber/web/synology_smart/smart_scheduler_config.php

Including port 443 or 80 also result in error 500. http://webber:80/web/synology_smart/smart_scheduler_config.php https://webber:443/web/synology_smart/smart_scheduler_config.php

wallacebrf commented 2 weeks ago

try getting rid of the /web in the URL as the root of the server "should" be /volume1/web

http://192.168.20.20:5070/synology_smart/smart_scheduler_config.php

for example, this works for me

http://192.168.1.13/synology_smart/smart_scheduler_config.php

wallacebrf commented 2 weeks ago

what is the port your web-server is running on? you appear to be trying to connect to port 5070?

wallacebrf commented 2 weeks ago

to further answer your question, sorry, missed some of it

yes, on my synology i have web station configured with my /volume1/web shared folder set as the server root. I then have the latest PHP installed and configured to be the backed of the webserver.

i can work on adding basic instructions on how to configure web station if that makes things easier for people

i am also planning to explain how to use the script WITHOUT the PHP web server and explain how to edit the config file directly.

007revad commented 2 weeks ago

http://192.168.20.20:5070/synology_smart/smart_scheduler_config.php also results in "Sorry, the page you are looking for is not found."

These all result in the 500 error https://192.168.20.20/synology_smart/smart_scheduler_config.php http://192.168.20.20/synology_smart/smart_scheduler_config.php https://192.168.20.20:443/synology_smart/smart_scheduler_config.php http://192.168.20.20:80/synology_smart/smart_scheduler_config.php

wallacebrf commented 2 weeks ago

can you provide any screen shots of how you have web-station configured?

007revad commented 2 weeks ago

what is the port your web-server is running on? on my synology i have web station configured with my /volume1/web shared folder set as the server root

Is this the "Personal website" mentioned in this screenshot? image

Other screenshots: image

image

image

wallacebrf commented 2 weeks ago

here is mine

image

image

image

image

wallacebrf commented 2 weeks ago

here are some instructions i will flesh out more and add to the read me

ensure web station and PHPO 8.2 are installed

inside web-station go to "Script Language Settings --> PHP tab --> Create

settings tab:
    Enter profile name "core"
    Enter Description as "core"
    choose PHO 8.2 for PHO version
    click "enable display_errors to display PHP error messages
    keep "customize PHO open_basedir as "default"
extensions tab:
    enable all extensions
FPM tab:
    leave as default
Core tab:
    leave as default

inside web-station to to "Web Service" --> create
choose "native script language website"
under service, click PHP 8.2
click next

enter a name "core"
Enter Description as "core"
choose document root as "volume1/web" shared folder
for HTTP back-end-server blick "Nginx"
leave timeout settings as default
click next

review the settings, and click "create"

inside web-station to to "Web Portal--> create
choose the "web service portal"
under "service" choose the "core" service we created previously
choose a hostname, like "home"
choose ports. suggest standard web-server ports 80/443
under HTTPS settings, choose to enable "HSTS"
under "access control profile" leave as "not configured"
under "error page profile" choose "default error page profile"
enable "enable access logs"
click create
007revad commented 2 weeks ago

choose a hostname, like "home" Does it have to be the network hostname of the NAS?

I believe there was step missing:

inside web-station to to "Web Service" --> create
choose "native script language website"
under service, click PHP 8.2
change "Default profile" to core        <----- missing ?
click next

Getting there. https://webber/ and http://webber/ both show the following: image

All of these give a 403 error https://webber/synology_smart/smart_scheduler_config.php http://webber/synology_smart/smart_scheduler_config.php https://webber/smart_scheduler_config.php http://webber/smart_scheduler_config.php

Then I realised the DS720+ hostname is senna (my old DS1812+ is webber). After changing the hostname in "web service portal" to SENNA I'm now getting a 403 error for https://senna/ and https://senna/

wallacebrf commented 2 weeks ago

on my spare DS920, which never had web-station setup, i just did this verbatim, BUT i did have to fix something that was causing an "alis error" under the over view section. i had to fully disable thew joomla, mediawiki etc that were installed but then removed.

ensure web station and PHP 8.2 are installed in package center

inside web-station go to "Script Language Settings --> PHP tab --> Create

settings tab: Enter profile name "core" Enter Description as "core" choose PHP 8.2 for PHP version click "enable display_errors to display PHP error messages keep "customize PHO open_basedir as "default" click next enable all extensions click next leave as default click next leave as default click next review the settings and click "create"

inside web-station to to "Web Service" --> create choose "native script language website" under service, click PHP 8.2 and choose the "core" PHP profile previously created

click next

enter a name "core" Enter Description as "core" choose document root as "/volume1/web" shared folder for HTTP back-end-server click "Nginx" leave timeout settings as default click next

review the settings, and click "create"

inside web-station to to "Web Portal--> create choose the "web service portal" under "service" choose the "core" service we created previously under portal type leave as "name based" choose a hostname, like "home". This should be same value as the NAS's name choose ports. suggest standard web-server ports 80/443 under HTTPS settings, choose to enable "HSTS" under "access control profile" leave as "not configured" under "error page profile" choose "default error page profile" enable "enable access logs" click create

i am now able to see the web interface fine on the DS-920 spare

wallacebrf commented 2 weeks ago

for your error, do you have the files in the correct shared folder and or have the webserver pointing to the right directory? when i was setting up, i had to choose the "web" shared folder during this step choose document root as "/volume1/web" shared folder

if you have homes enabled, your user might have a www folder that it wants the files placed to?

007revad commented 2 weeks ago

No www folder in homes.

i had to choose the "web" shared folder during this step choose document root as "/volume1/web" shared folder

I'm an idiot! I had it set to /volume1/web/synology_smart

Now that I've changed it to /volume1/web it works! YAY!!!!

The fields in the status and manual control table were messed up, because you've added the Synology Slot field since I last ran the script. So I added an extra ; before each /dev image

wallacebrf commented 2 weeks ago

So checking, there is a new error or you added the semi colon like I already did the main branch?

Why is it that nothing is in the Synology slot columns? It is because you are not running the latest version?

007revad commented 2 weeks ago

I edited the existing disk_scan_status.txt file to add the extra colon. The colon was only missing because I had not run a smart test with the latest version of the script yet.

The blank Synology slot columns was also because I had not run a smart test with the latest version of the script yet.

This is how it looked with the old disk_scan_status.txt file: image

I've run the latest version of the script now, trying to run manual short tests on all drives. It only ran the short tests on the USB drive.

And the USB drive is missing it's "Synology USB Disk 3", and missing the first column so the other columns are wrong. image

wallacebrf commented 2 weeks ago

can you confirm you have the latest of both the .sh and .php files?

the web-interface is working fine on my systems. it seems for some reason, your system is not saving the sata to the status file disk_scan_status.txt correctly?

perhaps delete all of the files in the log folder, AND delete either of the /config/syno_model.txt or /config/not_syno_model.txt files so it can "reset"?

image

wallacebrf commented 2 weeks ago

if everything checks out with your script versions and files, and it is till not working, then something is not working in the logic here in the .php file. this is where i parse out the different values out of the disk_scan_status file.

there are supposed to be 10x parameters saved per drive, even if it is not a synology system, where non-synology systems will just save a blank value for the synology drive slots.

if (file_exists("".$script_location."/log/disk_scan_status.txt")) {
        $data = file_get_contents("".$script_location."/log/disk_scan_status.txt");
        $pieces = explode(";", $data);
        $last_updated=$pieces[0];
        $number_drives=(sizeof($pieces)-1)/10;

        for ($x = 0; $x < $number_drives; $x++) {
            array_push($drive_slot, $pieces[1+$x*10]);
            array_push($drive_name, $pieces[2+$x*10]);
            array_push($drive_model, $pieces[3+$x*10]);
            array_push($drive_serial, $pieces[4+$x*10]);
            array_push($drive_test_status, $pieces[5+$x*10]);
            array_push($drive_test_percent, $pieces[6+$x*10]);
            array_push($drive_test_pass_fail, $pieces[7+$x*10]);
            array_push($drive_capacity, $pieces[8+$x*10]);
            array_push($drive_test_duration, $pieces[9+$x*10]);
            array_push($drive_smart_enabled, $pieces[10+$x*10]);
        }
}
007revad commented 2 weeks ago

I'm using the latest files from GitHub.

I just noticed there is a missing colon between the end of the drive in the expansion unit and the USB drive. 1Synology USB Disk 3

Here's the whole file, with new lines inserted to make it readable here. The 2nd last line is missing the colon.

11/13/24 09:38:25;
Synology Drive Slot: 1 [Main Unit];/dev/sata1;WD10JUCT-63CYNY0;WD-WXB1A25KZJHR;0;0;PASSED;User Capacity:    1,000,204,886,016 bytes [1.00 TB];( 209) minutes.;1;
Synology Drive Slot: 2 [Main Unit];/dev/sata2;SSDSC2BF180A4H;CVDA409005GJ1802GN;0;0;PASSED;User Capacity:    180,045,766,656 bytes [180 GB];(  58) minutes.;1;
Synology Drive Slot: 1 [Expansion Unit 1];/dev/sata3;ST3500312CS;9VVC68VP;0;0;PASSED;User Capacity:    500,107,862,016 bytes [500 GB];( 106) minutes.;1
Synology USB Disk 3;/dev/usb1;STT_FTM64GX25H;P595418-TFBX-B049450;0;0;PASSED;User Capacity:    64,023,257,088 bytes [64.0 GB];(   0) minutes.;1
wallacebrf commented 2 weeks ago

ok, so the issue is with the .sh file.

i do not understand the issue. per the latest code

#set disk drive slot and location variable
            if [[ "$syno_check" ]]; then
                #is a Synology
                if [[ $disk =~ "usb" ]] || is_usb "$disk"; then
                    #get usb_name as USB Disk 1 or USB Disk 2 etc (works in DSM 6 and 7)
                    usb_name="$(synousbdisk -info "$(basename "$disk")" | grep -E '^Name:' | cut -d" " -f2-)"
                    disk_drive_slot=";Synology $usb_name"
                else
                    disk_drive_slot=";Synology Drive Slot: ${disk_drive_slot_array[$xx]} [${disk_unit_location_array[$xx]}]"
                fi
            else
                disk_drive_slot=";"
            fi

the variable disk_drive_slot always starts with a semi-colon, so how is your file containing the semi-colon on some lines and not on other lines?

interesting......

007revad commented 2 weeks ago

Weird.

For some reason my file is missing the colon in 2 places.

            #set disk drive slot and location variable
            if [[ "$syno_check" ]]; then
                #is a Synology
                if [[ $disk =~ "usb" ]] || is_usb "$disk"; then
                    #get usb_name as USB Disk 1 or USB Disk 2 etc (works in DSM 6 and 7)
                    usb_name="$(synousbdisk -info "$(basename "$disk")" | grep -E '^Name:' | cut -d" " -f2-)"
                    disk_drive_slot="Synology $usb_name"
                else
                    disk_drive_slot=";Synology Drive Slot: ${disk_drive_slot_array[$xx]} [${disk_unit_location_array[$xx]}]"
                fi
            else
                disk_drive_slot=""
            fi

I'll download the files again.

007revad commented 2 weeks ago

I see the problem. You've updated the files since I downloaded them 6 hours ago :(

I also notice that you've changed the php web-ui's title from:

$page_title="Server2 S.M.A.R.T Scheduler";

to:

$page_title="DS-920-SPARE S.M.A.R.T Scheduler";
$home="https://192.168.1.13";

I assume you are planning on getting the hostname and IP address from the NAS... and mistakenly committed the php file with your NAS' hostname and IP address in it?

The tables are perfect now on both Synology and Asustor. And there's now a history logs table, nice.

wallacebrf commented 2 weeks ago

Yes long term i plan to directly get the host name from the nas, as what I have in there now is for testing

wallacebrf commented 2 weeks ago

read me updated:

sections added 6.6.) Synology Web-Station setup 6.7.) Asustor web portal setup 6.8.) Configuration of required user level settings 6.8.1.) Configuration through PHP Web-Interface 6.8.2.) Configuration without using a web-interface