Skip to content

Commit

Permalink
adding host-metrics RPM
Browse files Browse the repository at this point in the history
  • Loading branch information
arlake228 committed Oct 24, 2023
1 parent 92987d5 commit c4605e4
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 12 deletions.
3 changes: 3 additions & 0 deletions perfsonar-host-metrics/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AUTO_TARBALL := 1

include unibuild/unibuild.make
11 changes: 0 additions & 11 deletions perfsonar-host-metrics/exporter_opts.sh

This file was deleted.

Empty file.
18 changes: 18 additions & 0 deletions perfsonar-host-metrics/perfsonar-host-metrics/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Makefile for perfSONAR Host Metrics
#
default:
@true

install:
ifndef PERFSONAR-ROOTPATH
@echo No PERFSONAR-ROOTPATH specified for installation
@false
endif
ifndef HTTPD-CONFIGPATH
@echo No HTTPD-CONFIGPATH specified for installation
@false
endif
mkdir -p ${PERFSONAR-ROOTPATH}
mkdir -p ${HTTPD-CONFIGPATH}
install -m 755 exporter_opts.sh ${PERFSONAR-ROOTPATH}/
install -m 644 apache-node_exporter.conf ${HTTPD-CONFIGPATH}/
12 changes: 12 additions & 0 deletions perfsonar-host-metrics/perfsonar-host-metrics/exporter_opts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

TARGET_FILE="/etc/default/node_exporter"
EDIT_MARKER='#Edited by PS_HOST_METRICS'
NODE_EXPORTER_OPTS='PS_NODE_EXPORTER_OPTS=""'
grep -q PS_HOST_METRICS ${TARGET_FILE}
if [ $? -eq 1 ]; then
TEMPFILE=$(mktemp)
echo ${EDIT_MARKER} | cat - ${TARGET_FILE} > ${TEMPFILE}
sed -E 's/^NODE_EXPORTER_OPTS="(.*)"/NODE_EXPORTER_OPTS="\1 --collector.systemd --collector.systemd.unit-include=^(elmond|grafana-server|httpd|logstash|node_exporter|opensearch-dashboards|opensearch|owamp|(perfsonar-.+)|postgresql|(pscheduler-.+)|(psconfig-.+))\.service"/' -i ${TEMPFILE}
mv ${TEMPFILE} ${TARGET_FILE}
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
%define install_base /usr/lib/perfsonar
%define pkg_install_base %{install_base}/host_metrics
%define httpd_config_base /etc/httpd/conf.d

#Version variables set by automated scripts
%define perfsonar_auto_version 5.0.5
%define perfsonar_auto_relnum 1

# defining macros needed by SELinux
# SELinux policy type - Targeted policy is the default SELinux policy used in Red Hat Enterprise Linux.
%global selinuxtype targeted
# default boolean value needs to be changed to enable http proxy
%global selinuxbooleans httpd_can_network_connect=1

Name: perfsonar-host-metrics
Version: %{perfsonar_auto_version}
Release: %{perfsonar_auto_relnum}%{?dist}
Summary: perfSONAR Host Metrics
License: ASL 2.0
Group: Development/Libraries
URL: http://www.perfsonar.net
Source0: perfsonar-host-metrics-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
Requires: perfsonar-common
Requires: openssl
Requires: prometheus-node-exporter
Requires: httpd
Requires: mod_ssl
Requires: selinux-policy-%{selinuxtype}
Requires(post): selinux-policy-%{selinuxtype}
BuildRequires: selinux-policy-devel
%{?selinux_requires}

%description
A package that installs sets-up Prometheus node_exporter for a perfSONAR install

%prep
%setup -q -n perfsonar-host-metrics-%{version}

%build

%install
make PERFSONAR-ROOTPATH=%{buildroot}/%{pkg_install_base} HTTPD-CONFIGPATH=%{buildroot}/%{httpd_config_base} install

%clean
rm -rf %{buildroot}

%post
#Restart/enable opensearch and logstash
%systemd_post node_exporter.service
if [ "$1" = "1" ]; then
#set SELinux booleans to allow httpd proxy to work
%selinux_set_booleans -s %{selinuxtype} %{selinuxbooleans}
#update node_exporter to monitor pS processes
%{pkg_install_base}/exporter_opts.sh

######
#if new install, then enable
systemctl daemon-reload
systemctl enable node_exporter.service
systemctl restart node_exporter.service
#Enable and restart apache for reverse proxy
systemctl enable httpd
systemctl restart httpd
fi

%preun
%systemd_preun node_exporter.service

%postun
%systemd_postun_with_restart node_exporter.service
if [ $1 -eq 0 ]; then
%selinux_unset_booleans -s %{selinuxtype} %{selinuxbooleans}
fi

%files
%defattr(0644,perfsonar,perfsonar,0755)
%license LICENSE
%attr(0755, perfsonar, perfsonar) %{pkg_install_base}/exporter_opts.sh
%attr(0644, perfsonar, perfsonar) %{httpd_config_base}/apache-node_exporter.conf

%changelog
* Tue Oct 24 2023 [email protected] 5.0.5-0.0.a1
- Initial package
3 changes: 2 additions & 1 deletion unibuild-order
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ changecom()dnl
# See the documentation at https://github.com/perfsonar/unibuild for
# more information.
#
prometheus-node-exporter
prometheus-node-exporter
perfsonar-host-metrics

0 comments on commit c4605e4

Please sign in to comment.