-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
…grations-core into lewis/improve_postfix_check pull in changes from master
There was a problem hiding this 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 :)
postfix/CHANGELOG.md
Outdated
@@ -5,6 +5,14 @@ | |||
|
|||
### Changes | |||
|
|||
* [IMPROVEMENT] option to run the check using postqueue -p |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 👍
There was a problem hiding this 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 😊
add a sample postqueue -p output to code.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"monitored"
Dont forget we need to update the README to discuss this as well under the Configuration section. |
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
|
There was a problem hiding this 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.
Autodetect agent_major_version from agent_version
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
manifest.json
CHANGELOG.md
Additional Notes
The caveat is that postqueue will gather message counts for only the hold, active, and deferred queues.