fluent-plugin-papertrail 0.2.7 → 0.2.8
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/LICENSE +16 -0
 - data/README.md +1 -1
 - data/fluent-plugin-papertrail.gemspec +3 -4
 - data/lib/fluent/plugin/out_papertrail.rb +1 -1
 - data/lib/syslog_protocol.rb +8 -0
 - data/lib/syslog_protocol/common.rb +79 -0
 - data/lib/syslog_protocol/logger.rb +21 -0
 - data/lib/syslog_protocol/packet.rb +135 -0
 - data/lib/syslog_protocol/parser.rb +57 -0
 - metadata +10 -17
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 84fddf384c62427d43c934b1665c7c3ec1744829
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5318b95c3ef4621148087541c0c0c5fa4a88504c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 22c893fa7c09ded365afe97a06aae47385a23e103f88b061a94bda5f924439e39c7356d54db4cd6dab2f89774afba941825ea00dbf489246fbe48a8c9a6b9630
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d824bdcbe541245b3a2e023f9b5bb38b4f1d37783c25548e5e25238b71f81c46a0de64f0ab956a41981c67a9cd9a8b25fbeac74d1998b1ebd4f00282fda7b9a4
         
     | 
    
        data/LICENSE
    CHANGED
    
    | 
         @@ -199,3 +199,19 @@ 
     | 
|
| 
       199 
199 
     | 
    
         
             
               WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         
     | 
| 
       200 
200 
     | 
    
         
             
               See the License for the specific language governing permissions and
         
     | 
| 
       201 
201 
     | 
    
         
             
               limitations under the License.
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
            ------------------------------------------------
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
            This software includes portions of syslog_protocol from https://github.com/eric/syslog_protocol/
         
     | 
| 
      
 206 
     | 
    
         
            +
            under the following MIT license:
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
      
 208 
     | 
    
         
            +
            The MIT License (MIT)
         
     | 
| 
      
 209 
     | 
    
         
            +
             
     | 
| 
      
 210 
     | 
    
         
            +
            Copyright (c) 2013 Jake Douglas and Eric Lindvall
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -119,4 +119,4 @@ The gem is available as open source under the terms of the [Apache License](LICE 
     | 
|
| 
       119 
119 
     | 
    
         | 
| 
       120 
120 
     | 
    
         
             
            # Questions/Comments?
         
     | 
| 
       121 
121 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
            Please [open an issue](https://github.com/solarwinds/fluent-plugin-papertrail/issues/new), we'd love to hear from you. 
     | 
| 
      
 122 
     | 
    
         
            +
            Please [open an issue](https://github.com/solarwinds/fluent-plugin-papertrail/issues/new), we'd love to hear from you.
         
     | 
| 
         @@ -4,9 +4,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       6 
6 
     | 
    
         
             
              spec.name          = "fluent-plugin-papertrail"
         
     | 
| 
       7 
     | 
    
         
            -
              spec.version       = "0.2. 
     | 
| 
       8 
     | 
    
         
            -
              spec.authors       = ["Jonathan Lozinski", "Alex Ouzounis", "Chris Rust"]
         
     | 
| 
       9 
     | 
    
         
            -
              spec.email         = ["jonathan.lozinski@solarwinds.com", "alex.ouzounis@solarwinds.com", "chris.rust@solarwinds.com"]
         
     | 
| 
      
 7 
     | 
    
         
            +
              spec.version       = "0.2.8"
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.authors       = ["Jonathan Lozinski", "Alex Ouzounis", "Chris Rust", "Chris Erway"]
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.email         = ["jonathan.lozinski@solarwinds.com", "alex.ouzounis@solarwinds.com", "chris.rust@solarwinds.com", "chris.erway@solarwinds.com"]
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
              spec.summary       = %q{Remote Syslog Output Fluentd plugin for papertrail}
         
     | 
| 
       12 
12 
     | 
    
         
             
              spec.description   = %q{Remote Syslog Output Fluentd plugin for papertrail}
         
     | 
| 
         @@ -22,7 +22,6 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
              spec.add_dependency "fluentd", '>= 0.10', '< 2'
         
     | 
| 
       24 
24 
     | 
    
         
             
              spec.add_dependency "fluent-mixin-config-placeholders", "~> 0.4.0"
         
     | 
| 
       25 
     | 
    
         
            -
              spec.add_dependency "syslog_protocol"
         
     | 
| 
       26 
25 
     | 
    
         | 
| 
       27 
26 
     | 
    
         
             
              spec.add_development_dependency "bundler", "~> 1.12"
         
     | 
| 
       28 
27 
     | 
    
         
             
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
         @@ -81,7 +81,7 @@ module Fluent 
     | 
|
| 
       81 
81 
     | 
    
         
             
                  packet.facility = record['facility'] || 'local0'
         
     | 
| 
       82 
82 
     | 
    
         
             
                  packet.severity = record['severity'] || 'info'
         
     | 
| 
       83 
83 
     | 
    
         
             
                  packet.tag      = record['program'] || tag
         
     | 
| 
       84 
     | 
    
         
            -
                  packet.content  = record['message']
         
     | 
| 
      
 84 
     | 
    
         
            +
                  packet.content  = record['message'] || record['log']
         
     | 
| 
       85 
85 
     | 
    
         
             
                  packet.time     = time ? Time.at(time) : Time.now
         
     | 
| 
       86 
86 
     | 
    
         
             
                  packet
         
     | 
| 
       87 
87 
     | 
    
         
             
                end
         
     | 
| 
         @@ -0,0 +1,79 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module SyslogProtocol
         
     | 
| 
      
 2 
     | 
    
         
            +
              # These hashes stolen from Syslog.pm
         
     | 
| 
      
 3 
     | 
    
         
            +
              
         
     | 
| 
      
 4 
     | 
    
         
            +
              FACILITIES = {
         
     | 
| 
      
 5 
     | 
    
         
            +
                'kern'     => 0,
         
     | 
| 
      
 6 
     | 
    
         
            +
                'user'     => 1,
         
     | 
| 
      
 7 
     | 
    
         
            +
                'mail'     => 2,
         
     | 
| 
      
 8 
     | 
    
         
            +
                'daemon'   => 3,
         
     | 
| 
      
 9 
     | 
    
         
            +
                'auth'     => 4,
         
     | 
| 
      
 10 
     | 
    
         
            +
                'syslog'   => 5,
         
     | 
| 
      
 11 
     | 
    
         
            +
                'lpr'      => 6,
         
     | 
| 
      
 12 
     | 
    
         
            +
                'news'     => 7,
         
     | 
| 
      
 13 
     | 
    
         
            +
                'uucp'     => 8,
         
     | 
| 
      
 14 
     | 
    
         
            +
                'cron'     => 9,
         
     | 
| 
      
 15 
     | 
    
         
            +
                'authpriv' => 10,
         
     | 
| 
      
 16 
     | 
    
         
            +
                'ftp'      => 11,
         
     | 
| 
      
 17 
     | 
    
         
            +
                'ntp'      => 12,
         
     | 
| 
      
 18 
     | 
    
         
            +
                'audit'    => 13,
         
     | 
| 
      
 19 
     | 
    
         
            +
                'alert'    => 14,
         
     | 
| 
      
 20 
     | 
    
         
            +
                'at'       => 15,
         
     | 
| 
      
 21 
     | 
    
         
            +
                'local0'   => 16,
         
     | 
| 
      
 22 
     | 
    
         
            +
                'local1'   => 17,
         
     | 
| 
      
 23 
     | 
    
         
            +
                'local2'   => 18,
         
     | 
| 
      
 24 
     | 
    
         
            +
                'local3'   => 19,
         
     | 
| 
      
 25 
     | 
    
         
            +
                'local4'   => 20,
         
     | 
| 
      
 26 
     | 
    
         
            +
                'local5'   => 21,
         
     | 
| 
      
 27 
     | 
    
         
            +
                'local6'   => 22,
         
     | 
| 
      
 28 
     | 
    
         
            +
                'local7'   => 23
         
     | 
| 
      
 29 
     | 
    
         
            +
              }
         
     | 
| 
      
 30 
     | 
    
         
            +
              
         
     | 
| 
      
 31 
     | 
    
         
            +
              FACILITY_INDEX = {
         
     | 
| 
      
 32 
     | 
    
         
            +
                0   => 'kern',
         
     | 
| 
      
 33 
     | 
    
         
            +
                1   => 'user',
         
     | 
| 
      
 34 
     | 
    
         
            +
                2   => 'mail',
         
     | 
| 
      
 35 
     | 
    
         
            +
                3   => 'daemon',
         
     | 
| 
      
 36 
     | 
    
         
            +
                4   => 'auth',
         
     | 
| 
      
 37 
     | 
    
         
            +
                5   => 'syslog',
         
     | 
| 
      
 38 
     | 
    
         
            +
                6   => 'lpr',
         
     | 
| 
      
 39 
     | 
    
         
            +
                7   => 'news',
         
     | 
| 
      
 40 
     | 
    
         
            +
                8   => 'uucp',
         
     | 
| 
      
 41 
     | 
    
         
            +
                9   => 'cron',
         
     | 
| 
      
 42 
     | 
    
         
            +
                10  => 'authpriv',
         
     | 
| 
      
 43 
     | 
    
         
            +
                11  => 'ftp',
         
     | 
| 
      
 44 
     | 
    
         
            +
                12  => 'ntp',
         
     | 
| 
      
 45 
     | 
    
         
            +
                13  => 'audit',
         
     | 
| 
      
 46 
     | 
    
         
            +
                14  => 'alert',
         
     | 
| 
      
 47 
     | 
    
         
            +
                15  => 'at',
         
     | 
| 
      
 48 
     | 
    
         
            +
                16  => 'local0',
         
     | 
| 
      
 49 
     | 
    
         
            +
                17  => 'local1',
         
     | 
| 
      
 50 
     | 
    
         
            +
                18  => 'local2',
         
     | 
| 
      
 51 
     | 
    
         
            +
                19  => 'local3',
         
     | 
| 
      
 52 
     | 
    
         
            +
                20  => 'local4',
         
     | 
| 
      
 53 
     | 
    
         
            +
                21  => 'local5',
         
     | 
| 
      
 54 
     | 
    
         
            +
                22  => 'local6',
         
     | 
| 
      
 55 
     | 
    
         
            +
                23  => 'local7'
         
     | 
| 
      
 56 
     | 
    
         
            +
              }
         
     | 
| 
      
 57 
     | 
    
         
            +
              
         
     | 
| 
      
 58 
     | 
    
         
            +
              SEVERITIES = {
         
     | 
| 
      
 59 
     | 
    
         
            +
                'emerg'   => 0,
         
     | 
| 
      
 60 
     | 
    
         
            +
                'alert'   => 1,
         
     | 
| 
      
 61 
     | 
    
         
            +
                'crit'    => 2,
         
     | 
| 
      
 62 
     | 
    
         
            +
                'err'     => 3,
         
     | 
| 
      
 63 
     | 
    
         
            +
                'warn'    => 4,
         
     | 
| 
      
 64 
     | 
    
         
            +
                'notice'  => 5,
         
     | 
| 
      
 65 
     | 
    
         
            +
                'info'    => 6,
         
     | 
| 
      
 66 
     | 
    
         
            +
                'debug'   => 7 
         
     | 
| 
      
 67 
     | 
    
         
            +
              }
         
     | 
| 
      
 68 
     | 
    
         
            +
              
         
     | 
| 
      
 69 
     | 
    
         
            +
              SEVERITY_INDEX = {
         
     | 
| 
      
 70 
     | 
    
         
            +
                0  => 'emerg',
         
     | 
| 
      
 71 
     | 
    
         
            +
                1  => 'alert',
         
     | 
| 
      
 72 
     | 
    
         
            +
                2  => 'crit',
         
     | 
| 
      
 73 
     | 
    
         
            +
                3  => 'err',
         
     | 
| 
      
 74 
     | 
    
         
            +
                4  => 'warn',
         
     | 
| 
      
 75 
     | 
    
         
            +
                5  => 'notice',
         
     | 
| 
      
 76 
     | 
    
         
            +
                6  => 'info',
         
     | 
| 
      
 77 
     | 
    
         
            +
                7  => 'debug'
         
     | 
| 
      
 78 
     | 
    
         
            +
              }
         
     | 
| 
      
 79 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module SyslogProtocol
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Logger
         
     | 
| 
      
 3 
     | 
    
         
            +
                def initialize(hostname, tag, facility)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  @packet = Packet.new
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @packet.hostname = hostname
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @packet.tag      = tag
         
     | 
| 
      
 7 
     | 
    
         
            +
                  @packet.facility = facility
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
                
         
     | 
| 
      
 10 
     | 
    
         
            +
                SEVERITIES.each do |k,v|
         
     | 
| 
      
 11 
     | 
    
         
            +
                  define_method(k) do |content|
         
     | 
| 
      
 12 
     | 
    
         
            +
                    raise ArgumentError.new("Message may not be omitted") unless content and content.length > 0
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                    p = @packet.dup
         
     | 
| 
      
 15 
     | 
    
         
            +
                    p.severity = k
         
     | 
| 
      
 16 
     | 
    
         
            +
                    p.content = content
         
     | 
| 
      
 17 
     | 
    
         
            +
                    p.assemble
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,135 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module SyslogProtocol
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Packet
         
     | 
| 
      
 3 
     | 
    
         
            +
                attr_reader :facility, :severity, :hostname, :tag
         
     | 
| 
      
 4 
     | 
    
         
            +
                attr_accessor :time, :content
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                def to_s
         
     | 
| 
      
 7 
     | 
    
         
            +
                  assemble
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                def assemble(max_size = 1024)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  unless @hostname and @facility and @severity and @tag
         
     | 
| 
      
 12 
     | 
    
         
            +
                    raise "Could not assemble packet without hostname, tag, facility, and severity"
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  data = "<#{pri}>#{generate_timestamp} #{@hostname} #{@tag}: #{@content}"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  if string_bytesize(data) > max_size
         
     | 
| 
      
 17 
     | 
    
         
            +
                    data = data.slice(0, max_size)
         
     | 
| 
      
 18 
     | 
    
         
            +
                    while string_bytesize(data) > max_size
         
     | 
| 
      
 19 
     | 
    
         
            +
                      data = data.slice(0, data.length - 1)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  data
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                def facility=(f)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  if f.is_a? Integer
         
     | 
| 
      
 28 
     | 
    
         
            +
                    if (0..23).include?(f)
         
     | 
| 
      
 29 
     | 
    
         
            +
                      @facility = f
         
     | 
| 
      
 30 
     | 
    
         
            +
                    else
         
     | 
| 
      
 31 
     | 
    
         
            +
                      raise ArgumentError.new "Facility must be within 0-23"
         
     | 
| 
      
 32 
     | 
    
         
            +
                    end
         
     | 
| 
      
 33 
     | 
    
         
            +
                  elsif f.is_a? String
         
     | 
| 
      
 34 
     | 
    
         
            +
                    if facility = FACILITIES[f]
         
     | 
| 
      
 35 
     | 
    
         
            +
                      @facility = facility
         
     | 
| 
      
 36 
     | 
    
         
            +
                    else
         
     | 
| 
      
 37 
     | 
    
         
            +
                      raise ArgumentError.new "'#{f}' is not a designated facility"
         
     | 
| 
      
 38 
     | 
    
         
            +
                    end
         
     | 
| 
      
 39 
     | 
    
         
            +
                  else
         
     | 
| 
      
 40 
     | 
    
         
            +
                    raise ArgumentError.new "Facility must be a designated number or string"
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                def tag=(t)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  unless t && t.is_a?(String) && t.length > 0
         
     | 
| 
      
 46 
     | 
    
         
            +
                    raise ArgumentError, "Tag must not be omitted"
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
                  if t.length > 1024
         
     | 
| 
      
 49 
     | 
    
         
            +
                    raise ArgumentError, "Tag must not be longer than 1024 characters"
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
                  if t =~ /\s/
         
     | 
| 
      
 52 
     | 
    
         
            +
                    raise ArgumentError, "Tag may not contain spaces"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
                  if t =~ /[^\x21-\x7E]/
         
     | 
| 
      
 55 
     | 
    
         
            +
                    raise ArgumentError, "Tag may only contain ASCII characters 33-126"
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                  @tag = t
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                def severity=(s)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  if s.is_a? Integer
         
     | 
| 
      
 63 
     | 
    
         
            +
                    if (0..7).include?(s)
         
     | 
| 
      
 64 
     | 
    
         
            +
                      @severity = s
         
     | 
| 
      
 65 
     | 
    
         
            +
                    else
         
     | 
| 
      
 66 
     | 
    
         
            +
                      raise ArgumentError.new "Severity must be within 0-7"
         
     | 
| 
      
 67 
     | 
    
         
            +
                    end
         
     | 
| 
      
 68 
     | 
    
         
            +
                  elsif s.is_a? String
         
     | 
| 
      
 69 
     | 
    
         
            +
                    if severity = SEVERITIES[s]
         
     | 
| 
      
 70 
     | 
    
         
            +
                      @severity = severity
         
     | 
| 
      
 71 
     | 
    
         
            +
                    else
         
     | 
| 
      
 72 
     | 
    
         
            +
                      raise ArgumentError.new "'#{s}' is not a designated severity"
         
     | 
| 
      
 73 
     | 
    
         
            +
                    end
         
     | 
| 
      
 74 
     | 
    
         
            +
                  else
         
     | 
| 
      
 75 
     | 
    
         
            +
                    raise ArgumentError.new "Severity must be a designated number or string"
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                def hostname=(h)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  unless h and h.is_a? String and h.length > 0
         
     | 
| 
      
 81 
     | 
    
         
            +
                    raise ArgumentError.new("Hostname may not be omitted")
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
                  if h =~ /\s/
         
     | 
| 
      
 84 
     | 
    
         
            +
                    raise ArgumentError.new("Hostname may not contain spaces")
         
     | 
| 
      
 85 
     | 
    
         
            +
                  end
         
     | 
| 
      
 86 
     | 
    
         
            +
                  if h =~ /[^\x21-\x7E]/
         
     | 
| 
      
 87 
     | 
    
         
            +
                    raise ArgumentError.new("Hostname may only contain ASCII characters 33-126")
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                  @hostname = h
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                def facility_name
         
     | 
| 
      
 93 
     | 
    
         
            +
                  FACILITY_INDEX[@facility]
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                def severity_name
         
     | 
| 
      
 97 
     | 
    
         
            +
                  SEVERITY_INDEX[@severity]
         
     | 
| 
      
 98 
     | 
    
         
            +
                end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                def pri
         
     | 
| 
      
 101 
     | 
    
         
            +
                  (@facility * 8) + @severity
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                def pri=(p)
         
     | 
| 
      
 105 
     | 
    
         
            +
                  unless p.is_a? Integer and (0..191).include?(p)
         
     | 
| 
      
 106 
     | 
    
         
            +
                    raise ArgumentError.new "PRI must be a number between 0 and 191"
         
     | 
| 
      
 107 
     | 
    
         
            +
                  end
         
     | 
| 
      
 108 
     | 
    
         
            +
                  @facility = p / 8
         
     | 
| 
      
 109 
     | 
    
         
            +
                  @severity = p - (@facility * 8)
         
     | 
| 
      
 110 
     | 
    
         
            +
                end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                def generate_timestamp
         
     | 
| 
      
 113 
     | 
    
         
            +
                  time = @time || Time.now
         
     | 
| 
      
 114 
     | 
    
         
            +
                  # The timestamp format requires that a day with fewer than 2 digits have
         
     | 
| 
      
 115 
     | 
    
         
            +
                  # what would normally be a preceding zero, be instead an extra space.
         
     | 
| 
      
 116 
     | 
    
         
            +
                  day = time.strftime("%d")
         
     | 
| 
      
 117 
     | 
    
         
            +
                  day = day.sub(/^0/, ' ') if day =~ /^0\d/
         
     | 
| 
      
 118 
     | 
    
         
            +
                  time.strftime("%b #{day} %H:%M:%S")
         
     | 
| 
      
 119 
     | 
    
         
            +
                end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                if "".respond_to?(:bytesize)
         
     | 
| 
      
 122 
     | 
    
         
            +
                  def string_bytesize(string)
         
     | 
| 
      
 123 
     | 
    
         
            +
                    string.bytesize
         
     | 
| 
      
 124 
     | 
    
         
            +
                  end
         
     | 
| 
      
 125 
     | 
    
         
            +
                else
         
     | 
| 
      
 126 
     | 
    
         
            +
                  def string_bytesize(string)
         
     | 
| 
      
 127 
     | 
    
         
            +
                    string.length
         
     | 
| 
      
 128 
     | 
    
         
            +
                  end
         
     | 
| 
      
 129 
     | 
    
         
            +
                end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                SEVERITIES.each do |k,v|
         
     | 
| 
      
 132 
     | 
    
         
            +
                  define_method("#{k}?") { SEVERITIES[k] == @severity }
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
              end
         
     | 
| 
      
 135 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,57 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'time'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module SyslogProtocol
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              def self.parse(msg, origin=nil)
         
     | 
| 
      
 6 
     | 
    
         
            +
                packet = Packet.new
         
     | 
| 
      
 7 
     | 
    
         
            +
                original_msg = msg.dup
         
     | 
| 
      
 8 
     | 
    
         
            +
                pri = parse_pri(msg)
         
     | 
| 
      
 9 
     | 
    
         
            +
                if pri and (pri = pri.to_i).is_a? Integer and (0..191).include?(pri)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  packet.pri = pri
         
     | 
| 
      
 11 
     | 
    
         
            +
                else
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # If there isn't a valid PRI, treat the entire message as content
         
     | 
| 
      
 13 
     | 
    
         
            +
                  packet.pri = 13
         
     | 
| 
      
 14 
     | 
    
         
            +
                  packet.time = Time.now
         
     | 
| 
      
 15 
     | 
    
         
            +
                  packet.hostname = origin || 'unknown'
         
     | 
| 
      
 16 
     | 
    
         
            +
                  packet.content = original_msg
         
     | 
| 
      
 17 
     | 
    
         
            +
                  return packet
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                time = parse_time(msg)
         
     | 
| 
      
 20 
     | 
    
         
            +
                if time
         
     | 
| 
      
 21 
     | 
    
         
            +
                  packet.time = Time.parse(time)
         
     | 
| 
      
 22 
     | 
    
         
            +
                else
         
     | 
| 
      
 23 
     | 
    
         
            +
                  packet.time = Time.now
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
                hostname = parse_hostname(msg)
         
     | 
| 
      
 26 
     | 
    
         
            +
                packet.hostname = hostname || origin
         
     | 
| 
      
 27 
     | 
    
         
            +
                if m = msg.match(/^(\w+)(: | )(.*)$/)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  packet.tag = m[1]
         
     | 
| 
      
 29 
     | 
    
         
            +
                  packet.content = m[3]
         
     | 
| 
      
 30 
     | 
    
         
            +
                else
         
     | 
| 
      
 31 
     | 
    
         
            +
                  packet.tag = 'unknown'
         
     | 
| 
      
 32 
     | 
    
         
            +
                  packet.content = msg
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
                packet
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
              
         
     | 
| 
      
 37 
     | 
    
         
            +
              private
         
     | 
| 
      
 38 
     | 
    
         
            +
              
         
     | 
| 
      
 39 
     | 
    
         
            +
              def self.parse_pri(msg)
         
     | 
| 
      
 40 
     | 
    
         
            +
                pri = msg.slice!(/<(\d\d?\d?)>/)
         
     | 
| 
      
 41 
     | 
    
         
            +
                pri = pri.slice(/\d\d?\d?/) if pri
         
     | 
| 
      
 42 
     | 
    
         
            +
                if !pri or (pri =~ /^0/ and pri !~ /^0$/)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  return nil
         
     | 
| 
      
 44 
     | 
    
         
            +
                else
         
     | 
| 
      
 45 
     | 
    
         
            +
                  return pri
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
              
         
     | 
| 
      
 49 
     | 
    
         
            +
              def self.parse_time(msg)
         
     | 
| 
      
 50 
     | 
    
         
            +
                msg.slice!(/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\s|[1-9])\d\s\d\d:\d\d:\d\d\s/)
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
              
         
     | 
| 
      
 53 
     | 
    
         
            +
              def self.parse_hostname(msg)
         
     | 
| 
      
 54 
     | 
    
         
            +
                msg.slice!(/^[\x21-\x7E]+\s/).rstrip
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
              
         
     | 
| 
      
 57 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,16 +1,17 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: fluent-plugin-papertrail
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.8
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jonathan Lozinski
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Alex Ouzounis
         
     | 
| 
       9 
9 
     | 
    
         
             
            - Chris Rust
         
     | 
| 
      
 10 
     | 
    
         
            +
            - Chris Erway
         
     | 
| 
       10 
11 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
12 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       12 
13 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2019- 
     | 
| 
      
 14 
     | 
    
         
            +
            date: 2019-09-23 00:00:00.000000000 Z
         
     | 
| 
       14 
15 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
16 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
17 
     | 
    
         
             
              name: fluentd
         
     | 
| 
         @@ -46,20 +47,6 @@ dependencies: 
     | 
|
| 
       46 
47 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       47 
48 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       48 
49 
     | 
    
         
             
                    version: 0.4.0
         
     | 
| 
       49 
     | 
    
         
            -
            - !ruby/object:Gem::Dependency
         
     | 
| 
       50 
     | 
    
         
            -
              name: syslog_protocol
         
     | 
| 
       51 
     | 
    
         
            -
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       52 
     | 
    
         
            -
                requirements:
         
     | 
| 
       53 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       54 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       55 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       56 
     | 
    
         
            -
              type: :runtime
         
     | 
| 
       57 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
       58 
     | 
    
         
            -
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       59 
     | 
    
         
            -
                requirements:
         
     | 
| 
       60 
     | 
    
         
            -
                - - ">="
         
     | 
| 
       61 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       62 
     | 
    
         
            -
                    version: '0'
         
     | 
| 
       63 
50 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       64 
51 
     | 
    
         
             
              name: bundler
         
     | 
| 
       65 
52 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -121,6 +108,7 @@ email: 
     | 
|
| 
       121 
108 
     | 
    
         
             
            - jonathan.lozinski@solarwinds.com
         
     | 
| 
       122 
109 
     | 
    
         
             
            - alex.ouzounis@solarwinds.com
         
     | 
| 
       123 
110 
     | 
    
         
             
            - chris.rust@solarwinds.com
         
     | 
| 
      
 111 
     | 
    
         
            +
            - chris.erway@solarwinds.com
         
     | 
| 
       124 
112 
     | 
    
         
             
            executables: []
         
     | 
| 
       125 
113 
     | 
    
         
             
            extensions: []
         
     | 
| 
       126 
114 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
         @@ -134,6 +122,11 @@ files: 
     | 
|
| 
       134 
122 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       135 
123 
     | 
    
         
             
            - fluent-plugin-papertrail.gemspec
         
     | 
| 
       136 
124 
     | 
    
         
             
            - lib/fluent/plugin/out_papertrail.rb
         
     | 
| 
      
 125 
     | 
    
         
            +
            - lib/syslog_protocol.rb
         
     | 
| 
      
 126 
     | 
    
         
            +
            - lib/syslog_protocol/common.rb
         
     | 
| 
      
 127 
     | 
    
         
            +
            - lib/syslog_protocol/logger.rb
         
     | 
| 
      
 128 
     | 
    
         
            +
            - lib/syslog_protocol/packet.rb
         
     | 
| 
      
 129 
     | 
    
         
            +
            - lib/syslog_protocol/parser.rb
         
     | 
| 
       137 
130 
     | 
    
         
             
            homepage: https://github.com/solarwinds/fluent-plugin-papertrail
         
     | 
| 
       138 
131 
     | 
    
         
             
            licenses:
         
     | 
| 
       139 
132 
     | 
    
         
             
            - Apache-2.0
         
     | 
| 
         @@ -154,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       154 
147 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       155 
148 
     | 
    
         
             
            requirements: []
         
     | 
| 
       156 
149 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       157 
     | 
    
         
            -
            rubygems_version: 2.5.2. 
     | 
| 
      
 150 
     | 
    
         
            +
            rubygems_version: 2.5.2.3
         
     | 
| 
       158 
151 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       159 
152 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       160 
153 
     | 
    
         
             
            summary: Remote Syslog Output Fluentd plugin for papertrail
         
     |