blertr 0.2.4 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -0,0 +1,201 @@
1
+ h1. Blertr
2
+
3
+ h2. Alerts for long running scripts in bash.
4
+
5
+ Amazing moving logo found here:
6
+ "Blertr":http://vlandham.github.com/blertr
7
+
8
+ h2. What is it Good For?
9
+
10
+ Waiting around for a command to finish sucks. You know you need to start the next run after this script has completed, so you just keep checking that terminal for output. This is no fun. It disrupts what you are working on. It distracts you. It wastes your time.
11
+
12
+ Why can't the script just tell you when its done, when its done?
13
+
14
+ That's where Blertr comes in. Want an email when that long @cp@ is finally over? Done. Want a tweet when your custom perl script finally exits? You got it.
15
+
16
+ Of course, you *could* modify all your custom scripts to add a section to send an email to yourself at the end of execution. That's possible for custom scripts. But tedious and heavy handed. What about just running a straight bash command? No luck. Somebody else's scripts? Edit if you dare.
17
+
18
+ Blertr side-steps these issues by hooking into bash to do its alerting. Based on a wonderful Mac OSX hint (which I'm having trouble finding the link), Blertr catches terminal commands when they start and when they exit, and sends this information to the Blertr control center which dispatches the appropriate alerts to you based on the amount of time the command has taken to run. Easy.
19
+
20
+ h2. Blertr Notifications
21
+
22
+ Blertr comes with a bunch of notifiers that will tell you when a command has finished in a variety of ways.
23
+
24
+ Each notifier can be told how long a task should be running before you are notified by the notifier.
25
+
26
+ For example, you might want to get Growl notifications for tasks that run for 10 seconds or more. And then get emails for processes that run over an hour. This way you won't get bogged down in a bunch of emails from all your short processes, but you will be alerted through the correct channel based on how long it took the task to finish.
27
+
28
+ Here are the current Blertr Notifiers:
29
+
30
+ h3. Growl
31
+
32
+ "Growl":http://growl.info/ is a nice clean notification service for Mac OSX. To have Blertr notify you through growl, you'll need the growlnotify application installed, which is included in the "Extras" directory in the Growl dmg.
33
+
34
+ h3. Notify Send
35
+
36
+ Notify Send is the Linux version of Growl. It looks to be installed on a number of platforms (Ubuntu, CentOS). Its a nice, simple pop-up notification service.
37
+
38
+ h3. Email
39
+
40
+ Blertr can send you an email when a process is done. Great for long running tasks. Step away from your computer, and know with confidence when to come back.
41
+
42
+ Here is what a typical email from Blertr looks like:
43
+ <pre>
44
+ <code>
45
+
46
+ Title: bwa_align.sh is done!
47
+
48
+ Message:
49
+ bwa_align.sh has completed.
50
+ Command: bwa_align.sh 3 hjaa1 3 ../../files/
51
+ Time: 1.44 hours
52
+ </code>
53
+ </pre>
54
+
55
+ So, not only do you get an alert when the command has finished, you get the total time it took to run that command. Need to know how long a particular command runs? With Blertr, you are well on your way to finding that out.
56
+
57
+ h3. Twitter
58
+
59
+ Want to know when a process is complete, but don't like extra emails? Blertr can tweet you when your command is done!
60
+
61
+ (Work in progress).
62
+
63
+
64
+ h2. Requirements
65
+
66
+ All this awesomeness comes at a slight cost. Blertr only works with the Bash shell, and requires Ruby. Blertr currently has only been tested on ruby 1.9.2.
67
+
68
+ RVM can be used to quickly get up to speed on the ruby environment:
69
+ <pre>
70
+ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
71
+ rvm install 1.9.2
72
+ rvm use 1.9.2 --default
73
+ </pre>
74
+
75
+ Each of the Notifiers need a bit of configuration to work properly as well:
76
+ * *Growl* needs growlnotify installed and available.
77
+ * *Notify Send* needs notify-send installd.
78
+ * *Email* needs openssl support in ruby. On Linux, this might need to be compiled. Follow "these rvm-based steps":http://cjohansen.no/en/ruby/ruby_version_manager_ubuntu_and_openssl to get going quickly.
79
+ * *Twitter* needs some authentication stuff in the twitter notifier's config file. It also users the twitter gem.
80
+
81
+ But really, for the awesomeness that is Blertr, this setup isn't so bad.
82
+
83
+ h2. Install
84
+
85
+ Once you have Ruby 1.9.2 in place (using rvm) and the other stuff setup, installation should be simple:
86
+
87
+ <pre>
88
+ gem install blertr
89
+ blertr install
90
+ </pre>
91
+
92
+ Then you just need to add this line to the end of your @.bashrc@ file:
93
+
94
+ <code>
95
+ [[ -s "$HOME/.blertr/app/scripts/blertr" ]] && . "$HOME/.blertr/app/scripts/blertr"
96
+ </code>
97
+
98
+ This adds the hooks necessary to make Blertr run.
99
+
100
+ h2. Setup
101
+
102
+ You probably want to set your defaults up a bit once installed.
103
+
104
+ h3. Email
105
+
106
+ Blertr needs to know who to send emails to. Use this command to tell it:
107
+
108
+ <pre>
109
+ blertr set email to myemail@gmail.com
110
+ </pre>
111
+
112
+ Of course, use your own email for @myemail@. This command 'sets' the 'to' configuration for the 'email' notifier.
113
+
114
+ h3. Twitter
115
+
116
+ Currently, the twitter config file doesn't come with Blertr by default... We're working on something for that.
117
+
118
+ h3. Time
119
+
120
+ Blertr has default times for each notifier. These, you might want to tweak to your liking. You can see the time setting for a particular notifier using the @info@ command:
121
+
122
+ <pre>
123
+ blertr info growl
124
+ </pre>
125
+
126
+ Should return something like:
127
+ <pre>
128
+ Configuration for: growl
129
+ time: 10
130
+ </pre>
131
+
132
+ Meaning Blertr will notify via Growl for tasks that take longer than 10 seconds.
133
+
134
+ To change this, you can use the @time@ command:
135
+
136
+ <pre>
137
+ blertr time growl 20 seconds
138
+ </pre>
139
+
140
+ The time command takes time in a variety of formats. '5 minutes', '6 hours', '2 days' are all valid time entries.
141
+
142
+
143
+ h3. Exclusions
144
+
145
+ Alerts are great and all, but there are plenty of commands that you would rather not get emails about. You probably don't need a tweet every time you exit from a ssh connection. That's where Blertr exclusions come in. By default, there are a number of commands excluded from alerting you. You can add to the list using the @exclude@ command:
146
+
147
+ <pre>
148
+ blertr exclude git push
149
+ </pre>
150
+
151
+ Blertr won't alert you for any command that starts with 'git push'.
152
+
153
+ It might take a bit of work to perfect your exclusions, but it should be pretty easy to do.
154
+
155
+ h2. Commands
156
+
157
+ We already saw a bunch of commands already. Here is a full listing of what Blertr understands, from the @help@ command:
158
+
159
+ <pre>
160
+ help Output this help message
161
+
162
+ install Add symlinks to your system to allow
163
+ Blertr to function properly
164
+
165
+ uninstall Remove symlinks and other setup process
166
+ Effectively uninstalling Blertr
167
+
168
+ upgrade Updates current copy of blertr to latest version
169
+
170
+ info Pass in a notifier name to get the
171
+ information it is using to send notifications
172
+ Example: blertr info email
173
+
174
+ status For each notifier, Blertr lists if it currently can
175
+ send notifications and then lists any error messages
176
+ if it cannot. Useful for debuggin problems with notifiers
177
+
178
+ exclude Pass in a shell command to prevent Blertr from
179
+ sending notifications when that command is
180
+ executed
181
+ Example: blertr exclude ssh
182
+
183
+ time Pass in a notifier name and a time string to
184
+ set the time required to pass before the
185
+ notifier sends a message for a command
186
+ Example: blertr time email 5 minutes
187
+ This would make blertr send an email only if
188
+ the command executing took longer than 5 mins
189
+
190
+ set Pass in the notifier name, a configuration key, and
191
+ a value. Blertr will add this key / value to the
192
+ notifiers config file.
193
+ Example: blertr set mail to user@gmail.com
194
+ </pre>
195
+
196
+
197
+ h2. Suggestions
198
+
199
+ Have some feature ideas to make Blertr even more incredible? Send them to me!
200
+
201
+ Happy Blerting!
@@ -13,7 +13,7 @@ module Blertr
13
13
  end
14
14
 
15
15
  def command_short_name
16
- self.command.split(/ /)[0]
16
+ File.basename(self.command.split(/ /)[0])
17
17
  end
18
18
 
19
19
  def time_string
@@ -1,3 +1,3 @@
1
1
  module Blertr
2
- VERSION = "0.2.4".freeze
2
+ VERSION = "0.2.6".freeze
3
3
  end
data/spec/message_spec.rb CHANGED
@@ -1,6 +1,21 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe Blertr::Message do
4
+
5
+ describe "advanced short names" do
6
+ before(:each) do
7
+ @seconds = 240
8
+ end
9
+ it "should figure out base paths to commands" do
10
+ path_commands = {"../start.sh 123 -h -o" => "start.sh",
11
+ "/usr/bin/ruby -v ./runner.rb" => "ruby",
12
+ "../../../commands/bin -kill destroy" => "bin"}
13
+ path_commands.each do |command, short_name|
14
+ message = Blertr::Message.new(command, @seconds)
15
+ message.command_short_name.should == short_name
16
+ end
17
+ end
18
+ end
4
19
  describe "basic functionality" do
5
20
  before(:each) do
6
21
  @command = "cp -r ./ddd/aaa /aaa/ddd"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blertr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-29 00:00:00.000000000Z
12
+ date: 2011-08-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &869520 !ruby/object:Gem::Requirement
16
+ requirement: &2676140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *869520
24
+ version_requirements: *2676140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &868760 !ruby/object:Gem::Requirement
27
+ requirement: &2675820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.5'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *868760
35
+ version_requirements: *2675820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &867860 !ruby/object:Gem::Requirement
38
+ requirement: &2675590 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.3'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *867860
46
+ version_requirements: *2675590
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: simplecov
49
- requirement: &867350 !ruby/object:Gem::Requirement
49
+ requirement: &2675320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.4'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *867350
57
+ version_requirements: *2675320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: twitter
60
- requirement: &866540 !ruby/object:Gem::Requirement
60
+ requirement: &2674970 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,11 +65,10 @@ dependencies:
65
65
  version: 1.6.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *866540
68
+ version_requirements: *2674970
69
69
  description: Automatic alerts for when bash scripts and commands complete
70
70
  email: vvv@gmail.com
71
71
  executables:
72
- - blert
73
72
  - blertr
74
73
  extensions: []
75
74
  extra_rdoc_files:
@@ -83,7 +82,6 @@ files:
83
82
  - Gemfile.lock
84
83
  - LICENSE.textile
85
84
  - README.textile
86
- - bin/blert
87
85
  - bin/blertr
88
86
  - blertr.gemspec
89
87
  - config/blacklist.yaml
data/bin/blert DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Run the command, including arguments with spaces
4
- "$@"
5
- status=$?
6
-
7
- # decide which status to use
8
- if [ "$status" == "0" ] ; then
9
- result="completed"
10
- else
11
- result="FAILED ($status)"
12
- fi
13
-
14
- # decide which notifier we have
15
- env growlnotify -h > /dev/null 2> /dev/null
16
- has_growl=$?
17
- env notify-send > /dev/null 2> /dev/null
18
- has_libnotify=$?
19
-
20
- # notify the user, growl or libnotify
21
- if [ "$has_growl" == "0" ] ; then
22
- growlnotify -m "Script '$@' $result" -n "Blert Notification"
23
- elif [ "$has_libnotify" == "0" ] ; then
24
- notify-send "Script '$@' $result" "Blert Notification" &
25
- fi
26
-
27
- # exit with the original status
28
- exit $status
29
-