Some of our servers have multiple IP addresses configured – in most cases we want to use eth0:1 rather than eth0, but it wasn’t immediately clear how to do this on cPanel’s exim mail server.
The original solution was to modify /etc/exim.conf, but today I discovered that there is a specific file (/etc/mailips) where IPs can be specified per-domain or globally.
To get this working, just setup /etc/mailips as follows:
[domain]: [ip]
[domain2]: [ip]
Obviously, you need to replace [domain] and [ip] with the appropriate entries. In my case, this wasn’t ideal as I wanted to use a single IP globally. Luckily, that’s easily done by using an asterisk (*) for [domain]. I believe it even works alongside specific domain entries, so you could have certain domains sending mail out on unique IPs, and then globally route everything else through another.
Once that file has been edited, you need to modify the cPanel exim configuration by going to Exim Configuration Editor within WHM. If you search for mailips on that page, you’ll see which box you need to check (don’t forget to save afterwards).
Nick Other
I have knocked up a simple Ruby script (my first – please be gentle) to parse the output of ps -u -o pid,rss,command and convert the KB values to MB for easier reading.
The script recurses through each process and displays the process ID, memory usage (in megabytes) and the command that it’s executing. It then displays the total memory usage at the end.
Download
memusage.rb (1.21 KB — RB file)
Nick Other Ruby, WebFaction
I discovered a while back that my SSH sessions weren’t staying active despite having the appropriate settings in /etc/ssh/ssh_config.
The other day, I found an article on Google with another way to get keep-alives working – luckily this seems to have worked.
Read more…
Nick Other Mac, Shell
A list of some useful bits and pieces gathered from the WebFaction forum, support system and so on.
Find a process and kill it
ps -u <username> -o pid,command
kill <process_id>
Memory usage (outputs in Kilobytes)
ps -u <username> -o rss,command
Cron Setup
If you’re not familiar with vi, you can change the default editor to something easier such as nano by typing: export VISUAL='nano'.
You can add/modify/remove your cron-jobs by typing: crontab -e
Software
Nick Other WebFaction
Sigh…
It’s taken me about a day of fiddling about to finally get Redmine to work with my Bazaar repositories.
This is the first time I’ve ever used Redmine (as well as Rails), so much Googling was required.
Read more…
Nick Development Bazaar
I found this useful page for counting lines in projects that I work on.
There are a couple of different techniques there, but I personally use the following:
find . -type f -name '*.php' | xargs wc -l
Nick Development Shell
Mike from ClickableBliss (which incidentally makes a really nice invoicing application for Mac) has pointed out something that really irks me with modern web companies – they are too informal!
Whenever I see informal communication between the company and user (i.e. a message displayed on their website), it conjures up images of long-haired hippies, sitting around an office full of children’s toys, shrugging their shoulders, saying “meh” a lot, and generally pretending that they are 10 years younger (on the basis that they’re likely to be in their twenties).
Why do these companies think it’s all cool and new-age (or whatever) to communicate in such a juvenile manner? It all seems to emanate from this abundance of start-ups (including more established start-ups). It’s all down to this web 2.0 nonsense. I predict another dot-com bubble is soon to burst.
I understand that companies should want to appear more “open” with their customers, but does that mean that professionalism should be forgotten or disregarded?
Don’t get me wrong, I admire what most of these companies are trying to achieve, but if they’re in a position where they’re trying to make money or a (positive) reputation, it doesn’t particularly give a good impression to the customer if the communication they receive is informal, vague or suchlike.
Then again, maybe nobody else cares
Nick Other
This handy function allows you to pass a filesize in bytes and have it returned with the appropriate suffix.
Credit is due, but I don’t remember where I originally found it (possibly the PHP documentation site).
Read more…
Nick Repository PHP
Here is an easy to use function to allow you to display a list of countries to your users – this avoids them having to type it out (potentially incorrectly), and is ideal for use in a select field (drop-down box).
As an added bonus, you can also download a collection of flag images, with each image filename renamed to match the corresponding array key. The original images can be found at famfamfam.
Read more…
Nick Repository PHP
I’ve just created a privacy policy as Google now requires this for their new interest-based advertising, due to launch in April.
I spent a while Googling for a suitable template aimed at UK-based websites, and managed to stumble upon this, which I have modified for use on this website.
Hopefully this will save somebody the effort of finding a suitable template for their own site!
Nick Other