Posts

Showing posts from November, 2018

Running Concurrent Bash Scripts and TasksMax Settings

Image
For a long time, I had an Expect script to login network devices, fetch information and put the output together as a Web page. Think of it as a script checking router version, memory etc. It took about 30 seconds to finish checking a single target and would take hours to finish scanning several subnets. Finally I think it is time to parallel these tasks so the whole scan could take the same time as scan only one device (etc. 30 seconds versus hours).  And is excited to find out the simple and powerful usage of xargs -P option. Here are man xargs result regarding -P:     -P max-procs, --max-procs=max-procs Run  up  to  max-procs processes at a time; the default is 1.  If max-procs is 0, xargs will run as many processes as possible at a time.  Use the -n option or the -L option with -P; otherwise chances are that only one exec will be done. Put together into my small script: #!/usr/bin/bash echo >/tmp/list subnets="192.168.4...

Tracking Traffic using Google

Image
I hate traffic so almost every night I would check traffic to home on Google Map before leaving work. It has saved me several times from stuck in traffic jam but  occasionally I forgot to do so and then found myself driving 20 mph in the highway. So one day I thought about this and decided to write a small AJAX script to update the traffic status in the front page of my Web browser every minute. Then by saving the data (from Google Map) and incorporate into Google Chart (thanks!), I got a daily traffic chart going on to monitor traffic both ways between home and work.   Now I have about 4 weeks' of data and here are some observations: Base time : ~ 20 mins between Home and Work when there is no/light traffic Rush hours :  Morning rush hour ( when traffic >30 mins ) is always around 7:20 to 10AM in weekdays Afternoon rush hours , however, starts about 20 mins earlier everyday from Monday to Friday, so it appears people have more work on Monday Mo...