forked from m-lab/ndt-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud-config.yaml
49 lines (47 loc) · 1.85 KB
/
cloud-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#cloud-config
write_files:
- path: /var/lib/cloud/scripts/prom_vdlimit_metrics.sh
permissions: 0700
owner: root:root
content: |
#!/bin/bash
VDLIMIT_TEXT=""
VDLIMIT_FILE="/var/spool/node_exporter/vdlimit.prom"
USED=$(df --output="used" /mnt/stateful_partition | tail -n1 )
FREE=$(df --output="avail" /mnt/stateful_partition | tail -n1 )
SIZE=$(df --output="size" /mnt/stateful_partition | tail -n1 )
VDLIMIT_TEXT="vdlimit_used{experiment=\"ndt.iupui\"} ${USED}\n"
VDLIMIT_TEXT+="vdlimit_free{experiment=\"ndt.iupui\"} ${FREE}\n"
VDLIMIT_TEXT+="vdlimit_total{experiment=\"ndt.iupui\"} ${SIZE}\n"
echo -e $VDLIMIT_TEXT > $VDLIMIT_FILE
- path: /etc/systemd/system/prom-vdlimit-metrics.service
permissions: 0644
owner: root:root
content: |
[Unit]
Description=Writes vdlimit Prom metrics to /var/spool/node_exporter/vdlimit.prom
[Service]
Type=oneshot
ExecStart=/var/lib/cloud/scripts/prom_vdlimit_metrics.sh
- path: /etc/systemd/system/prom-vdlimit-metrics.timer
permissions: 0644
owner: root:root
content: |
[Unit]
Description=Run /usr/bin/prom_vdlimit_metrics.sh every 5 minutes.
[Timer]
OnBootSec=1min
OnUnitActiveSec=5min
[Install]
WantedBy=multi-user.target
# The iptables command below is necessary due to the way that the Google
# Container-Optimized OS works. For COS, it is necessary to both open holes in
# the VPC firewall as well as opening the firewall on the VM itself.
# https://cloud.google.com/container-optimized-os/docs/how-to/firewall
runcmd:
- systemctl daemon-reload
- systemctl enable prom-vdlimit-metrics.service
- systemctl enable prom-vdlimit-metrics.timer
- systemctl start prom-vdlimit-metrics.service
- systemctl start prom-vdlimit-metrics.timer
- iptables -A INPUT -p tcp -j ACCEPT