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.



46
47
48
49
# File 'lib/nsca/packet.rb', line 46

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.



51
52
53
# File 'lib/nsca/packet.rb', line 51

def hostname
  @hostname
end

#return_codeObject

Returns the value of attribute return_code.



51
52
53
# File 'lib/nsca/packet.rb', line 51

def return_code
  @return_code
end

#serviceObject

Returns the value of attribute service.



51
52
53
# File 'lib/nsca/packet.rb', line 51

def service
  @service
end

#statusObject

Returns the value of attribute status.



51
52
53
# File 'lib/nsca/packet.rb', line 51

def status
  @status
end

#timestampObject

Returns the value of attribute timestamp.



51
52
53
# File 'lib/nsca/packet.rb', line 51

def timestamp
  @timestamp
end

Class Method Details

.register_version(version, klass) ⇒ Object



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

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

.versions(version = nil) ⇒ Object



33
34
35
36
# File 'lib/nsca/packet.rb', line 33

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