Server heartbeat

This little perl program allows you to check the availability of an IP address via a cron command that outputs the result in a text file.

#!/usr/bin/perl
# This script pings IP addresses
#
# In a live application, read host list
# from a config file
@hosts = ("192.168.1.1","192.168.1.19");
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$mon += 1;
$min = sprintf("%02d", $min);
$sec = sprintf("%02d", $sec);
$mon = sprintf("%02d", $mon);
$mday = sprintf("%02d", $mday);
$year = sprintf("%02d", $year % 100);

@live = ();
foreach $h (@hosts) {
        $r = `ping -c2 $h`;
        if ($r =~ /2 re/) {
                push @live,$h;
                }
        }
$alive = "@live";
print ("You have $alive on $mday $mon $year @ $hour:$min:$sec\n");

This script can then be used in a cron like:

*/5 * * * * /path/to/file/pingtest.pl >> /some/path/pingtest.txt

This command will write the result on a new line in the file called pingtest.txt every 5 minutes. Which will look like that:

You have 192.168.1.1 192.168.1.19 on 06 01 13 @ 20:05:01
You have 192.168.1.1 192.168.1.19 on 06 01 13 @ 20:10:01
You have 192.168.1.1 192.168.1.19 on 06 01 13 @ 20:15:01

Plesk panel, backup strategy when low in space

Plesk backup is a real pain in the backside, if your server disk space is limited, even when choosing to backup in a ftp repository. All the files are created locally and then send over via ftp.

Prerequisites

Note that in order to implement this backup strategy, one must have an external backup space available like rsync.net (which I use) so that you can use the “rsync” command to transfer your files.

Minimising disk usage

In order to exclude any gigantic compressed (or not) archives being stored in your local hard drive, here is a little guide to help you avoid filling your server disk.

The first thing to backup regularly is the Plesk server configuration, this backup will not save the websites/email/database data but the content/configuration of your Panel, which is the first thing to restore if your server packs up.

Backing up Plesk (11) configuration

  1. Open your Plesk Panel as Admin
  2. Choose Tools & Settings from the Server Management sub-menu
  3. Click on Backup Manager
  4. Select Scheduled Backup Settings
  5. Activate the scheduled backup
  6. Select Store backup in: Server repository (or you can chose ftp there also as the files aren’t big, a couple of MB’s)
  7. I have set the Maximum number of backups in repository to “3”, but you can choose another value here
  8. Under the Backup content section, select  “
  9. Press OK

Obviously the choice of Schedule and prefix is at your convenience, I personally back up every day at 00:10 and the prefix is set to “configuration”.

If you aren’t using ftp, the content of this backup is stored in the /var/lib/psa/dumps/ directory. So in order to backup this on another server, simple rsync this location with a command that could be:

rsync -avz /var/lib/psa/dumps/ user@domain.rsync.net:var/lib/psa/dumps

If you don’t want to keep aggregated data add the –delete option:

rsync -avz --delete /var/lib/psa/dumps/ user@domain.rsync.net:var/lib/psa/dumps

To automate

To automate all this simply stick it in a cron (one can use the “Scheduled Tasks” under “Tools & Settings” (select root user) with a command that could look like this:

nice -20 rsync -avz --stats --delete /var/lib/psa/dumps/ user@domain.rsync.net:var/lib/psa/dumps 2>&1 | mail -s "backups dir rsync report" you@youremail

Databases

I will refer to MySQL databases in this section.

Database content is important, and you must back them up regularly, be it incrementally or not. I have Perl scripts that are in charge of dumping the content of the entire dataset and compress it. The file for my setup ends up being about 300MB, which is acceptable. I proceed to dump the content of the dataset via a “schedule” (root cron) and another cron simply “rsync’s” this file over to the backup server.

Email

All the email accounts are in /var/qmail/mailnames, the process is the same as above, use a rsync via a cron:

rsync -avz /var/lib/qmail/mainames/ user@domain.rsync.net:var/qmail/mailnames

Website content

Same as email but the directory is /var/www/vhosts/ so:

rsync -avz /var/www/vhosts/ user@domain.rsync.net:var/www/vhosts

There you have it, obviously I am providing this entirely as guidance and will in no way be liable for any loss you may get using these instructions. Even if you are on a cloud server (like me) it is a good idea to be able to extract files, especially databases or web content should a mistake be made that a cloud server cannot prevent like deleting a site by mistake etc…

Feel free to comment if you have any questions or if I have missed some important bits to backups that a Plesk backup may make which aren’t in this article.

Thunderbird: There was an error saving the message to Draft. Retry?

There was an error saving the message to Draft Retry? = Crash

A nagging problem has really made me crazy today, so much so that I finally decided to fix it. As usual this problem is probably not common, basically I could not save messages in the draft folder on one of my accounts. I don’t usually use the Draft folder, however Thunderbird does, automatically, try to save messages into draft after a set period. Having a problem saving to draft always led me to lose very long messages for ever (having to restart the whole thing really did it for me!). So  I tried the following:

  1. Compact folder (a popular one for Thunderbird users)
  2. Changed the folder permissions
  3. Deleted the folder and the Draft.msf file
  4. Repaired folder (under folder properties)

None of the above worked.

The fix

So if this happens to you also, this is how I finally fixed it:

  • Closed Thunderbird
  • Created a new folder under the Mail directory
  • Changed the local folder in the account settings > server settings in Thunderbird to point to the newly created above folder.
  • Copied the content of the old folder to the new one (I omitted  the Draft folder  and draft.msf file though, they were empty – remember I could not save into it)

Restarting Thunderbird made the problem go away. Finally!

 

Website layout and content best practice

In view of a recent article regarding the situation of websites rankings on major Search Engines, particularly Google. I think it is time for me to digest most of it and get some sound bites out for reference.

This article will treat both causes and effects relating to SEO and good website content, there are no secret recipes, just plain common sense. Unfortunately, common sense tends to go out of the window when a few simple facts are apparents:

  1. The website is designed using WYSIWYG editors by an non coder
  2. The website is not HTML Compliant
  3. The website is full of typos and makes no sense
  4. The website is lacking good honest real information humanely readable

Let’s not kid ourselves, Search Engines, any search engines, haven’t got the clairvoyance of a human reader, yet the situation is quite comical in a way, as most people scan a web page in a hurry to find the next thing they’re hunting about and you work towards making a website “scan-able” but wait, you have to expect a Search Engine to understand what that web page is about and serve this page to a visitor looking for that specific information whichever it may be.

It is no surprise that people behind search engines are seeing that quality is important, so by using these criteria, a new era of website craftsmanship is [back] upon us; it is time for people that know how to design websites to harness their powers as devised by the creator of the world wide web: Tim Berners-Lee.

Put simply:

Write compliant and correctly spelled web  content which makes sense.

That’s it. Combine this with your niche market and you should be all good (well… not bad).

Know your HTML and the rest

Yes folks, that means you must at least know your HTML from your CSS and JavaScript and be able to write clean code, so that alienates how many % of the Industry? What about those “free website templates” resources and the like… I don’t reckon these will keep on going or will they? Come to think of it, they probably will, but not to worry!

If you knew how much I laugh sometimes when I look at some web pages source code you’d laugh with me. I recently came across an SEO company that had their own website entirely designed in Flash. I kid you not!

Knowing HTML coding [I do all my websites in native code] allows you to also know exactly what the optimal hyper text mark-up language for the page is. Obviously Search Engines like that (why wouldn’t they?).

Untie style from content, have a  separate CSS file and don’t clutter the page with on-page styling. Well you might let the  non-coders do their stuff and then clean afterwards for them, bless.

Know your grammar

Anyone can type text as long as they’ve got the right tools, well unless they’ve got a problem with reading and writing in the first place, the tools usually come with a spell checker, use them, and have someone else read after you. Sometimes staring at your own work hides things for all to see but you.

By having clean HTML surrounded by correctly written content is half the battle, at least you can rest happy that all the badly spelled and written websites can only behind yours in the Search results (Although the purists would tell you that it actually makes sense to exploit the mistakes made by others).

Know what and how to write

This probably is the most important aspect of a website content, years ago it was common practice to emphasise keywords with bold and use a lot of Header title tags including purposefully key-worded links within a tight number of words per page to maximise your ranking. Today I am not sure it is as relevant, Search Engines algorithms should be considering these as spam anyway. So I think that if content quality is more predominant than in the past let’s scrap the rule books and start to write web pages with the “scan” factor of the reader in mind whilst providing the “understanding” factor of the Search Engines algorithms, that alone is a tall order you might say, however people in the know simply know this, period.

To summarise: write clear content that makes sense with heading titles in the right order and meaningful sentences within properly defined tags containing all the required (and non-required) attributes allowed.

The importance of linking

Back links are (still) hugely important. However if these links are placed on irrelevant pages it makes no difference, you might just as well have none. So link build wisely my Friend. Also I think the emphasis on websites that actually link to other reference content (especially when the originating site may look like a reference in itself, right?) will be more pronounced. So don’t be afraid to link to relevant content (or irrelevant if it is required, you can still do that!). Don’t simply accept any links that are to be pasted on your “Links” page any more, in fact I would scrap the links page all together.

Be unique

And that does not just mean write your own stuff but design your own unique site as well (or have someone like me do it), be it HTML 4 transitional or XHTML 1.0 Strict does not matter, using DIVs or TABLEs does not matter. On a side note I would say that web 2 stuff should be avoided for important bits like navigation and so on (unless it degrades gracefully), as long as your code is in good shape but not replicated on 1000’s of other websites (funny that we’re getting back to free websites templates again) you should be all good.

Check and re-check, don’t forget to check again..!

This is the most important bit, HTML, Copy Writing, Spelling, Titles, Keywords, Descriptions, Alt tags, they all matter.

Other aspects worth noting

Apparently the Geo-location of your site is somewhat quite important too, so if your market is for Fish and Chips Take Away for the British market don’t host in the US for example, host in the UK. If you can host in various countries do it you can get hosting for next to nothing, but remember to target the market, mirroring your own site will not do.

Host your site on a fast server. Most people (I am one of them) aren’t going to wait around more than 4 or 5 seconds looking at a white page of a sluggish site, Personally I am gone in less than that, again, Search Engines would probably consider that to be showing signs of bad design and/or lousy hosting service and by doing so reducing the quality of your own business in the process.

If you are providing a service, for God’s sake, PROVIDE all of it, that means being there for your customers, don’t necessarily provide a phone number if you don’t want to be called at 2am in your home business phone line, but reply to your customer in a timely manner, and keep them updated at all times, you’ll be amazed how much good that does to your reputation, and that gives you another edge against your competition, you need it, remember?

Social

Be active on social websites with news and updates regarding your business, you may have the same news replicated on your own site, but keep the site for a formal type of news and loosen up a bit on Facebook or Twitter, it’s almost a full time job (I know! but I am lucky I am not the one doing it. :-)). It might be good to have a Like button on your website, I have developed a JavaScript code that I simply stick into an “include” and the JavaScript does the rest… I don’t have to worry about the link not being seen by S.E. as I think the social website’s got enough incoming already and Search Engines probably disregard that. But don’t stop there, keep your clients, followers and friends in the loop as well to make them remember you.

If you have a mailing list you must use that, however email being so elusive and seen as a spam harbour that, one day, it might not proving to make marketing  sense any-more. So using social networks make perfect sense, but obviously it does not mean that these are mutually exclusives, far from it.

Use the power of youtube, get an HD camera (there are very good and quite cheap ones now) and take the time to make a video promoting your business, it does not need to be fancy, make sure the shots are steady enough (use a tripod) and video editing software, if it is too complicated for you, hire someone, do it as it makes you stand out more than those who haven’t got a video, that also is probably a criteria for Search Engines Optimisation.

How Exciting!

Just added a new Plugin on this Blog to enable me to be more creative. I am still experiencing with it. I am glad to see that one of the biggest issues with CMS systems is still their level of complexity.

The most important barrier to past, modern and future technologies is simplicity and foremost usability and ability to remember how it works. In 2001 that was when I saw a website called Superupdate, now Hannon Hill advertising their CMS, I looked into it, it was relatively simple. So I though, I can easily do that even easier and simpler and created my own CMS system A very simple system, so simple that It is for people that are barely able to use Computers at all. Most of these people being the mature generation,

This is not a problem for things that you’re using all the time like Smart phones (well how much do you actually know about the phone you’re using? Do you know for example it’s got a feature allowing you to make phone calls). It’s more like when you tend to not do it often and you’re not an Internet Guru, let alone a PC wiz kid. For most people having or managing a website is not necessarily something they do on a full time basis. like the chairman of a Club or a charity or a one man business. That is my target market. My website design site provides an unique design plus the ability to edit the pages easily and fast without having to hold a degree in Computing Science. My clients only contact me when they need technical assistance, it works because it is KISS.

WordPress

This CMS system is quite good I must say, (the one that I used to create this content.), it is relatively simple, the strategy is working great especially the Plug-In system, although I must say that I struggle, it’s getting too complicated for me already.

How Exciting?

Now the reason, finally, of my excitement is that when you are using WordPress you tend get a lot of spam messages (well this site does). I am happy to announce that on this front there’s  been a development, with the use of a Plug-in called Spam-stopper which is the easiest one ever. I have yet to receive a single spam comments 🙂 or any comments at all for that matter.

Fruit shopping

As I went to get some fruit from my local Supermarket, I decided to take a look at their Country of origin, the Bananas where from Colombia, the Apples from Brazil the Corn on the  Cob from Portugal and a salad from Morocco.

There were no British Fruit, This is hardly promoting local Producers. It is amazing that despite the transport cost, it still make sense to have most cheap products imported from half way across the World than help the economy by buying and producing British. But ah, there’s a problem, buy British and face a sensible increase in price. Yet the economy is on its knees, no-ones buying local produce and no-one’s getting paid …Once in the hole….

I recently bought very cheap (and very good when Barbecued) Lamb steaks, coming from New Zealand, dear Lord! My regular Bacon is from Denmark thank God(!), not too far off then. I buy British, sorry, Scottish Chicken*, which is less than half what you’d be expected to pay for a similar one in Switzerland (yet the price of milk is about the same).

I decided to get my Free range eggs from a local Neighbour like I used to do a couple of months ago, the eggs are really good and they charge £1.50 for half a dozen. Try you get “as good as” Eggs in a shop at that price since January this year.

But the plans is really to get my own Hens and have my very own Free Range Eggs in the not too distant future.

I think I will start to grow my own, again… We should all do. At least we’d have more money for Fuel. Now how much is recycled plastic sheeting?

*And very good too with Roasted Potatoes (which are also Scottish phew).

The situation on planet Earth, especially Europe.

I have been pondering about Europe, Syria, Scottish independence and I think that there’s a lot of stuff I learn through the media and always think, based on that, what do I think about  all this?

Well, Europe’s at a crossing point, the future is “apparently” bleak and the UK Government has taken “contingency” plans to prevent influx of non longer European migrant from Greece and other possible countries likely to break up from the Eurozone.

That’s all media reporting. Europe is at a critical point but it’s not really sunken in that everyone’s into it: We’re still paying for the mistake of the past, Banks like the England’s one still trying to pump money into the economy to try to keep a system afloat that is controlled by mathematicians tweaking their computer program algorithms to extract every single bit of profit from the “hunt”.

Let me rephrase that:

Once in the hole, stop digging

Yet that’s exactly what’s happening at the moment. Europe as we know it is doomed, there’s a lot to contend about the Greek government, yes I hear that people in Greece try all to avoid paying tax if they can. The Greek people are amongst the people that work the most hours in Europe.

These people make the economy what it is. Their transactional policy is cash, probably more than it is elsewhere in the EU. it’s not hard to confirm that the Greeks are simply using cash more than other, still they work hard for their money and the price of everything is well known to them for sure, more than can be said about people in any other EU countries, it’s not a secret that Tax is not really coming into the equation with cash.

So can they be all lazy? come on! Think about it, they still need to function, they’re people like us, living a life like us, they’ve just been profiting from the boom as well as we all did, however they’ve not been too lucky and, what would it be if it wasn’t the job of the Government to make sure it didn’t happen? When I see the head of Government of Greece he doesn’t look like he’s been depriving himself has he? The guy can barely move in the hot Greek weather so unfit and fat he looks. That one of the problem; European bureaucracy has brought so much red tape, subsidiaries and other help, yes to make it easier to trade on the wider area that is Europe, but at what cost? visibly a ruinous one.

Let’s not kid ourself, it’s a time to start to see that the system is wrong and needs to be corrected. The German people, again show that they’ve got it sorted, it’s a bit like Europe is only Germany at the present time, to be able to bail so much money to other, at VERY high risk is showing real community spirit, almost like communism.

Syria

Syria’s a nightmare, It’s not Libya, there’s a lot of affinity with the West for many aspect not least Israel. A hot pot of pro American policy and yet people are massacred in their very own streets? Where does the blame lies? The Government, the rebels? I am unsure. The neighbouring Liban is starting to become unstable again, it’s worrying.The UK Prime Minister must know something that we don’t when he recently commented about the “dreadful regime” in Syria (Hein? Quoi?).

Also Iran not being far away, can only add more fuel to the fire, Egypt’s also moving toward People elected Government, I say Bravo, a country where people decided to take their destiny in their own hands.

Scottish independence

I am not Scottish, so I can’t decide. I think it’s risky, very risky, it can pay off in a big way with Scotland becoming able to use the Euro currency to trade with the rest of Europe. But hang on, the European system, with its single currency is no longer, well not presently, a viable route, so what are the Scots going to use for currency, the £ Sterling?

If the people of Scotland (that’s interesting to see what the Greek people are going to decide about staying in Europe, apparently most of them are willing to.) decide to indeed go independent, I say go on, however somehow I  think, that it would be wise to look into  past similar experiments for lessons to learn.

There’s a apparently 75 years period before history tends to repeat itself, well at least Adam and Eve are far enough to have been forgotten (Really?!). So where are we at? 2012-75= 1937, two years before the second world War, funny that we’re 4 year in a crisis, does not seem that it has been so long has it? But I digress. Funny too that This time its not land but money that created this mess and Germany rules again (?!) and the worst is yet to materialise. Sounds familiar

Afterthoughts

As a Swiss Citizen, I am however able to say that us Swiss, have been independent for 721 years, we’ve build a nation of high working with high core values. (I have read references as “mildly repressive”, give me a break!) people that take work as a passion with high rewards, Switzerland is one of the wealthiest nation on earth and it’s one of the tiniest as well, (Hey Scotland take note) .

Ok, ok, I hear you say “the second World War, the Nazi Gold, the Bank secrecy…” Are we to blame for doing a good job at everything that we do? Is it our fault if people in other parts of the World (rightfully) see this a a safe place with lots of advantages (the fiscal one being a prime example). Sorry for just being too good at minding our own business(es) when it comes to minding others.

Switzerland’s a unique World experiment where everything is “propre en ordre” (clean and in order) where everything is just the way and what it should be. The people decide for everything if enough of them feel like it is worth deciding in the first place, it is called Direct Democracy, sorry wrong link: here it is Direct Democracy.

So when it comes to all this, I think that Europe, like Communism, Capitalism and whatever else is a very good idea really, but it’s not really working in practice. Man has always been driven by survival, survival of the fittest. Somehow there’s a strange connotation with what we’ve been, we are and will be experiencing in the inexorable advance of that elusive particle, time.

Bootnote

As far as 1996, some Analyst thought that the idea of Europe and the single currency was a good idea in theory, but in practice, as Europe was becoming less industrial, the idea was out of date, that is why Germany is very good for the European system, others like the Greeks aren’t. So let’s rework this coherently.

Besides I am also looking forward to what’s going to happen with that French President? I will not be surprised if he falls flat on his face (désolé Monsieur Hollande, pardon, Mr le Président, rien de personnel).

qq trouble in home directory (#4.3.0) Plesk 10

A recent problem appeared on my system, an emails address was refusing emails sent internally and a message was coming back immediately (if using a mail client like Kmail or deferred if using a webmail service like Gmail):

451 451 qq trouble in home directory (#4.3.0) (state 17)

Searching for this problem on Google does not return much. however I tried to do the steps of switching from Qmail to Postfix based on BStar’s Code Snippets experience.

After changing from Qmail to Postfix, I could not do the reverse immediately (Plesk install returned an error I was using the CP)

This changed the problem to state that the mailbox was full. Yet funnily enough the recipient in question had no Mailbox, only a redirect.

In the end I had to remove the mail account and re-create it as before. since then all is back to normal.

I also managed to switch back to Qmail using the CP afterward.

File access PHP on Plesk

On certain occasions, and if you’re running Plesk on a dedicated server (like I do), there are certain problems with file access and other upload permissions which aren’t allowed unless you turn file permission to 777!

Obviously this isn’t the recommended way to operate a website, turning directories and files all open with rwx is kind of risky.

So I have found a solution that works everytime, simply change the “PHP Support” to run as “FastCGI Application” instead of the default “Apache”. This option is found under the Hosting setting of the domain.

I must point out that this hack only works if you’re running Plesk (10+) on Linux Servers.

Wind power

I am beginning to wonder if this wind turbine mania is going to be a regrettable experiment in years to come. I am currently located in an area where they seem to be sprouting like mushrooms.

I am all in favour of natural progression of human kind and preservation of natural resources for future generations, so wind power is a good idea as such, however I am not sure that this will turn out to be such a good strategy once most of the country has more wind pylons than trees, and by the look of it it’s not going to take long.

Let’s wait 20 years from now and see if the result will be like other “big investments” that turned to be detrimental in the long run. I for one think it’s going to be one of those “money spinners” that made sense at the time but turned out to be a waste of money in the end.