notifyme 1.1.4 → 1.1.5
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.
- data/lib/notifyme.rb +1 -0
 - data/lib/notifyme/log/mail.rb +35 -43
 - data/lib/notifyme/start.rb +1 -1
 - data/notifyme_config.rb +8 -7
 - metadata +68 -72
 - data/lib/vendor/smtp_add_tls_support.rb +0 -113
 
    
        data/lib/notifyme.rb
    CHANGED
    
    
    
        data/lib/notifyme/log/mail.rb
    CHANGED
    
    | 
         @@ -2,74 +2,66 @@ module NotifyMe 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Log
         
     | 
| 
       3 
3 
     | 
    
         
             
                class Mail < Logger
         
     | 
| 
       4 
4 
     | 
    
         
             
                  def <<(task)
         
     | 
| 
       5 
     | 
    
         
            -
                    require 'vendor/smtp_add_tls_support.rb'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
5 
     | 
    
         
             
                    param = @parameters
         
     | 
| 
       8 
6 
     | 
    
         
             
                    param = {} unless param.is_a?(Hash)
         
     | 
| 
       9 
7 
     | 
    
         | 
| 
       10 
8 
     | 
    
         
             
                    # some default settings
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
9 
     | 
    
         
             
                    default_host = 'localhost'
         
     | 
| 
       13 
     | 
    
         
            -
                     
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                       
     | 
| 
       16 
     | 
    
         
            -
                    else
         
     | 
| 
       17 
     | 
    
         
            -
                      default_port = 25
         
     | 
| 
       18 
     | 
    
         
            -
                      Net::SMTP.disable_tls
         
     | 
| 
      
 10 
     | 
    
         
            +
                    smtp_port = param[:port]
         
     | 
| 
      
 11 
     | 
    
         
            +
                    unless smtp_port
         
     | 
| 
      
 12 
     | 
    
         
            +
                      smtp_port = param[:tls] ? 587 : 25
         
     | 
| 
       19 
13 
     | 
    
         
             
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
                    smtp_host = (param[:address] || param[:host]) || default_host
         
     | 
| 
       20 
15 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                    default_from_email = 'notifyme@' +  
     | 
| 
      
 16 
     | 
    
         
            +
                    default_from_email = 'notifyme@' + smtp_host
         
     | 
| 
       22 
17 
     | 
    
         | 
| 
       23 
18 
     | 
    
         
             
                    param[:subject] = "NotifyMe report (#{fact(:hostname)} # #{fact(:ipaddress)}): #{task.name}"
         
     | 
| 
       24 
19 
     | 
    
         
             
                    param[:subject] = param[:subject] % 
         
     | 
| 
       25 
20 
     | 
    
         | 
| 
       26 
21 
     | 
    
         
             
                    param[:from_email] ||= param[:account]
         
     | 
| 
       27 
22 
     | 
    
         
             
                    param[:from_email] ||= default_from_email
         
     | 
| 
      
 23 
     | 
    
         
            +
                    from = if param[:from_name]
         
     | 
| 
      
 24 
     | 
    
         
            +
                             "#{param[:from_name]} <#{param[:from_email]}>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                           else
         
     | 
| 
      
 26 
     | 
    
         
            +
                             param[:from_email]
         
     | 
| 
      
 27 
     | 
    
         
            +
                           end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                    param[:body] = param[:body_header].to_s + 
         
     | 
| 
       30 
30 
     | 
    
         
             
                      generate(task) +
         
     | 
| 
       31 
31 
     | 
    
         
             
                      param[:body_footer].to_s
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                    smtp = Net::SMTP.new(
         
     | 
| 
       34 
     | 
    
         
            -
                      (param[:address] || param[:host]) || default_host, 
         
     | 
| 
       35 
     | 
    
         
            -
                      param[:port] || default_port
         
     | 
| 
       36 
     | 
    
         
            -
                    )
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
33 
     | 
    
         
             
                    # go go go!
         
     | 
| 
       39 
34 
     | 
    
         
             
                    recipients = if param[:to_email].is_a? Hash
         
     | 
| 
       40 
     | 
    
         
            -
                                   param[:to_email]. 
     | 
| 
      
 35 
     | 
    
         
            +
                                   param[:to_email].collect{|name, email| "#{name} <#{email}>"}
         
     | 
| 
       41 
36 
     | 
    
         
             
                                 else
         
     | 
| 
       42 
37 
     | 
    
         
             
                                   param[:to_email]
         
     | 
| 
       43 
38 
     | 
    
         
             
                                 end
         
     | 
| 
       44 
     | 
    
         
            -
                    smtp.start(param[:helo_domain] || default_host, 
         
     | 
| 
       45 
     | 
    
         
            -
                               param[:account], 
         
     | 
| 
       46 
     | 
    
         
            -
                               param[:password], 
         
     | 
| 
       47 
     | 
    
         
            -
                               param[:authtype] || :plain
         
     | 
| 
       48 
     | 
    
         
            -
                              ) do |mail|
         
     | 
| 
       49 
     | 
    
         
            -
                                mail.send_message message(param, task), param[:from_email], recipients 
         
     | 
| 
       50 
     | 
    
         
            -
                              end
         
     | 
| 
       51 
     | 
    
         
            -
                  end
         
     | 
| 
       52 
39 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                           param[:to_email].collect{|v| "#{v.split('@').first} <#{v}>"}.join(", ")
         
     | 
| 
       60 
     | 
    
         
            -
                         else
         
     | 
| 
       61 
     | 
    
         
            -
                           "#{param[:to_name] || param[:to_email].split('@').first} <#{param[:to_email]}>"
         
     | 
| 
       62 
     | 
    
         
            -
                         end
         
     | 
| 
      
 40 
     | 
    
         
            +
                    mail = ::Mail.new do
         
     | 
| 
      
 41 
     | 
    
         
            +
                      from from
         
     | 
| 
      
 42 
     | 
    
         
            +
                      to recipients
         
     | 
| 
      
 43 
     | 
    
         
            +
                      subject param[:subject]
         
     | 
| 
      
 44 
     | 
    
         
            +
                      body param[:body]
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
       63 
46 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
                     
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
      
 47 
     | 
    
         
            +
                    if param[:host]
         
     | 
| 
      
 48 
     | 
    
         
            +
                      smtp_settings = {
         
     | 
| 
      
 49 
     | 
    
         
            +
                        :address => smtp_host,
         
     | 
| 
      
 50 
     | 
    
         
            +
                        :port => param[:port] || smtp_port,
         
     | 
| 
      
 51 
     | 
    
         
            +
                        :domain => param[:helo_domain] || default_host,
         
     | 
| 
      
 52 
     | 
    
         
            +
                        :user_name => param[:account] || param[:user_name],
         
     | 
| 
      
 53 
     | 
    
         
            +
                        :password => param[:password],
         
     | 
| 
      
 54 
     | 
    
         
            +
                        :authentication => param[:authentication] || :plain,
         
     | 
| 
      
 55 
     | 
    
         
            +
                        :openssl_verify_mode => param[:openssl_verify_mode],
         
     | 
| 
      
 56 
     | 
    
         
            +
                        :enable_starttls_auto => param[:enable_starttls_auto] || true,
         
     | 
| 
      
 57 
     | 
    
         
            +
                        :tls => param[:tls],
         
     | 
| 
      
 58 
     | 
    
         
            +
                        :ssl => param[:ssl]
         
     | 
| 
      
 59 
     | 
    
         
            +
                      }
         
     | 
| 
      
 60 
     | 
    
         
            +
                      mail.delivery_method :smtp, smtp_settings
         
     | 
| 
      
 61 
     | 
    
         
            +
                    else
         
     | 
| 
      
 62 
     | 
    
         
            +
                      mail.delivery_method :sendmail
         
     | 
| 
      
 63 
     | 
    
         
            +
                    end
         
     | 
| 
      
 64 
     | 
    
         
            +
                    mail.deliver
         
     | 
| 
       73 
65 
     | 
    
         
             
                  end
         
     | 
| 
       74 
66 
     | 
    
         
             
                end
         
     | 
| 
       75 
67 
     | 
    
         
             
              end
         
     | 
    
        data/lib/notifyme/start.rb
    CHANGED
    
    
    
        data/notifyme_config.rb
    CHANGED
    
    | 
         @@ -5,20 +5,19 @@ NotifyMe::Start.config do 
     | 
|
| 
       5 
5 
     | 
    
         
             
              log :mail, 
         
     | 
| 
       6 
6 
     | 
    
         
             
                :host => 'smtp.gmail.com',
         
     | 
| 
       7 
7 
     | 
    
         
             
                :helo_domain => 'gmail.com',
         
     | 
| 
       8 
     | 
    
         
            -
                :tls => true,
         
     | 
| 
       9 
8 
     | 
    
         | 
| 
       10 
9 
     | 
    
         
             
                :account => 'xxx@gmail.com', 
         
     | 
| 
       11 
10 
     | 
    
         
             
                :password => '***',
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
       13 
12 
     | 
    
         
             
                :from_email => 'from@gmail.com',
         
     | 
| 
       14 
     | 
    
         
            -
                :from_name => ' 
     | 
| 
      
 13 
     | 
    
         
            +
                :from_name => 'From Name',
         
     | 
| 
       15 
14 
     | 
    
         | 
| 
       16 
15 
     | 
    
         
             
                :to_email => 'to@gmail.com',
         
     | 
| 
       17 
     | 
    
         
            -
                :to_name => ' 
     | 
| 
      
 16 
     | 
    
         
            +
                :to_name => 'To Name'
         
     | 
| 
       18 
17 
     | 
    
         | 
| 
       19 
18 
     | 
    
         
             
                # or
         
     | 
| 
       20 
     | 
    
         
            -
                :to_email => {'User  
     | 
| 
       21 
     | 
    
         
            -
                :to_email => ['User  
     | 
| 
      
 19 
     | 
    
         
            +
                :to_email => {'User A' => 'a@gmail.com', 'User B' => 'b@gmail.com'}
         
     | 
| 
      
 20 
     | 
    
         
            +
                :to_email => ['User A <a@gmail.com>', 'User B<b@gmail.com'] 
         
     | 
| 
       22 
21 
     | 
    
         
             
            =end
         
     | 
| 
       23 
22 
     | 
    
         | 
| 
       24 
23 
     | 
    
         
             
              # log :file, '/tmp/test.txt'
         
     | 
| 
         @@ -30,8 +29,10 @@ NotifyMe::Start.config do 
     | 
|
| 
       30 
29 
     | 
    
         | 
| 
       31 
30 
     | 
    
         
             
              # set nagios directory
         
     | 
| 
       32 
31 
     | 
    
         
             
              # nagios_directory "/usr/lib/nagios/plugins"
         
     | 
| 
      
 32 
     | 
    
         
            +
              #
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
               
     | 
| 
      
 34 
     | 
    
         
            +
              ## !! NOTICE: for new installation,
         
     | 
| 
      
 35 
     | 
    
         
            +
              ## !!         It's not recommended that to put "check tasks" in the notifyme_config.rb file.
         
     | 
| 
       35 
36 
     | 
    
         | 
| 
       36 
37 
     | 
    
         
             
              #
         
     | 
| 
       37 
38 
     | 
    
         
             
              # check disk space usage every 60 seconds, 
         
     | 
| 
         @@ -41,7 +42,7 @@ NotifyMe::Start.config do 
     | 
|
| 
       41 
42 
     | 
    
         
             
                t.sleep_time = 60
         
     | 
| 
       42 
43 
     | 
    
         
             
                t.command = lambda {
         
     | 
| 
       43 
44 
     | 
    
         
             
                  if %x{df -h}.scan(/\s+(\d+)%\s+/).find {|pcent| pcent.first.to_i > 95}
         
     | 
| 
       44 
     | 
    
         
            -
                    "Warning: at least 1 disk space usage > 95%"
         
     | 
| 
      
 45 
     | 
    
         
            +
                    raise "Warning: at least 1 disk space usage > 95%"
         
     | 
| 
       45 
46 
     | 
    
         
             
                  else
         
     | 
| 
       46 
47 
     | 
    
         
             
                    nil
         
     | 
| 
       47 
48 
     | 
    
         
             
                  end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,124 +1,120 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: notifyme
         
     | 
| 
       3 
     | 
    
         
            -
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.1.4
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
       5 
4 
     | 
    
         
             
              prerelease: 
         
     | 
| 
      
 5 
     | 
    
         
            +
              version: 1.1.5
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
     | 
    
         
            -
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors: 
         
     | 
| 
       8 
8 
     | 
    
         
             
            - xianhua.zhou
         
     | 
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2013-03-03 00:00:00 Z
         
     | 
| 
      
 14 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       15 
16 
     | 
    
         
             
              name: daemons
         
     | 
| 
       16 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       17 
     | 
    
         
            -
                none: false
         
     | 
| 
       18 
     | 
    
         
            -
                requirements:
         
     | 
| 
       19 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       20 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       21 
     | 
    
         
            -
                    version: 1.1.0
         
     | 
| 
       22 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       23 
17 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       24 
     | 
    
         
            -
               
     | 
| 
      
 18 
     | 
    
         
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
       25 
19 
     | 
    
         
             
                none: false
         
     | 
| 
       26 
     | 
    
         
            -
                requirements:
         
     | 
| 
       27 
     | 
    
         
            -
                - -  
     | 
| 
       28 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 20 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 21 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 22 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
       29 
23 
     | 
    
         
             
                    version: 1.1.0
         
     | 
| 
       30 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       31 
     | 
    
         
            -
              name: json_pure
         
     | 
| 
       32 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       33 
     | 
    
         
            -
                none: false
         
     | 
| 
       34 
     | 
    
         
            -
                requirements:
         
     | 
| 
       35 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       36 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       37 
     | 
    
         
            -
                    version: 1.4.2
         
     | 
| 
       38 
24 
     | 
    
         
             
              type: :runtime
         
     | 
| 
      
 25 
     | 
    
         
            +
              version_requirements: *id001
         
     | 
| 
      
 26 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 27 
     | 
    
         
            +
              name: json_pure
         
     | 
| 
       39 
28 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       40 
     | 
    
         
            -
               
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
       41 
30 
     | 
    
         
             
                none: false
         
     | 
| 
       42 
     | 
    
         
            -
                requirements:
         
     | 
| 
       43 
     | 
    
         
            -
                - -  
     | 
| 
       44 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 31 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 32 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 33 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
       45 
34 
     | 
    
         
             
                    version: 1.4.2
         
     | 
| 
       46 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       47 
     | 
    
         
            -
              name: http_request.rb
         
     | 
| 
       48 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       49 
     | 
    
         
            -
                none: false
         
     | 
| 
       50 
     | 
    
         
            -
                requirements:
         
     | 
| 
       51 
     | 
    
         
            -
                - - ! '>='
         
     | 
| 
       52 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       53 
     | 
    
         
            -
                    version: 1.1.13
         
     | 
| 
       54 
35 
     | 
    
         
             
              type: :runtime
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: *id002
         
     | 
| 
      
 37 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 38 
     | 
    
         
            +
              name: http_request.rb
         
     | 
| 
       55 
39 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       56 
     | 
    
         
            -
               
     | 
| 
      
 40 
     | 
    
         
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         
     | 
| 
       57 
41 
     | 
    
         
             
                none: false
         
     | 
| 
       58 
     | 
    
         
            -
                requirements:
         
     | 
| 
       59 
     | 
    
         
            -
                - -  
     | 
| 
       60 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 42 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 43 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 44 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
       61 
45 
     | 
    
         
             
                    version: 1.1.13
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
      
 46 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 47 
     | 
    
         
            +
              version_requirements: *id003
         
     | 
| 
      
 48 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       63 
49 
     | 
    
         
             
              name: facter
         
     | 
| 
       64 
     | 
    
         
            -
               
     | 
| 
      
 50 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 51 
     | 
    
         
            +
              requirement: &id004 !ruby/object:Gem::Requirement 
         
     | 
| 
       65 
52 
     | 
    
         
             
                none: false
         
     | 
| 
       66 
     | 
    
         
            -
                requirements:
         
     | 
| 
       67 
     | 
    
         
            -
                - -  
     | 
| 
       68 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 53 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 54 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 55 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
       69 
56 
     | 
    
         
             
                    version: 1.6.17
         
     | 
| 
       70 
57 
     | 
    
         
             
              type: :runtime
         
     | 
| 
      
 58 
     | 
    
         
            +
              version_requirements: *id004
         
     | 
| 
      
 59 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 60 
     | 
    
         
            +
              name: mail
         
     | 
| 
       71 
61 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       72 
     | 
    
         
            -
               
     | 
| 
      
 62 
     | 
    
         
            +
              requirement: &id005 !ruby/object:Gem::Requirement 
         
     | 
| 
       73 
63 
     | 
    
         
             
                none: false
         
     | 
| 
       74 
     | 
    
         
            -
                requirements:
         
     | 
| 
       75 
     | 
    
         
            -
                - -  
     | 
| 
       76 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       77 
     | 
    
         
            -
                    version:  
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
               
     | 
| 
      
 64 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 65 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 66 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 67 
     | 
    
         
            +
                    version: 2.5.3
         
     | 
| 
      
 68 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 69 
     | 
    
         
            +
              version_requirements: *id005
         
     | 
| 
      
 70 
     | 
    
         
            +
            description: NotifyMe is a monitoring script, it can monitor processes, services etc. with ruby scripts.
         
     | 
| 
       80 
71 
     | 
    
         
             
            email: xianhua.zhou@gmail.com
         
     | 
| 
       81 
     | 
    
         
            -
            executables:
         
     | 
| 
      
 72 
     | 
    
         
            +
            executables: 
         
     | 
| 
       82 
73 
     | 
    
         
             
            - notifyme_daemon
         
     | 
| 
       83 
74 
     | 
    
         
             
            - notifyme
         
     | 
| 
       84 
75 
     | 
    
         
             
            extensions: []
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
       85 
77 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
            - lib/notifyme 
     | 
| 
       89 
     | 
    
         
            -
            - lib/notifyme/log 
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 80 
     | 
    
         
            +
            - lib/notifyme.rb
         
     | 
| 
      
 81 
     | 
    
         
            +
            - lib/notifyme/log.rb
         
     | 
| 
       90 
82 
     | 
    
         
             
            - lib/notifyme/log/mail.rb
         
     | 
| 
       91 
83 
     | 
    
         
             
            - lib/notifyme/log/stdout.rb
         
     | 
| 
       92 
     | 
    
         
            -
            - lib/notifyme/log.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - lib/notifyme/log/file.rb
         
     | 
| 
       93 
85 
     | 
    
         
             
            - lib/notifyme/start.rb
         
     | 
| 
      
 86 
     | 
    
         
            +
            - lib/notifyme/check.rb
         
     | 
| 
       94 
87 
     | 
    
         
             
            - lib/notifyme/task.rb
         
     | 
| 
       95 
     | 
    
         
            -
            - lib/notifyme.rb
         
     | 
| 
       96 
88 
     | 
    
         
             
            - INSTALL
         
     | 
| 
       97 
89 
     | 
    
         
             
            - notifyme_config.rb
         
     | 
| 
       98 
90 
     | 
    
         
             
            - bin/notifyme_daemon
         
     | 
| 
       99 
91 
     | 
    
         
             
            - bin/notifyme
         
     | 
| 
       100 
92 
     | 
    
         
             
            homepage: http://github.com/xianhuazhou/NotifyMe
         
     | 
| 
       101 
93 
     | 
    
         
             
            licenses: []
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
       102 
95 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       103 
96 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
       105 
99 
     | 
    
         
             
            - lib
         
     | 
| 
       106 
     | 
    
         
            -
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 100 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
       107 
101 
     | 
    
         
             
              none: false
         
     | 
| 
       108 
     | 
    
         
            -
              requirements:
         
     | 
| 
       109 
     | 
    
         
            -
              - -  
     | 
| 
       110 
     | 
    
         
            -
                - !ruby/object:Gem::Version
         
     | 
| 
       111 
     | 
    
         
            -
                  version:  
     | 
| 
       112 
     | 
    
         
            -
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 102 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 103 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 104 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 105 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 106 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
       113 
107 
     | 
    
         
             
              none: false
         
     | 
| 
       114 
     | 
    
         
            -
              requirements:
         
     | 
| 
       115 
     | 
    
         
            -
              - -  
     | 
| 
       116 
     | 
    
         
            -
                - !ruby/object:Gem::Version
         
     | 
| 
       117 
     | 
    
         
            -
                  version:  
     | 
| 
      
 108 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 109 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 110 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 111 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
       118 
112 
     | 
    
         
             
            requirements: []
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
       119 
114 
     | 
    
         
             
            rubyforge_project: notifyme
         
     | 
| 
       120 
115 
     | 
    
         
             
            rubygems_version: 1.8.24
         
     | 
| 
       121 
116 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       122 
117 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       123 
118 
     | 
    
         
             
            summary: It's a kind of cronjob.
         
     | 
| 
       124 
119 
     | 
    
         
             
            test_files: []
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
         @@ -1,113 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # http://happiness-is-slavery.net/wp-content/rails-plugins/smtp_add_tls_support/lib/smtp_add_tls_support.rb
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'net/smtp'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'timeout'
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            begin
         
     | 
| 
       7 
     | 
    
         
            -
              require 'openssl'
         
     | 
| 
       8 
     | 
    
         
            -
            rescue LoadError
         
     | 
| 
       9 
     | 
    
         
            -
            end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            Net::SMTP.class_eval do
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
              alias_method :old_initialize, :initialize
         
     | 
| 
       14 
     | 
    
         
            -
              def initialize(hostname, port)
         
     | 
| 
       15 
     | 
    
         
            -
                @usetls = @@usetls
         
     | 
| 
       16 
     | 
    
         
            -
                old_initialize hostname, port
         
     | 
| 
       17 
     | 
    
         
            -
              end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              @@usetls = false
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              def self.enable_tls()
         
     | 
| 
       22 
     | 
    
         
            -
                @@usetls = true
         
     | 
| 
       23 
     | 
    
         
            -
              end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
              def self.disable_tls()
         
     | 
| 
       26 
     | 
    
         
            -
                @@usetls = false
         
     | 
| 
       27 
     | 
    
         
            -
              end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
              def self.use_tls?()
         
     | 
| 
       30 
     | 
    
         
            -
                @@usetls
         
     | 
| 
       31 
     | 
    
         
            -
              end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
              def use_tls?()
         
     | 
| 
       34 
     | 
    
         
            -
                @usetls
         
     | 
| 
       35 
     | 
    
         
            -
              end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
              def enable_tls()
         
     | 
| 
       38 
     | 
    
         
            -
                @usetls = true
         
     | 
| 
       39 
     | 
    
         
            -
              end
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
              def disable_tls()
         
     | 
| 
       42 
     | 
    
         
            -
                @usetls = false
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
              def use_tls?()
         
     | 
| 
       46 
     | 
    
         
            -
                @usetls
         
     | 
| 
       47 
     | 
    
         
            -
              end
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
              private
         
     | 
| 
       50 
     | 
    
         
            -
              def do_start(helodomain, user, secret, authtype)
         
     | 
| 
       51 
     | 
    
         
            -
                raise IOError 'SMTP session already started' if @started
         
     | 
| 
       52 
     | 
    
         
            -
                check_auth_args user, secret if user or secret
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                sock = timeout(@open_timeout) {
         
     | 
| 
       55 
     | 
    
         
            -
                  TCPSocket.open(@address, @port)
         
     | 
| 
       56 
     | 
    
         
            -
                }
         
     | 
| 
       57 
     | 
    
         
            -
                @socket = Net::InternetMessageIO.new(sock)
         
     | 
| 
       58 
     | 
    
         
            -
                @socket.read_timeout = @read_timeout
         
     | 
| 
       59 
     | 
    
         
            -
                @socket.debug_output = nil
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                check_response(critical{
         
     | 
| 
       62 
     | 
    
         
            -
                  recv_response()
         
     | 
| 
       63 
     | 
    
         
            -
                })
         
     | 
| 
       64 
     | 
    
         
            -
                do_helo(helodomain)
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                if @usetls 
         
     | 
| 
       67 
     | 
    
         
            -
                  raise 'openssl is not installed' unless defined?(OpenSSL)
         
     | 
| 
       68 
     | 
    
         
            -
                  ssl = OpenSSL::SSL::SSLSocket.new(sock)
         
     | 
| 
       69 
     | 
    
         
            -
                  starttls
         
     | 
| 
       70 
     | 
    
         
            -
                  ssl.sync_close = true
         
     | 
| 
       71 
     | 
    
         
            -
                  ssl.connect
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                  @socket = Net::InternetMessageIO.new(ssl)
         
     | 
| 
       74 
     | 
    
         
            -
                  @socket.read_timeout = @read_timeout
         
     | 
| 
       75 
     | 
    
         
            -
                  @socket.debug_output = nil
         
     | 
| 
       76 
     | 
    
         
            -
                  do_helo(helodomain)
         
     | 
| 
       77 
     | 
    
         
            -
                end
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                authenticate user, secret, authtype if user
         
     | 
| 
       80 
     | 
    
         
            -
                @started = true
         
     | 
| 
       81 
     | 
    
         
            -
              ensure
         
     | 
| 
       82 
     | 
    
         
            -
                @socket.close if not @started and @socket and not @socket.closed?
         
     | 
| 
       83 
     | 
    
         
            -
              end
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
              def do_helo(helodomain)
         
     | 
| 
       86 
     | 
    
         
            -
                begin
         
     | 
| 
       87 
     | 
    
         
            -
                  if @esmtp
         
     | 
| 
       88 
     | 
    
         
            -
                    ehlo helodomain
         
     | 
| 
       89 
     | 
    
         
            -
                  else
         
     | 
| 
       90 
     | 
    
         
            -
                    helo helodomain
         
     | 
| 
       91 
     | 
    
         
            -
                  end
         
     | 
| 
       92 
     | 
    
         
            -
                rescue Net::ProtocolError
         
     | 
| 
       93 
     | 
    
         
            -
                  if @esmtp
         
     | 
| 
       94 
     | 
    
         
            -
                    @esmtp = false
         
     | 
| 
       95 
     | 
    
         
            -
                    @error_occured = false
         
     | 
| 
       96 
     | 
    
         
            -
                    retry
         
     | 
| 
       97 
     | 
    
         
            -
                  end
         
     | 
| 
       98 
     | 
    
         
            -
                  raise
         
     | 
| 
       99 
     | 
    
         
            -
                end
         
     | 
| 
       100 
     | 
    
         
            -
              end
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
              def starttls
         
     | 
| 
       103 
     | 
    
         
            -
                getok('STARTTLS')
         
     | 
| 
       104 
     | 
    
         
            -
              end
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
              def quit
         
     | 
| 
       107 
     | 
    
         
            -
                begin
         
     | 
| 
       108 
     | 
    
         
            -
                  getok('QUIT')
         
     | 
| 
       109 
     | 
    
         
            -
                rescue EOFError
         
     | 
| 
       110 
     | 
    
         
            -
                  # gmail sucks
         
     | 
| 
       111 
     | 
    
         
            -
                end
         
     | 
| 
       112 
     | 
    
         
            -
              end
         
     | 
| 
       113 
     | 
    
         
            -
            end
         
     |