Wiki source code of Monitor Gateway

Version 4.3 by Xiaoling on 2022/07/14 15:23

Show last authors
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 ~1. Create account in ThingsSpeak and creat channel.
26 )))
27
28 (((
29 2. Download script from dragino site and move it to properly directory
30 )))
31
32 (% class="box" %)
33 (((
34 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]]
35 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']]
36 Connecting to 162.241.22.11:80
37 Writing to 'monitor_gateway.sh'
38 monitor_gateway.sh   100% |~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~**|  1860   0:00:00 ETA
39 Download completed (1860 bytes)
40 root@dragino-1baf44:~~# chmod +x monitor_gateway.sh;mv monitor_gateway.sh /usr/bin/
41 root@dragino-1baf44:~~#
42 root@dragino-1baf44:~~#
43 )))
44
45 (((
46 3. change the script monitor_gateway.sh with properly users setting:
47 )))
48
49 (% class="box" %)
50 (((
51 USER='xxxxx'             # user name in your thinkspeak ~-~-> Profile
52 PASS='xxxxx'     #MQTT_API_KEY in your thinkspeak ~-~-> Profile
53 )))
54
55 (% class="box" %)
56 (((
57 CHAN_ID='xxxx'    #Channel ID   of the channel for this gateway
58 CHAN_KEY='xxxxx'   #Channel Write API  of the channel for this gateway
59 )))
60
61 (((
62 ~1. run **/usr/bin/monitor_gateway.sh** to test if upload is good.
63 )))
64
65 (((
66 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
67 )))
68
69 (% class="box" %)
70 (((
71 # For details see man 4 crontabs
72 # Example of job definition:
73 # .~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- minute (0 - 59)
74 # | .~-~-~-~-~-~-~-~-~-~-~-~-- hour (0 - 23)
75 # | | .~-~-~-~-~-~-~-~-~-~- day of month (1 - 31)
76 # | | | .~-~-~-~-~-~-- month (1 - 12) OR jan,feb,mar,apr ...
77 # | | | | .~-~-~-~- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
78 # | | | | |
79 # * * * * * user-name command to be executed
80 #*/10 * * * *  checklog
81 ~* 23 * * *  /etc/init.d/auto_update start
82 */20 * * * *  /usr/bin/monitor_gateway.sh 
83 )))
84
85 (((
86 3. Reboot device.
87 )))
88
89
90 = **3.  Monitor Public IP** =
91
92
93 The monitor_gateway.sh has been updated to upload the public ip of the device as well.
94
95 (((
96 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.
97 )))
98
99 [[image:image-20220527111850-2.png]]
100
101 Find Public IP