Sep 19 2007

Cacti on Fedora: Blank Graphs

Tag: Fedora, Linux, Techjs @ 6:08 pm

After getting Cacti up and running successfully on Fedora Core 5, I had a problem with the graphing. Caci was receiving the SNMP data correctly (the graph legends would show the proper data values), but the actual neato colors and lines were absent in the graph image. After some research I found a fix: Everything in the rra file must be owned by the cacti user, or the user running the poller crontab. Pretty simple:

chown -R cacti.cacti /usr/share/cacti/rra

Once the rra files were owned by the cacti user, the graphs started to appear in all their colored and lined splendor!

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Jul 21 2007

PHP & imagettftext with Webcore TrueType fonts.

Tag: Fedora, Linux, PHP, Techjs @ 1:37 pm

If you’re trying to write some text using PHP/GD & the imagettftext function, you will of course need some TrueType fonts to work with. I’ve found a great set of fonts available for free: Webcore. Webcore contains all the fonts webdesigners constantly use, things like Arial, Tahoma, Verdana, Georgia, etc..

To install, simply download to your server and install the RPM (Fedora):

shell> wget http://avi.alkalay.net/software/webcore-fonts/webcore-fonts-3.0-1.noarch.rpm
shell> rpm -i webcore-fonts-3.0-1.noarch.rpm

These fonts will now be available to you in /usr/share/fonts/webcore/.

Make sure you specify the full path when calling imagettftext(), eg:

<?php

// Set the content-type
header(”Content-type: image/png”);

// Replace path by your own font path
$font = ‘/usr/share/fonts/webcore/arial.ttf’;

// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = ‘Hello world!’;

// Add some text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

Your mileage may vary if you are using a different distribution, but the docs state that this RPM should work on other distros.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Jul 03 2007

vi: Get rid of Windows formatted linebreaks (^M)

Tag: Fedora, FreeBSD, Linux, Ubuntujs @ 11:10 am

If you’ve ever tried to edit a Windows-created file in Unix or OSX, you’ve probably encountered a messy translation in line breaks: A file full of “^M” characters. There is an easy search/replace you can use in vi/vim to format the file Unix-style:

:%s/\r/\r/g
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Oct 25 2006

Yum: Cannot find a valid baseurl for repo: core

Tag: Fedora, Linux, Techjs @ 2:17 pm

I went to update my Fedora Core 5 machine today, and received the following error:

[root ~] yum check-update
Loading “installonlyn” plugin
Setting up repositories
core [1/3]
Cannot find a valid baseurl for repo: core
Error: Cannot find a valid baseurl for repo: core

I tried running yum clean all but it didn’t help. After looking around I found that all of my repo files in /etc/yum.repos.d/ had their baseurl values commented out. Don’t ask me how that happened, I have no idea. Simply uncommenting all the baseurl values in all my repo files fixed the problem, and yum is once again running as expected. So if you run into this problem, make sure everything is set up right in /etc/yum.repos.d/*.repo

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

May 23 2006

Installing PDFlib Lite as a PHP module on Fedora Core 4

Tag: Fedora, Linux, PHP, Techjs @ 3:15 pm

The instructions for doing so (here) seemed straightforward enough, but I ran into a few problems. So here’s how I got PDFLib working with my PHP install on Fedora Core 4.

First we need to build PDFlib Lite from Source. Download it from here. Unpack it, then:

./configure
make
make install

Easy enough. Now:

yum install automake
yum install php-devel
pecl install pdflib

(Note: php-devel is required because we need phpize which is used by the pecl command.)

The PECL install will ask you a question: “Path to PDFlib installation?” This is where I ran into problems. You must put /usr/local/ and NOT /usr/local/include because the script is hardcoded to look inside the include directory automatically. Once PECL finds pdflib.h it will continue and finish compiling our shared object, pdf.so. The script will install it for us in /usr/lib/php/modules/
Now we just have to tell PHP to load the SO. Open up php.ini and add the following line:

extension=pdf.so

Save & exit, and restart your apache with apachectl graceful. Now browse to a file containing the phpinfo() function and check to see if PDFlib is now active. If you see it, you’re good to go!

NOTE: I ran into a problem with RPM GPG Keys at the automake install step. I was getting the following error:

warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID db42a60e
public key not available for autoconf-2.59-5.noarch.rpm
Retrieving GPG key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
The GPG key at file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora (0×4F2A6FD2)
is already installed but is not the correct key for this package.
Check that this is the correct key for the “Fedora Core 4 - i386 - Base” repository.

To get around this we need to import all the keys by run the following command:

rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*

I found this solution in this thread.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Feb 27 2006

Red Hat Fedora Linux: Add an additional IP to your network card.

Tag: Fedora, Linux, Techjs @ 2:38 pm

Adding an additional IP or IPs to your network card in Linux is easy. Here’s how I did it in my Fedora Core 4 installation:

cd /etc/sysconfig/network-scripts/
cp ifcfg-eth0 ifcfg-eth0:0

Now you will need to open your newly created ifcfg-eth0:0 file in your favorite editor and modify it to fit your needs. The two lines you MUST change are the following, the rest are optional:

DEVICE=eth0:0
IPADDR=192.x.x.x

Of course you will want to fill in the IPADDR value to fit your needs.

Now, to make the changes take effect, you will need to bring your new IP up by issuing the following command:

./ifup eth0:0

Or if you want you can just restart the entire network:

/etc/rc.d/init.d/network reload

There you go! Run ifconfig and you should see your new IP assigned to eth0:0. It should look something like this:

eth0:0 Link encap:Ethernet HWaddr 00:D0:B7:B7:XX:XX
inet addr:192.168.1.XX Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

You can add even more IPs by repeating this process and incrementing the value of eth0:0, for example you can add eth0:1, eth0:2, etc.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Feb 17 2005

MRTG Error: gd-png: fatal libpng error: Invalid filter type specified

Tag: Fedora, Linux, Techjs @ 10:08 am

I recently upgraded my MRTG install from v 2.10.13 to 2.11.1, and while the upgrade went fine, I ran into problems running mrtg:

[bash] /usr/local/mrtg-2/bin/mrtg /etc/mrtg/mrtg.cfg
gd-png: fatal libpng error: Invalid filter type specified
gd-png error: setjmp returns error condition
gd-png: fatal libpng error: Invalid filter type specified
gd-png error: setjmp returns error condition
gd-png: fatal libpng error: Invalid filter type specified
gd-png error: setjmp returns error condition
…..

I did a thorough Google search and never found a good answer or fix, except for a patch to the MRTG source code, which I didn’t find satisfactory. So it turns out that it was a problem with the PNG libraries. The machine was running an old Redhat 7.2, and libpng had previously been installed via RPM, with the libpng files from this RPM residing in /usr/lib. Prior to upgrading MRTG I had installed a newer libpng via source, with the new libpng files residing in /usr/local/lib. So the problem was that I had two different versions of libpng installed in different places on the machine, and this was causing the problems. This was easily fixed by creating symbolic links from the old RPM dir (/usr/lib) to the new manually installed dir (/usr/local/lib)

[bash] cd /usr/lib
[bash] mv libpng.a libpng.a.old
[bash] ln -s /usr/local/lib/libpng.a libpng.a
[bash] ln -s /usr/local/lib/libpng.so.3.1.2.8 libpng.so.3
[bash] ln -s /usr/local/lib/libpng.so.3 libpng.so

Once this library hell was fixed, MRTG went back to operating as expected.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]