mission_control-servers 0.2.4 → 0.2.5
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: 5eef0e07ac8fee585155c704088b7cbfcbf9736440ee11af15bd780ce5077664
|
4
|
+
data.tar.gz: f219f8ee1ddcfbed49ee3f80c0493bab20d433173a4863e6fba4abbca367e713
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 062a231db01dff3d63e7b342dabb170184ec5c9ac0421f3f86f3c9981250c54ccd2a7746854abdc6697c2f1241b8eda3d198c68fe8a158f47a8674e5a31bc6cb
|
7
|
+
data.tar.gz: 060a236e9e8d5651175f328c790fc38fc02689ae01ad7cfb353fd7e589ba9fe35252e54335073dfc4366779f1668e1a446da36a37b862b44cbca5a415606350c
|
@@ -4,10 +4,9 @@ module MissionControl::Servers
|
|
4
4
|
before_action :set_project
|
5
5
|
|
6
6
|
def create
|
7
|
-
head :unprocessable_entity and return unless @project
|
8
7
|
ingress = @project.services.new(ingress_params)
|
9
8
|
|
10
|
-
if ingress.save
|
9
|
+
if ingress.save
|
11
10
|
head :ok
|
12
11
|
else
|
13
12
|
head :unprocessable_entity
|
@@ -17,7 +16,7 @@ module MissionControl::Servers
|
|
17
16
|
private
|
18
17
|
# Use callbacks to share common setup or constraints between actions.
|
19
18
|
def set_project
|
20
|
-
@project = Project.find_by(token: params[:project_id])
|
19
|
+
@project = Project.find_by!(token: params[:project_id])
|
21
20
|
end
|
22
21
|
|
23
22
|
def ingress_params
|
@@ -3,7 +3,6 @@ module MissionControl::Servers
|
|
3
3
|
before_action :set_project
|
4
4
|
|
5
5
|
def show
|
6
|
-
head :not_found and return unless @project
|
7
6
|
response.content_type = 'text/plain'
|
8
7
|
|
9
8
|
# Render the script directly or from a file
|
@@ -13,7 +12,7 @@ module MissionControl::Servers
|
|
13
12
|
private
|
14
13
|
# Use callbacks to share common setup or constraints between actions.
|
15
14
|
def set_project
|
16
|
-
@project = Project.find_by(token: params[:project_id])
|
15
|
+
@project = Project.find_by!(token: params[:project_id])
|
17
16
|
end
|
18
17
|
|
19
18
|
def script_content
|
@@ -42,22 +41,43 @@ module MissionControl::Servers
|
|
42
41
|
fi
|
43
42
|
|
44
43
|
cat <<'EOF' > metrics.sh
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
44
|
+
#!/bin/bash
|
45
|
+
|
46
|
+
DEBUG=0
|
47
|
+
if [[ "$1" == "--debug" ]]; then
|
48
|
+
DEBUG=1
|
49
|
+
fi
|
50
|
+
|
51
|
+
debug() {
|
52
|
+
if [[ $DEBUG -eq 1 ]]; then
|
53
|
+
echo "Debug: $1"
|
54
|
+
fi
|
55
|
+
}
|
56
|
+
|
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
|
+
|
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
|
+
|
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
|
+
|
74
|
+
debug "Data being sent: $data"
|
75
|
+
|
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
|
61
81
|
EOF
|
62
82
|
|
63
83
|
chmod +x metrics.sh
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mission_control-servers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Kimura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|