Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#138 ログ化機能・ログ送信機能の分離、及びNWアクセス制御 #191

Merged
merged 7 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions osect_sensor/Application/edge_cron/common/common_config.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@

SEND_REQUST_TIMEOUT = 180
""" ログ送信時のタイムアウト値 """

IS_CLOSED_NETWORK = True
""" モバイル経由のフラグ """
20 changes: 19 additions & 1 deletion osect_sensor/Application/edge_cron/cron/management/commands/pcap_to_log_to_server.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import requests
import zstandard as zstd
import serial
from common.common_config import (
ALLOWED_LOG_EXT, # BACNET_SHELL_COMMAND,
ALLOWED_PCAP_EXT,
Expand Down Expand Up @@ -46,6 +47,7 @@
API_URL,
LABEL_ID,
CLIENT_CERTIFICATE_PATH,
IS_CLOSED_NETWORK,
)

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

try:
send_server(tar_list)
if IS_CLOSED_NETWORK:
# コア網チェック
with serial.Serial("/dev/ttyUSB1", baudrate=115200, timeout=1) as sara:
sara.write(b"at\r\n")
b = sara.read(16)
cnum = b.decode().split("\n")

if "OK\r" in cnum:
# ログ送信
send_server(tar_list)
else:
logger.error(
"can not send compressed file. Unable to connect to closed network. "
)
else:
# ログ送信
send_server(tar_list)
except Exception as e:
logger.error("can not send compressed file. " + str(e))

Expand Down
1 change: 1 addition & 0 deletions osect_sensor/Infrastructure/edge_cron/work/requirements.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ meson==0.56.0
requests==2.31.0
urllib3==1.26.6
zstandard==0.18.0
pyserial==3.4
35 changes: 35 additions & 0 deletions osect_sensor/README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,41 @@ NTT Comから提供されたクライアント証明書を以下に格納しま
$ ~/osect_sensor/keys/client.pem
```

### 3.5. ログ送信方式の設定

有線経由でログを送信する場合は以下の設定をします。

設定ファイル:

```bash
$ vi Application/edge_cron/common/common_config.py
```

変更箇所:

```python
# 無線経由で送信
IS_CLOSED_NETWORK = True
# 有線経由で送信
IS_CLOSED_NETWORK = False
```

設定ファイル:

```bash
$ vi docker-compose.yml
```

変更箇所:

```yml
devices:
- "/dev/ttyUSB1:/dev/ttyUSB1"
(削除)
```

## 4. コンテナの構築・起動

コンテナを構築、起動します。
Expand Down
2 changes: 2 additions & 0 deletions osect_sensor/docker-compose.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ services:
edge_cron:
image: cron:revxxx
build: "./Infrastructure/edge_cron/"
devices:
- "/dev/ttyUSB1:/dev/ttyUSB1"
volumes:
- ./Application/edge_cron:/opt/edge_cron
- pcap-logs-volume:/opt/edge_cron/paper/sc_src/input/pcap/complete/
Expand Down