Advertise here!



Linux Web Server Hack - How to Write Automated Load Balancing Script!

Posted in A+Featured Hacks, Blog, Consumer, Cool, DoItYourself!, Educational, HOWTO, Hack, Web, Wordpress by max on the September 23rd, 2008 at 9:15 am

Well, I have been manually managing the dedicated server for this site for last 2 years or so but I found a better way to automate the server so it doesn’t ever go down due to overload.

One of the common problems in dedicated servers is the fact that load can go out of control and your web server along with it, causing you to hard-restart the server.

A better way to deal with this over-load problem is to shut down the HTTPD server (web server) before your server load gets to something around 2 to 5.

When the server load drops under 2, the script then can restart the server.

By doing this, you save a lot of headaches especially if you get “digged” or simply need the site up as much as possible.

Believe it or not, there’s no script that does this available free online so I made one for all you webmasters:


#!/bin/bash
loadavg=`uptime | awk ‘{print $9}’`
RESTART=”/sbin/service httpd restart”
# bash doesn’t understand floating point
# so convert the number to an interger
thisloadavg=`echo $loadavg|awk -F \. ‘{print $1}’`
if [ "$thisloadavg" -ge "5" ]; then
echo “Busy - Load Average $loadavg ($thisloadavg) “
httpd -k stop
elif [ "$thisloadavg" -le "2" ]; then
echo “Okay - Load Average $loadavg ($thisloadavg) “
pgrep httpd
if [ $? -ne 0 ] # if apache not running
then
# restart apache
$RESTART
echo “restart!”
else
echo “no restart!”
fi
else
echo “waiting…!”
fi

Save this code somewhere such as /root/checkload.sh.

Then add the following to your cron job.  (/etc/cron.d/sa-update for Fedora Linux)

*/1 * * * * root sh /root/checkloadsh

This will run the script every 1 minute to check the load and if load is too high, web server will be turned off, if it’s lower than 2 and web server is off, it will turn the web server on.

There’s a lot of things that can go wrong with your web server whether from extra traffic or whatnot, but this script will be handy and I do recommend it to anyone who’s having trouble with high-load web servers that go down often. (like this blog)

Now, go install this script, you will never have to worry about your web server dying from high load ever again.

You can also change the value of “2″ in the code to something higher such as 5 or 10, which will wait longer to shut the web server off if load goes high.

I didn’t write the code from scratch, I took 2-3 different scripts and mixed it up so here’s the resources I used for the code:

Load Average Script - This one is the main skeleton I used

Check/Restart HTTPD Script - This one I used to check HTTPD server before trying to restart it.

Cron Task Scheduler - I keep forgetting that the most left number is the minutes, darn.

NOTE - This is a simple solution to keep your dedicated server running on 1 server (like this one), if you can afford more servers, you will need to resort to load balancing the “servers”, load balancing here refers to balancing within 1 server.

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 2.33 out of 5)
Loading ... Loading ...


Linus Torvalds - Software is like sex: it’s better when it’s free

Posted in A+Featured Entertainment, Computer, Consumer, Cool, Educational, Entertainment, Funny, Linux, Ubuntu by max on the September 22nd, 2008 at 5:05 am

I remember first hearing about Linus Travolds back in the early 90s and I thought Linux was going to be a hit in year 2000.

Well, it turns out I was right, just about 10 years early.  You have to admit, Linux is really taking over the world right now with web servers (including this one) and Eee PCs and other laptops that come loaded with Linux.

Anyways, I don’t want to bore my readers, here’s the 15 Great Quotes from the Linus Travolds and Stallman:

1. “To be able to choose between proprietary software packages is to be able to choose your master. Freedom means not having a master. And in the area of computing, freedom means not using proprietary software.”
-Richard M. Stallman

2. “Software is like sex: it’s better when it’s free.”
-Linus Torvalds

3. “Value your freedom or you will lose it, teaches history. ‘Don’t bother us with politics’, respond those who don’t want to learn.”
-Richard M. Stallman

4. “Software patents are a huge potential threat to the ability of people to work together on open source. Making it easier for companies and communities that have patents to make those patents available in a common pool for people to use is one way to try to help developers deal with the threat.”
-Linus Torvalds

5. “If programmers deserve to be rewarded for creating innovative programs, by the same token they deserve to be punished if they restrict the use of these programs.”
-Richard M. Stallman

6. “One of the questions I’ve always hated answering is how do people make money in open source. And I think that Caldera and Red Hat — and there are a number of other Linux companies going public — basically show that yes, you can actually make money in the open-source area.”
-Linus Torvalds

7. “Control over the use of one’s ideas really constitutes control over other people’s lives; and it is usually used to make their lives more difficult.”
-Richard M. Stallman

8. “It just makes it even harder for people to even approach the (open source) side, when they then end up having to worry about … public humiliation.”
-Linus Torvalds

9. “I founded the free software movement, a movement for freedom to cooperate. Open source was a reaction against our idealism. We are still here and the open-source people have not wiped us out.”
-Richard M. Stallman

10. “When it comes to software, I much prefer free software, because I have very seldom seen a program that has worked well enough for my needs, and having sources available can be a life-saver.”
-Linus Torvalds

11. “If you focus your mind on the freedom and community that you can build by staying firm, you will find the strength to do it.”
-Richard M. Stallman

12. “Anybody who tells me I can’t use a program because it’s not open source, go suck on rms. I’m not interested. 99% of that I run tends to be open source, but that’s _my_ choice, dammit.”
-Linus Torvalds

13. “’Free software’ is a matter of liberty, not price. To understand the concept, you should think of ‘free’ as in ‘free speech,’ not as in ‘free beer’.”
-Richard M. Stallman

14. “I’m doing a free operating system just a hobby, won’t be big and professional like gnu for 386 (486) AT clones.”
-Linus Torvalds

15. “Once GNU is written, everyone will be able to obtain good system software free, just like air.”
-Richard M. Stallman

via junauza

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


DIY iPhone HACK - How to get Free Online Magazines!

Posted in Consumer, Cool, DoItYourself!, Educational, Entertainment, Gadgets, HOWTO, Hack, cell phones, iPhone by max on the June 11th, 2008 at 11:02 pm

Well, here’s another cool hack that lets you get free online magazines using the same hack to get free wifi at Starbucks.

You have an iPhone, or the handy User Agent Switcher for Firefox, there are a couple of sites that offer free digital versions of several popular magazines. I guess the idea is to try and capture email addresses, but you can cancel through the input boxes and get straight to the content fairly easily.

If you are using Firefox, you can fake your browser into reporting itself to web servers as an iPhone by downloading User Agent Switcher and adding an “iPhone” entry with the following user agent string under Tools->User Agent Switcher->Options:

Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419 (United States)

Once you’ve switched to that user agent profile, most sites will think you are browsing from the iPhone platform and display the content that is targeted to that device - in this case, free magazines. The two sites that provide magazine content targeted to the iPhone are:

  • http://iphone.texterity.com/magazines/
  • via hackszine

    , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...


    Top 10 Reasons Why Linux will be on every PC in 10 Years!

    Posted in Computer, Consumer, Cool, Gadgets, Linux by max on the June 5th, 2008 at 3:09 pm

    1. Linux is free, open-source platform operating system that’s being developed by engineers all over the world.

    2. Linux is not 1 operating system, there are hundreds of different Linux systems including embedded Linux.

    3. Google is supporting embedded Linux for mobile phones with its Android platform with thousands of app builders.

    4. In 5 years, all desktop applications will be available online, there will be no need to use Microsoft Outlook, Word, or any of that shit.

    5. Linux is already taking near 50% market of mini-notebooks, netbooks, whatever.

    6. Linux is now picking up more pace with major manufacturers such as Samsung, Asus, etc…etc…

    7. Linux is unlimited, Windows is limited to EXE files.

    8. Over 50% of web servers in the world already run Linux, proving the stability of the operating system.

    9. Linux is about freedom, Windows is about Money.

    10. Mac already runs an operating system similar to Linux, based on a unix-like structure.

    , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...