Class: NSCA::Packet

Inherits:
Object
  • Object
show all
Defined in:
lib/nsca/packet.rb

Direct Known Subclasses

PacketV3

Defined Under Namespace

Classes: CSC32CheckFailed, VersionCheckFailed

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timestamp, return_code, hostname, service, status) ⇒ Packet

Returns a new instance of Packet.

Parameters:

  • timestamp (Time, Integer, nil)

    Checked at this time

  • return_code (0..3)

    ‘NSCA::ReturnCode`

  • String(length<64),nil] (String(length<64),nil] hostname If nil, local hostname will be used. Must be known by Nagios.)

    hostname If nil, local hostname will be used. Must be known by Nagios.

  • String(length<128)] (String(length<128)] service Name of Service. Must be known by Nagios.)

    service Name of Service. Must be known by Nagios.

  • String(length<512)] (String(length<512)] status Status-line inclusive optional Performance Data.)

    status Status-line inclusive optional Performance Data.



21
22
23
24
# File 'lib/nsca/packet.rb', line 21

def initialize timestamp, return_code, hostname, service, status
  @timestamp, @return_code, @hostname, @service, @status =
    Time.at( timestamp.to_f), return_code, hostname, service, status
end

Instance Attribute Details

#hostnameObject

Returns the value of attribute hostname.



26
27
28
# File 'lib/nsca/packet.rb', line 26

def hostname
  @hostname
end

#return_codeObject

Returns the value of attribute return_code.



26
27
28
# File 'lib/nsca/packet.rb', line 26

def return_code
  @return_code
end

#serviceObject

Returns the value of attribute service.



26
27
28
# File 'lib/nsca/packet.rb', line 26

def service
  @service
end

#statusObject

Returns the value of attribute status.



26
27
28
# File 'lib/nsca/packet.rb', line 26

def status
  @status
end

#timestampObject

Returns the value of attribute timestamp.



26
27
28
# File 'lib/nsca/packet.rb', line 26

def timestamp
  @timestamp
end

Class Method Details

.register_version(version, klass) ⇒ Object



13
# File 'lib/nsca/packet.rb', line 13

def self.register_version( version, klass) versions[version] = klass end

.versions(version = nil) ⇒ Object



8
9
10
11
# File 'lib/nsca/packet.rb', line 8

def self.versions version = nil
  @@versions ||= {}
  version ? @@versions[version] : @@versions
end