Wiki source code of Monitor Gateway
Last modified by Xiaoling on 2022/07/14 15:37
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
4.2 | 1 | **Table of** **Contents:** |
![]() |
1.2 | 2 | |
![]() |
1.1 | 3 | {{toc/}} |
4 | |||
5 | |||
![]() |
4.3 | 6 | = **1. Introduction** = |
![]() |
1.1 | 7 | |
![]() |
4.3 | 8 | |
![]() |
1.8 | 9 | ((( |
![]() |
1.2 | 10 | 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]] |
![]() |
4.3 | 11 | |
12 | |||
![]() |
1.8 | 13 | ))) |
![]() |
1.1 | 14 | |
![]() |
3.2 | 15 | [[image:image-20220527111742-1.png]] |
![]() |
1.1 | 16 | |
![]() |
1.2 | 17 | Monitor Gateway |
![]() |
1.1 | 18 | |
![]() |
1.3 | 19 | |
![]() |
1.1 | 20 | |
![]() |
4.3 | 21 | = **2. Steps** = |
22 | |||
23 | |||
![]() |
1.7 | 24 | ((( |
![]() |
4.4 | 25 | (% style="color:blue" %)**1. Create account in ThingsSpeak and creat channel.** |
26 | |||
27 | |||
![]() |
1.7 | 28 | ))) |
![]() |
1.1 | 29 | |
![]() |
1.7 | 30 | ((( |
![]() |
4.4 | 31 | (% style="color:blue" %)**2. Download script from dragino site and move it to properly directory** |
![]() |
1.7 | 32 | ))) |
![]() |
1.5 | 33 | |
![]() |
1.3 | 34 | (% class="box" %) |
35 | ((( | ||
36 | 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]] | ||
37 | 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 | 38 | Connecting to 162.241.22.11:80 |
39 | Writing to 'monitor_gateway.sh' | ||
![]() |
1.3 | 40 | monitor_gateway.sh 100% |~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~**| 1860 0:00:00 ETA |
![]() |
1.2 | 41 | Download completed (1860 bytes) |
![]() |
1.3 | 42 | root@dragino-1baf44:~~# chmod +x monitor_gateway.sh;mv monitor_gateway.sh /usr/bin/ |
43 | root@dragino-1baf44:~~# | ||
44 | root@dragino-1baf44:~~# | ||
45 | ))) | ||
![]() |
1.1 | 46 | |
![]() |
4.4 | 47 | |
![]() |
1.7 | 48 | ((( |
![]() |
4.4 | 49 | (% style="color:blue" %)**3. change the script monitor_gateway.sh with properly users setting:** |
![]() |
1.7 | 50 | ))) |
![]() |
1.1 | 51 | |
![]() |
1.3 | 52 | (% class="box" %) |
53 | ((( | ||
![]() |
4.4 | 54 | **USER='xxxxx' # user name in your thinkspeak ~-~-> Profile |
55 | PASS='xxxxx' # MQTT_API_KEY in your thinkspeak ~-~-> Profile** | ||
![]() |
1.3 | 56 | ))) |
![]() |
1.1 | 57 | |
![]() |
1.3 | 58 | (% class="box" %) |
59 | ((( | ||
![]() |
4.4 | 60 | **CHAN_ID='xxxx' # Channel ID of the channel for this gateway |
61 | CHAN_KEY='xxxxx' # Channel Write API of the channel for this gateway** | ||
![]() |
1.3 | 62 | ))) |
![]() |
1.1 | 63 | |
![]() |
1.7 | 64 | ((( |
![]() |
4.4 | 65 | 1). run **/usr/bin/monitor_gateway.sh** to test if upload is good. |
![]() |
1.7 | 66 | ))) |
![]() |
1.1 | 67 | |
![]() |
1.7 | 68 | ((( |
![]() |
4.4 | 69 | 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 | 70 | ))) |
![]() |
1.1 | 71 | |
![]() |
1.3 | 72 | (% class="box" %) |
73 | ((( | ||
74 | # For details see man 4 crontabs | ||
![]() |
1.2 | 75 | # Example of job definition: |
![]() |
1.3 | 76 | # .~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- minute (0 - 59) |
77 | # | .~-~-~-~-~-~-~-~-~-~-~-~-- hour (0 - 23) | ||
78 | # | | .~-~-~-~-~-~-~-~-~-~- day of month (1 - 31) | ||
79 | # | | | .~-~-~-~-~-~-- month (1 - 12) OR jan,feb,mar,apr ... | ||
80 | # | | | | .~-~-~-~- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat | ||
![]() |
1.2 | 81 | # | | | | | |
82 | # * * * * * user-name command to be executed | ||
![]() |
1.3 | 83 | #*/10 * * * * checklog |
84 | ~* 23 * * * /etc/init.d/auto_update start | ||
![]() |
1.5 | 85 | */20 * * * * /usr/bin/monitor_gateway.sh |
![]() |
1.3 | 86 | ))) |
![]() |
1.2 | 87 | |
![]() |
1.7 | 88 | ((( |
![]() |
4.4 | 89 | 3). Reboot device. |
![]() |
1.7 | 90 | ))) |
![]() |
1.2 | 91 | |
![]() |
3.2 | 92 | |
![]() |
4.4 | 93 | |
![]() |
4.3 | 94 | = **3. Monitor Public IP** = |
![]() |
1.2 | 95 | |
![]() |
4.3 | 96 | |
![]() |
1.2 | 97 | The monitor_gateway.sh has been updated to upload the public ip of the device as well. |
98 | |||
![]() |
1.6 | 99 | ((( |
![]() |
1.2 | 100 | 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 | 101 | ))) |
![]() |
1.2 | 102 | |
![]() |
3.2 | 103 | [[image:image-20220527111850-2.png]] |
![]() |
1.2 | 104 | |
105 | Find Public IP | ||
![]() |
4.4 | 106 | |
107 |