Sha256: dbf1ef592504b5cbbf2d707b5446533287b58c7f7cb3ac328cb8c34db234db9f

Contents?: true

Size: 932 Bytes

Versions: 10

Compression:

Stored size: 932 Bytes

Contents

module MCollective
  module RPC
    # An audit plugin that just logs to a file
    #
    # You can configure which file it logs to with the setting
    #
    #   plugin.rpcaudit.logfile

    class Logfile<Audit
      require 'pp'

      def audit_request(request, connection)
        logfile = Config.instance.pluginconf["rpcaudit.logfile"] || "/var/log/puppetlabs/mcollective/mcollective-audit.log"

        now = Time.now
        # Already told timezone to be in UTC so we don't look it up again
        # This avoids platform specific timezone representation issues
        now_iso8601 = now.utc.strftime("%Y-%m-%d %H:%M:%S UTC")

        File.open(logfile, "a") do |f|
          f.puts("[#{now_iso8601}] reqid=#{request.uniqid}: reqtime=#{request.time} caller=#{request.caller}@#{request.sender} agent=#{request.agent} action=#{request.action} data=#{request.data.pretty_print_inspect}")
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mcollective-client-2.12.5 lib/mcollective/audit/logfile.rb
mcollective-client-2.12.4 lib/mcollective/audit/logfile.rb
mcollective-client-2.12.3 lib/mcollective/audit/logfile.rb
mcollective-client-2.12.1 lib/mcollective/audit/logfile.rb
mcollective-client-2.12.0 lib/mcollective/audit/logfile.rb
mcollective-client-2.11.4 lib/mcollective/audit/logfile.rb
mcollective-client-2.11.3 lib/mcollective/audit/logfile.rb
mcollective-client-2.11.2 lib/mcollective/audit/logfile.rb
mcollective-client-2.11.1 lib/mcollective/audit/logfile.rb
mcollective-client-2.11.0 lib/mcollective/audit/logfile.rb