Thursday, June 10, 2010

Setting up iperf as a daemon on CentOS

So I had a need to run iperf continuously on one of my CentOS servers today. I tested iperf in daemon mode and found that it wasn't very reliable. It crashed often, with the process needing to be killed and restarted. So I wrote up an init script and installed monit to monitor the port that iperf uses. Here is what you need to do:
yum -y install iperf monit
nano /etc/init.d/iperfd

Paste the following into the file:

#!/bin/bash
#
# iperfd iperf network bandwidth test
#
# chkconfig: 2345 80 30
# description: iperf network bandwidth test
# pidfile: /var/run/iperf.pid
# Source function library.

. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

start() {
echo -n "Starting iperfd: "
/usr/bin/iperf -s -D >/dev/null 2>&1
touch /var/lock/subsys/iperfd
pidofproc iperf > /var/run/iperf.pid
return 1
}

stop() {
echo -n "Shutting down iperfd: "
killproc iperf
rm -f /var/lock/subsys/iperfd
rm -f /var/run/iperf.pid
return 1
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status iperf
;;
restart)
stop
start
;;
*)
echo "Usage: iperfd {start|stop|restart}"
exit 1
;;
esac
exit $?

Setup Monit

nano /etc/monit.d/iperf

Paste the following into the file:

check process iperf with pidfile /var/run/iperf.pid
start program = "/etc/init.d/iperfd start"
stop program = "/etc/init.d/iperfd stop"
if failed host 127.0.0.1 port 5001 type TCP then restart
if 5 restarts within 5 cycles then timeout

chmod the monit files:

chmod 0700 /etc/monit.conf
chmod 0700 /etc/monit.d/iperf

Start up your services:

chkconfig monit on
chkconfig iperfd on
service iperfd start
service monit start

Tuesday, January 19, 2010

IO-Compress-Zlib error while emerging

This is caused by the fact that /IO-Compress replaces perl-core/Compress-Zlib, perl-core/IO-Compress-Zlib, perl-core/IO-Compress-Bzip2, perl-core/IO-Compress-Base. Just remove all the replaced packages and re-install IO-Compress.

Error relocating virtual machine in VMware

Got this error while migrating to a new datastore:
A general system error occurred: Storage VMotion failed
to copy one or more of the VM's disks. Please consult
the VM's log for more details, looking for lines
starting with "CBTMotion".


Problem was the block size was different on the new datastore. One of the disks had a larger block size. You can remove the datastore and format it with a different block size.

Error emerging netpbm

No shortage of errors while doing these updates. Here is the latest:
In file included from /usr/include/signal.h:33,

from parallel.c:43:

/usr/include/bits/sigset.h:117: parse error before `]'

/usr/include/bits/sigset.h: In function `__sigismember':

/usr/include/bits/sigset.h:117: number of arguments doesn't match prototype

/usr/include/bits/sigset.h:103: prototype declaration

/usr/include/bits/sigset.h:117: `__sig' undeclared (first use in this function)

/usr/include/bits/sigset.h:117: (Each undeclared identifier is reported only once

/usr/include/bits/sigset.h:117: for each function it appears in.)

/usr/include/bits/sigset.h:117: `__set' undeclared (first use in this function)

/usr/include/bits/sigset.h:117: warning: control reaches end of non-void function

/usr/include/bits/sigset.h: At top level:

/usr/include/bits/sigset.h:118: parse error before `]'

/usr/include/bits/sigset.h: In function `__sigaddset':

/usr/include/bits/sigset.h:118: number of arguments doesn't match prototype

/usr/include/bits/sigset.h:104: prototype declaration

/usr/include/bits/sigset.h:118: `__sig' undeclared (first use in this function)

/usr/include/bits/sigset.h:118: `__set' undeclared (first use in this function)

/usr/include/bits/sigset.h:118: warning: left-hand operand of comma expression has no effect

/usr/include/bits/sigset.h: At top level:

/usr/include/bits/sigset.h:119: parse error before `]'

/usr/include/bits/sigset.h: In function `__sigdelset':

/usr/include/bits/sigset.h:119: number of arguments doesn't match prototype

/usr/include/bits/sigset.h:105: prototype declaration

/usr/include/bits/sigset.h:119: `__sig' undeclared (first use in this function)

/usr/include/bits/sigset.h:119: `__set' undeclared (first use in this function)

/usr/include/bits/sigset.h:119: warning: left-hand operand of comma expression has no effect

In file included from /usr/include/math.h:350,

from /home/installers/netpbm-10.11.3/converter/ppm/ppmtompeg/headers/all.h:67,

from parallel.c:44:

/usr/include/bits/mathinline.h: At top level:

/usr/include/bits/mathinline.h:427: warning: no previous declaration for `__atan2l'

/usr/include/bits/mathinline.h:442: warning: no previous declaration for `__sqrtl'

/usr/include/bits/mathinline.h:448: warning: no previous declaration for `__fabsl'

make[3]: *** [parallel.o] Error 1

make[3]: Leaving directory `/home/installers/netpbm-10.11.3/converter/ppm/ppmtompeg'

make[2]: *** [ppmtompeg/all] Error 2

make[2]: Leaving directory `/home/installers/netpbm-10.11.3/converter/ppm'

make[1]: *** [ppm/all] Error 2

make[1]: Leaving directory `/home/installers/netpbm-10.11.3/converter'

make: *** [converter/all] Error 2


Fix was:

emerge -av glibc

Friday, January 15, 2010

Minimal Services on CentOS

These are the services I turn off on all VMware Centos Guest installs:
Reference: anchorite.org

chkconfig anacron off
chkconfig apmd off
chkconfig atd off
chkconfig autofs off
chkconfig cpuspeed off
chkconfig cups off
chkconfig cups-config-daemon off
chkconfig gpm off
chkconfig isdn off
chkconfig netfs off
chkconfig nfslock off
chkconfig openibd off
chkconfig pcmcia off
chkconfig portmap off
chkconfig rawdevices off
chkconfig readahead_early off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig smartd off
chkconfig xfs off
chkconfig ip6tables off
chkconfig avahi-daemon off
chkconfig firstboot off
chkconfig yum-updatesd off
chkconfig sendmail off
chkconfig mcstrans off
chkconfig pcscd off
chkconfig bluetooth off
chkconfig hidd off"

Monday, January 11, 2010

Failed to update lm_sensors-2.10.7

Another problem trying to update a gentoo machine, getting the following error:

make: *** No rule to make target `asm/bitsperlong.h', needed by `prog/dump/i2cbusses.rd'. Stop.
*
* ERROR: sys-apps/lm_sensors-2.10.7 failed.
* Call stack:
* ebuild.sh, line 49: Called src_compile
* environment, line 3443: Called die
* The specific snippet of code:
* emake CC=$(tc-getCC) LINUX=${KV_DIR} I2C_HEADERS=${KV_DIR}/include user || die "emake user failed"
* The die message:
* emake user failed
*
* If you need support, post the topmost build error, and the call stack if relevant.
* A complete build log is located at '/var/tmp/portage/sys-apps/lm_sensors-2.10.7/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/sys-apps/lm_sensors-2.10.7/temp/environment'.
*

>>> Failed to emerge sys-apps/lm_sensors-2.10.7, Log file:


2.10.7 appears to have some bugs. Solution:
nano /etc/portage/package.keywords
>sys-apps/lm_sensors-2.10.7

emerge gentoolkit fails

Get this error while updating gentoolkit:

emerge: there are no ebuilds built with USE flags to satisfy "dev-lang/python[xml]".
!!! One of the following packages is required to complete your request:
- dev-lang/python-2.6.4 (Change USE: +xml)
(dependency required by "app-portage/gentoolkit-0.2.4.5" [ebuild])
(dependency required by "gentoolkit" [argument])


The error tells you how to resolve this one "Change USE +xml" Basically you just need to update /etc/portage/package.use and add python with an xml flag.

mktemp-1.5 error while trying to Update in Gentoo

Got the following error while trying to update world:

* Error: The above package list contains packages which cannot be
* installed at the same time on the same system.

('binary', '/', 'sys-apps/mktemp-1.5', 'merge') pulled in by
sys-apps/mktemp required by world

('ebuild', '/', 'sys-apps/coreutils-6.10-r2', 'merge') pulled in by
>=sys-apps/coreutils-5.2.1 required by ('ebuild', '/', 'sys-apps/baselayout-1.12.11.1', 'merge')
>=sys-apps/coreutils-6.10-r1 required by ('ebuild', '/', 'sys-apps/baselayout-1.12.11.1', 'merge')
sys-apps/coreutils required by world
(and 1 more)


As I understand it mktemp is no longer needed as it is now in the updated version of coreutils. DO NOT REMOVE COREUTILS, you will lose very basic linux functions.

Here is how to resolve this error:

emerge -C mktemp
emerge coreutils

Gentoo Package Hell

I inherited 15 Gentoo servers, all of which haven't been updated in a few years. If you are familiar with Gentoo then you know this is really bad as now it becomes very difficult to get it updated to the current version. The next posts will be dedicated to all the package dependency conflicts and other Gentoo things I'm dealing with. When I'm done I plan on writing a few blurbs about why I think Gentoo is a terrible choice for server operating systems.