This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| app-hotes:wwan-statistics [2025/11/24 16:10] – [3. Set up the SDK script on the router] gray | app-hotes:wwan-statistics [2025/11/24 17:16] (current) – [4. Important settings in the SDK script] gray | ||
|---|---|---|---|
| Line 92: | Line 92: | ||
| After pressing the plus button, a new window opens with settings. | After pressing the plus button, a new window opens with settings. | ||
| + | {{: | ||
| - | ---- | + | First, assign a '' |
| - | + | ||
| - | + | ||
| + | ---- | ||
| + | The “check_data_volume.are” script can be downloaded via the “show code” link. | ||
| ++++show code| | ++++show code| | ||
| <code – check_data_volume.are> | <code – check_data_volume.are> | ||
| - | |||
| /* DESC: This script resets the statistics value of the WWAN1 module once a month. | /* DESC: This script resets the statistics value of the WWAN1 module once a month. | ||
| | | ||
| Line 113: | Line 112: | ||
| */ | */ | ||
| + | release_point = 0; | ||
| + | release_point_alert_email = 1; | ||
| + | release_point_alert2_email = 1; | ||
| + | alert2_value = 0; | ||
| + | release_point_info_email = 1; | ||
| + | info_value = 0; | ||
| + | release_point_info2_email = 1; | ||
| + | info2_value = 0; | ||
| + | |||
| + | ###################################################################### | ||
| + | ########### | ||
| + | ###################################################################### | ||
| + | |||
| + | interval | ||
| + | datavolume = 30000000000; | ||
| + | |||
| + | to = "< | ||
| + | sms_number = "< | ||
| + | |||
| + | # *** 100 percent alert all 20 minutes *** | ||
| + | |||
| + | alert2_value_time = 18; # The interval time multiplied by the alert2_value_time value < 1200 sec * 18 = 6 hours > 90 percent | ||
| + | info_value_time = 36; # The interval time multiplied by the info_value_time value < 1200 sec * 36 = 12 hours > 75 percent | ||
| + | info2_value_time = 72; # The interval time multiplied by the info_value_time value < 1200 sec * 72 = 24 hours > 50 percent | ||
| + | |||
| + | ###################################################################################################### | ||
| + | DEBUG=false; | ||
| + | ###################################################################################################### | ||
| + | |||
| + | printf(" | ||
| + | while (true) { | ||
| + | year = strftime(" | ||
| + | year = (int) year; | ||
| + | | ||
| + | month = strftime(" | ||
| + | month = (int) month; | ||
| + | | ||
| + | if (month == 2) { | ||
| + | ## leap year check | ||
| + | if ((year % 400 == 0) || (year % 100 != 0 && year % 4 == 0)){ | ||
| + | | ||
| + | | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | } | ||
| + | } else if (month == 4 || month == 6 || month == 9 || month == 11){ | ||
| + | if(DEBUG)printf(" | ||
| + | number_of_days = 30; | ||
| + | } else { | ||
| + | if(DEBUG)printf(" | ||
| + | number_of_days = 31; | ||
| + | } | ||
| + | | ||
| + | | ||
| + | | ||
| + | if (current_days == number_of_days){ | ||
| + | | ||
| + | if (release_point == 0) { | ||
| + | ret = nb_reset_statistics (" | ||
| + | | ||
| + | | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | } | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | temp = date_download; | ||
| + | | ||
| + | (int) i = 0; | ||
| + | count = date_download; | ||
| + | while (count >= 1024 && i < 4) { | ||
| + | count = (float) count; | ||
| + | count /= 1024; | ||
| + | i++; | ||
| + | } | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | if (percentage_value > 100){ | ||
| + | | ||
| + | | ||
| + | if (release_point_alert_email == 1){ | ||
| + | msg = sprintf(" | ||
| + | subj = sprintf(" | ||
| + | ret = nb_email_send(to, | ||
| + | | ||
| + | if (ret == 0){ | ||
| + | | ||
| + | | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | id = nb_sms_send(sms_number , subj); | ||
| + | | ||
| + | if (id){ | ||
| + | | ||
| + | | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | } else if (percentage_value >= 90 && percentage_value < 100){ | ||
| + | if(DEBUG)printf(" | ||
| + | alert2_value = alert2_value + 1; | ||
| + | if(DEBUG)printf(" | ||
| + | if (release_point_alert2_email == 1){ | ||
| + | msg = sprintf(" | ||
| + | subj = sprintf(" | ||
| + | ret = nb_email_send(to, | ||
| + | sleep(1); | ||
| + | if (ret == 0){ | ||
| + | if(DEBUG)printf(" | ||
| + | release_point_alert2_email = 0; | ||
| + | alert2_value = 0; | ||
| + | } else { | ||
| + | if(DEBUG)printf(" | ||
| + | nb_syslog(" | ||
| + | release_point_alert2_email = 1; | ||
| + | } | ||
| + | } | ||
| + | } else if (percentage_value >= 75){ | ||
| + | if(DEBUG)printf(" | ||
| + | info_value = info_value + 1; | ||
| + | if(DEBUG)printf(" | ||
| + | if (release_point_info_email == 1){ | ||
| + | msg = sprintf(" | ||
| + | subj = sprintf(" | ||
| + | ret = nb_email_send(to, | ||
| + | sleep(1); | ||
| + | if (ret == 0){ | ||
| + | if(DEBUG)printf(" | ||
| + | release_point_info_email = 0; | ||
| + | info_value = 0; | ||
| + | } else { | ||
| + | if(DEBUG)printf(" | ||
| + | nb_syslog(" | ||
| + | release_point_info_email = 1; | ||
| + | } | ||
| + | } | ||
| + | } else if (percentage_value >= 50){ | ||
| + | if(DEBUG)printf(" | ||
| + | info2_value = info2_value + 1; | ||
| + | if(DEBUG)printf(" | ||
| + | if (release_point_info2_email == 1){ | ||
| + | msg = sprintf(" | ||
| + | subj = sprintf(" | ||
| + | ret = nb_email_send(to, | ||
| + | sleep(1); | ||
| + | if (ret == 0){ | ||
| + | if(DEBUG)printf(" | ||
| + | release_point_info2_email = 0; | ||
| + | info2_value = 0; | ||
| + | } else { | ||
| + | if(DEBUG)printf(" | ||
| + | nb_syslog(" | ||
| + | release_point_info2_email = 1; | ||
| + | } | ||
| + | } | ||
| + | } else if (percentage_value >= 25){ | ||
| + | if(DEBUG)printf(" | ||
| + | } else { | ||
| + | | ||
| + | } | ||
| + | | ||
| + | | ||
| + | | ||
| + | if (alert2_value >= alert2_value_time){ | ||
| + | | ||
| + | } | ||
| + | if (info_value >= info_value_time){ | ||
| + | | ||
| + | } | ||
| + | if (info2_value >= info2_value_time){ | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | exit(0); | ||
| </ | </ | ||
| ++++ | ++++ | ||
| + | ---- | ||
| + | |||
| + | Next, set up the trigger that will start the script. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Here, too, pressing the plus button opens a new window with insertion options. | ||
| ---- | ---- | ||
| + | |||
| + | Here, too, pressing the plus button opens a new window with insertion options. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Again, start by assigning a '' | ||
| + | |||
| + | ---- | ||
| + | |||
| + | In the last step, we activate the SDK script on the router. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Again, enter the name for the SDK process first. If you want to activate the first SDK script on the router, the two fields “Trigger” and “Script” are already filled with the options you set up earlier. If you already have multiple scripts, you must select the correct option (Trigger and Script) from the pull-down menu. As before, click “Apply” to apply the setting to the router. In this case, the SDK script is also activated. | ||
| + | |||
| + | ---- | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Using the Administration option under point 1, you can view information under the Status tab, point 2, to see whether the SDK script has started correctly and is running without errors. | ||
| + | |||
| + | ---- | ||
| + | |||
| + | |||
| ===== - Important settings in the SDK script ===== | ===== - Important settings in the SDK script ===== | ||
| + | |||
| + | ** | ||
| + | <WRAP center round important 60%> | ||
| + | Please only make changes in this section of the block. | ||
| + | </ | ||
| + | ** | ||
| + | |||
| + | What options do you have for modifying the SDK script to suit your needs? | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Under '' | ||
| + | |||
| + | Under '' | ||
| + | |||
| + | An email address must be entered under '' | ||
| + | |||
| + | A phone number for the SMS service must be entered under '' | ||
| + | |||
| + | Under '' | ||
| + | |||
| + | Under '' | ||
| + | |||
| + | Under '' | ||
| ---- | ---- | ||
| Line 125: | Line 377: | ||
| ===== - Additional information ===== | ===== - Additional information ===== | ||
| + | |||
| + | ++++show code| | ||
| + | <code – check_data_volume.are> | ||
| + | /* DESC: This script resets the statistics value of the WWAN1 module once a month. | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | * Copyright (C) 2025 NetModule AG, Switzerland | ||
| + | */ | ||
| + | |||
| + | release_point = 0; | ||
| + | release_point_alert_email = 1; | ||
| + | release_point_alert2_email = 1; | ||
| + | alert2_value = 0; | ||
| + | release_point_info_email = 1; | ||
| + | info_value = 0; | ||
| + | release_point_info2_email = 1; | ||
| + | info2_value = 0; | ||
| + | |||
| + | ###################################################################### | ||
| + | ########### | ||
| + | ###################################################################### | ||
| + | |||
| + | interval | ||
| + | datavolume = 30000000000; | ||
| + | |||
| + | to = "< | ||
| + | sms_number = "< | ||
| + | |||
| + | # *** 100 percent alert all 20 minutes *** | ||
| + | |||
| + | alert2_value_time = 18; # The interval time multiplied by the alert2_value_time value < 1200 sec * 18 = 6 hours > 90 percent | ||
| + | info_value_time = 36; # The interval time multiplied by the info_value_time value < 1200 sec * 36 = 12 hours > 75 percent | ||
| + | info2_value_time = 72; # The interval time multiplied by the info_value_time value < 1200 sec * 72 = 24 hours > 50 percent | ||
| + | |||
| + | ###################################################################################################### | ||
| + | DEBUG=false; | ||
| + | ###################################################################################################### | ||
| + | |||
| + | printf(" | ||
| + | while (true) { | ||
| + | year = strftime(" | ||
| + | year = (int) year; | ||
| + | | ||
| + | month = strftime(" | ||
| + | month = (int) month; | ||
| + | | ||
| + | if (month == 2) { | ||
| + | ## leap year check | ||
| + | if ((year % 400 == 0) || (year % 100 != 0 && year % 4 == 0)){ | ||
| + | | ||
| + | | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | } | ||
| + | } else if (month == 4 || month == 6 || month == 9 || month == 11){ | ||
| + | if(DEBUG)printf(" | ||
| + | number_of_days = 30; | ||
| + | } else { | ||
| + | if(DEBUG)printf(" | ||
| + | number_of_days = 31; | ||
| + | } | ||
| + | | ||
| + | | ||
| + | | ||
| + | if (current_days == number_of_days){ | ||
| + | | ||
| + | if (release_point == 0) { | ||
| + | ret = nb_reset_statistics (" | ||
| + | | ||
| + | | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | } | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | temp = date_download; | ||
| + | | ||
| + | (int) i = 0; | ||
| + | count = date_download; | ||
| + | while (count >= 1024 && i < 4) { | ||
| + | count = (float) count; | ||
| + | count /= 1024; | ||
| + | i++; | ||
| + | } | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | if (percentage_value > 100){ | ||
| + | | ||
| + | | ||
| + | if (release_point_alert_email == 1){ | ||
| + | msg = sprintf(" | ||
| + | subj = sprintf(" | ||
| + | ret = nb_email_send(to, | ||
| + | | ||
| + | if (ret == 0){ | ||
| + | | ||
| + | | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | id = nb_sms_send(sms_number , subj); | ||
| + | | ||
| + | if (id){ | ||
| + | | ||
| + | | ||
| + | } else { | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | } else if (percentage_value >= 90 && percentage_value < 100){ | ||
| + | if(DEBUG)printf(" | ||
| + | alert2_value = alert2_value + 1; | ||
| + | if(DEBUG)printf(" | ||
| + | if (release_point_alert2_email == 1){ | ||
| + | msg = sprintf(" | ||
| + | subj = sprintf(" | ||
| + | ret = nb_email_send(to, | ||
| + | sleep(1); | ||
| + | if (ret == 0){ | ||
| + | if(DEBUG)printf(" | ||
| + | release_point_alert2_email = 0; | ||
| + | alert2_value = 0; | ||
| + | } else { | ||
| + | if(DEBUG)printf(" | ||
| + | nb_syslog(" | ||
| + | release_point_alert2_email = 1; | ||
| + | } | ||
| + | } | ||
| + | } else if (percentage_value >= 75){ | ||
| + | if(DEBUG)printf(" | ||
| + | info_value = info_value + 1; | ||
| + | if(DEBUG)printf(" | ||
| + | if (release_point_info_email == 1){ | ||
| + | msg = sprintf(" | ||
| + | subj = sprintf(" | ||
| + | ret = nb_email_send(to, | ||
| + | sleep(1); | ||
| + | if (ret == 0){ | ||
| + | if(DEBUG)printf(" | ||
| + | release_point_info_email = 0; | ||
| + | info_value = 0; | ||
| + | } else { | ||
| + | if(DEBUG)printf(" | ||
| + | nb_syslog(" | ||
| + | release_point_info_email = 1; | ||
| + | } | ||
| + | } | ||
| + | } else if (percentage_value >= 50){ | ||
| + | if(DEBUG)printf(" | ||
| + | info2_value = info2_value + 1; | ||
| + | if(DEBUG)printf(" | ||
| + | if (release_point_info2_email == 1){ | ||
| + | msg = sprintf(" | ||
| + | subj = sprintf(" | ||
| + | ret = nb_email_send(to, | ||
| + | sleep(1); | ||
| + | if (ret == 0){ | ||
| + | if(DEBUG)printf(" | ||
| + | release_point_info2_email = 0; | ||
| + | info2_value = 0; | ||
| + | } else { | ||
| + | if(DEBUG)printf(" | ||
| + | nb_syslog(" | ||
| + | release_point_info2_email = 1; | ||
| + | } | ||
| + | } | ||
| + | } else if (percentage_value >= 25){ | ||
| + | if(DEBUG)printf(" | ||
| + | } else { | ||
| + | | ||
| + | } | ||
| + | | ||
| + | | ||
| + | | ||
| + | if (alert2_value >= alert2_value_time){ | ||
| + | | ||
| + | } | ||
| + | if (info_value >= info_value_time){ | ||
| + | | ||
| + | } | ||
| + | if (info2_value >= info2_value_time){ | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | exit(0); | ||
| + | </ | ||
| + | ++++ | ||
| ---- | ---- | ||