changeset 25:d058481276aa

replace logstash embedded web server with kibana
author Carl Byington <carl@five-ten-sg.com>
date Mon, 29 Apr 2013 13:38:05 -0700
parents 0f249d38da21
children 610835fb4209
files Kibana.rc Kibana.spec Makefile logstash.rc logstash.spec logstash.sysconfig
diffstat 6 files changed, 217 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Kibana.rc	Mon Apr 29 13:38:05 2013 -0700
@@ -0,0 +1,94 @@
+#!/bin/bash
+#
+#	/etc/rc.d/init.d/Kibana
+#
+#	Starts Kibana as a daemon
+#
+# chkconfig: 2345 20 80
+# description: Starts Kibana as a daemon
+# pidfile: /var/run/Kibana.pid
+
+### BEGIN INIT INFO
+# Provides: Kibana
+# Required-Start: $local_fs $remote_fs
+# Required-Stop: $local_fs $remote_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: S 0 1 6
+# Short-Description: Kibana
+# Description: Starts Kibana as a daemon.
+
+### END INIT INFO
+
+DESC="Kibana Daemon"
+JAVA=$(which java)
+if [ "$(which jruby 2>/dev/null)" == '' ]; then
+    JRUBY_CMD="$JAVA -jar /usr/share/jruby.jar"
+else
+    JRUBY_CMD="jruby"
+fi
+LOGFILE=/var/log/Kibana/Kibana.log
+PIDFILE=/var/run/Kibana.pid
+base=Kibana
+
+. /etc/init.d/functions
+
+#
+# Function that starts the daemon/service
+#
+do_start() {
+    cd /usr/share/java/Kibana
+    pid=$(
+    exec sudo -u kibana /bin/bash - <<EOF
+        export GEM_HOME=$(pwd)
+        export GEM_PATH=
+        $JRUBY_CMD kibana.rb >$LOGFILE 2>&1 &
+        echo \$!
+EOF
+    )
+    echo $pid >$PIDFILE
+    [ -n "$pid" ] && success $"$base startup" || failure $"$base startup"
+}
+
+
+#
+# Function that stops the daemon/service
+#
+do_stop() {
+    killproc -p $PIDFILE Kibana
+}
+
+
+case "$1" in
+  start)
+    echo -n "Starting $DESC: "
+    do_start
+    touch /var/lock/subsys/$base
+    ;;
+  stop)
+    echo -n "Stopping $DESC: "
+    do_stop
+    rm /var/lock/subsys/$base 2>/dev/null
+    rm $PIDFILE               2>/dev/null
+    ;;
+  restart)
+    echo -n "Restarting $DESC: "
+    do_stop
+    do_start
+    ;;
+  reload)
+    echo -n "Reloading $DESC: "
+    pid=$(cat $PIDFILE)
+    [ -n "$pid" ] && pkill -HUP -u Kibana -P $pid
+    ;;
+  status)
+    echo -n "$base "
+    status -p $PIDFILE
+    ;;
+  *)
+    echo "Usage: service $base {start|stop|status|restart}" >&2
+    exit 3
+    ;;
+esac
+
+echo
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Kibana.spec	Mon Apr 29 13:38:05 2013 -0700
@@ -0,0 +1,100 @@
+# prevent brp repack jar files
+%define __os_install_post %{nil}
+
+%global commit df8ae2344433e5072a8dfe77082acfd1c9b6ed62
+%global shortcommit %(c=%{commit}; echo ${c:0:8})
+%global name2 kibana
+
+Name:           Kibana
+Version:        0.2.0
+Release:        0%{?dist}
+Summary:        Kibana is a user friendly way to view, search and visualize your log data
+
+Group:          System Environment/Daemons
+License:        MIT
+URL:            http://kibana.org/
+BuildArch:      noarch
+#Source0:        https://codeload.github.com/rashidkpc/Kibana/tar.gz/v%{version} >%{name}-%{version}.tar.gz
+#Source0:        %{name}-%{version}.tar.gz
+Source0:        https://nodeload.github.com/rashidkpc/Kibana/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz
+Source10:       %{name}.rc
+BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+Autoreq:        0
+
+BuildRequires:  jruby java-devel
+
+Requires:       jruby java-devel elasticsearch logstash
+Requires(pre):          /usr/sbin/useradd
+Requires(pre):          /usr/bin/getent
+Requires(postun):       /usr/sbin/userdel
+Requires(post,preun):   /sbin/chkconfig
+Requires(post,preun):   /sbin/service
+
+%description
+Kibana is a highly scalable interface for Logstash and ElasticSearch
+that allows you to efficiently search, graph, analyze and otherwise
+make sense of a mountain of logs.
+
+
+%prep
+%setup -qn %{name}-%{commit}
+#%setup -q
+
+
+%build
+if [ "$(which jruby)" == '' ]; then
+    JRUBY_CMD="java -jar /usr/share/jruby.jar"
+else
+    JRUBY_CMD="jruby"
+fi
+export GEM_HOME=$(pwd)
+export GEM_PATH=
+$JRUBY_CMD -S gem install bundler
+$JRUBY_CMD bin/bundle install
+rm -rf gems/*/test
+rm -rf gems/*/spec
+rm -rf gems/*/examples
+rm -rf sample spec
+
+
+%install
+rm -rf                          $RPM_BUILD_ROOT
+install -d                      $RPM_BUILD_ROOT/var/log/%{name}
+install -d                      $RPM_BUILD_ROOT/%{_javadir}/%{name}
+cp -a *                         $RPM_BUILD_ROOT/%{_javadir}/%{name}
+install -D -m 755 %SOURCE10     $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
+
+
+%pre
+/usr/bin/getent passwd %{name2} >/dev/null || /usr/sbin/useradd -r -c "%{name} pseudo-user" %{name2} >/dev/null
+
+
+%post
+/sbin/chkconfig --add %{name}
+
+
+%preun
+[ $1 = 0 ] && /sbin/service %{name} stop    || :
+[ $1 = 0 ] && /sbin/chkconfig --del %{name} || :
+
+
+%postun
+[ $1 = 0 ] && userdel %{name2} || :
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root,-)
+%attr(0750,%{name2},root) %{_javadir}/*
+%dir %attr(0750,%{name2},root) /var/log/%{name}
+/etc/rc.d/init.d/%{name}
+
+
+
+%changelog
+* Fri Apr 25 2013  <carl@five-ten-sg.com> - 0.2.0-0
+- Initial build.
+
--- a/Makefile	Fri Apr 19 17:48:29 2013 -0700
+++ b/Makefile	Mon Apr 29 13:38:05 2013 -0700
@@ -12,6 +12,11 @@
 jv=1.7.3
 j=jruby-complete-$(jv).jar
 k=GeoLite-City-2013-01-18.dat.gz
+lcc=df8ae2344433e5072a8dfe77082acfd1c9b6ed62
+lcs=df8ae234
+lv=0.2.0
+#l=Kibana-$(lv).tar.gz
+l=Kibana-$(lv)-$(lcs).tar.gz
 
 download:
 	[ -f $(f) ] || curl https://logstash.objects.dreamhost.com/release/$(f) >$(f)
@@ -20,6 +25,8 @@
 	[ -f $(i) ] || curl https://nodeload.github.com/NickPadilla/GraphTastic/tar.gz/$(icc) >$(i)
 	[ -f $(j) ] || curl http://repository.codehaus.org/org/jruby/jruby-complete/$(jv)/$(j) >$(j)
 	[ -f $(k) ] || curl http://logstash.objects.dreamhost.com/maxmind/$(k) >$(k)
+	#[ -f $(l) ] || curl https://codeload.github.com/rashidkpc/Kibana/tar.gz/v$(lv) >$(l)
+	[ -f $(l) ] || curl https://nodeload.github.com/rashidkpc/Kibana/tar.gz/$(lcc) >$(l)
 
 srpm: download
 	# build the classpath in a manifest file
@@ -28,6 +35,7 @@
 		echo "  $$i" >>logstash.manifest; \
 	done
 	# build the source rpms
+	rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs Kibana.spec
 	rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs jruby.spec
 	rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs GraphTastic-client.spec
 	rpmbuild --define "dist $(dist)" --define "_sourcedir $(shell pwd)" --define "_srcrpmdir $(shell pwd)" --define "_rpmdir $(shell pwd)" -bs elasticsearch.spec
@@ -37,6 +45,7 @@
 	# kill off maven repository cache
 	rm -rf ~/.m2
 	# build binary rpms
+	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild Kibana-$(lv)-0$(dist).src.rpm
 	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild jruby-$(jv)-0$(dist).src.rpm
 	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild GraphTastic-client-0.0.0-0$(dist).src.rpm
 	rpmbuild --define "dist $(dist)" --define "_rpmdir $(shell pwd)" --rebuild elasticsearch-$(hv)-0$(dist).src.rpm
--- a/logstash.rc	Fri Apr 19 17:48:29 2013 -0700
+++ b/logstash.rc	Mon Apr 29 13:38:05 2013 -0700
@@ -31,7 +31,7 @@
 CONFIGFILE=/etc/logstash/logstash.conf
 LOGFILE=/var/log/logstash/logstash.log
 JARNAME=/usr/share/java/logstash.jar
-ARGS="$JAVAARGS -jar $JARNAME agent --config $CONFIGFILE --log $LOGFILE $AGENTARGS -- web $WEBARGS"
+ARGS="$JAVAARGS -jar $JARNAME agent --config $CONFIGFILE --log $LOGFILE $AGENTARGS -- $WEBARGS"
 PIDFILE=/var/run/logstash.pid
 base=logstash
 
--- a/logstash.spec	Fri Apr 19 17:48:29 2013 -0700
+++ b/logstash.spec	Mon Apr 29 13:38:05 2013 -0700
@@ -5,8 +5,9 @@
 Name:           logstash
 Version:        1.1.10
 Release:        0%{?dist}
+
+Group:          System Environment/Daemons
 License:        Apache 2.0
-Group:          System Environment/Daemons
 URL:            http://logstash.net/
 BuildArch:      noarch
 #Source0:        https://logstash.objects.dreamhost.com/release/%{name}-%{version}-monolithic.jar
@@ -24,14 +25,16 @@
 Source21:       sendmail.pattern
 Source22:       dnsbl.pattern
 BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
-Requires:       logrotate httpd java-1.7.0-openjdk python-pip python-argparse python-ordereddict
+
+BuildRequires:  ragel jruby java-devel
+
+Requires:       logrotate httpd java-devel python-pip python-argparse python-ordereddict
 Requires:       jruby elasticsearch GraphTastic-client
 Requires(pre):          /usr/sbin/useradd
 Requires(pre):          /usr/bin/getent
 Requires(postun):       /usr/sbin/userdel
 Requires(post,preun):   /sbin/chkconfig
 Requires(post,preun):   /sbin/service
-BuildRequires:  ragel jruby
 
 
 %description
@@ -54,8 +57,8 @@
 
 
 %install
-rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT/var/log/%{name}
+rm -rf                                $RPM_BUILD_ROOT
+install -d                            $RPM_BUILD_ROOT/var/log/%{name}
 install -D -m 750 build/logstash.jar  $RPM_BUILD_ROOT/%{_javadir}/%{name}.jar
 install -D -m 750 %SOURCE1            $RPM_BUILD_ROOT/%{_javadir}/logstash_index_cleaner.py
 install -D -m 755 %SOURCE10           $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
--- a/logstash.sysconfig	Fri Apr 19 17:48:29 2013 -0700
+++ b/logstash.sysconfig	Mon Apr 29 13:38:05 2013 -0700
@@ -3,10 +3,14 @@
 
 
 # used by /etc/rc.d/init.d/logstash
+
 # extra args for java
 #JAVAARGS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000 -verbose"
 #JAVAARGS=-verbose
+
 # extra args for agent
 #AGENTARGS=-vvv
+
 # args for web
-WEBARGS="--backend elasticsearch://127.0.0.1/?local"
+#WEBARGS="web --backend elasticsearch://127.0.0.1/?local"
+#WEBARGS=