Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
No network activity
#1
Hi Gintaras, hi all

first happy new year to all.

Now my problem.

From a previous post, I was able to shutdown my computer when my VPN is disconnected, I wished and successed stop my laptop in that
circumstance.

I use this to achieve that:

Function ActiviteInternet
Code:
Copy      Help
MIB_IF_TABLE2* t
int hr=GetIfTable2(&t); if(hr) end _s.dllerror("" "" hr)

int found
for _i 0 t.NumEntries
,MIB_IF_ROW2& r=t.Table[_i]
,if(strcmp(mibName F"{&r.Description%%S}")!=0) continue
,mibInfo=r
,found=1; break
FreeMibTable t
ret found

Function VPNActif
Code:
Copy      Help
ActiviteInternet("TAP-Windows Adapter V9" &VPN)
ret VPN.MediaConnectState

Now, i'd like a little more. Sometimes, my VPN stalls but does not disconnect so everything is hanging and all connections
are blocked until I restart the VPN.

The disconnect method is not appopriate there as it is still connected.

I'd like to be able to shutdown my laptop when network activity is 0 or near 0 for a certain time say 5 min.

The code should monitor any network interface, as I don't exactly know how to find the VPN one.


How to implement that?

Thanks.
#2
Easier to monitor all network interfaces with performance counters, with class CPerformanceCounter from Archive.qml.
"\Network Interface(*)\Bytes Received/sec"
GetIfTable2 gets many duplicates etc, I don't know how to filter/find the correct one. Or you can calculate the sum of their InOctets (bytes received).
#3
Yep but I have problems due to langage specific strings, and
"\Memory\Available MBytes" is reported unknown, so I guess
the syntax is incorrect or is not adequate.

Thought you knew a "generic" method....
#4
tried this

Macro CPerformanceCounter help
Code:
Copy      Help
#compile __CPerformanceCounter
CPerformanceCounter c
c.Open("\\ASUS-75VX\Interface réseau(Qualcomm Atheros AR8151 PCI-E Gigabit Ethernet Controller [NDIS 6.20])\Total des octets/s") ;;bytes received/s by all network adapters.

from this (see capture)...
I get an error message about specified object not found on the computer...
quite sure it involves a syntax problem...


Attached Files Image(s)
   
#5
The class did not support Unicode. Download updated version.
Performance counters
#6
bad file format when importing CPerformanceCounter.qml from viewtopic.php?t=3543

5 times downloaded...
#7
sorry, try now
#8
Yep, functional now, thanks.

Now how to use it as a monitor to see if network is used in a time lapse to determine if network is active.

Any advice to begin with?


Forum Jump:


Users browsing this thread: 1 Guest(s)