Repository: isucon/isucon11-qualify (language: go)

Issue:
[infra] bench がメトリクスを node_exporter に吐くようにする
* [ ] bench VM に node_exporter のインストール
* [ ] bench に node_exporter が食べるメトリクスを吐かせる
    * 参考: https://github.com/isucon/isucon10-final/blob/e858b2588a199f9c7407baacf48b53126b8aeed6/benchmarker/main.go#L291-L308


Discussion / hints:

Fix patch:
diff --git a/provisioning/ansible/roles/bench.node_exporter/files/etc/systemd/system/prometheus-node-exporter.service.d/dropin.conf b/provisioning/ansible/roles/bench.node_exporter/files/etc/systemd/system/prometheus-node-exporter.service.d/dropin.conf
new file mode 100644
index 000000000..c1faf623f
--- /dev/null
+++ b/provisioning/ansible/roles/bench.node_exporter/files/etc/systemd/system/prometheus-node-exporter.service.d/dropin.conf
@@ -0,0 +1,36 @@
+# vim: ft=systemd
+[Service]
+RuntimeDirectory=prometheus-node-exporter
+RuntimeDirectoryPreserve=yes
+ExecStartPre=/bin/mkdir -p /run/prometheus-node-exporter/textfile
+ExecStartPre=/bin/chmod 2777 /run/prometheus-node-exporter/textfile
+ExecStart=
+ExecStart=/usr/bin/prometheus-node-exporter \
+  --collector.bonding \
+  --collector.conntrack \
+  --collector.cpu \
+  --collector.cpufreq \
+  --collector.diskstats \
+  --collector.entropy \
+  --collector.filefd \
+  --collector.filesystem \
+  --collector.hwmon \
+  --collector.loadavg \
+  --collector.logind \
+  --collector.mdadm \
+  --collector.meminfo \
+  --collector.netclass \
+  --collector.netdev \
+  --collector.netstat \
+  --collector.nfs \
+  --collector.nfsd \
+  --collector.sockstat \
+  --collector.stat \
+  --collector.systemd \
+  --collector.textfile \
+  --collector.time \
+  --collector.uname \
+  --collector.vmstat \
+  --collector.zfs \
+  --collector.textfile.directory /run/prometheus-node-exporter/textfile \
+  --collector.systemd.unit-whitelist "sshd?.service|isuxportal-supervisor.service"
diff --git a/provisioning/ansible/roles/bench.node_exporter/tasks/main.yml b/provisioning/ansible/roles/bench.node_exporter/tasks/main.yml
new file mode 100644
index 000000000..2f4000f22
--- /dev/null
+++ b/provisioning/ansible/roles/bench.node_exporter/tasks/main.yml
@@ -0,0 +1,33 @@
+---
+
+- name: "roles/bench.node_exporter/tasks/main: Install node_exporter"
+  become_user: root
+  apt:
+    name:
+    - prometheus-node-exporter
+    update_cache: yes
+
+- name: "roles/bench.supervisor/tasks/main: Mkdir for dropin of prometheus-node-exporter.service"
+  become_user: root
+  file:
+    state: directory
+    path: /etc/systemd/system/prometheus-node-exporter.service.d
+    owner: root
+    group: root
+    mode: "0755"
+
+- name: "roles/bench.supervisor/tasks/main: Deploy dropin of prometheus-node-exporter.service"
+  become_user: root
+  copy:
+    src: etc/systemd/system/prometheus-node-exporter.service.d/dropin.conf
+    dest: /etc/systemd/system/prometheus-node-exporter.service.d/dropin.conf
+    owner: root
+    group: root
+    mode: "0644"
+
+- name: "roles/bench.node_exporter/tasks/main: Enable prometheus-node-exporter.service"
+  become_user: root
+  systemd:
+    daemon_reload: "yes"
+    name: "prometheus-node-exporter.service"
+    enabled: "yes"
diff --git a/provisioning/ansible/roles/bench.supervisor/files/etc/systemd/system/isuxportal-supervisor.service b/provisioning/ansible/roles/bench.supervisor/files/etc/systemd/system/isuxportal-supervisor.service
index 4ebdc94c7..fad34e2a6 100644
--- a/provisioning/ansible/roles/bench.supervisor/files/etc/systemd/system/isuxportal-supervisor.service
+++ b/provisioning/ansible/roles/bench.supervisor/files/etc/systemd/system/isuxportal-supervisor.service
@@ -5,7 +5,9 @@ After=network.target
 [Service]
 # 基本設定
 User=isucon
-ExecStart=/home/isucon/bin/isuxportal-supervisor /home/isucon/bench/bench -timeout=5s -tls
+ExecStart=/home/isucon/bin/isuxportal-supervisor /home/isucon/bench/bench \
+          -tls \
+          -prom-out /run/prometheus-node-exporter/textfile/xsuconbench.prom
 WorkingDirectory=/home/isucon/bench
 LogsDirectory=isuxportal-supervisor
 LimitNOFILE=2000000
diff --git a/provisioning/ansible/site.yml b/provisioning/ansible/site.yml
index a4343c3e8..99bbb7c22 100644
--- a/provisioning/ansible/site.yml
+++ b/provisioning/ansible/site.yml
@@ -27,6 +27,7 @@
     - langs.go
     - langs.rust
     - bench
+    - bench.node_exporter
     - bench.supervisor
 
 - name: "bench (standalone) roles"


Test patch: