LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 12-14-2011, 05:05 PM   #1
lebrun
LQ Newbie
 
Registered: Nov 2005
Location: Venezuela
Distribution: Kubuntu
Posts: 4

Rep: Reputation: 0
Post Detect machines on LAN & adjust Deluge limits


Since I share my internet connection with other people I started using Deluge's bandwidth scheduler plugin to avoid hogging the connections (and avoid conflicts)

I set Deluge max to 60KBps, and on the evening hours it goes down to 40KBps.

But during the day, even this seemed wasteful if no one was home. Increasing the max (or setting it to unlimited) would make the connection useless for anyone working from home (and yes, sometimes that includes me)

So I made a small script to be run via cron say, every 5 minutes. It uses smbtree to count the number of Windows machines on the network, excluding the current host. When no other machine is found, deluge is set for a higher max download limit, and when other machines are detected, it reverts deluge to more modest settings.

Here is the code, which is also hosted at: https://github.com/acarroz/autobw


Code:
#!/bin/bash

logfile=$(echo "$0.log" | sed "s/.sh//g")

maxdownspeed="90.0"
maxupspeed="30.0"

regdownspeed="60.0"
regupspeed="15.0"

wincount=$(smbtree -S -N -b | grep '\\\\' | grep -v "`hostname`" | wc -l)
currdownspeed=$(deluge-console "config max_download_speed" | sed 's/ max_download_speed: //g')
now=$(date +"%F %T")

if [ $wincount -gt 0 ]; then
if [ $currdownspeed != $regdownspeed ]; then
deluge-console "config --set max_download_speed $regdownspeed"
    deluge-console "config --set max_upload_speed $regupspeed"

    echo "$now *REG* $wincount hosts found" >> $logfile
  fi
else
if [ $currdownspeed != $maxdownspeed ]; then
deluge-console "config --set max_download_speed $maxdownspeed"
    deluge-console "config --set max_upload_speed $maxupspeed"

    echo "$now *MAX* $wincount hosts found" >> $logfile
  fi
fi

The script will only detect Windows (or Samba) hosts, but for my particular situation, I can live with that.
 
Old 12-15-2011, 11:28 AM   #2
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
Instead of smbtree you could use nast to list any machines on LAN not just Samba, something like:

Quote:
nast -m -i eth1
You'll then need to account for your own machine and your router(s).
 
Old 12-15-2011, 11:37 AM   #3
lebrun
LQ Newbie
 
Registered: Nov 2005
Location: Venezuela
Distribution: Kubuntu
Posts: 4

Original Poster
Rep: Reputation: 0
Didn't know about nast, but I did look into other similar tools. Some of them were quite fast, but all of them had the same problem as nast: they require root access.

Last edited by lebrun; 12-19-2011 at 12:40 PM.
 
  


Reply

Tags
torrent


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't see other machines on LAN WinnieNicklaus Linux - Networking 3 01-21-2011 11:06 AM
Is it possible to adjust NAT settings so one external address is allowed onto LAN NetGuru Linux - Networking 5 03-06-2009 11:00 AM
2 machines having same private IP in a LAN? koyi Linux - Networking 1 01-07-2007 07:55 PM
How to know what machines are in LAN ? pvv Linux - Networking 3 03-25-2004 04:59 AM
Processor & TCP limits thethinker101 Mandriva 4 12-20-2003 05:49 AM


All times are GMT -5. The time now is 01:37 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration