Last active
June 23, 2018 10:58
-
-
Save nshun/9a6cd9e8f453ef1fa238cd8a86634627 to your computer and use it in GitHub Desktop.
GPU サーバのログを ELK サーバに送信して管理する ref: https://qiita.com/shun_n/items/e15451888a348706c672
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http input from gpu server on port 5141 | |
input { | |
http { | |
port => 5141 | |
type => "gpu" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter { | |
if [type] == "gpu" { | |
grok { | |
match => ["message", "(?<name>[^,]*),(?<Date>[^,]*),(?<gpu_util>[^,]*),(?<memory_util>[^,]*),(?<memory_total>[^,]*),(?<memory_free>[^,]*),(?<memory_used>[^,]*),(?<temperature>[^,]*)"] | |
} | |
date{ | |
match => ["Date" , "yyyy/MM/dd HH:mm:ss.SSS"] | |
timezone => "Asia/Tokyo" | |
} | |
mutate{ | |
convert => { | |
gpu_util => float | |
memory_util => float | |
memory_total => float | |
memory_free => float | |
memory_used => float | |
temperature => float | |
} | |
remove_field => ["headers"] | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output { | |
if [type] == "gpu" { | |
elasticsearch { | |
hosts => ["localhost:9200"] | |
index => "logstash-gpu-%{+YYYY.MM.dd}" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /etc/logstash/conf.d/ | |
$ sudo vim ./01-inputs.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo chmod +x ./sendlog.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt install curl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ crontab -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* * * * * bash /home/${ユーザー名}/sendlog.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo vim ./10-gpu-filter.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo vim ./30-outputs.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo ufw allow 5141 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nvidia-smi | |
Sat Jun 23 16:24:39 2018 | |
+-----------------------------------------------------------------------------+ | |
| NVIDIA-SMI 396.26 Driver Version: 396.26 | | |
|-------------------------------+----------------------+----------------------+ | |
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | |
|===============================+======================+======================| | |
| 0 GeForce GTX 1080 Off | 00000000:01:00.0 Off | N/A | | |
| 0% 35C P0 35W / 180W | 0MiB / 8119MiB | 0% Default | | |
+-------------------------------+----------------------+----------------------+ | |
+-----------------------------------------------------------------------------+ | |
| Processes: GPU Memory | | |
| GPU PID Type Process name Usage | | |
|=============================================================================| | |
| No running processes found | | |
+-----------------------------------------------------------------------------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Failed to initialize NVML: Driver/library version mismatch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd ~ | |
$ sudo vim ./sendlog.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
nvidia-smi --query-gpu=timestamp,utilization.gpu,utilization.memory,memory.total,memory.free,memory.used,temperature.gpu --format=csv,noheader,nounits | (read log ; curl -XPUT ${ELK サーバの IP }:5141 -d "${GPU サーバの名前},${log}" > /dev/null 2>&1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment