downtime 0.0.1 → 0.0.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 +8 -8
- data/.gitignore +1 -0
- data/README.md +6 -6
- data/bin/downtime +2 -10
- data/lib/downtime/version.rb +1 -1
- data/lib/downtime.rb +8 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
Y2IxMzQ3N2U2NThhOWFjZTNjYTcwYTY4YmNhNjNmNDc0MmIzYjg4Yg==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
NWVjMDlmZTc3Y2U4NWM3M2MyOWQ5OGY3YmQ3ODBiODNiMDY2Yjc0ZQ==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
N2QxMWViYWI0YmU4NjA3OWJhMjQ0NmZjN2ZkY2MxNmIzOGYxNzk4ZTU2MWRh
|
|
10
|
+
ODdhNzNlNGI0NmQ1NDUyZjg2NzcwYWNjMWU4NTliNzY0ZTQ0MzkzMjMzZGM5
|
|
11
|
+
MzY0ZWVkYWYwZTMzZGJjYTA4ZjBmNjA3MTY5YzRkMDE5Y2IxMWU=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
N2ZmOGExNTY3NzkxYTE5YzBjMzJmNjczOTlhZjA4MjBjOTMzOGQxNmVkOTVj
|
|
14
|
+
NDhmYzYwMTI5YmY4Y2VhMjdlYjRiMDk3MDMwNWZmN2E0ZGQyZDJkODNjZTFm
|
|
15
|
+
OTA4OGFkNGY2NmI1MDVmMzZhZjAyZDM3NjE0ZGNkZjZkYjY3ZDA=
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -31,12 +31,12 @@ It will create a `downtime.log` file in the current working directory.
|
|
|
31
31
|
|
|
32
32
|
The file (`downtime.log`) will look like this:
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
# This file was generated by the downtime ruby gem.
|
|
35
|
+
2015-01-01-10-22 up till 2015-01-02-08-10
|
|
36
|
+
! went down after 1000 minutes up
|
|
37
|
+
2015-01-02-08-10 down till 2015-01-03-08-40
|
|
38
|
+
! went up after 30 minutes down
|
|
39
|
+
2015-01-02-08-40 up till 2015-01-03-08-45
|
|
40
40
|
|
|
41
41
|
## Caveats
|
|
42
42
|
|
data/bin/downtime
CHANGED
|
@@ -2,19 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
require 'downtime'
|
|
4
4
|
|
|
5
|
-
# Check last state
|
|
6
|
-
# check current state
|
|
7
|
-
# if last = up
|
|
8
|
-
# if current = up
|
|
9
|
-
# if current = down
|
|
10
|
-
# if last = down
|
|
11
|
-
# if current = up
|
|
12
|
-
# if current = down
|
|
13
|
-
#
|
|
14
|
-
|
|
15
5
|
check = Downtime::DowntimeCheck.new
|
|
16
6
|
check.perform
|
|
17
7
|
|
|
8
|
+
# I'd like a friendly exit code
|
|
9
|
+
|
|
18
10
|
#if Downtime.up?
|
|
19
11
|
# Downtime.up_now!
|
|
20
12
|
# exit 0
|
data/lib/downtime/version.rb
CHANGED
data/lib/downtime.rb
CHANGED
|
@@ -37,14 +37,14 @@ module Downtime
|
|
|
37
37
|
else
|
|
38
38
|
# "stayed down"
|
|
39
39
|
# Modify last line.
|
|
40
|
-
lines[-1].gsub!(/till.*/, "till #{@timestamp}")
|
|
40
|
+
lines[-1].gsub!(/till.*/, "till #{@timestamp} (#{minutes} minutes)")
|
|
41
41
|
end
|
|
42
42
|
else
|
|
43
43
|
# was up before
|
|
44
44
|
if up
|
|
45
45
|
# "stayed up."
|
|
46
46
|
# Modify last line.
|
|
47
|
-
lines[-1].gsub!(/till.*/, "till #{@timestamp}")
|
|
47
|
+
lines[-1].gsub!(/till.*/, "till #{@timestamp} (#{minutes} minutes)")
|
|
48
48
|
else
|
|
49
49
|
# "went down."
|
|
50
50
|
lines << "! went down after #{minutes} minutes of uptime."
|
|
@@ -70,5 +70,11 @@ module Downtime
|
|
|
70
70
|
def timestamp!
|
|
71
71
|
@timestamp = Timestamp.new
|
|
72
72
|
end
|
|
73
|
+
|
|
74
|
+
def append_to_logfile text
|
|
75
|
+
File.open(@log_file, 'a') do |f|
|
|
76
|
+
f.puts text
|
|
77
|
+
end
|
|
78
|
+
end
|
|
73
79
|
end
|
|
74
80
|
end
|