Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error checking in psql_metrics causes an error #77

Closed
Sharpie opened this issue Jan 21, 2021 · 0 comments
Closed

Error checking in psql_metrics causes an error #77

Sharpie opened this issue Jan 21, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@Sharpie
Copy link
Member

Sharpie commented Jan 21, 2021

Describe the Bug

A bug in the error checking of the psql_metrics script causes it to exit with an error:

# /opt/puppetlabs/puppet-metrics-collector/scripts/psql_metrics --output_dir /opt/puppetlabs/puppet-metrics-collector/postgres
ERROR NoMethodError: undefined method `[]' for nil:NilClass

Data is still written, but the logging to STDERR and non-zero exit code cause some mail spam from the cron daemon.

Expected Behavior

Script runs without error on a fresh PE install.

Steps to Reproduce

  • Classify a PE Primary Server with the puppet_metrics_collector::system class
  • Run puppet agent -t
  • Execute:
/opt/puppetlabs/puppet-metrics-collector/scripts/psql_metrics --output_dir /opt/puppetlabs/puppet-metrics-collector/postgres

Environment

  • puppet_metrics_collector 6.2.0
  • PE 2019.8.4
  • CentOS 7

Additional Context

This issue fell out of some last minute changes around munging . character to - characters in hostnames (for consistency with other metrics datasets). The error checking logic uses the hostname to look up results for a node to see if any errors were recorded:

https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/blob/6.2.0/files/psql_metrics#L576

This lookup needs to use hostname.gsub('.', '-').

@Sharpie Sharpie added the bug Something isn't working label Jan 21, 2021
Sharpie added a commit to Sharpie/puppetlabs-puppet_metrics_collector that referenced this issue Jan 21, 2021
This commit updates the psql_metrics collection script to fix an
issue with error checking. Previously, the script sanitized the
hostname that output data was stored under by replacing "." characters
with "-" characters. But, the error checking routine attempted to
look up data using the un-sanitized hostname. This caused error
checking to always register a failure even when data collection
was successful, which resulted in email spam from cron.

Ref. puppetlabs#71
Fixes puppetlabs#77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant