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 installing sensu-plugins-postgres #1

Closed
luisdalves opened this issue Jul 24, 2015 · 56 comments
Closed

Error installing sensu-plugins-postgres #1

luisdalves opened this issue Jul 24, 2015 · 56 comments

Comments

@luisdalves
Copy link
Contributor

I'm getting the following error when I try to install sensu-plugins-postgres

root@somewhere:~# /opt/sensu/embedded/bin/gem install sensu-plugins-postgres
Building native extensions.  This could take a while...
ERROR:  Error installing sensu-plugins-postgres:
    ERROR: Failed to build gem native extension.

    /opt/sensu/embedded/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/opt/sensu/embedded/bin/ruby
    --with-pg
    --without-pg
    --enable-windows-cross
    --disable-windows-cross
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


Gem files will remain installed in /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/pg-0.18.2 for inspection.
Results logged to /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/pg-0.18.2/ext/gem_make.out
root@somewhere:~# /opt/sensu/embedded/bin/gem --version
2.0.14
root@somewhere:~# /opt/sensu/embedded/bin/ruby --version
ruby 2.0.0p645 (2015-04-13 revision 50299) [x86_64-linux]
root@somewhere:~# uname -a
Linux somewhere 3.13.0-52-generic #86-Ubuntu SMP Mon May 4 04:32:59 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
root@somewhere:~# dpkg -l | grep sensu
ii  sensu                                                       0.20.0-1                                            amd64        A monitoring framework that aims to be simple, malleable, and scalable.
root@so
@tas50
Copy link
Contributor

tas50 commented Jul 24, 2015

This is an omnibus issue that's discussed here in the context of chef. There's no fix at the moment though

sous-chefs/postgresql#212

@NeckBeardPrince
Copy link

So pretty much if you use the embedded ruby with Sensu this plugin will not work?

@tas50
Copy link
Contributor

tas50 commented Jul 30, 2015

At the moment yes

@NeckBeardPrince
Copy link

sigh and the issue is closed..

@mattyjones
Copy link
Member

I am actually going to leave it open for now as this question is asked quite frequently.

@mattyjones mattyjones added the Bug label Jul 30, 2015
@luisdalves
Copy link
Contributor Author

anybody know if is there any alternative to this gem or script to retrieve postgres metrics?

@cintiadr
Copy link

cintiadr commented Oct 2, 2015

I'm having the same issue. Apparently this is caused by this:
https://groups.google.com/forum/#!topic/ruby-pg/oCo8hDHR16A

Using Ubuntu 12.04, which provides only ruby 1.8.7 (the 1.9.3 sub-version unfortunately is not supported by puppet).
I think the only solution I could use now is install pg gem in system ruby (version 0.17.1) together with sensu-plugin gem, and make the checks use system ruby (full path).

It's a silly solution, but it appears to at least to be one possibility while I cannot upgrade ruby and get rid of embedded ruby.

@eheydrick
Copy link
Contributor

I was able to get the pg gem installed into the sensu embedded ruby install by adapting chrisroberts' ruby recipe from the postgresql cookbook. This workaround links the pg gem against the openssl included in the embedded sensu ruby rather than the system one. This is definitely not ideal but it does allow the use of the postgresql plugins.

https://gist.github.com/eheydrick/c16f85f7ab8a2a9d3c5d

@luisdalves
Copy link
Contributor Author

@eheydrick thanks, I will try it.

@eheydrick
Copy link
Contributor

Another approach is to build the postgresql client into the sensu embedded directory. This gets postgresql linked against sensu's openssl and avoids issues trying to use the system postgresql and openssl. This chef recipe will accomplish this: https://gist.github.com/eheydrick/f337643bdca1bb70c453

@delhora
Copy link

delhora commented May 11, 2016

Hello there

I've been googling arround trying to find a solution but I can't still install plugin.

Any hints?

As far I can see it's something about sensu openssl and system's one, but I can't find the key

Thanks!

EDIT: I "solved" using ruby from the system, not the most clean way, but well... Still appreciate if anyone had any hint :)

@cintiadr
Copy link

@delhora I did the same 'fix', used the system ruby for only this single sensu plugin.

@TJC
Copy link

TJC commented Jun 20, 2016

+1 for hitting this bug :(

@z-matth
Copy link
Contributor

z-matth commented Sep 17, 2016

+1

2 similar comments
@teadur
Copy link
Contributor

teadur commented Sep 20, 2016

+1

@Hypnocrit
Copy link

+1

@stefan-as
Copy link

Since nearly two years there is this bug that makes it impossible to install this sensu-plugin? C'mon, really?

@upadhyay-prashant
Copy link

+1

1 similar comment
@bjornkl
Copy link

bjornkl commented Mar 10, 2017

+1

@asifmuradkhan
Copy link

asifmuradkhan commented Mar 17, 2017

@eheydrick

I'm getting following error when I try to run metric-postgres-graphite.rb, but when I run check-postgres-replication.rb shows ok.

ubuntu@sensu:~$ /opt/sensu/embedded/bin/metric-postgres-graphite.rb -m pgmaster -s pgslave -d db01 -u user -p 123456
Check failed to run: fe_sendauth: no password supplied
, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/pg-0.18.3/lib/pg.rb:45:in `initialize'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/pg-0.18.3/lib/pg.rb:45:in `new'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/pg-0.18.3/lib/pg.rb:45:in `connect'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-postgres-1.0.1/bin/metric-postgres-graphite.rb:81:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:58:in `block in <class:CLI>'"]
ubuntu@sensu:~$ /opt/sensu/embedded/bin/check-postgres-replication.rb -m pgmaster -s pgslave -d db01 -u user -p 123456
CheckPostgresReplicationStatus OK: replication delayed by 0.0MB :: master:3/D1001410 slave:3/D1001410 m_segbytes:16777216

@teadur
Copy link
Contributor

teadur commented Mar 23, 2017

For people not using Chef, i made the @eheydrick 's second solution to simple commands:
https://gist.github.com/teadur/1b257022fd018888c5e9ed35d488df7f

@asifmuradkhan
Copy link

@teadur could you please check my issue, thanks.

@teadur
Copy link
Contributor

teadur commented Mar 27, 2017

@asifmuradkhan #28 this should fix it

@jothoma1
Copy link

Hi
Using Puppet i cannot install sensu-plugins-postgres ...
Same error
This bug is open since 2 years, is there a workaround to deploy this plugin with puppet ?
Thanks

@zakir-hyder
Copy link

@jothoma1 the fix is merged 028ccec.

@mikerev
Copy link

mikerev commented May 10, 2017

@eheydrick thanks for a reasonable solution for now.

@jothoma1
Copy link

@zakir-hyder I dont know why but i still can't install it ? same error.

@majormoses
Copy link
Member

@marcinhlybin
Copy link
Contributor

I added explanation why it happens to the README: https://github.com/sensu-plugins/sensu-plugins-postgres/blob/master/README.md#known-issues

Working solution is to install sensu-plugins-postgres gem system-wide outside embedded ruby.

@mrtrotl
Copy link

mrtrotl commented Aug 15, 2017

@majormoses Thanks, I have created an issue few minutes ago.

@Chrisbuuren
Copy link

@mrtrotl i am using embedeed, and with puppet automation, apparently when i installed psql i didn't installed psql-devel...

@mrtrotl
Copy link

mrtrotl commented Aug 15, 2017

@Chrisbuuren It' is interesting. I don't have much experiences with EPEL distros. In debian based distros is problem with incompatibility of sensu openssl and system libpg. Is there any possibility, that sensu is using same openssl as the CentOS/RHEL?

@Chrisbuuren
Copy link

OpenSSL 1.0.1e-fips this is what i use in Centos7...i don't know what debian machines use..or i don't understand the question

@mrtrotl
Copy link

mrtrotl commented Aug 15, 2017

The question was about openssl library in sensu and in CentOS, if that libraries are same (version, compile options). I have no other explanation of why it works in centos with system libpg and does not work in debian based distros.

@mikerev
Copy link

mikerev commented Aug 16, 2017

So is the official hack for this to patch embedded sensu or install against a system gem? Surprisingly I'm finding it more hackish to integrate the system-wide installed plugins with our existing Chef deployed sensu framework that leverages the Sensu cookbook in creating config files, etc. Maybe I misinterpreted the README? I've spent a lot of time getting these plugins to just work and I'm not sure which is the least intrusive/less hackish approach.

@mrtrotl
Copy link

mrtrotl commented Aug 16, 2017

@mikerev It is debian package, which integrates libpg into embedded sensu environment. This package make installation of pg gem to embedded ruby possible.

@mikerev
Copy link

mikerev commented Aug 16, 2017

@mrtrotl Understood, thank you for your contribution. The question I'm raising is that patching embedded is not what is recommended according to the README. It would be good to clear up confusion as to what the best approach is to get around this long-standing issue. I understand the purpose of the .deb (it just wraps what I have already codified in Chef) but it doesn't seem like there's any consensus between the maintainer(s) and people who are watching this thread/issue. Would just like some clarity on this before I commit to using these plugins in production and tying it into my framework.

@majormoses
Copy link
Member

@mikerev yup, that was prior to someone dedicating the time to have a better solution. Now we have one and we should update it. I have transferred over the repo and will update the documentation that for debian based systems the new prefered method is to use the deb, for epel based systems until someone dedicates the time to make an rpm the old method works. I will probably get to that this weekend.

@mikerev
Copy link

mikerev commented Aug 18, 2017

@majormoses sounds good, thanks.

@mikerev
Copy link

mikerev commented Aug 18, 2017

@majormoses @mrtrotl it looks like this will not work for people using the apt repo on Ubuntu 14.04 due to the minimum version requirement for sensu.

@mrtrotl
Copy link

mrtrotl commented Aug 18, 2017

@majormoses That's true, this package was compiled against sensu 1.0.2. It should be possible to build package against older version, but You need to change dependencies in control file. I will try to find a way how to define the dependencies dynamically.

@itdevon
Copy link

itdevon commented Feb 22, 2018

@majormoses looks like if you just install the postgresql96-devel rpm package like @Chrisbuuren mentioned, the gem install works fine. Not sure if this is a late reply :)

@majormoses
Copy link
Member

majormoses commented Feb 23, 2018

Never too late the removed labels was due to a label migration. That might work for epel but debian based installs still need the custom package mentioned from my understanding.

@jeremyj
Copy link

jeremyj commented Jun 22, 2018

the solution proposed by @ahes returns a buggy output:

"output": "Ignoring json-1.8.6 because its extensions are not built. Try: gem pristine json --version 1.8.6\nIgnoring json-1.8.6 because its extensions are not built. Try: gem pristine json --version 1.8.6\nIgnoring json-1.8.6 because its extensions are not built. Try: gem pristine json --version 1.8.6\nIgnoring json-1.8.6 because its extensions are not built. Try: gem pristine json --version 1.8.6\nCheckPostgres OK: Server version: {\"version\"=>\"PostgreSQL 9.5.12 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609, 64-bit\"}\n"

Any idea how to fix this?

@mikerev
Copy link

mikerev commented Jun 22, 2018

@jeremyj https://github.com/sensu-plugins/sensu-pg

@majormoses
Copy link
Member

@jeremyj that is not a bug but an env/deploy issue. There are potentially many reasons for that to happen and it is not specific to this gem if you want to hit me up in slack I am more than happy to help you clean that up. The slack link wont work forever (since we are an open source project and do not pay the blood money): https://sensucommunity.slack.com/archives/C68LV5M9U/p1529110949000014 but this was one example of a environment/deployment issue rather than an issue with the gem itself.

@phumpal
Copy link
Contributor

phumpal commented Sep 27, 2019

Support for ruby-2.0.0 was dropped in 90ac91c

ruby-2.0.0 has been EOL since 2016.02.24

@majormoses is this is a legacy issue? Any sense in keeping it open?

@majormoses
Copy link
Member

@phumpal ya all the way to 2.4 has been deprecated: https://www.ruby-lang.org/en/news/2019/03/31/support-of-ruby-2-3-has-ended/ I am not sure if this issue exists in ruby 2.4 or later, if it does not then lets close this out. We could probably update this to 2.4: https://github.com/sensu-plugins/sensu-plugins-postgres/blob/2.3.2/sensu-plugins-postgres.gemspec#L31

@majormoses
Copy link
Member

I am gonna close this issue out, we can re-open if this is still an issue on modern rubies and systems. I would appreciate a PR to add something to the wiki if needed rather than leaving this open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests