Building of a Icinga2 Agent installation on AWS AMI 2017.03 is not possible

This forum was archived to /woltlab and is now in read-only mode.
  • Dear community,


    we've an Icinga2 server with Icinga2 Director running on CentOS and we'll monitor several dynamic Linux hosts with Amazon Linux (AMI 2017.03). Unfortunately no ready to use rpm package is currently available for Amazon Linux. Therefore we compiled Icinga2 from source with 'cmake' what's going on without problems (but take a long time to compile).


    To speed up the installation process we tried to create an Icinga2 rpm-file to roll out with each new AWS AMI client together with the agent file generated from Icinga2 Director. We installed all necessary packages like e.g. boost-devel and followed the official documentation on 'https://github.com/Icinga/icinga2/blob/master/INSTALL.md'. In addition we grab the latest version of the Icinga2 spec-file and added the following lines:

    Code
    1. -DICINGA2_WITH_MYSQL=OFF
    2. -DICINGA2_WITH_PGSQL=OFF
    3. -DINSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT=ON

    I'd like to point out that 'devtools-2' is not available for AMI Linux too. But the installed 'boost-devel' package on the machine is identically with the version Icinga2 reccommended (1.53).


    The compile process finished without problems to us but the make process ends with the following error:

    Code
    1. /usr/bin/ld: cannot find -lexecinfo

    Unfortunately Google doesnt know a lot about this error. Therefore I've following questions to the community:

    1. How can I create a working rpm package from source on Amazon Linux (AMI 2017.03) ?
    2. Is there a more simple way to install an Icinga2 Agent on Linux (without bells and whistles like IDO, database, Vim, Nano) ?

    Attached you'll find the error and output log of 'cmake'.


    Thanks in advance for any help,


    Ray

    Files

    The post was edited 1 time, last by ts2010 ().

  • you could try to simply remove the lexecinfo from the make file, but I do not know what would happen.


    On the other hand, try looking for libexecinfo.so, this is the lib it tries to use when that error occures.

    Linux is dead, long live Linux


    Remember to NEVER EVER use git repositories in a productive environment if you CAN NOT control them

  • I don't have any knowledge about Amazon Linux, but isn't that sort of based on RHEL7? That would allow to rebuild the source RPM for el7 over there.

  • First of all thank you for your replies.


    Regarding Kevins note I looked for the lexecinfo in the make files but found nothing. Also the libexecinfo.so file was not detected on the system and I cant found any package to install it on Amazon Linux.


    In reference to dnsmichi's statement: Amazon Linux is a strange mix of RHEL6 and Fedora. That lead me to the idea to build the rpm on a Fedora-25 system and move it afterwards to my Amazon Linux 2017.03 machine. I compiled it on Feodora with the vendor RedHat-Parameter as followed:

    Code
    1. rpmbuild -bb --define="_vendor redhat" SPECS/icinga2.spec

    The make process exit with a similar error:

    Code
    1. /usr/bin/ld: cannot find -lpthreads

    and the same output on screen as on Centos:

    What I'm doing wrong? Could it be that there is bug in version 2.6.3 or in the icinga2.spec file ?


    I attached the Fedora error and output file to this message.


    Best, Ray

  • you are doing nothing wrong, this is most likely due to some packages not available.

    everytime it say that it can not find something, that means you are missing some packages that are required

    Linux is dead, long live Linux


    Remember to NEVER EVER use git repositories in a productive environment if you CAN NOT control them

  • 1.) The RPM build errors for ido* originate from your CMake parameter change. You're just disabling those for make and make install, but later on you are still building the icinga2-ido-mysql and icinga2-ido-pgsql packages. That will fail, if you do not remove them.


    2.) double listed files shouldn't result in an error, that's normally a warning.


    3.) pthread error sounds strange, I suspect g++ isn't properly setup.



    I don't have any free AWS minutes left and am not in the mood to spin something up, but there's Vagrant box which seems similar: https://atlas.hashicorp.com/mvbcoding/boxes/awslinux/


    For testing your issue, I've just added it here: https://github.com/Icinga/icinga-vagrant/pull/72


    Note: The box requires at least 4 GB RAM otherwise compiling fails with OOM.


    I found some slight problems with the classicui-config package when building, but I'll kick that away soon.


    There is a bug in the spec file which enables systemd on amzn (and there isn't any). That can be fixed with a simple diff, the rest is more or less "the same".



    I'd also opt for building mysql/postgresql since you just need to pull in the headers, and it doesn't hurt - by using the same spec file as upstream, this is the desired solution.


    Code
    1. yum -y install libedit-devel ncurses-devel gcc-c++ libstdc++-devel openssl-devel \
    2. cmake flex bison boost-devel mysql-devel postgresql-devel httpd \
    3. selinux-policy-devel checkpolicy selinux-policy selinux-policy-doc


    solves the build requirements issue.


    Code
    1. Erstellt: /root/rpmbuild/SRPMS/icinga2-2.6.3-1.amzn1.src.rpm
    2. Erstellt: /root/rpmbuild/RPMS/x86_64/icinga2-2.6.3-1.amzn1.x86_64.rpm
    3. Erstellt: /root/rpmbuild/RPMS/x86_64/icinga2-bin-2.6.3-1.amzn1.x86_64.rpm
    4. Erstellt: /root/rpmbuild/RPMS/x86_64/icinga2-common-2.6.3-1.amzn1.x86_64.rpm
    5. Erstellt: /root/rpmbuild/RPMS/x86_64/icinga2-doc-2.6.3-1.amzn1.x86_64.rpm
    6. Erstellt: /root/rpmbuild/RPMS/x86_64/icinga2-libs-2.6.3-1.amzn1.x86_64.rpm
    7. Erstellt: /root/rpmbuild/RPMS/x86_64/icinga2-ido-mysql-2.6.3-1.amzn1.x86_64.rpm
    8. Erstellt: /root/rpmbuild/RPMS/x86_64/icinga2-ido-pgsql-2.6.3-1.amzn1.x86_64.rpm
    9. Erstellt: /root/rpmbuild/RPMS/x86_64/vim-icinga2-2.6.3-1.amzn1.x86_64.rpm
    10. Erstellt: /root/rpmbuild/RPMS/x86_64/nano-icinga2-2.6.3-1.amzn1.x86_64.rpm


    I'll update INSTALL.md and the spec file for the required fixes.


    https://github.com/Icinga/icinga2/pull/5303

    https://github.com/Icinga/icinga2/pull/5304


    If you're using the patched spec file and install the dependencies, your package should just build fine. Feedback much appreciated inside the linked PRs :)

  • Dear dnsmichi,


    first of all I will thank you for the lot of changes you've prepared regarding this issue.


    I followed up your suggestions but I'll get still the same error on the AMI 2017.03 and the rpm's are not created (see details in the attached logfile).

    Code
    1. /usr/bin/ld: cannot find -lexecinfo

    To understand what I've done on my machine here my steps:


    1. Preparation of my build environment (I build the rpm with the Amazon Linux default user 'ec2-user' due to the recommendation to build not with 'root')

    Code
    1. sudo yum install rpmdevtools boost-devel flex cmake bison gcc-c++ nagios-plugins-all openssl-devel \
    2. perl-Nagios-Plugin libedit-devel ncurses-devel postgresql-devel mysql-devel \
    3. libstdc++-devel selinux-policy-devel checkpolicy selinux-policy selinux-policy-do
    4. sudo yum groupinstall Development
    5. mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
    6. echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

    2. I copied the latest spec file from the repo and grab the source.

    Code
    1. curl https://raw.githubusercontent.com/Icinga/icinga2/master/icinga2.spec -o $HOME/rpmbuild/SPECS/icinga2.spec
    2. cd $HOME/rpmbuild/SOURCES
    3. spectool -g ../SPECS/icinga2.spec

    3. I modified the spec-file as mentioned by you. In addition I wraped all the conditions for the depricated gui you recommended here https://github.com/Icinga/icinga2/pull/5303. In addition I added the following cmake parameter to the spec-file:

    Code
    1. ..
    2. -DICINGA2_WITH_MYSQL=OFF \
    3. -DICINGA2_WITH_PGSQL=OFF \
    4. -DINSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT=ON \
    5. ..

    Btw: I found a typo here https://github.com/Icinga/icinga2/pull/5304/files in line 184.

    4. Then I start the build process.

    Code
    1. cd $HOME/rpmbuild/
    2. rpmbuild -ba SPECS/icinga2.spec


    It seems that we're a glimpse away from the rpm's but what the h**l is execinfo. If I search the ldconfig library the .so is not installed. It seems that Amazon Linux or EPEL doesn't supply this lib.

    Code
    1. ldconfig --print-cache | grep execinfo

    Any further ideas?


    Best , Ray

  • Don't edit the spec file, just use the one from git master. I've rebased and merged all PRs. spectool will automatically download the source binary, as you already do.


    Also just install the headers for mysql and postgresql and let them pull the dependencies. I won't go into details building the rpm without - you can still just ignore the built rpm packages.


    I've asked gunnarbeutner about execinfo - that's only detected on BSD like systems, and should not be included/linked on RHEL based OS'es.


    The strange part here is - it just works in my AMI Vagrant box. I'm only pulling "rpmdevtools" and in addition the icinga2 package requirements.

    See the details here: https://github.com/Icinga/icin…LL.md#build-icinga-2-rpms


    I also build as root, even if guides suggest otherwise.


    sudo yum groupinstall Development - that might pull in additional packages. Are you using any specific extra repositories which could override existing packages?


    Can you show the specific tool versions involved here?


    Code
    1. g++ -v
    2. cmake --version
  • OK, I'll follow strict your guide soon. Here my versions of c++ and cmake:

  • OK, now it works.


    There were three mandatory steps for me to get it compiled on Amazon Linux AMI 2017.03:

    • You must be 'root'. Otherwise the compile process ends with '/usr/bin/ld: cannot find -lexecinfo'
    • Don't make any changes on CMAKE_OPTS parameters. Leave it as it is.
    • In my case 'yum install postgresql-devel' installed version 9.2 instead of the latest 9.5. Therefore better install 'yum install postgresql95-devel'.

    Finally here are my steps to complete:


    dnsmichi, thank you for your awesome help. If it would be helpful for you, I can support you with the created Amazon Linux AMI 2017.03 rpm's to promote these on the Icinga website. Please let me know.


    Best, Ray

    The post was edited 1 time, last by ts2010 ().

  • Really glad it works out for you :-)


    I'll poke lazyfrosch about the RPM packages, if we can make them available somehow, thanks for the kind offer :)


    For now, everyone can just build them on their own looking in here or the INSTALL.md file. That was my main concern - make it work for everyone and have it documented. Even if that feels like sort of a workaround ;)

  • Aaaah. Now I understand, thanks again.


    https://github.com/Icinga/icinga2/pull/5317


    Btw - you can also edit that file directly on GitHub, and send in the changes as new PR. Directly in the browser, that's what I just did :)

  • Hi,


    on my AWS AIM Linux Host i followed the steps mentionend up.

    But i get the following error:



    Here you find the steps that i made:

  • looks like it expects a changelog but there is none, to ignoe the error, just create an empty file called CHANGELOG.md

    Linux is dead, long live Linux


    Remember to NEVER EVER use git repositories in a productive environment if you CAN NOT control them

  • Hi all,


    I have also followed the steps mentioned above (used by ghovat) on my AWS Linux Host.

    I solved the error from ghovat by:

    • renaming CHANGELOG.md with ChangeLog in the file icinga2.spec.
    • Copying the missing file check_nscp_api.cpp from the official repo inhttps://github.com/Icinga/icinga2/blob/master/plugins/check_nscp_api.cpp and renamed in check_nscp_api.


    After these changes, rpmbuild does not return any errors. However, icinga2 is not present in /etc/init.d/ and running service icinga2 start

    still returns icinga2: unrecognized service. So it seems not to be installed at all.


    Any tips?

  • Looks like the systemd service is not installed. There should be a "icinga2" named file in /etc/systemd/system and "systemctl list-units --type=service | grep icinga" should return a service.


    If the file is missing, there should be a template in the repo. If the service is missing, a quick "systemctl enable icinga2" should solve it.