Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

bmcapture process stops monitoring sometimes #30

Open
codebox opened this issue Mar 18, 2012 · 5 comments
Open

bmcapture process stops monitoring sometimes #30

codebox opened this issue Mar 18, 2012 · 5 comments

Comments

@codebox
Copy link
Owner

codebox commented Mar 18, 2012

bmcapture process stops monitoring sometimes (on OSX, and possibly others, all pcap thread stop, leaving only main thread running)

@codebox
Copy link
Owner Author

codebox commented Apr 15, 2012

Similar issues reported on Windows 7 after waking from hibernation. Errors in log file on windows relating to bpf compilation problems (see http://codebox.org.uk/forum/posts/list/0/28934.page#40454) which do not appear on OSX, so this may be 2 separate problems

@maphew
Copy link

maphew commented Oct 16, 2015

I see this on Win7 and Win10, with Bitmeter 0.8.0. It happens after shutdown as well as hibernate.

The forum link above shows a blank page for me.

Restarting the service restarts data capture. I tried setting up a scheduled task to restart the process on Workstation Unlock event but it had no effect. I couldn't find a reason (hard to troubleshoot scheduled tasks; you have to add your own error logging etc.), but suspect it's around elevated permissions.

I also tried putting the restart batch file in the Startup group (and learned this pro tip: Winkey-R >> shell:startup to get there quickly) but it didn't work there either.

Workaround

Create a shortcut to this batch file and under Advanced properties check "Run as administrator", and run on-demand as needed.

@:: restart-bitmeter-capture-service.bat, save in BitMeter OS install folder
@pushd %~dp0
sc stop  BitMeterCaptureService
sc start BitMeterCaptureService
@ping -n 7 localhost > nul
@   :: pause for 7 secs
@popd

Yesterday I found a post somewhere on Stack Overflow or Server Fault about a possible race condition with services using winpcap. I can't find it again (on a different computer and no access to browser history), but the gist of it was that you needed to start winpcap after the dependent service. I remember it because that order seemed odd to me, because it's the reverse of how I normally think of dependencies.

@maphew
Copy link

maphew commented Oct 16, 2015

Finally found the log file (should have read the FAQ first, sorry), it doesn't say much:

2015-10-15 13:14:23 WEB recv() returned 0

2015-10-15 13:14:24 WEB recv() returned 0

2015-10-15 21:13:00 WEB recv() returned 0

The same faq shows bmdb capstop and bmdb capstart for the capture service. Do those do something different from the restart service method I concocted above? (e.g. does it matter which method is used?). The console feedback indicates it might just be a convenience wrapper around sc.

@maphew
Copy link

maphew commented Oct 27, 2015

I have a working scheduled task! Fix was to use the Powershell Restart-Service cmdlet instead of my batch file. For debugging the scheduled task you might want/need to enable task history logging. I have it set to trigger on Startup (30s delay), Logon, and Workstation Unlock, and runs under SYSTEM account with highest privileges. Only condition is "run only if any network connection"

The command is simply PowerShell Restart-Service BitmeterCaptureService. There is no console feedback, use Get-Service to query.

To test:

  • disable scheduled task
  • open a browser to the Bitmeter Monitor page
  • put computer to sleep, then re-awake
  • check Monitor. If your computer has the bug, the Current in/out will be zero.
  • enable task
  • repeat sleep>>wake>>monitor. Current in/out should show traffic (might need to wait a few seconds for the task to fire)

The task definition for easy importing: https://gist.github.com/maphew/3c58576f50ebd7513fa6

@VinceS2
Copy link

VinceS2 commented Feb 11, 2018

It is an old topic but the problem is current. There is a simpler solution I have found. Simply making the batch file as nominated and running as Admin works, but we're lazier than that right? First, to clarify -
what is not explained in the above post that you are to go copy the linked html info and save it as a RestartBitMeter.xml file (by making a .txt file with Notepad then dumping the content then getting rid of the .txt bit. Then start Task Scheduler and right click on the Library folder and Import a task, pick this task you just made then it should work as instructed. Needs Powershell. Or there is this other way...

Go to the Task Scheduler and right click in Library and Create Basic Task. Describe it as you like, but use this info:
Trigger: "When a specific event is logged"
Log: System
Source: Power-Troubleshooter
Event ID: 1
Action: Start a program
(select the BitMeterHeartStarter.bat file you made from the above). Text copy-pasted here for convenience:

@:: restart-bitmeter-capture-service.bat, save in BitMeter OS install folder
@pushd %~dp0
sc stop BitMeterCaptureService
sc start BitMeterCaptureService
@ping -n 7 localhost > nul
@ :: pause for 7 secs
@POPD

no arguments or start-in info needed
tick Open the Properties Dialogue when I finish
(if you forget, then right click your new task and select Properties)
tick Run with highest privileges
change Windows version to suit what you have

All other defaults are OK, as best I remember. Hope this helps. Enjoy!

Edit: Nope, forgot to add a trigger for "On Log on of any user". You need this too! Just edit properties of the task and add it on the trigger tab.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants