Sophie

Sophie

distrib > Mageia > 3 > i586 > media > core-release-src > by-pkgid > 14c6c19009a762ac5c5e629205d7faa3 > files > 2

nagios-check_temperature-1.1-8.mga3.src.rpm

%define _enable_debug_packages	%{nil}
%define debug_package		%{nil}

Summary:	A Nagios wrapper script around digitemp
Name:		nagios-check_temperature
Version:	1.1
Release:	%mkrel 8
License:	BSD-like
Group:		Networking/Other
URL:		http://www.hoppie.nl/tempsens/
Source0:	http://www.hoppie.nl/tempsens/check_temperature
Requires:	digitemp
Requires:	nagios-plugins
BuildArch:  noarch
BuildRoot:	%{_tmppath}/%{name}-%{version}

%description
check_temperature: Nagios wrapper script around digitemp. Used to monitor a
couple of 1-wire temperature sensors and to raise an alarm when one of them
reports a temperature outside a predefined band.

%prep
%setup -q -T -c

%build

%install
rm -rf %{buildroot}

install -d -m 755 %{buildroot}%{_bindir}
cat > %{buildroot}%{_bindir}/get_temperature << 'EOF'
#!/bin/bash
#
# get_temperature: polls the temperature sensor array and leaves the
# temperatures in a state file. Called by cron every 5 minutes.

TMPFILE="/tmp/temperature.XXXXXX"
STATEFILE="%{_localstatedir}/lib/temperature/current"
DIGITEMP="%{_bindir}/digitemp"
DIGICONF="%{_sysconfdir}/digitemp.conf"

# error check #1
if ! [ -f \$DIGITEMP ]; then
    echo "\$DIGITEMP does not exist."
    echo "please do \"ln -snf %{_bindir}/digitemp_DS9097 %{_bindir}/digitemp\""
    exit 1
fi

# error check #2
if ! [ -f \$DIGICONF ]; then
    echo "\$DIGICONF does not exist."
    echo "please do \"%{_bindir}/digitemp -i -c \$DIGICONF -s /dev/ttyS0\""
    exit 1
fi

# Abort after first script error.
set -e

# Get a unique temporary tamper-proof file name.
tmp=\$(mktemp \$TMPFILE)

# Create a full poll list of the temperature array. This takes up to
# 5 seconds per sensor, and therefore must be done to a (slowly growing)
# temporary file.
\$DIGITEMP -c \$DIGICONF -a -q > \$tmp
chmod 644 \$tmp

# 'Atomically' move the freshly created state file in place.
mv \$tmp \$STATEFILE
EOF
chmod +x %{buildroot}%{_bindir}/get_temperature

install -d -m 755 %{buildroot}%{_datadir}/nagios/plugins
install -m 755 %{SOURCE0} %{buildroot}%{_datadir}/nagios/plugins

install -d -m 755 %{buildroot}%{_sysconfdir}/nagios/plugins.d
cat > %{buildroot}%{_sysconfdir}/nagios/plugins.d/check_temperature.cfg <<'EOF'
define command {
        command_name	check_temperature
        command_line	%{_datadir}/nagios/plugins/check_temperature -s $ARG1$ -t $ARG2$ -w $ARG3$ -c $ARG4$
}
EOF

install -d -m 755 %{buildroot}%{_sysconfdir}/cron.d
cat > %{buildroot}%{_sysconfdir}/cron.d/%{name} <<'EOF'
# Poll the temperature sensor array every five minutes.
*/5 * * * * root %{_bindir}/get_temperature

# Append the last poll to the history file after each whole hour.
4 * * * * root cat %{_localstatedir}/lib/temperature/current >> /var/log/temperature.log
EOF

install -d -m 755 %{buildroot}%{_sysconfdir}/logrotate.d
cat > %{buildroot}%{_sysconfdir}/logrotate.d/%{name} <<'EOF'
/var/log/temperature.log {
    missingok
    monthly
    compress
}
EOF

install -d -m 755 %{buildroot}%{_localstatedir}/lib/temperature

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/nagios/plugins.d/check_temperature.cfg
%config(noreplace) %{_sysconfdir}/cron.d/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_datadir}/nagios/plugins/check_temperature
%{_bindir}/get_temperature
%{_localstatedir}/lib/temperature




%changelog

* Sat Jan 12 2013 umeabot <umeabot> 1.1-8.mga3
+ Revision: 360736
- Mass Rebuild - https://wiki.mageia.org/en/Feature:Mageia3MassRebuild

* Thu Mar 03 2011 ennael <ennael> 1.1-7.mga1
+ Revision: 63070
- clean spec file
- imported package nagios-check_temperature