Linux tips & techniques for developers and system administrators.


Installing the new Zabbix 2.0.0rc2

By jbayer - Last updated: Tuesday, April 10, 2012

I’ve taken my script for an automatic installation of Zabbix and modified it to install the 2.0.0rc2.

It is designed to work with any RHEL5+, CentOS 5+, Scientific Linux 5+ or higher systems.

It is best to start with a minimal install. It will download and install all necessary packages.

I’ve developed a directory structure for my zabbix installs, which this uses:

/etc/zabbix – main config directory
/etc/zabbix/alert.d – Alert files go here
/etc/zabbix/cron.d – Cron files go here
/etc/zabbix/externalscripts – External scripts go here
/etc/zabbix/zabbix_agentd.d – zabbix_agentd.conf includes this directory

I hope this helps someone, and would be interested in hearing about any comments.


Filed in Open Source, Zabbix

Installing Zabbix on Redhat/CentOS – v. 1.5

By jbayer - Last updated: Monday, April 9, 2012

Another update.  Changes below.

  1. Updated Zabbix version to 1.8.11
  2. Added install of php-xml and php-xmlrpc, needed for template import
  3. Added better Apache config, inspired by
  4. Updated URL for epel repo
  5. Make default mysql conf file my-large.conf
  6. Added option to use Percona server
  7. Modified zabbix_agentd.conf to include files from zabbix_agentd.d
  8. Changed locations of log files, all files (both client & server) now go in /var/log/zabbix
  9. Added modified init scripts which properly wait for prog to exit before restarting
Filed in Administration, Open Source, Zabbix

Patching Checkinstall to save options between runs

By jbayer - Last updated: Thursday, April 5, 2012

I had a problem where I was working on an existing, installed package for our systems here.  I needed to have the new RPMs be the same as the old ones, except for the release number being incremented.  Checkinstall, while a great program, doesn’t do anything to save options, so you have to re-enter them every time you run it (or create a script to run it).

The attached patch is applied against checkinstall 1.6.2, and adds an automatic method to save all the options in a file called .checkinstall_opts in the directory of the package you are creating. (1.1 KiB, 141 hits)

Filed in Building packages, Open Source

Yum and RPM install history

By jbayer - Last updated: Friday, March 30, 2012

Sometimes I need to find out when something was installed.  The following two commands will show the history for yum and rpm, respectively

To get a history of all the yum installs, look at:



Rpm package installation history

If you need when the packages installed in Red Hat or Fedora

rpm -qa –queryformat ‘%{NAME}:\t %{INSTALLTIME:date}\n’

Use the following to get the list of packages sorted by install date/time:

rpm -qa –queryformat ‘%{installtime} (%{installtime:date}) %{name}\n’ | sort -n

Filed in Administration

Installing latest virt-manager on RHEL6/CentOS6

By jbayer - Last updated: Monday, March 5, 2012

The virt-manager which comes with RHEL6/CentOS6 is somewhat old, being version 0.8.6, which was released on 1/14/2011.  The attached script will take a basic system and download/install all necessary RPMs, and then download and install the latest virt-manager, version 0.9.1 released 1/31/2012

There are a lot of nice improvements which make this a very worthwhile upgrade.


  kvm_on_6.tar.gz (1.2 KiB, 0 hits)

Filed in Virtulization

Using Partitioning on Zabbix DB tables to improve performance

By jbayer - Last updated: Monday, March 5, 2012

This script will partition your zabbix database to improve the efficiency. It will also create stored procedures to do the necessary housekeeping, and create a cronjob to do this on a daily basis. This script was inspired by the following:

While the basic SQL is from the above page, this script both creates the necessary SQL for the desired tables, and can create new partitions as the time goes on assuming that the cronjob has been properly entered.

Use all information and scripts at your own risk. Make backups! (4.0 KiB, 1,080 hits)



./ [-h host][-u user][-p password][-d min_days][-y startyear]
 -h host database host
 -u user db user
 -p password user password
 -d min_days Minimum number of days of history to keep
 -m min_months Minimum number of months to keep trends
 -y startyear First year to set up with partitions

After running this script, don’t forget to disable housekeeping if you didn’t have the script disable it, and add the following cronjob:

Change the file /etc/zabbix/zabbix_server.conf as follows to disable the housekeeping:

### Option: DisableHousekeeping
 # If set to 1, disables housekeeping.
 # Mandatory: no
 # Range: 0-1
 ################### Uncomment and change the following line to 1 in
 ################### Then restart the zabbix server

Cron job

0 0 * * * /etc/zabbix/cron.d/


Filed in Database, Zabbix

Adding a bridge interface to Linux

By jbayer - Last updated: Thursday, March 1, 2012

A bridge is a way to connect two Ethernet segments together in a protocol independent way. Packets are forwarded based on Ethernet address, rather than IP address (like a router). Since forwarding is done at Layer 2, all protocols can go transparently through a bridge.

Among other reasons, if you are running KVM or Xen, and you want your virtual machines to have their own IP addresses on the network, you will have to set up and use a bridge.

These instructions are specific to RedHat and derived systems.  Tested on 5.6 and beyond.

These instructions assume that the interface you want to bridge is eth0, and that eth0 is the gateway device.  It is advisable that you do this at a console and not ssh’d in, since if networking doesn’t restart properly you won’t be able to ssh in to fix it.

  1. Backup all your networking files:
    tar czf /etc/sysconfig.tar.gz /etc/sysconfig
  2. Copy the file /etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-br0
  3. In the file /etc/sysconfig/network-scripts/ifcfg-eth0, delete all the lines, and put the following lines in instead:
  4. In /etc/sysconfig/network-scripts/ifcfg-br0, change and add the following:
  5. Leave the IPADDR, NETMASK and (if there) HWADDR & GATEWAY alone.
  6. If the interface currently is set to DHCP and you want to change it to a static address:a. To assign a static IP address, change the BOOTPROTO line in the ifcfg-br0 file to:

    b. And add the following lines, with the appropriate IP info set:

  7. Change the file /etc/sysconfig/network, if GATEWAYDEV is there, set it to:
  8. If you have any aliases on the device you are bridging to, you will rename the aliases to refer to the bridge instead of the device.  For example, if in normal mode you have:

    In bridging mode you will have:

  9. Restart networking, and check that networking is working properly.  Try pinging a system outside your network for verification that the routing is working.
Filed in Administration, Networking

Install latest virt-manager on RHEL6+, CentOS6+, SL6+

By jbayer - Last updated: Monday, February 27, 2012

RedHat ships an old version of virt-manager on RHEL 6.  This script will install the latest version of virt-manager and virtinst onto a clean RHEL 6 (or CentOS, SL, etc) system.

  kvm_on_6.tar.gz (1.2 KiB, 659 hits)

Just download it and run as root.

Filed in Virtulization

Enable/disable core dumps

By jbayer - Last updated: Tuesday, January 10, 2012

While it normally isn’t a good idea to have core dumps enabled on a production server, sometimes that is the only way to debug a problem.

There are several things which are needed to be done to enable core dumps on a modern Linux.  The attached script does this automatically for you.  It  has been tested on Redhat & CentOS systems

To enable core dumps, either log in or su to root, and type:

/path/to/script/ on

To disable them, type:

/path/to/script/ off


Be aware that Bash has it’s own ulimit value, so if you want to change the value in your current shell OR call this inside a shell script, type:

. /path/to/script/ on


. /path/to/script/ off (1.5 KiB, 570 hits)

Filed in Administration

Skip duplicate entries in a slave with MySql

By jbayer - Last updated: Tuesday, January 10, 2012

While setting up some replication, I got a duplicate key error on the slave.

Since I knew it wasn’t a problem, I just wanted to bypass it and continue with the replication.

The attached script will do that.

Briefly, it checks the slave status and if there is a Duplicate entry error, then it stops the slave, does a “set global sql_slave_skip_counter=1”, and then restarts the slave.

It loops once every 7 seconds, and can either be an infinite loop or a limited number.  I had to run this 4 or 5 times before the errors were skipped.

Other than the number of seconds to sleep, nothing is hard-coded;   you have to enter the db user and password.  It is set so that if you want to, it can be run from a cron. (587 bytes, 146 hits)

Filed in Administration, Database