Admins eHow SysAdmin Tips & Tricks

March 13, 2010

Shell script to show network speed

Filed under: CentOS,Debian,DreamBox,General — Tags: , , , , , , , , , — admin @ 11:37 am

The following shell script shows current download and upload speeds for the network interface you choose.

Copy the shell script in a file named, i.e:

Then after setting execution permissions:

chmod a+x

You can run the shell script passing as the first argument the network interface you want to monitor:

./ eth0

You will get a line like that:
eth0 DOWN:15 KB/s UP:880 B/s

This script works parsing /proc/net/dev file and calculating the difference between current transmitted or received bytes and their values one second ago.


# This shell script shows the network speed, both received and transmitted.

# Usage: interface
#   e.g: eth0

# Global variables

# This function parses /proc/net/dev file searching for a line containing $interface data.
# Within that line, the first and ninth numbers after ':' are respectively the received and transmited bytes.
    line=$(cat /proc/net/dev | grep $interface | cut -d ':' -f 2 | awk '{print "received_bytes="$1, "transmitted_bytes="$9}')
    eval $line

# Function which calculates the speed using actual and old byte number.
# Speed is shown in KByte per second when greater or equal than 1 KByte per second.
# This function should be called each second.

    let vel=$value-$old_value
    let velKB=$vel/1024
    if [ $velKB != 0 ];
 echo -n "$velKB KB/s";
 echo -n "$vel B/s";

# Gets initial values.

# Shows a message and waits for one second.
echo "Starting...";
sleep 1;
echo "";

# Main loop. It will repeat forever.
while true; 

    # Get new transmitted and received byte number values.

    # Calculates speeds.
    vel_recv=$(get_velocity $received_bytes $old_received_bytes)
    vel_trans=$(get_velocity $transmitted_bytes $old_transmitted_bytes)

    # Shows results in the console.
    echo -en "$interface DOWN:$vel_recv\tUP:$vel_trans\r"

    # Update old values to perform new calculations.

    # Waits one second.
    sleep 1;


Source : Linux Clues

March 12, 2010

Axel download manager for dreambox (dm800)

Filed under: DreamBox — Tags: , , , , — admin @ 4:57 pm

From Axel Project official site :

Axel tries to accelerate HTTP/FTP downloading process by using multiple connections for one file. It can use multiple mirrors for a download. Axel has no dependencies and is lightweight, so it might be useful as a wget clone on byte-critical systems.

I found a working compiled version of axel download manager for my dm800.
You can download it from here : Click here to download axel mipsel
First decompress the zip file then put it in /usr/bin folder of your dreambox and make it executable and enjoy 🙂

March 5, 2010

How to sync dreambox date and time automatically

Filed under: DreamBox — Tags: , , , — admin @ 9:37 am

I could not find rdate or ntpclient packages for dreambox , so I came up with another solution to sync my dreambox date and time when it boots up.
First you need another server with synced date and time , so we can read the correct date and time from it. also we need a webserver and php installed on it.
Create a script named “dreambox-date.php” on root folder of your web server with following content :

echo date("Y.m.d-G:i:s");

Create another file named “03datesync” in “/etc/network/if-up.d” folder of your dreambox with following content :

date -u -s `wget -O - http://IP_OR_FQDN/dreambox-date.php`

Change IP_OR_FQDN to your own hosting IP and domain name.
Also make it executable :

chmod +x 03datesync

All done 🙂 Now when dreambox boots up and its network interface is up , the above script would be called and it syncs your dreambox date and time.

February 28, 2010

How to install nano on your dreambox

Filed under: DreamBox — Tags: , , , — admin @ 2:50 am

The bundled vi package with dreambox really sucks ! and I am a big fan of nano text editor , as always I was disappointed to find a rebuilt nano package in Gemini or even dreamboxupdate repos , so I searched the net and wonderfully found a nano package which works with my dm800 😀
instruction to install nano :

cd /sbin
mv mipsel-nano_2.0 nano
chmod +x nano

February 27, 2010

How to make your dreambox an automatic super downloader

Filed under: DreamBox — admin @ 9:22 pm

I am creating this post mostly for my own reference in future , the scenario is that my ISP gives me a free PPPOE username and password with unlimited traffic to download between 3am-7am and I didn’t want to keep my desktop PC up and running on midnights , so I thought I can make my dreambox which is always on an automatic midnight super downloader and after 24 hours of work , I accomplished it.
1.Create a file named “dl” containing the commands to download files in /media/sda (where flash disk is mounted) , format of file is :

wget -q -c "ftp://user:pass@ftphost/filename1" &
wget -q -c "ftp://user:pass@ftphost/filename2" &

2.make it executable :

chmod +x /media/sda/dl

3.edit /etc/ppp/ip-up and add the following to the end of file :

cd /media/sda
echo "`date` : PPPD IP-UP" >> /media/sda/dl.log

4.edit /etc/ppp/ip-down and add the following to the end of file :

killall wget
echo "`date` : PPPD IP-DOWN" >> /media/sda/dl.log

ip-up is automatically called when PPP connection is established. it starts all downloads automatically.
ip-down is automatically called when PPP connection is disconnected. it stops all downloads automatically.
5.Create monitor-pppd in /media/sda and put the following inside it ( also make it executable ) :

if [ ! -e "/proc/sys/net/ipv4/conf/ppp0" ];
        echo "`date` : restarting pppd" >> /media/sda/dl.log
        killall pppd
        pppd plugin eth0 user USERNAME password PASSWORD noauth defaultroute replacedefaultroute

6.create a cron job by creating a file named root inside /etc/cron/crontabs folder and paste the following inside it :

* 3,4,5,6 * * * /media/sda/monitor-pppd

and restart the cron daemon by calling :

/usr/script/ restart

the cron daemon will establish the PPPOE connection automatically and monitor-ppd will monitor it.
don’t forget the time should be synchronized and timezone should be set correctly.

Set date,time and timezone on dreambox (dm800)

Filed under: DreamBox — Tags: , , , , — admin @ 6:49 pm

You can set the time and date on dm800 by following command :

date -s YYYY.MM.DD-hh:mm:ss

YYYY is Year
MM is Month
DD is Day
hh is Hour (0-24)
mm is Minute
ss is Second

for changing the timezone , first get a file list of cities by following command :

ls /usr/share/zoneinfo/

choose your city or nearest city to you , then use the following command to change the timezone ( replace YOUR_CITY with your chosen city ) :

ln -sf /usr/share/zoneinfo/YOUR_CITY /etc/localtime

How to setup a PPPOE connection on your dreambox

Filed under: DreamBox — Tags: , , , — admin @ 3:58 pm

Setting up a PPPOE connection on my dm800 was one of the hardest challenges I’ve ever had , I wonder why there is no documentation about it on the net ! I guess I am the first one documenting it in the world 🙂
In this article we will install PPPOE on my dm800 box , I have Gemini 4.6 installed on it now. a “uname -a” command give the following output :

root@dm800:/etc# uname -a
Linux dm800 2.6.12-5.1-brcmstb-dm800 #1 Wed Mar 11 20:59:15 CET 2009 7401c0-nand unknown

first we need to install several kernel modules on our dreambox :

ipkg install kernel-module-slhc
ipkg install kernel-module-ppp-generic
ipkg install kernel-module-pppox
ipkg install kernel-module-pppoe

then we need to install PPP and PPPOE package , I don’t know why they are not available in default repo of Gemini image , but after a lot of search I found them in repo , so next step is to download and install them :

cd /tmp
ipkg install ppp_2.4.3-r2_mipsel.ipk
ipkg install ppp-oe_2.4.3-r2_mipsel.ipk

after installing all of required packages , we need to load the required kernel modules into memory.
so run the following commands :

depmod -a
modprobe pppoe

now we should have all required kernel modules loaded :

root@dm800:/etc/init.d# lsmod
Module                  Size  Used by    Tainted: P
pppoe 12416 0 - Live 0xc01ed000
pppox 2864 1 pppoe, Live 0xc01a8000
ppp_generic 29792 2 pppoe,pppox, Live 0xc01b3000
slhc 7552 1 ppp_generic, Live 0xc01a5000

Please note pppoe kernel module is loaded now.

OK , now we are ready to go and connect our PPPOE connection , to do this simply run the following command ( change USERNAME & PASSWORD in following command to your own PPPOE username and password ) :

pppd plugin eth0 user USERNAME password PASSWORD noauth defaultroute replacedefaultroute persist maxfail 0

thats it 🙂 if you have done everything correctly now , you should be connected now.
to disconnect from your PPPOE connection , simply run the following command :

killall pppd

Troubeshooting :
Sometimes I noticed , pppoe module doesnt get loaded (by command “modprobe pppoe”) with an error message while I had all required modules installed , after a lot of tries and errors I found out a reinstall of ppp_2.4.3-r2_mipsel.ipk resolves the issue , may be it is a bug.
After you have pppoe loaded in memory and checked it by “lsmod” command , if your connection still does not work , you can debug it by running syslog daemon and adding a “debug” option to the end of “pppd” command as follows :

pppd plugin eth0 user USERNAME password PASSWORD noauth defaultroute replacedefaultroute persist maxfail 0 debug

now you can go to “/var/log/” folder and check messages file. any errors or problems should be reported there , I suggest you to open another telnet or ssh to your dreambox and run the following commands :

cd /var/log/
tail -f messages

and now run the pppd , you can simultaneously see all debug messages.

Powered by WordPress