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

Lewis/improve postfix check #665

Merged
merged 13 commits into from
Oct 4, 2017
Merged

Lewis/improve postfix check #665

merged 13 commits into from
Oct 4, 2017

Conversation

ls339
Copy link
Contributor

@ls339 ls339 commented Aug 8, 2017

What does this PR do?

Will add an option to run the check using postqueue -p to gather message counts for hold, active, and deferred mail queues.

Motivation

The postqueue binary is ran with set-group ID privileges, so that it can connect to Postfix daemon processes without the use of sudo.

Testing Guidelines

Tested on a postfix 2.11.1.

Versioning

  • [] Bumped the version check in manifest.json
  • Updated CHANGELOG.md

Additional Notes

The caveat is that postqueue will gather message counts for only the hold, active, and deferred queues.

@bits-bot
Copy link
Collaborator

bits-bot commented Aug 8, 2017

@ls339, thanks for your PR! By analyzing the history of the files in this pull request, we identified @masci, @gmmeyer and @truthbk to be potential reviewers.

Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ls339 looks pretty good, and dropping the sudo dependency would be sweet. You might need to add some more instructions though :)

@@ -5,6 +5,14 @@

### Changes

* [IMPROVEMENT] option to run the check using postqueue -p
Copy link
Member

@truthbk truthbk Aug 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If 1.1.0 is unreleased, then I guess this should all be below? Looks like we have two 1.1.0 entries in the changelog.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Gotcha, moved my change under 1.1.0

postfix/check.py Outdated
@@ -24,15 +24,24 @@ class PostfixCheck(AgentCheck):
YAML config options:
"directory" - the value of 'postconf -h queue_directory'
"queues" - the postfix mail queues you would like to get message count totals for

Optionally we can run the check to use `postqueue -p` which is ran with set-group ID privileges,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we grab all metrics doing this? Do you have a link to the doc detailing this behavior? It would be nice to have here + understand what our continued dependency on sudo may be.

Also, please note that on a production server, it's unlikely that postqueue would have access to all queues by all users. Configuration would typically be set in the configuration files:

Postfix doesn't use unix permission feature to limit access to postqueue. 
Instead it uses parameters like ' authorized_mailq_users' in its configuration files.

We'd have to explain how to do this in our docs/config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some documentation in the code. Will also add this to the config.

postfix/check.py Outdated
hold_count = 0
deferred_count = 0

for line in output.splitlines():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a small comment here showing some sample output from postqueue -p

postfix/check.py Outdated
if line[0:1].isdigit():
deferred_count += 1
self.log.debug('Postfix Version: %s' % postfix_version)
self.log.debug('active_count: %d' % active_count)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need to log active_count, hold_count and deferred_count to be honest - we can see those values on the UI. Postfix version is 👍

Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually approved accidentally 😊

@truthbk truthbk added this to the 5.17 milestone Aug 11, 2017
@irabinovitch
Copy link
Contributor

irabinovitch commented Aug 16, 2017

This seems like a more sane default than find. Thoughts on making it the normal behavior rather than an opt in? I understand we lose incoming here, but that seems like a reasonable trade off for sudo privs.

postfix/check.py Outdated
Optionally we can run the check to use "postqueue -p" which is ran with set-group ID privileges
so that the agent user can connect to Postfix daemon processes without sudo.

Monitoring the mail queue using "postqueu" will only monitor the following queues.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing an e here? "postqueue"

postfix/check.py Outdated
- hold
- active
- deferred
Unlike using the "sudo" method, the "incoming" queue will not be moitored. Postqueue does
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"monitored"

@irabinovitch
Copy link
Contributor

Dont forget we need to update the README to discuss this as well under the Configuration section.

@ls339
Copy link
Contributor Author

ls339 commented Aug 17, 2017

We can also add a service check in the future to check if the active queue has hit its limit. I believe its at this limit that we can tell if the incoming queue is backed up or will start to be.

http://www.postfix.org/QSHAPE_README.html#incoming_queue

The queue manager scans the incoming queue bringing any new mail into the "active" queue if the
active queue resource limits have not been exceeded. By default, the active queue accommodates
at most 20000 messages. Once the active queue message limit is reached, the queue manager
stops scanning the incoming (and deferred, see below) queue.

@olivielpeau olivielpeau modified the milestones: 5.18, 5.17 Aug 22, 2017
Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, also backward compatible which was my main concern. As much as the new option is saner, we probably should stick to respecting the current behavior. We can revisit how many people are using postfix.queue.size in monitors and dashboards before making a decision to make it the default behavior.

@truthbk truthbk merged commit 9b41d24 into master Oct 4, 2017
@ls339 ls339 deleted the lewis/improve_postfix_check branch October 25, 2017 03:02
gml3ff pushed a commit that referenced this pull request May 14, 2020
Autodetect agent_major_version from agent_version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants