Skip to content

Commit a927a8a

Browse files
authored
Merge pull request #191 from nttcom/log_send_check
#138 ログ化機能・ログ送信機能の分離、及びNWアクセス制御
2 parents eba40e8 + 5660172 commit a927a8a

File tree

5 files changed

+60
-1
lines changed

5 files changed

+60
-1
lines changed

osect_sensor/Application/edge_cron/common/common_config.py

100644100755
+3
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,6 @@
8686

8787
SEND_REQUST_TIMEOUT = 180
8888
""" ログ送信時のタイムアウト値 """
89+
90+
IS_CLOSED_NETWORK = True
91+
""" モバイル経由のフラグ """

osect_sensor/Application/edge_cron/cron/management/commands/pcap_to_log_to_server.py

100644100755
+19-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import requests
1818
import zstandard as zstd
19+
import serial
1920
from common.common_config import (
2021
ALLOWED_LOG_EXT, # BACNET_SHELL_COMMAND,
2122
ALLOWED_PCAP_EXT,
@@ -46,6 +47,7 @@
4647
API_URL,
4748
LABEL_ID,
4849
CLIENT_CERTIFICATE_PATH,
50+
IS_CLOSED_NETWORK,
4951
)
5052

5153
# from common.common_function import pcap2log
@@ -146,7 +148,23 @@ def handle(self, *args, **options):
146148
# logger.info("sleep " + str(sleep_time) + "s")
147149

148150
try:
149-
send_server(tar_list)
151+
if IS_CLOSED_NETWORK:
152+
# コア網チェック
153+
with serial.Serial("/dev/ttyUSB1", baudrate=115200, timeout=1) as sara:
154+
sara.write(b"at\r\n")
155+
b = sara.read(16)
156+
cnum = b.decode().split("\n")
157+
158+
if "OK\r" in cnum:
159+
# ログ送信
160+
send_server(tar_list)
161+
else:
162+
logger.error(
163+
"can not send compressed file. Unable to connect to closed network. "
164+
)
165+
else:
166+
# ログ送信
167+
send_server(tar_list)
150168
except Exception as e:
151169
logger.error("can not send compressed file. " + str(e))
152170

osect_sensor/Infrastructure/edge_cron/work/requirements.txt

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ meson==0.56.0
44
requests==2.31.0
55
urllib3==1.26.6
66
zstandard==0.18.0
7+
pyserial==3.4

osect_sensor/README.md

100644100755
+35
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,41 @@ NTT Comから提供されたクライアント証明書を以下に格納しま
201201
$ ~/osect_sensor/keys/client.pem
202202
```
203203

204+
### 3.5. ログ送信方式の設定
205+
206+
有線経由でログを送信する場合は以下の設定をします。
207+
208+
設定ファイル:
209+
210+
```bash
211+
$ vi Application/edge_cron/common/common_config.py
212+
```
213+
214+
変更箇所:
215+
216+
```python
217+
# 無線経由で送信
218+
IS_CLOSED_NETWORK = True
219+
220+
# 有線経由で送信
221+
IS_CLOSED_NETWORK = False
222+
```
223+
224+
設定ファイル:
225+
226+
```bash
227+
$ vi docker-compose.yml
228+
```
229+
230+
変更箇所:
231+
232+
```yml
233+
devices:
234+
- "/dev/ttyUSB1:/dev/ttyUSB1"
235+
236+
(削除)
237+
```
238+
204239
## 4. コンテナの構築・起動
205240

206241
コンテナを構築、起動します。

osect_sensor/docker-compose.yml

100644100755
+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ services:
33
edge_cron:
44
image: cron:revxxx
55
build: "./Infrastructure/edge_cron/"
6+
devices:
7+
- "/dev/ttyUSB1:/dev/ttyUSB1"
68
volumes:
79
- ./Application/edge_cron:/opt/edge_cron
810
- pcap-logs-volume:/opt/edge_cron/paper/sc_src/input/pcap/complete/

0 commit comments

Comments
 (0)