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