Archive for the "Linux" Category

Installing dig on a Centos Linux Server with Yum

Installing dig on a CentOS server is pretty easy, using yum.   Dig is part of the bind utils package, so you will want to install bind-utils.


Installation will look something like the following:

And you’re now ready to use dig!



Creating RRD files in PHP

I was looking for a way to store (and graph) data for all of our physical servers.  Now sure, we could install SNMP on every machine and just use MRTG, but as a lot of them are leased by clients, I wanted something out of band which will ‘just work’.  We have a very nice IMPI based system which we use for provisioning every server on the network.  That seemed like a good way to go!  Pulling all the fun info via IPMI is really easy:

That gives us quite a useful amount of info!  Though for our purposes, we’ll ignore everything except the first three columns.

Handling that in PHP, we do something like the following:

Then we need to think about the RRD’s.  We need to check if we HAVE one, if so we put the data in.  Or we generate a new RRD and put the data in.

What we’re doing above is creating the datastore, and creating Round Robin Archives for Min, Max, and Average. Storing a sample every 5 minutes for 24 hours (288 samples), a sample every hour for 7 days, and a sample every day for a year.

Now we need to store our data.  That’s the easy part!

And we’re now storing data.  Note the use of the shell_exec.  At least in PHP5.4 on Ubuntu, rrd_update and rrd_graph do not work.

But that’s not much fun if we can’t display the graphs when we need them!

I could write them out to file and then include them from static HTML etc.  But I’d rather have it all dynamically generated.  I have a php file which generates the HTML table referencing the graphs:

And then the actual graphing script:

And now it’s working very nicely indeed!



Quick Tip: Get the UUID for a Disk or Partition

I was just quickly running up a small linux server to use as a backup server at a remote site, and added a new disk to an existing install.

Since it’s at a remote site, I don’t want the chance of it barfing on boot, so I definitely want to specify my partition by UUID.

The UUID is used to identify a device, independently from its device name. Especially useful when mounting physical disks, it’s also useful for LVM volumes, etc.

There are a few ways to get the UUID, but by far the easiest is to simply do an ls -l in /dev/disk/by-uuid.

In my case, I’m pointing at a LVM Logical Volume, so I can take a guess that I’m looking for dm-0, but to be sure, I want to check in /dev/mapper:

Yep, so to mount that new volume in fstab, I want to add a line like the following: