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

POC: remote data collection over existing postgres connection #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

a1exsh
Copy link
Member

@a1exsh a1exsh commented Mar 15, 2017

  • Can collect Host information: uptime, hostname, loadavg, etc.

  • Can collect System information: cpu utilization, context switches, etc.

  • Can collect Memory information.

  • Requires stored procs in plpythonu to be installed on the server. Could
    install automatically on startup assuming enough permissions.

  • Partition and Postgres collectors are really tricky, but should be doable.

* Can collect Host information: uptime, hostname, loadavg, etc.
* Can collect System information: cpu utilization, context switches, etc.
* Can collect Memory information.

* Requires stored procs in plpythonu to be installed on the server.  Could
  install automatically on startup assuming enough permissions.

* Partition and Postgres collectors are really tricky, but should be doable.
Copy link
Contributor

@alexeyklyukin alexeyklyukin left a comment

Choose a reason for hiding this comment

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

Looks like a viable approach to me. The problem is that creating a sproc in an untrusted language requires superuser privileges. One can solve it by running with --install option first, followed by the normal call.

As for the disk statistics, we can simply call the df and du less often.

collectors.append(HostStatCollector())
collectors.append(SystemStatCollector())
collectors.append(MemoryStatCollector())
use_local_data = not(options.host) or options.host.startswith('/')
Copy link
Contributor

Choose a reason for hiding this comment

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

host name can be also read from the configuration file

part = groups[name].get('partitions')
if part:
pg = groups[name]['pg']
part.ncurses_set_prefix(pg.ncurses_produce_prefix())
Copy link
Contributor

Choose a reason for hiding this comment

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

This will not show useful information about the cluster (i.e. version, max connections, active and idle ones). I think we need to do pg.ncurses_set_prefix(pg.ncurses_produce_prefix()), attaching it to the header of pg collector.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a temp hack to avoid it crashing because partition collector doesn't have a remote data source yet.

import socket
from multiprocessing import cpu_count
try:
with open('/proc/uptime', 'rU') as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a nitpick, we should not use hard-coded names when generating sprocs text.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was just copy-paste from my psql prompt, so I don't lose the func definition ;-)

@a1exsh
Copy link
Member Author

a1exsh commented Mar 22, 2017

@alexeyklyukin I also think we need a separate call to install the funcs (with security definer option). Then we could grant some role like pgview permission to execute them, and then finally grant pgview to anyone we trust to run it remotely.

As for du/df: running less often makes a lot of sense, since these readings are not expected to change very quickly. Every 3-5 ticks should be reasonable. Can we then get rid of subprocesses/queues altogether?

@alexeyklyukin
Copy link
Contributor

I'd probably supply a SQL file along the way and instruct users to install it with their tools of choice.
Actually, for du/df there is another issue: it take a lot of time to return the data, so one of the "ticks" would be slower than the others. Therefore, I'd like to keep the existing multi-threaded functionality at least locally.

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.

2 participants