Wiki source code of Monitor Gateway
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
1.2 | 1 | **Contents:** |
2 | |||
![]() |
1.1 | 3 | {{toc/}} |
4 | |||
5 | |||
![]() |
1.2 | 6 | = 1. Introduction = |
![]() |
1.1 | 7 | |
![]() |
1.8 | 8 | ((( |
![]() |
1.2 | 9 | This introduction shows how to use a script to monitor the gateway. The video link for this instruction is: [[https:~~/~~/youtu.be/8PieIwfSF_g>>url:https://youtu.be/8PieIwfSF_g]] |
![]() |
1.8 | 10 | ))) |
![]() |
1.1 | 11 | |
![]() |
1.2 | 12 | [[image:https://wiki.dragino.com/images/thumb/d/dc/Monitor_gateway.png/600px-Monitor_gateway.png||height="456" width="600"]] |
![]() |
1.1 | 13 | |
![]() |
1.2 | 14 | Monitor Gateway |
![]() |
1.1 | 15 | |
![]() |
1.3 | 16 | |
![]() |
1.2 | 17 | = 2. Steps = |
![]() |
1.1 | 18 | |
![]() |
1.7 | 19 | ((( |
![]() |
1.5 | 20 | ~1. Create account in ThingsSpeak and creat channel. |
![]() |
1.7 | 21 | ))) |
![]() |
1.1 | 22 | |
![]() |
1.7 | 23 | ((( |
![]() |
1.5 | 24 | 2. Download script from dragino site and move it to properly directory |
![]() |
1.7 | 25 | ))) |
![]() |
1.5 | 26 | |
![]() |
1.3 | 27 | (% class="box" %) |
28 | ((( | ||
29 | root@dragino-1baf44:~~# wget [[http:~~/~~/www.dragino.com/downloads/downloads/LoRa_Gateway/LPS8/Firmware/customized_script/monitor_gateway.sh>>url:http://www.dragino.com/downloads/downloads/LoRa_Gateway/LPS8/Firmware/customized_script/monitor_gateway.sh]] | ||
30 | Downloading '[[http:~~/~~/www.dragino.com/downloads/downloads/LoRa_Gateway/LPS8/Firmware/customized_script/monitor_gateway.sh'>>url:http://www.dragino.com/downloads/downloads/LoRa_Gateway/LPS8/Firmware/customized_script/monitor_gateway.sh']] | ||
![]() |
1.2 | 31 | Connecting to 162.241.22.11:80 |
32 | Writing to 'monitor_gateway.sh' | ||
![]() |
1.3 | 33 | monitor_gateway.sh 100% |~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~**| 1860 0:00:00 ETA |
![]() |
1.2 | 34 | Download completed (1860 bytes) |
![]() |
1.3 | 35 | root@dragino-1baf44:~~# chmod +x monitor_gateway.sh;mv monitor_gateway.sh /usr/bin/ |
36 | root@dragino-1baf44:~~# | ||
37 | root@dragino-1baf44:~~# | ||
38 | ))) | ||
![]() |
1.1 | 39 | |
![]() |
1.7 | 40 | ((( |
![]() |
1.5 | 41 | 3. change the script monitor_gateway.sh with properly users setting: |
![]() |
1.7 | 42 | ))) |
![]() |
1.1 | 43 | |
![]() |
1.3 | 44 | (% class="box" %) |
45 | ((( | ||
46 | USER='xxxxx' # user name in your thinkspeak ~-~-> Profile | ||
47 | PASS='xxxxx' #MQTT_API_KEY in your thinkspeak ~-~-> Profile | ||
48 | ))) | ||
![]() |
1.1 | 49 | |
![]() |
1.3 | 50 | (% class="box" %) |
51 | ((( | ||
52 | CHAN_ID='xxxx' #Channel ID of the channel for this gateway | ||
53 | CHAN_KEY='xxxxx' #Channel Write API of the channel for this gateway | ||
54 | ))) | ||
![]() |
1.1 | 55 | |
![]() |
1.7 | 56 | ((( |
![]() |
1.5 | 57 | ~1. run **/usr/bin/monitor_gateway.sh** to test if upload is good. |
![]() |
1.7 | 58 | ))) |
![]() |
1.1 | 59 | |
![]() |
1.7 | 60 | ((( |
![]() |
1.5 | 61 | 2. Add monitor_gateway.sh to cron work **/etc/crontabs/root** to make this script runs perdiocally, below is an example to update every 20 minutes |
![]() |
1.7 | 62 | ))) |
![]() |
1.1 | 63 | |
![]() |
1.3 | 64 | (% class="box" %) |
65 | ((( | ||
66 | # For details see man 4 crontabs | ||
![]() |
1.2 | 67 | # Example of job definition: |
![]() |
1.3 | 68 | # .~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- minute (0 - 59) |
69 | # | .~-~-~-~-~-~-~-~-~-~-~-~-- hour (0 - 23) | ||
70 | # | | .~-~-~-~-~-~-~-~-~-~- day of month (1 - 31) | ||
71 | # | | | .~-~-~-~-~-~-- month (1 - 12) OR jan,feb,mar,apr ... | ||
72 | # | | | | .~-~-~-~- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat | ||
![]() |
1.2 | 73 | # | | | | | |
74 | # * * * * * user-name command to be executed | ||
![]() |
1.3 | 75 | #*/10 * * * * checklog |
76 | ~* 23 * * * /etc/init.d/auto_update start | ||
![]() |
1.5 | 77 | */20 * * * * /usr/bin/monitor_gateway.sh |
![]() |
1.3 | 78 | ))) |
![]() |
1.2 | 79 | |
![]() |
1.7 | 80 | ((( |
![]() |
1.5 | 81 | 3. Reboot device. |
![]() |
1.7 | 82 | ))) |
![]() |
1.2 | 83 | |
84 | = 3. Monitor Public IP = | ||
85 | |||
86 | The monitor_gateway.sh has been updated to upload the public ip of the device as well. | ||
87 | |||
![]() |
1.6 | 88 | ((( |
![]() |
1.2 | 89 | User can find the public ip in field7, the chart is not able to show the complete public ip, user can check that in the export. |
![]() |
1.6 | 90 | ))) |
![]() |
1.2 | 91 | |
92 | [[image:https://wiki.dragino.com/images/thumb/8/8f/Monitor_gateway_1.png/600px-Monitor_gateway_1.png||height="340" width="600"]] | ||
93 | |||
94 | Find Public IP |