Summary: Nagios Statistics - Cacti scripts and templates
Name: cacti-template-%{template}
Version: 0.1
-Release: 0.5
+Release: 0.6
License: GPL v2
Group: Applications/WWW
Source0: http://forums.cacti.net/download/file.php?id=18185#/nacti.tar.gz
# Source0-md5: 758d07f15a58c845169b3359bce837c5
Source1: cacti_host_template_nagios_statistics.xml
+Source2: check_nagios.sh
Patch0: pld.patch
URL: http://forums.cacti.net/about33806.html
BuildRequires: rpmbuild(macros) >= 1.554
%setup -qc
%patch0 -p1
cp -a %{SOURCE1} .
+cp -a %{SOURCE2} .
+%{__sed} -i -e 's,check_nagios.pl,check_nagios.sh,' *
%install
rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT{%{resourcedir},%{scriptsdir},%{nagioscgidir}}
-install -p check_nagios.pl $RPM_BUILD_ROOT%{scriptsdir}
+install -p check_nagios.sh $RPM_BUILD_ROOT%{scriptsdir}
install -p mrtgstats.cgi $RPM_BUILD_ROOT%{nagioscgidir}
cp -a *.xml $RPM_BUILD_ROOT%{resourcedir}
%files
%defattr(644,root,root,755)
%doc README
-%attr(755,root,root) %{scriptsdir}/check_nagios.pl
+%attr(755,root,root) %{scriptsdir}/check_nagios.sh
%{resourcedir}/*.xml
# nagios-cacti-nagiostats
--- /dev/null
+#!/bin/sh
+# vim:ft=sh
+# enable for debugging:
+set -x
+exec 2>>/tmp/nagios-cacti.log
+#exec 1>&2
+
+url="$1"
+type="$2"
+user="$3"
+password="$4"
+
+# Remove trailing slash if needed
+url="${url%/}"
+
+# pass user and password conditionally.
+# this way we can even have passwords in them.
+# retry only once with timeout of 30s
+wget -t 1 -T 30 --no-check-certificate -q -O- ${user:+--user="$user" --password="$password"} "$url/mrtgstats.cgi?type=$type"
+echo $? >&2