Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuously run powershell to get disk free space #4328

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

lukebakken
Copy link
Collaborator

@lukebakken lukebakken commented Mar 22, 2022

Much faster than starting it every time.

Fixes #4140.

Update: this has been superseded by #5241.

@lukebakken lukebakken self-assigned this Mar 22, 2022
@michaelklishin
Copy link
Member

Free disk space monitoring on Windows, again 😢

@lukebakken lukebakken force-pushed the rabbitmq-server-4140 branch 3 times, most recently from 77ca333 to 9374edc Compare July 13, 2022 01:55
@lukebakken lukebakken marked this pull request as ready for review July 13, 2022 03:20
@lukebakken lukebakken marked this pull request as draft July 13, 2022 09:02
@lukebakken
Copy link
Collaborator Author

Marking as a draft again, I just thought of something.

@lukebakken lukebakken force-pushed the rabbitmq-server-4140 branch 2 times, most recently from c49fc80 to 1880a0a Compare July 13, 2022 14:02
@lukebakken lukebakken marked this pull request as ready for review July 13, 2022 14:04
@lukebakken lukebakken requested a review from dumbbell July 13, 2022 14:04
@lukebakken
Copy link
Collaborator Author

lukebakken commented Jul 13, 2022

Here's how I built the windows packages from Linux:

make FULL=1 RABBITMQ_PACKAGING_REPO="$HOME/development/rabbitmq/rabbitmq-packaging" UNIX_TO_DOS=unix2dos package-windows

I had to use UNIX_TO_DOS since I don't have the usual todos package.

Then, extract the zip file and start up RabbitMQ. In powershell, I did this:

Config file:

log.console = true
log.console.level = debug
log.file.level = debug

Commands:

$env:RABBITMQ_ALLOW_INPUT='true'
$env:RABBITMQ_CONFIG_FILE='C:\Users\bakkenl\conf\rabbitmq.conf'
.\sbin\rabbitmq-server.bat

In the interactive Erlang terminal, you can run the following to see that the free disk space has been retrieved:

rabbit_disk_monitor:get_disk_free().

You can bring up a program like Task Manager or Process Explorer to see the running powershell instance:

image

Go ahead and kill it and you will see it be restarted.

Much faster than starting it every time.

Fixes #4140

Take noeol into account
@dumbbell
Copy link
Member

I tested this branch on a Windows 10 and it worked as advertised. Killing the PowerShell process also worked and rabbit_disk_monitor:get_disk_free() continued to report the correct value.

Copy link
Member

@dumbbell dumbbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! This is really cool

@michaelklishin michaelklishin modified the milestone: 3.10.7 Jul 15, 2022
@michaelklishin michaelklishin merged commit c41b03a into master Jul 15, 2022
@michaelklishin michaelklishin deleted the rabbitmq-server-4140 branch July 15, 2022 15:38
michaelklishin added a commit that referenced this pull request Jul 15, 2022
Continuously run powershell to get disk free space (backport #4328)
@lukebakken
Copy link
Collaborator Author

Thanks @dumbbell for the review!

@lukebakken
Copy link
Collaborator Author

lukebakken commented Jul 15, 2022

@dumbbell @michaelklishin my next step was to look into disksup in Erlang/OTP itself. Currently, you can only enable disk monitoring down to the minute, BUT, if you start os_mon, look at what you can get:

Eshell V13.0.2  (abort with ^G)
1> os_mon_sysinfo:get_disk_info().
** exception exit: {noproc,{gen_server,call,[os_mon_sysinfo,get_disk_info]}}
     in function  gen_server:call/2 (gen_server.erl, line 367)
2> application:ensure_all_started(os_mon).
{ok,[sasl,os_mon]}
3> os_mon_sysinfo:get_disk_info().        
["C:\\ DRIVE_FIXED 720577376256 1013310287872 720577376256\n"

AHA! Much better than Powershell. It uses a port program called win32sysinfo.exe:

https://github.com/erlang/otp/blob/master/lib/os_mon/c_src/win32sysinfo.c

Expect an updated set of changes for free disk on Win32.

lukebakken added a commit that referenced this pull request Jul 15, 2022
Follow-up to #4140

In #4328, I use Powershell to get disk info. This PR changes that
to use the "included with OTP" win32sysinfo.exe
lukebakken added a commit that referenced this pull request Jul 16, 2022
Follow-up to #4140

In #4328, I use Powershell to get disk info. This PR changes that
to use the "included with OTP" win32sysinfo.exe

Remove Powershell code

Correctly parse the return value of os_mon_sysinfo:get_disk_info/0
mergify bot pushed a commit that referenced this pull request Jul 19, 2022
Follow-up to #4140

In #4328, I use Powershell to get disk info. This PR changes that
to use the "included with OTP" win32sysinfo.exe

Remove Powershell code

Correctly parse the return value of os_mon_sysinfo:get_disk_info/0

(cherry picked from commit c0f2f6a)
michaelklishin pushed a commit that referenced this pull request Jul 19, 2022
Follow-up to #4140

In #4328, I use Powershell to get disk info. This PR changes that
to use the "included with OTP" win32sysinfo.exe

Remove Powershell code

Correctly parse the return value of os_mon_sysinfo:get_disk_info/0

(cherry picked from commit c0f2f6a)
@inikulshin
Copy link

@lukebakken @michaelklishin is this PR (and #5241) planned to be merged into 3.9?

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

Successfully merging this pull request may close these issues.

Retrieving free disk space on Windows can time out
4 participants