Wiki source code of Monitor Gateway

Version 1.7 by Xiaoling on 2022/05/12 15:31

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