mission_control-servers 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc4409da6282e65c894099e85c2386922bf4720cf2501c7f303ae4ab53feec1b
|
4
|
+
data.tar.gz: ba445e16464f045a01623072ab1e67343757d14604ad67f9e199863969984f4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b7e78d6f062679dff60f16360af3aee1edfde5c696dcd3189c39e029039be81916b5856538cdc1af0a9f62f2b928df1ede6b5c06af79a55438739102740687d
|
7
|
+
data.tar.gz: c6596961ef8050eaa270ca7b052c5a588ef2438a9958096ea65ac64bf03f5647a8946031b11c603daba4c21ac3d83667d1f2913ada6f12a68c079e2d1f9539df
|
@@ -41,43 +41,43 @@ module MissionControl::Servers
|
|
41
41
|
fi
|
42
42
|
|
43
43
|
cat <<'EOF' > metrics.sh
|
44
|
-
|
44
|
+
#!/bin/bash
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
DEBUG=0
|
47
|
+
if [[ "$1" == "--debug" ]]; then
|
48
|
+
DEBUG=1
|
49
|
+
fi
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
debug() {
|
52
|
+
if [[ $DEBUG -eq 1 ]]; then
|
53
|
+
echo "Debug: $1"
|
54
|
+
fi
|
55
|
+
}
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
endpoint="#{project_ingress_url(@project.token)}"
|
58
|
+
cpu_usage=$(vmstat 1 5 | awk 'NR==4 {print 100 - $15}')
|
59
|
+
mem_used=$(free -m | awk '/^Mem:/ {print $3}')
|
60
|
+
mem_free=$(free -m | awk '/^Mem:/ {print $7}')
|
61
|
+
disk_free=$(df -h | awk '$NF=="/"{print $4}')
|
62
|
+
hostname=$(hostname)
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
# Debug outputs
|
65
|
+
debug "CPU Usage: $cpu_usage"
|
66
|
+
debug "Memory Used: $mem_used MB"
|
67
|
+
debug "Memory Free: $mem_free MB"
|
68
|
+
debug "Disk Free: $disk_free"
|
69
|
+
debug "Hostname: $hostname"
|
70
70
|
|
71
|
-
|
72
|
-
|
71
|
+
data=$(printf "service[cpu]=%s&service[mem_used]=%s&service[mem_free]=%s&service[disk_free]=%s&service[hostname]=%s" \
|
72
|
+
"$cpu_usage" "$mem_used" "$mem_free" "$disk_free" "$hostname")
|
73
73
|
|
74
|
-
|
74
|
+
debug "Data being sent: $data"
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
if [[ $DEBUG -eq 1 ]]; then
|
77
|
+
curl -v -X POST "$endpoint" -d "$data"
|
78
|
+
else
|
79
|
+
curl -X POST "$endpoint" -d "$data"
|
80
|
+
fi
|
81
81
|
EOF
|
82
82
|
|
83
83
|
chmod +x metrics.sh
|
@@ -85,7 +85,7 @@ module MissionControl::Servers
|
|
85
85
|
cron_job="* * * * * $(pwd)/metrics.sh"
|
86
86
|
(crontab -l 2>/dev/null | grep -v -F "$cron_job"; echo "$cron_job") | crontab -
|
87
87
|
echo "Sending first request to the server..."
|
88
|
-
$(pwd)/metrics.sh
|
88
|
+
bash $(pwd)/metrics.sh
|
89
89
|
echo
|
90
90
|
echo "████████████████████████████████████████████████████████████████████████████"
|
91
91
|
echo "█ █"
|