Skip to main content

puppetlabs-pe_status_check fails with a Facter error in Puppet Enterprise

Did this solve your problem?
0 out of 1 found this helpful

How can we improve this article?

2 comments

  • Dinan Yin

    After upgrading the module to the latest 2.6.0, the error doesn't affect the entire custom fact, however I'm still getting it as a warning:

    Warning: Facter: Error in fact 'pe_status_check.S0039' when querying puppetserver access logs: invalid date or strptime format - `[08/Mar./2023:00:00:00 +1100]' `[%d/%b/%Y:%H:%M:%S %Z]'

    The issue seems to be `strptime` in the S0039 chunk:

      chunk(:S0039) do
        # PuppetServer
        next unless ['primary', 'legacy_primary', 'replica', 'pe_compiler', 'legacy_compiler'].include?(Facter.value('pe_status_check_role'))

        logfile = File.dirname(Puppet.settings['logdir'].to_s) + '/puppetserver/puppetserver-access.log'
        apache_regex = %r{^(\S+) \S+ (\S+) (?<time>\[([^\]]+)\]) "([A-Z]+) ([^ "]+)? HTTP/[0-9.]+" (?<status>[0-9]{3})}

        has_503 = File.foreach(logfile).any? do |line|
          match = line.match(apache_regex)
          next unless match && match[:time] && match[:status]

          time = Time.strptime(match[:time], '[%d/%b/%Y:%H:%M:%S %Z]')
          since_lastrun = Time.now - time
          current = since_lastrun.to_i <= Puppet.settings['runinterval']

          match[:status] == '503' and current
        rescue StandardError => e
          Facter.warn("Error in fact 'pe_status_check.S0039' when querying puppetserver access logs: #{e.message}")
          Facter.debug(e.backtrace)
          break
        end

        { S0039: !has_503 }
      end

    0
  • DeLeon DeMicoli

    Hi Dinan,

    I see you submitted a ticket with support. A support engineer will get back to you soon.

    Thanks!

    0

Please sign in to leave a comment.