Sign in to follow this  
Followers 0
omnomnom

logging internet usage of entire computer?

8 posts in this topic

#1 ·  Posted (edited)

Hi there, i was wondering if its possible to track the internet usage of the entire computer?

This is because i have a bandwidth/download limit and i need to know how much i have downloaded each day so i can track if i am going over my limit.

Please could you point me in the right direction of which commands to use?

Thanks

Edited by omnomnom

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <Constants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $str[20], $trimmed = 0, $alltrimmed = 0, $stout = ""
$Form1 = GUICreate("Form1", 321, 70, 355, 477)
$Label1 = GUICtrlCreateLabel("Received bytes", 8, 24, 117, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("0", 154, 24, 153, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)

AdlibEnable("GetInfo", 1000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func GetInfo()
    $cmd = Run(@comspec & " /c netstat -e", @SystemDir, @SW_HIDE,  $STDIN_CHILD & $STDOUT_CHILD)
    Sleep(500)
    $line = StdoutRead($cmd)
    ;getting from STDOUT only number of received bytes and update control whith this info:
    $str = StringSplit($line,@CR)
    For $i = 1 to $str[0]-1 Step 2
        If $str[$i] <> "" And $i = 5 Then
            $strn = StringSplit($str[$i],"")
            $string = $str[$i]
            For $n = 1 to $strn[0] Step 1
                If StringIsDigit($strn[$n]) And $trimmed = 0 Then
                    $alltrimmed = 1
                    $stout = $stout & $strn[$n]
                ElseIf Not StringIsDigit($strn[$n]) And $alltrimmed = 1 Then
                    $trimmed = 1
                EndIf
            Next
                GUICtrlSetData($Input1, $stout)
                $stout = ""
                $trimmed = 0
                $alltrimmed = 0

        EndIf
    Next

    EndFunc

Edited by GodlessSinner

_____________________________________________________________________________

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <Constants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $str[20], $trimmed = 0, $alltrimmed = 0, $stout = ""
$Form1 = GUICreate("Form1", 321, 70, 355, 477)
$Label1 = GUICtrlCreateLabel("Received bytes", 8, 24, 117, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("0", 154, 24, 153, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)

AdlibEnable("GetInfo", 1000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func GetInfo()
    $cmd = Run(@comspec & " /c netstat -e", @SystemDir, @SW_HIDE,  $STDIN_CHILD & $STDOUT_CHILD)
    Sleep(500)
    $line = StdoutRead($cmd)
    ;getting from STDOUT only number of received bytes and update control whith this info:
    $str = StringSplit($line,@CR)
    For $i = 1 to $str[0]-1 Step 2
        If $str[$i] <> "" And $i = 5 Then
            $strn = StringSplit($str[$i],"")
            $string = $str[$i]
            For $n = 1 to $strn[0] Step 1
                If StringIsDigit($strn[$n]) And $trimmed = 0 Then
                    $alltrimmed = 1
                    $stout = $stout & $strn[$n]
                ElseIf Not StringIsDigit($strn[$n]) And $alltrimmed = 1 Then
                    $trimmed = 1
                EndIf
            Next
                GUICtrlSetData($Input1, $stout)
                $stout = ""
                $trimmed = 0
                $alltrimmed = 0

        EndIf
    Next

    EndFunc

Thanks, however i get an error...

ERROR: AdlibEnable(): undefined function.

AdlibEnable("GetInfo", 1000)

Also, would you mind explaining the code a little more? i would hate to just copy and use it without at least understanding it.

Thanks

EDIT: i can fix the error by changing adlibenable to adlibregister. however i still do not understand the rest of the code...

EDIT2: it seems that it calls netstat -e which gets the info from ethernet... i am using a wireless adapter, will that make any difference?

Edited by omnomnom

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

oops, I using 3G modem and info returned via netstat is little >, than what I see in Connection properties, and I don't know where is the truth.

So the right way is to search for " get traffic info by DllCall"

Edited by GodlessSinner

_____________________________________________________________________________

Share this post


Link to post
Share on other sites

oops, I using 3G modem and info returned via netstat is little >, than what I see in Connection properties, and I don't know where is the truth.

So the right way is to search for " get traffic info by DllCall"

had a look at dllcall, although i dont know which dll i would have to call for it to be useful?

Thanks

Share this post


Link to post
Share on other sites

You can use Networx.

It's a bandwidth monitoring tool. It tracks the current network transfer rate and keeps a database of traffic quantities over time. It's also free to use.

Just set it so it only monitor the correct network traffic so it only senses your internet traffic.

Share this post


Link to post
Share on other sites

You can use Networx.

It's a bandwidth monitoring tool. It tracks the current network transfer rate and keeps a database of traffic quantities over time. It's also free to use.

Just set it so it only monitor the correct network traffic so it only senses your internet traffic.

Thanks, however I am mostly looking to create my own so i can use it at work... I am only allowed to use stuff created by me (I am one of the IT guys) which is why i was looking how to create my own...

Any help?

Thanks

Share this post


Link to post
Share on other sites

Bump

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0