-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter Sandin
committed
Jan 7, 2014
1 parent
9e49d1a
commit 6ac630c
Showing
18 changed files
with
986 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,70 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
|
||
SUCCESS="\E[32;40mSuccess\E[0m" | ||
FAILED="\E[31;40mFailed\E[0m" | ||
### BEGIN INIT INFO | ||
# Provides: longview | ||
# Required-Start: $network $local_fs | ||
# Required-Stop: $network $local_fs | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: Longview Monitoring Agent | ||
### END INIT INFO | ||
|
||
LV="/opt/linode/longview/Linode/Longview.pl" | ||
set -e | ||
|
||
umask 022 | ||
|
||
DAEMON="/opt/linode/longview/Linode/Longview.pl" | ||
PID="/var/run/longview.pid" | ||
. /lib/lsb/init-functions | ||
|
||
case "$1" in | ||
start) | ||
echo -n $"Starting longview: " | ||
$LV | ||
RET=$? | ||
[ $RET -eq 0 ] && echo -e $SUCCESS || echo -e $FAILED | ||
exit $RET | ||
;; | ||
log_daemon_msg "Starting Longview Agent" "longview" | ||
if start-stop-daemon --start -p $PID --startas $DAEMON 2>/dev/null; then | ||
log_end_msg 0 | ||
else | ||
log_end_msg 1 | ||
fi | ||
;; | ||
debug) | ||
echo -n $"Starting longview (With Debug Flag): " | ||
$LV Debug | ||
RET=$? | ||
[ $RET -eq 0 ] && echo -e $SUCCESS || echo -e $FAILED | ||
exit $RET | ||
;; | ||
log_daemon_msg "Starting Longview Agent (With Debug Flag)" "longview" | ||
if start-stop-daemon --start -p $PID --startas $DAEMON Debug 2>/dev/null; then | ||
log_end_msg 0 | ||
else | ||
log_end_msg 1 | ||
fi | ||
;; | ||
stop) | ||
echo -n $"Stopping longview: " | ||
kill `cat /var/run/longview.pid` 2>/dev/null | ||
RET=$? | ||
[ $RET -eq 0 ] && echo -e $SUCCESS || echo -e $FAILED | ||
exit $RET | ||
;; | ||
log_daemon_msg "Stopping Longview Agent" "longview" | ||
if start-stop-daemon --stop --quiet -p $PID 2>/dev/null; then | ||
log_end_msg 0 | ||
else | ||
log_end_msg 1 | ||
fi | ||
;; | ||
restart) | ||
$0 stop | ||
$0 start | ||
;; | ||
log_daemon_msg "Restarting Longview Agent" "longview" | ||
start-stop-daemon --stop --quiet --oknodo --retry 30 -p /var/run/longview.pid | ||
if start-stop-daemon --start -p $PID --startas $DAEMON 2>/dev/null; then | ||
log_end_msg 0 | ||
else | ||
log_end_msg 1 | ||
fi | ||
;; | ||
reload|force-reload) | ||
log_daemon_msg "Restarting Longview Agent" "longview" | ||
if start-stop-daemon --stop --quiet --oknodo --signal HUP -p /var/run/longview.pid; then | ||
log_end_msg 0 | ||
else | ||
log_end_msg 1 | ||
fi | ||
;; | ||
status) | ||
[ ! -e /var/run/longview.pid ] && echo "No longview pid file: status unknown" && exit 1 | ||
PID=`cat /var/run/longview.pid` | ||
grep "linode-longview" "/proc/$PID/cmdline" 2>/dev/null | ||
RET=$? | ||
[ $RET -eq 0 ] && echo "Longview is running" || echo "Longview is not running" | ||
exit $RET | ||
;; | ||
status_of_proc -p $PID $DAEMON longview && exit 0 || exit $? | ||
;; | ||
*) | ||
echo $"Usage: $0 {start|stop|restart|status}" | ||
;; | ||
esac | ||
log_action_msg "Usage: /etc/init.d/longview {start|stop|restart|force-reload|reload|status}" | ||
exit 1 | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
#chkconfig: 2345 50 10 | ||
#description: Longview statistics gathering | ||
#processname: linode-longview | ||
|
||
LVDAEMON="/opt/linode/longview/Linode/Longview.pl" | ||
|
||
. /etc/rc.d/init.d/functions | ||
|
||
case "$1" in | ||
start) | ||
echo -n "Starting longview: " | ||
$LVDAEMON | ||
RET=$? | ||
[ $RET -eq 0 ] && success || failure | ||
echo | ||
exit $RET | ||
;; | ||
debug) | ||
echo -n "Starting longview (With Debug Flag): " | ||
$LVDAEMON Debug | ||
RET=$? | ||
[ $RET -eq 0 ] && success || failure | ||
echo | ||
exit $RET | ||
;; | ||
stop) | ||
echo -n "Stopping longview: " | ||
kill `cat /var/run/longview.pid` 2>/dev/null | ||
RET=$? | ||
[ $RET -eq 0 ] && success || failure | ||
[ $RET -eq 0 ] && rm /var/run/longview.pid | ||
echo | ||
exit $RET | ||
;; | ||
restart) | ||
$0 stop | ||
$0 start | ||
;; | ||
status) | ||
status -p /var/run/longview.pid longview | ||
;; | ||
*) | ||
echo $"Usage: $0 {start|stop|restart|status}" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
SUCCESS="\E[32;40mSuccess\E[0m" | ||
FAILED="\E[31;40mFailed\E[0m" | ||
|
||
LV="/opt/linode/longview/Linode/Longview.pl" | ||
|
||
case "$1" in | ||
start) | ||
echo -n $"Starting longview: " | ||
$LV | ||
RET=$? | ||
[ $RET -eq 0 ] && echo -e $SUCCESS || echo -e $FAILED | ||
exit $RET | ||
;; | ||
debug) | ||
echo -n $"Starting longview (With Debug Flag): " | ||
$LV Debug | ||
RET=$? | ||
[ $RET -eq 0 ] && echo -e $SUCCESS || echo -e $FAILED | ||
exit $RET | ||
;; | ||
stop) | ||
echo -n $"Stopping longview: " | ||
kill `cat /var/run/longview.pid` 2>/dev/null | ||
RET=$? | ||
[ $RET -eq 0 ] && echo -e $SUCCESS || echo -e $FAILED | ||
exit $RET | ||
;; | ||
restart) | ||
$0 stop | ||
$0 start | ||
;; | ||
status) | ||
[ ! -e /var/run/longview.pid ] && echo "No longview pid file: status unknown" && exit 1 | ||
PID=`cat /var/run/longview.pid` | ||
grep "linode-longview" "/proc/$PID/cmdline" 2>/dev/null | ||
RET=$? | ||
[ $RET -eq 0 ] && echo "Longview is running" || echo "Longview is not running" | ||
exit $RET | ||
;; | ||
*) | ||
echo $"Usage: $0 {start|stop|restart|status}" | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
Name: linode-longview | ||
Version: 1.1 | ||
Release: 3 | ||
Summary: Linode Longview Agent | ||
License: GPLv2+ | ||
BuildArch: noarch | ||
|
||
Requires: perl(Crypt::SSLeay),perl(DBD::mysql) | ||
Obsoletes: longview | ||
|
||
%description | ||
The Linode Longview data collection agent | ||
|
||
%prep | ||
http_fetch() { | ||
mkdir -p `dirname $2` | ||
if command -v wget >/dev/null 2>&1; then | ||
wget -q -4 -O $2 $1 || { | ||
echo >&2 "Failed to fetch $1. Aborting install."; | ||
exit 1; | ||
} | ||
elif command -v curl >/dev/null 2>&1; then | ||
curl -sf4L $1 > $2 || { | ||
echo >&2 "Failed to fetch $1. Aborting install."; | ||
exit 1; | ||
} | ||
else | ||
echo "Unable to find curl or wget, can not fetch needed files" | ||
exit 1 | ||
fi | ||
} | ||
[ -e $OLDPWD/Extras/lib/perl5/Linux/Distribution.pm ] || http_fetch http://cpansearch.perl.org/src/CHORNY/Linux-Distribution-0.21/lib/Linux/Distribution.pm $OLDPWD/Extras/lib/perl5/Linux/Distribution.pm | ||
[ -e $OLDPWD/Extras/lib/perl5/Try/Tiny.pm ] || http_fetch http://cpansearch.perl.org/src/DOY/Try-Tiny-0.18/lib/Try/Tiny.pm $OLDPWD/Extras/lib/perl5/Try/Tiny.pm | ||
|
||
%install | ||
rm -rf %{buildroot} | ||
mkdir -p %{buildroot}/opt/linode/longview/lib/perl5/ | ||
mkdir -p %{buildroot}/opt/linode/longview/Linode/Longview/DataGetter/Packages/ | ||
mkdir -p %{buildroot}/opt/linode/longview/Extras/ | ||
mkdir -p %{buildroot}/etc/init.d/ | ||
mkdir -p %{buildroot}/etc/linode/longview.d | ||
cp $OLDPWD/Extras/init/longview.centos.sh %{buildroot}/etc/init.d/longview | ||
cp -r $OLDPWD/Extras/lib/perl5/* %{buildroot}/opt/linode/longview/lib/perl5/ | ||
cp -r $OLDPWD/Linode %{buildroot}/opt/linode/longview/ | ||
cp $OLDPWD/Extras/Modules/Packages/YUM.pm %{buildroot}/opt/linode/longview/Linode/Longview/DataGetter/Packages/YUM.pm | ||
cp $OLDPWD/Extras/app-report.pl %{buildroot}/opt/linode/longview/Extras/app-report.pl | ||
cp $OLDPWD/Extras/conf/* %{buildroot}/etc/linode/longview.d/ | ||
|
||
%files | ||
/etc/init.d/longview | ||
/opt/linode/longview/lib/perl5/Linux/Distribution.pm | ||
/opt/linode/longview/lib/perl5/Try/Tiny.pm | ||
/opt/linode/longview/Linode/Longview.pl | ||
/opt/linode/longview/Linode/Longview/*.pm | ||
/opt/linode/longview/Linode/Longview/DataGetter/*.pm | ||
/opt/linode/longview/Linode/Longview/DataGetter/Applications/*.pm | ||
/opt/linode/longview/Linode/Longview/DataGetter/Packages/YUM.pm | ||
%config %attr(640,root,root) /etc/linode/longview.d/*.conf | ||
/opt/linode/longview/Extras/app-report.pl | ||
|
||
%post | ||
if [ $1 -eq 1 ] ; then | ||
# Initial installation | ||
service longview start || : | ||
chkconfig --add longview | ||
chkconfig --level 35 longview on | ||
fi | ||
chmod -R o-rwx /etc/linode/longview.d/ | ||
|
||
%preun | ||
if [ $1 -eq 0 ] ; then | ||
# Package removal, not upgrade | ||
service longview stop || : | ||
chkconfig --del longview | ||
fi | ||
|
||
%postun | ||
/bin/systemctl daemon-reload >/dev/null 2>&1 || : | ||
if [ $1 -ge 1 ] ; then | ||
# Package upgrade, not uninstall | ||
service longview restart || : | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
Name: linode-longview | ||
Version: 1.1 | ||
Release: 3 | ||
Summary: Linode Longview Agent | ||
License: GPLv2+ | ||
BuildArch: noarch | ||
Source: https://github.com/linode/longview/archive/v%{version}.%{release}.tar.gz | ||
|
||
Requires: perl-LWP-Protocol-https,perl-DBD-MySQL | ||
|
||
BuildRequires: systemd-units | ||
Requires(post): systemd-units | ||
Requires(preun): systemd-units | ||
Requires(postun): systemd-units | ||
|
||
%description | ||
The Linode Longview data collection agent | ||
|
||
%prep | ||
http_fetch() { | ||
mkdir -p `dirname $2` | ||
if command -v wget >/dev/null 2>&1; then | ||
wget -q -4 -O $2 $1 || { | ||
echo >&2 "Failed to fetch $1. Aborting install."; | ||
exit 1; | ||
} | ||
elif command -v curl >/dev/null 2>&1; then | ||
curl -sf4L $1 > $2 || { | ||
echo >&2 "Failed to fetch $1. Aborting install."; | ||
exit 1; | ||
} | ||
else | ||
echo "Unable to find curl or wget, can not fetch needed files" | ||
exit 1 | ||
fi | ||
} | ||
[ -e $OLDPWD/Extras/lib/perl5/Linux/Distribution.pm ] || http_fetch http://cpansearch.perl.org/src/CHORNY/Linux-Distribution-0.21/lib/Linux/Distribution.pm $OLDPWD/Extras/lib/perl5/Linux/Distribution.pm | ||
[ -e $OLDPWD/Extras/lib/perl5/Try/Tiny.pm ] || http_fetch http://cpansearch.perl.org/src/DOY/Try-Tiny-0.18/lib/Try/Tiny.pm $OLDPWD/Extras/lib/perl5/Try/Tiny.pm | ||
|
||
|
||
%install | ||
echo $OLDPWD | ||
rm -rf %{buildroot} | ||
mkdir -p %{buildroot}/opt/linode/longview/lib/perl5/ | ||
mkdir -p %{buildroot}%{_unitdir} | ||
mkdir -p %{buildroot}/etc/linode/longview.d | ||
mkdir -p %{buildroot}/opt/linode/longview/Linode/Longview/DataGetter/Packages | ||
mkdir -p %{buildroot}/opt/linode/longview/Extras/ | ||
cp $OLDPWD/Extras/init/longview.service %{buildroot}%{_unitdir}/longview.service | ||
cp -r $OLDPWD/Extras/lib/perl5/* %{buildroot}/opt/linode/longview/lib/perl5/ | ||
cp -r $OLDPWD/Linode %{buildroot}/opt/linode/longview/ | ||
cp $OLDPWD/Extras/app-report.pl %{buildroot}/opt/linode/longview/Extras/app-report.pl | ||
cp $OLDPWD/Extras/Modules/Packages/YUM.pm %{buildroot}/opt/linode/longview/Linode/Longview/DataGetter/Packages/YUM.pm | ||
cp $OLDPWD/Extras/conf/* %{buildroot}/etc/linode/longview.d/ | ||
|
||
%files | ||
%{_unitdir}/longview.service | ||
/opt/linode/longview/lib/perl5/Linux/Distribution.pm | ||
/opt/linode/longview/lib/perl5/Try/Tiny.pm | ||
/opt/linode/longview/Linode/Longview.pl | ||
/opt/linode/longview/Linode/Longview/*.pm | ||
/opt/linode/longview/Linode/Longview/DataGetter/*.pm | ||
/opt/linode/longview/Linode/Longview/DataGetter/Applications/*.pm | ||
/opt/linode/longview/Linode/Longview/DataGetter/Packages/YUM.pm | ||
%config %attr(640,root,root) /etc/linode/longview.d/*.conf | ||
/opt/linode/longview/Extras/app-report.pl | ||
|
||
%post | ||
if [ $1 -eq 1 ] ; then | ||
# Initial installation | ||
/bin/systemctl daemon-reload >/dev/null 2>&1 || : | ||
/bin/systemctl enable longview.service >/dev/null 2>&1 || : | ||
fi | ||
|
||
%preun | ||
if [ $1 -eq 0 ] ; then | ||
# Package removal, not upgrade | ||
/bin/systemctl --no-reload disable longview.service > /dev/null 2>&1 || : | ||
/bin/systemctl stop longview.service > /dev/null 2>&1 || : | ||
fi | ||
|
||
%postun | ||
/bin/systemctl daemon-reload >/dev/null 2>&1 || : | ||
if [ $1 -ge 1 ] ; then | ||
# Package upgrade, not uninstall | ||
/bin/systemctl try-restart longview.service >/dev/null 2>&1 || : | ||
fi |
Oops, something went wrong.