Archive for April, 2008

I think about queues all the time.

Thursday, April 24th, 2008

Here’s something to waste your time and bore your brains out.

There are three nodes, say Nodes A, B and C. Node A and C are application servers. Node B is a messenger for nodes A and C. Although Node B is not needed but for reasons I’m not allowed to discuss and would rather not discuss, it has to be there and is the root cause why we have a problem.

Let’s start with an example series of events. A new transaction begins from Node C which sends data to Node B. Node B stores the data in a queue. Node A fetches x items from the queue every y seconds.

After Node A processes the transaction, it begins a new transaction. Node A sends data to Node B only this time, it is no longer stored in a queue. Node B immediately forwards the data to Node C.

On some occasions, Node C starts a new transaction as an acknowledgment from the data that originated from Node A. This transaction is treated as a transaction similar to the first one only that Node A knows that it’s an acknowledgment.

Originally, Node A and Node C communicated to each other directly. The queue didn’t exist. The queue came in to fix a couple of problems but it introduced new ones. Recently, the script in Node A that polls data from Node B died and now it’s catching up with backlog. The script processed data one by one. This showed how slow the main application in Node A is.

I already have a solution in mind and I enjoy writing boring stuff but I’d like to hear other views.

The Few Good Stuff on Television

Sunday, April 20th, 2008

For me, there are three elements for a good television show: geeks, a hot chick and sarcasm. Lahaina told me to check out The Big Bang Theory and I got hooked the minute I saw the first episode.

The show is set with two physicists and a hot chick who just moved in across their apartment. Given the poor socializing skills of most some geeks (you can count me in), you’d probably get the drift of the series.

Here’s a keeper to spoil you.

I like the chemistry shirts that Leonard wears on most episodes. This show is da sex! I can relate to it a lot. So much that I usually see myself in Leonard and Sheldon.

Reduce Attacks on Apache+PHP

Sunday, April 20th, 2008

A couple of days ago I thought that one of my servers got compromised. I thought someone cracked my password by brute force and kept shutting down Apache at 4AM. As it turned out, I made a mistake with the log rotation configuration that the post-rotation restart fails to start Apache.

I immediately installed DenyHosts, disabled keyboard-interactive login and hardened the firewall. It made me feel more insecure which resulted into today’s post.

With a fresh install of FreeBSD 7 on another server yesterday, I wanted to make sure that I do it properly from the start this time.

Apache adds the Server header that reveals the OS, version and some modules. PHP also adds an X-Powered-By header that shows the version of PHP. With those information publicly available, someone can write a script that could exploit vulnerabilities on specific versions of Apache and/or PHP.

For Apache, you can use mod_security. It’s available as a port and at Karanbir Singh’s yum repository for CentOS users. See the directive below.

<IfModule security_module>
  SecServerSignature "Apache"
</IfModule>

Also, just to be a happy camper, I used a new configuration file to be included. Consult your configuration for the path. On CentOS, the default configuration directory is at /etc/httpd/conf.d. On FreeBSD, it’s at /usr/local/etc/apache[n]/Includes, where n may be your Apache version.

For PHP, simply set expose_php to off in your php.ini

Disclaimer: This works for me but I’m not sure if this is the best way to do it. I tried mod_headers first but it didn’t work.

Notebook Memory

Friday, April 4th, 2008

If your laptap starts to crawl if you have too much programs running at the same time, you can try adding IGB of RAM from PC Express.

Free Image Hosting at www.ImageShack.us

[found by D. Billano]

Insert to Asterisk’s Queue Log When a Member Is Called

Friday, April 4th, 2008

Asterisk’s queue_log can come in handy in many cases (queues in Asterisk can be called ACD). There are systems that go as far as depending solely on the queue_log to operate (including mine).

Every now and then requests requirements for a feature to tell if a call in the queue is being transferred to a queue member (an agent) comes up. I had a workaround that used an AGI script but it didn’t work all the time. I’ve been digging around the source code so that it’s inserted into queue_log instead. After three attempts of hacking one friggin’ line of C code, I finally did it. My sincerest apologies to my COMPRO1 and COMPRO2 professors.

You may get the patch for asterisk-1.4.19 over here.

P.S. I know that watching the queue_log isn’t much of a good idea. I only stole the concept and I wasn’t aware of AMI at that time. Migration plans are on the way.