Skip to content

Instantly share code, notes, and snippets.

@kennonkwok
Created November 5, 2015 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennonkwok/92e3da9aec1c43a35d6f to your computer and use it in GitHub Desktop.
Save kennonkwok/92e3da9aec1c43a35d6f to your computer and use it in GitHub Desktop.
sumologic_source.rb
require 'json'
resource_name :sumologic_source
# properties/defaults from: https://service.sumologic.com/help/Using_JSON_to_configure_Sources.htm
property :name, String, name_property: true
property :description, String, default: nil
property :category, String, default: nil
property :hostName, String, default: nil
property :timeZone, String, default: nil
# sourceType can be
# "LocalFile", "RemoteFile?", "LocalWindowsEventLog",
# "RemoteWindowsEventLog", "Syslog?", "Script?"
property :sourceType, String, required: true
property :automaticDateParsing, [TrueClass, FalseClass], default: true
property :multilineProcessingEnabled, [TrueClass, FalseClass], default: true
property :useAutolineMatching, [TrueClass, FalseClass], default: true
property :manualPrefixRegexp, String
property :forceTimeZone, [TrueClass, FalseClass]
property :defaultDateFormat, String, default: false
property :filters, Array, default: []
# Local File Source properties
property :pathExpression, String
property :blacklist, Array, default: []
property :encoding, String, default: 'UTF-8'
# Remote File Source properties
property :remoteHosts, Array
property :remotePort, Fixnum
property :remoteUser, String
property :remotePassword, String
property :keyPath, String
property :keyPassword, String, default: nil
property :pathExpression, String
property :authMethod, String
property :blacklist, Array, default: []
# Remote Windows Event Log Source
property :domain, String
property :username, String
property :password, String
property :hosts, Array
property :logNames, Array
# Syslog Source properties
property :protocol, String, default: 'UDP'
property :port, Fixnum
# Script Source properties
property :commands, Array, default: []
# property :file, String, default: nil
property :workingDir, String, default: nil
property :timeout, Fixnum, default: 0
property :script, String, default: nil
property :cronExpression, String
action :create do
source = {
'api.version' => 'v1',
'source' => {
'name' => name,
'sourceType' => sourceType,
'category' => category,
'pathExpression' => pathExpression
}
}
file "/etc/sumo.d/#{name}.json" do
content JSON.pretty_generate(source)
action :create
end
end
action :delete do
file "/etc/sumo.d/#{name}.json" do
action :delete
end
end
@tekbuddha
Copy link

For Kevin: figure out how to populate the JSON hash for output to the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment