Monday, May 10, 2010

How to download ASL wt DVD script

#!/usr/bin/perl 

my $year = 2010;
my $x = 0;
for my $month ( 1 .. 12 ) {
   printf "downloading month %s", $month;
   for my $article ( 1 .. 6 ) {
       $file = sprintf "%s_%s_%04d%02d%02d_%02d.m4v", "w", "ASL", $year, $month, 15, $article;
       next if -e $file and -s $file < 16;
       $url = sprintf "http://download.jw.org/files/media_magazines/%s\n", $file;
       print $url, "\n";
       system("curl -O $url");
       $error=$_;
       print "$error\n";
       system("rm $file") if $error =~ /No such/ or $error =~ /File not found/ or -s $file < 16;
    }
 } 

Thursday, May 6, 2010

Linux Resource Troubleshooting Commands

Command that reveal the inner workings of our machine

ulimit
free
vmstat
netstat
sysstat
mpstat
iostat
ping -c 1
traceroute 
sar

What is the process consuming the most CPU
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -2


What is the memory usage after 16:30 ...
   sar -s 16:30:00 -r
What is the disk paging after 16:30 ..
   sar -s 16:30:00 -B
Another day on I/O and mem usage
sar -f /var/log/sa/sa12 -u -n SOCK -B -r -s 15:30:00 -e 16:10:00

If you used previous versions of jvmstat you may be familiar with some of the older names... Here is a mapping of the old names to the new names:
JDK 5.0
jvmps is now jps, sse docs
jvmstat is now jstat
perfagent is now jstatd
jvmstat 3.0
visualgc is still visualgc