Sha256: be3a5923073917b73db3dda6a71c6d938fce6cdc71d0efdf251d41d0b2f4ea72

Contents?: true

Size: 974 Bytes

Versions: 6

Compression:

Stored size: 974 Bytes

Contents

#!/usr/bin/env ruby

require 'syslogstash'
require 'yaml'

if ARGV.length != 1
	$stderr.puts <<-EOF.gsub(/^\t\t/, '')
		Invalid usage

		Usage:
		  #{$0} <configfile>
	EOF

	exit 1
end

unless File.exist?(ARGV[0])
	$stderr.puts "Config file #{ARGV[0]} does not exist"
	exit 1
end

unless File.readable?(ARGV[0])
	$stderr.puts "Config file #{ARGV[0]} not readable"
	exit 1
end

cfg = YAML.load_file(ARGV[0])

unless cfg.is_a? Hash
	$stderr.puts "Config file #{ARGV[0]} does not contain a YAML hash"
	exit 1
end

%w{sockets servers}.each do |section|
	unless cfg.has_key?(section)
		$stderr.puts "Config file #{ARGV[0]} does not have a '#{section}' section"
		exit 1
	end

	unless cfg[section].respond_to?(:empty?)
		$stderr.puts "Config file #{ARGV[0]} has a malformed '#{section}' section"
		exit 1
	end

	if cfg[section].empty?
		$stderr.puts "Config file #{ARGV[0]} has an empty '#{section}' section"
		exit 1
	end
end

Syslogstash.new(cfg['sockets'], cfg['servers']).run

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
syslogstash-0.1.5 bin/syslogstash
syslogstash-0.1.4 bin/syslogstash
syslogstash-0.1.3 bin/syslogstash
syslogstash-0.1.2 bin/syslogstash
syslogstash-0.1.1 bin/syslogstash
syslogstash-0.1.0 bin/syslogstash