This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
app-notes:dashboard [2023/10/31 14:02] – [Switch to another wanlink] klueppel | app-notes:dashboard [2023/11/02 08:48] (current) – [Check your installation] klueppel | ||
---|---|---|---|
Line 7: | Line 7: | ||
{{ : | {{ : | ||
- | |||
===== Prerequierments ===== | ===== Prerequierments ===== | ||
Line 34: | Line 33: | ||
In the script tab copy and paste the sdk script. | In the script tab copy and paste the sdk script. | ||
- | < | + | {{ : |
- | SUPER DUPER SCRIPT | + | |
+ | < | ||
+ | ID = 1; | ||
+ | hotlink = ""; | ||
+ | |||
+ | |||
+ | string pp_var(var) { | ||
+ | |||
+ | tmp=tolower(var); | ||
+ | tmp=explode(tmp); | ||
+ | |||
+ | tmp[0] = toupper(tmp[0]); | ||
+ | for (i=0; i< | ||
+ | |||
+ | if (tmp[i] == ' | ||
+ | tmp[i] = ' '; | ||
+ | tmp[i+1] = toupper(tmp[i+1]); | ||
+ | } | ||
+ | } | ||
+ | return implode(tmp); | ||
+ | |||
+ | } | ||
+ | |||
+ | string pp(value) { | ||
+ | switch (value) { | ||
+ | case " | ||
+ | case " | ||
+ | case " | ||
+ | |||
+ | case " | ||
+ | case " | ||
+ | |||
+ | case " | ||
+ | case " | ||
+ | } | ||
+ | |||
+ | return value; | ||
+ | } | ||
+ | |||
+ | |||
+ | void print_table(array fields) { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | if (struct_get(wan, | ||
+ | nb_page_respond(page, | ||
+ | < | ||
+ | nb_page_respond(page, | ||
+ | nb_page_respond(page, | ||
+ | } | ||
+ | |||
+ | | ||
+ | |||
+ | for (i=0; i < length(fields); | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | /* register page */ | ||
+ | page = nb_userpage_register(ID, | ||
+ | if (is_void(page)) { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | while (1) { | ||
+ | |||
+ | printf(" | ||
+ | /* wait for page request */ | ||
+ | request = nb_page_request(page); | ||
+ | |||
+ | if (!is_void(request)) { | ||
+ | /* evaluate GET params */ | ||
+ | GET = struct_get(request, | ||
+ | } | ||
+ | for (k = 0; k < length(GET); | ||
+ | key = struct_get(GET[k], | ||
+ | if (key == " | ||
+ | hotlink = struct_get(GET[k], | ||
+ | } | ||
+ | if (key == " | ||
+ | action = struct_get(GET[k], | ||
+ | if (action == " | ||
+ | nb_reboot(0); | ||
+ | } | ||
+ | } | ||
+ | if (hotlink != "" | ||
+ | nb_wanlink_priorize(hotlink, | ||
+ | sleep(5); | ||
+ | } | ||
+ | |||
+ | |||
+ | fields = mkarray(); | ||
+ | |||
+ | wan = nb_status(" | ||
+ | for (i=1; i <=9; i++) { | ||
+ | |||
+ | wan_state = struct_get(wan, | ||
+ | wan_idx = sprintf(" | ||
+ | |||
+ | if (strlen(wan_state) > 0) { | ||
+ | |||
+ | // Attributes for WWAN link | ||
+ | wan_array = mkarray(sprintf(" | ||
+ | sprintf(" | ||
+ | sprintf(" | ||
+ | sprintf(" | ||
+ | sprintf(" | ||
+ | sprintf(" | ||
+ | ); | ||
+ | |||
+ | // Attributes for ETH/LAN link | ||
+ | eth_array = mkarray(sprintf(" | ||
+ | sprintf(" | ||
+ | sprintf(" | ||
+ | sprintf(" | ||
+ | ); | ||
+ | |||
+ | |||
+ | type = struct_get(wan, | ||
+ | switch (type) { | ||
+ | case " | ||
+ | break; | ||
+ | case " | ||
+ | break; | ||
+ | } | ||
+ | fields[i-1] = tmp_array; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | nb_page_respond(page, | ||
+ | nb_page_respond(page, | ||
+ | nb_page_respond(page, | ||
+ | |||
+ | nb_page_respond(page, | ||
+ | nb_page_respond(page, | ||
+ | nb_page_respond(page, | ||
+ | |||
+ | nb_page_respond(page, | ||
+ | nb_page_respond(page,'< | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | nb_page_respond(page, | ||
+ | nb_page_respond(page, | ||
+ | |||
+ | |||
+ | for (j=0; j< | ||
+ | if (!is_void(fields[j])) { | ||
+ | print_table(fields[j]); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | nb_page_finish(page); | ||
+ | } | ||
+ | |||
+ | nb_page_unregister(page); | ||
+ | exit(0); | ||
+ | |||
</ | </ | ||
- | {{ : | + | |
+ | |||
=== Create a SDK job === | === Create a SDK job === | ||
Line 59: | Line 232: | ||
Navigate to HOME -> Overwiev -> Interfaces | Navigate to HOME -> Overwiev -> Interfaces | ||
+ | {{ : | ||
The page might look diffrent, depending on your number of wanlinks. | The page might look diffrent, depending on your number of wanlinks. | ||
- | {{ : | ||
Line 72: | Line 245: | ||
==== Reboot the Router ==== | ==== Reboot the Router ==== | ||
- | The page has also a reboot button. The device will reboot after 5 seconds. | + | The page has a reboot button. The device will reboot after 5 seconds. |
==== Extend the info for a wanlink ==== | ==== Extend the info for a wanlink ==== | ||
- | You can add/remove the fields that will be shown. | + | You can add/remove the fields that are shown. |
Line 100: | Line 273: | ||
- | A full list for all availible | + | For all attributes, use the shell command "cli status -s wan": |
< | < | ||
Line 146: | Line 319: | ||
</ | </ | ||
+ | |||
+ | Thats it. Enjoy your new status page. | ||