thomas-krenn / check_ipmi_sensor_v3

Monitoring plugin to check IPMI sensors
https://www.thomas-krenn.com/en/wiki/IPMI_Sensor_Monitoring_Plugin
GNU General Public License v3.0
54 stars 21 forks source link

problem creating rpm under redhat 6 #24

Closed tlo8640 closed 5 years ago

tlo8640 commented 6 years ago

Hello,

I tried to create rpms from this project for rhel 6 and 7. It worked for rhel7, but it failed for rhel 6, because of a strange problem of automatic dependency resolution for perl modules in the rpm build process. This feature (automatic dependency resolution) tries to create a dependency list of perl modules for the package for installing them when you will install the built rpm package on a system. I don't know how exactly this feature works, but somehow it scans the code for the "use" keyword and takes the word after use as a needed module name and add this to the dependency list. If you grep your script for "use" at the beginning of a line you will find some lines:

egrep '^[[:blank:]]*use' check_ipmi_sensor
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use IPC::Run qw( run ); #interact with processes
         username monitoring
       use a sel exclude file to exclude entries from the system event log.
       use an exclude file to exclude sensors.
use of this software. The mailing list is available at

the created rpm cannot be installed on rhel 6:

...
Error: Package: check_ipmi_sensor-3.12-3.el6.noarch 
           Requires: perl(a)
Error: Package: check_ipmi_sensor-3.12-3.el6.noarch 
           Requires: perl(an)
...

Perhaps it's a problem of the rpm macros for redhat 6 only, because it works with redhat 7. Disabling automatic dependency resolution solves this proble. But If you want this, you have to move the "use" away from the beginning of the line or replace it with another word (e.g. "take"). But only where it is not the part of the perl code! :-)

Regards Thomas

P.S. Thank you for this script, it helps us a lot!

tlo8640 commented 6 years ago

the following line in spec file fixed the wrong requirements for me:

%if 0%{?el6}
%filter_from_requires /perl(a[n]*)/d
%filter_setup
%endif
gschoenberger commented 6 years ago

So finally you could build the RPM package?

tlo8640 commented 6 years ago

Hello,

yes, at least it worked fine for rhel6, too. So, it's not a bug in your code, more an info for other people who need/want to built rpms from your code. Thanks and regards Thomas

gschoenberger commented 6 years ago

Can you post the full spec file? Maybe we should add it to the master branch as additional info, THX

tlo8640 commented 6 years ago

Hello, here it comes (i removed the changelog, there are only my entries where I tried getting the spec file running) I've built with tito (https://github.com/dgoodwin/tito). It helped me, keeping the files in git and creating tgz, srpm and rpm) there is an additional sudo entriy needed, I post it under the Spec file, because the script needs root rights for calling ipmi-sel. You should take a look at "License", "Packager", "Vendor" that it fits your needs. The other entries could need a closer look, too. :-) I'm not a hero of rpm packaging, but mostly my packages are working. This one is only tested on Redhat EL 6(64 Bit) and 7

Name:           check_ipmi_sensor
Version:        3.12
Release:        6%{dist}
Summary:        ipmi sensors icinga check plugin
Packager:       Thomas Loescher, <thomas.loescher@swisscom.com>
Vendor:         Thomas-Krenn AG

Group:          Application/System
License:        GPLv3
Source0:        %{name}-%{version}.tar.gz
BuildArch:      noarch

Requires:       perl-IPC-Run
Requires:       perl-IO-Tty
Requires:       freeipmi

%if 0%{?el6}
%filter_from_requires /perl(a[n]*)/d
%filter_setup
%endif

%description
check_plugin for hardware monitoring using the ipmi interface

%prep
%setup -q

%build

%install
%{__install} -D check_ipmi_sensor $RPM_BUILD_ROOT%{_libdir}/nagios/plugins/check_ipmi_sensor
%{__install} -D sudo_icinga_ipmi $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d/icinga_ipmi
%{__install} -D changelog.txt $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}/changelog.txt
%{__install} -D COPYING $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}/COPYING
%{__install} -d contrib $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}/contrib
%{__install} -D contrib/default-combinedgraph.template $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}/contrib/default-combinedgraph.template

%files
%defattr(0664,root,root) 
%attr(0755,root,root) %{_libdir}/nagios/plugins/check_ipmi_sensor
%attr(0660,root,root) %config(noreplace) %{_sysconfdir}/sudoers.d/icinga_ipmi
%{_defaultdocdir}/%{name}/changelog.txt
%{_defaultdocdir}/%{name}/COPYING
%{_defaultdocdir}/%{name}/contrib/default-combinedgraph.template

%changelog
* Fri Oct 12 2018 Thomas Loescher <thomas.loescher@swisscom.com> 3.12-6
- remove AutoReq, use %filter_from_requires for rhel6 perl dependencies
  (thomas.loescher@swisscom.com)

here comes the sudoers include, If someone thinks about using this script with nrpe, additional lines with User nrpe or nagios (depends what user is running nrpe) should added. currently this file is located in the root of the git repo.

# icinga is allowed to run check_ipmi_sensor
icinga       ALL=NOPASSWD:     /usr/sbin/ipmi-sel *,/usr/sbin/ipmi-sensors *

Hope it helps Regards Thomas

tniedermeier commented 5 years ago

Thank you @tlo8640 also from my side for providing the spec file, I added it with commit a00ce9ee0e5813879335b807b21ae6c81de581c7.

Best regards Thomas