upstreamstatus 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/upstreamstatus/version.rb +1 -1
- data/lib/upstreamstatus.rb +31 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0574acb6b6f4cfcace06f749b340dcceec598036
|
4
|
+
data.tar.gz: 359a6ec366793c11839dae58b1ca9f0b352c1dbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf81420263c53b452278242639fad404cda95174b2e81f66a55635f01da4c32b818333a93f79108795e0e9fda6d4d8e92c994e672235880c5109bcad186f792d
|
7
|
+
data.tar.gz: 0fc8c5690afdc50f2d0c1452033a32bee461dedb2da77134cb5c1f3b926419be339e855327dcdd0c045615cafa981b2a565482bb18e49667fdfc4fc00e2c3f8f
|
data/lib/upstreamstatus.rb
CHANGED
@@ -50,6 +50,8 @@ class Upstreamstatus
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def current_status
|
53
|
+
return fake_servers if opts[:simulate]
|
54
|
+
|
53
55
|
r = Unirest.get status_check_url
|
54
56
|
|
55
57
|
unless (200..299).include?(r.code)
|
@@ -63,6 +65,31 @@ class Upstreamstatus
|
|
63
65
|
|
64
66
|
private
|
65
67
|
|
68
|
+
def fake_servers
|
69
|
+
[
|
70
|
+
{
|
71
|
+
'index': 0,
|
72
|
+
'upstream': 'testupstream',
|
73
|
+
'name': '10.0.0.1:8080',
|
74
|
+
'status': 'up',
|
75
|
+
'rise': 10_459,
|
76
|
+
'fall': 0,
|
77
|
+
'type': 'http',
|
78
|
+
'port': 0
|
79
|
+
},
|
80
|
+
{
|
81
|
+
'index': 1,
|
82
|
+
'upstream': 'testupstream',
|
83
|
+
'name': '10.0.0.2:8080',
|
84
|
+
'status': 'down',
|
85
|
+
'rise': 10_029,
|
86
|
+
'fall': 0,
|
87
|
+
'type': 'http',
|
88
|
+
'port': 0
|
89
|
+
}
|
90
|
+
]
|
91
|
+
end
|
92
|
+
|
66
93
|
def clear_active_alerts!
|
67
94
|
return unless File.exist? '/var/run/active_upstream_alert'
|
68
95
|
File.delete('/var/run/active_upstream_alert')
|
@@ -113,6 +140,10 @@ class Upstreamstatus
|
|
113
140
|
'Notify alert service on failure',
|
114
141
|
short: '-n',
|
115
142
|
default: false
|
143
|
+
opt :simulate,
|
144
|
+
'Simulate a failed server',
|
145
|
+
short: '-s',
|
146
|
+
default: false
|
116
147
|
end
|
117
148
|
end
|
118
149
|
|