Archive for category Uncategorized

Nothing compares to a traditional tubewell!

What do you guys say? Yea, don’t expect mangoes when you plant papayas.
So, this weekend was really exciting. Had a chance to visit our village with brothers. The most enthusiastic part, of course, a bathe in the traditional tubewell. No matter how advance technology has gone through, no mater what stylish wadding pools you’ve – if you’ve once been under the sheer burst of cool water being pushed from the heart of earth and then pressuring your skin, you’ll be blown out of your mind and would forget modern swimming deluge. If don’t know what it is, it’s just a modified form of a motor water-well pump with a small or large housing reservoir built out of it to hold water for a while but having adjusted drainages that keep water fresh while it flows off to fields to irrigate them, which of course is main purpose of having any pump in village fields.

Ours is just in the middle of mango trees’ garden and it makes the whole adventure quite more fascinating than fun, it sounds :D The borehole of well is more than 150 feet and seeing it from top makes your vision a bit dizzy and you can fall off right into it if you’re seeing by bending yourself. I’m afraid of heights but that doesn’t mean I may also be afraid of depths (holly shame-o, lol) but that’s exactly this level of depth does. It’s illusionary. So, I had to sit down, pull my hand above this 20′ diameter of wide-open hole and take a snap from there, lol :D But that’s not much scary if you go down by downstairs’ side. Pump that throws water up is a 4HP.

There’s small sort of control room out of it that’s closed most of the times unless there’s a problem. In summer it runs all day usually! Then there’s when fun begins. When you put your head under full speed blowing water, you get your ears and nose full of water. As water in reservoir was full up to my neck and above all its floor was slippery, I really cannot withstand compelling force of blazingly cold water and fell off couple of times. Hilarious but funny as hell! Check out rest of the snaps, while I try to find out a way of eating these mangoes floating on icy water in this bucket. You really don’t get mangoes if you seed papayas ;) !!!

, ,

4 Comments

Highly transparent Squid proxy.

Most of the times you don’t want to show off the proxy server reference in your web requests despite the fact that it’s main purpose of any proxy software, for many reasons. With Squid 2.6, its quite easy to do. Add this to squid.conf.

via off
forwarded_for off

And then the below ‘via’ entity would disappear from web header requests being sent from a web browser making recipient webservers unaware of the intermediary proxy location, you’re coming from!

, ,

No Comments

Crontab and Unicode Characters

Crontab in Linux likes to keep its own shell environment and this can really cause frustrating problems with output of your cron jobs if they don’t get fixed as its too much ironic to see not the same behiviour of your shell scripts when they are run in crons than to what you normally see in a bash.

I was running a script that included a few of other scripts and it was not showing unicode characters properly when it ran as in a cron. Solution is to include ‘export LANG=en_US.UTF-8′ in your shell script but the ideal way to do so I found was to pass on this environment variable directly in command parameter of a cron job.

The unicode character that was missing earlier ‘degree‘ symbol became visible as soon as I added the variable LANG=en_US.UTF-8 to crontab’s command.

# crontab -l
MAILTO=""
57 9 * * * LANG=en_US.UTF-8 /root/back/hdd-report/report

2 Comments

Linux System Variables

Ever wanted to list down all of system built-in global or local variables stored for your shell? Well, it can be with ‘env‘ and ‘set‘ commands.
The env lists global variables and set lists local ones. Difference between the two is that, global variables are built-in into any shell while local variables include the ones which are set by different applicatons. Such as MAILCHECK (which controls mail checking frequency and informs shell prompt when new mail arrives), only appears in ‘set’ command’s output.

,

No Comments

Expanding the C: drive (system boot partition)

So, I ran out of space on system partition in one of my primary xen virtual machines. Yea, things like this happen quite often when I literally underestimate myself. Unlike Linux, in this case there’s no power of init which lets you expand an LVM or move a system partition to new disk even without going through any reboots. I guess Microsoft realised that its an important option Windows should have so they provided in Windows Server 2008 and Windows 7 under Disk Management with an on the fly ability to either shrink or expand a system volume. But still its a painful risky process in XP or Server 2003. I’m familiar with third party softwares that help in resizing the partitions including GParted but like always I like to follow vendor supported methodologies on production machines. And it was ‘diskpart’ here. Booting the system from a Server 2008 / Vista DVD’s recovery tools or from WinPE, you can use diskpart. But first things first – there are three requirements you must have before going ahead.

  1. Free space should exist contiguous right after the system partition
  2. That free space partition must be of ‘primary’ type and must not be a logical partition.
  3. It should also be in ‘unallocated’ or deleted form without an existence of a ‘drive’ on it.

I had 10Gig C: and D: drive on a 20Gig of a disk. Added 10 more from XenCenter totalling into 30. As I needed a primary unallocated partition after C: drive so I had to use robocopy to backup the D: drive’s data into a network samba share, format and then split it into one primary and one extended partition.

Legends:

Red = Total system drive space before and after the expand
Blue = Total free space on disk before and after expand
Green = Commands issued.

, , , ,

No Comments

Error Logging to Console

Sometimes when some applications start logging to console, it can really bleed your eyes when something wrong happens. Not mentioning about standard output or standard errors which are rather easily controllable but it could be anything else invoked by kernel such as iptables logging when you  would like to log any rules to a log file or default syslog. But “hideously” such applications log to system console too and can surprise you when you plug monitor and see a messy mesh of error loggings all the way back and forth, specifically when a machine is virtual – of course in that case VM would be unresponsive ;)

I was trying to look into syslog.conf to control but found out that this is not what a syslog daemon has dominance over; in fact, needs kernel-level  logging modified. And this can be done through either of these ways.

Instruct kernel to log only “errors” instead of informational notifications.

Controlled by ‘printk’ kernel parameter. Defaults are:

# sysctl -a | grep printk
kernel.printk_ratelimit_burst = 10
kernel.printk_ratelimit = 5
kernel.printk = 6    4    1    7
# find /proc -name '*printk*' -exec cat {} \;
6    4    1    7

Just change ’6 4 1 7′ to ’3 4 1 7′.

# echo "kernel.printk = 3 4 1 7" >> /etc/sysctl.conf
# sysctl -p

Documentation goes over here, if you’re intrested /usr/share/doc/kernel-doc-2.6.18/Documentation/sysctl/kernel.txt

printk:

The four values in printk denote:
 console_loglevel,
 default_message_loglevel,
 minimum_console_loglevel and
 default_console_loglevel respectively.

These values influence printk() behavior when printing or
 logging error messages. See 'man 2 syslog' for more info on
 the different loglevels.

- console_loglevel: messages with a higher priority than this will be printed to the console
 - default_message_level: messages without an explicit priority will be printed with this priority
 - minimum_console_loglevel: minimum (highest) value to which console_loglevel can be set
 - default_console_loglevel: default value for console_loglevel

Definitions of kernel logging numbers, from Syslog’s manual:

#define KERN_EMERG    "<0>"  /* system is unusable               */
 #define KERN_ALERT    "<1>"  /* action must be taken immediately */
 #define KERN_CRIT     "<2>"  /* critical conditions              */
 #define KERN_ERR      "<3>"  /* error conditions                 */
 #define KERN_WARNING  "<4>"  /* warning conditions               */
 #define KERN_NOTICE   "<5>"  /* normal but significant condition */
 #define KERN_INFO     "<6>"  /* informational                    */
 #define KERN_DEBUG    "<7>"  /* debug-level messages             */

Change kernel ring buffer logging level

Just keep in mind, using this approach only limits console logging and issuing dmesg would still print the over all logs.

# dmesg -n 3
or
# dmesg -n 4

No Comments

Raid tricks

Increasing the rebuild speed

Sometimes when you’re quite lazy or bored and don’t like the noticeable amount of free resources on your server, you may like to increase the raid building and resyncing process speed.

# echo 250000 > /proc/sys/dev/raid/speed_limit_max
# echo 250000 > /proc/sys/dev/raid/speed_limit_min

And this would spin up the hards faster to their maximum extent saving almost half of the time!
Defaults were:

 # cat /proc/sys/dev/raid/speed_limit_max
200000
# cat /proc/sys/dev/raid/speed_limit_min
1000

And looks like my hards have 100M/s speed.

#hddtemp /dev/sda
/dev/sda: ST3750330AS: 31°C
# hdparm -t /dev/sda
/dev/sda:
 Timing buffered disk reads:  280 MB in  3.01 seconds =  93.09 MB/sec
 

Checking and repairing

The larger the hard drive is the greater the probability of having its blocks corrupted. Its better to check for consistency against any bad blocks or md superblocks.

# cat /sys/block/md0/md/sync_action
idle
# echo check > /sys/block/md0/md/sync_action

And if there are any, repair them.

# echo repair > /sys/block/md0/md/sync_action

Setting up RAID alerts to send emails about any errors

Red Hat family distros come with built in service daemon mdmonitor which runs ‘mdadm –monitor’ in a daemon mode.

# mdadm --detail --scan >> /etc/mdadm.conf
# echo "MAILADDR some-email-address" >> /etc/mdadm.conf
# chkconfig mdmonitor on
# service mdmonitor restart

Remember to add “DEVICE partitions” or partitions being components of an md array to top of file /etc/mdadm.conf.

Monitoring all RAID events and changing default email template

Last edited on: Tue Mar  9 11:41:38 PST 2010
Added the two new tweaks.

, , , ,

2 Comments