Skip to content

Instantly share code, notes, and snippets.

@isalgueiro
Last active March 16, 2018 09:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isalgueiro/8f3c35136ad028d009ac515ac21d4821 to your computer and use it in GitHub Desktop.
Save isalgueiro/8f3c35136ad028d009ac515ac21d4821 to your computer and use it in GitHub Desktop.
Run metricbeat with old kernels where original init.d script fails with `kernel too old` message

In old kernels (~2.6.20) beats fail to start with a message like this:

FATAL: kernel too old
/bin/bash: line 1:  5496 Segmentation fault      /usr/share/metricbeat/bin/metricbeat-god -r / -n -p /var/run/metricbeat.pid -- /usr/share/metricbeat/bin/metricbeat -c /etc/metricbeat/metricbeat.yml -path.home /usr/share/metricbeat -path.config /etc/metricbeat -path.data /var/lib/metricbeat -path.logs /var/log/metricbeat
                                                           [FAILED]

You can replace original /etc/init.d/metricbeat file with this script to run metricbeat in old Red Hat systems. After replacing the file run checkconfig --add metricbeat so metricbeat starts automatically with every system start.

This was tested in:

Distribution Kernel Test result
Fedora 8 2.6.23.1-42.fc8 Original metricbeat init.d script fails. This script works OK.
Fedora 8 2.6.26.8-57.fc8 Both original and this init.d scripts works OK.
CentOS 5.2 2.6.18-92.1.22.el5 Original metricbeat init.d script fails. This script works OK.
Red Hat Enterprise Linux Server release 5.11 (Tikanga) 2.6.18-409.el5 Original metricbeat init.d script fails. This script is no tested, but should work OK.
Red Hat Enterprise Linux Server release 5.11 (Tikanga) 2.6.18-412.el5 Original metricbeat init.d script fails. This script is no tested, but should work OK.
Red Hat Enterprise Linux Server release 5.11 (Tikanga) 2.6.18-416.el5 Original metricbeat init.d script fails. This script is no tested, but should work OK.
#!/bin/bash
# chkconfig: 345 99 01
# description: Metricbeat startup script for old RH systems
# processname: metricbeat
. /etc/rc.d/init.d/functions
prog="metricbeat"
prog_path="/usr/share/metricbeat/bin/"
OPTIONS="-c /etc/metricbeat/metricbeat.yml -path.home /usr/share/metricbeat -path.config /etc/metricbeat -path.data /var/lib/metricbeat -path.logs /var/log/metricbeat &"
pidfile="/var/run/$prog.pid"
lockfile="/var/lock/subsys/$prog"
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon $prog_path$prog $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -d 10 $prog
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment