Google Drive for Desktop Throttling

malexander
New Contributor II

So it was decided at our school to do Drive for desktop as everyone's backup solution. However once everyone installed it, our Wifi performance crashed because Drive was taking up all of our bandwidth. After speaking with our Google agent, they suggested running the following commands in terminal in order to throttle the amount of bandwidth Drive for Desktop uses.

defaults write com.google.drivefs.settings BandwidthRxKBPS 100
 
defaults write com.google.drivefs.settings BandwidthTxKBPS 100.
 
I have confirmed that the commands work when entered in terminal, but I can't get the policy to execute properly on the scoped machine. here is my script:
 
#!/bin/bash
defaults write com.google.drivefs.settings BandwidthRxKBPS 100
defaults write com.google.drivefs.settings BandwidthTxKBPS 100
exit 0
 
it runs on the machine, but nothing changes or happens with the preference file, and jamf shows no details about why the script didn't execute when I look at the policy logs.
 
I should mention that I am filling in for the sysadmin who is out sick at my school and I don't really have that much experience with deploying policies and even less experience in scripting. Please be gentle.
1 ACCEPTED SOLUTION

sdagley
Esteemed Contributor II

@malexander When you run those commands manually in Terminal you're modifying the values in the user's preferences settings. When running via a Jamf Policy you're modifying the system settings, and Google Drive may not recognize those. Try the following script instead:

 

#!/bin/bash

runAsUser() {  
	currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
	currentUserID=$(id -u "$currentUser")

  if [ "$currentUser" != "loginwindow" ]; then
    /bin/launchctl asuser "$currentUserID" sudo -u "$currentUser" "$@"
  fi
}

runAsUser defaults write com.google.drivefs.settings BandwidthRxKBPS 100
runAsUser defaults write com.google.drivefs.settings BandwidthTxKBPS 100

exit 0

Note: A Configuration Profile is probably a better way to enforce these settings, but if the defaults write approach works for you...

 

View solution in original post

4 REPLIES 4

sdagley
Esteemed Contributor II

@malexander When you run those commands manually in Terminal you're modifying the values in the user's preferences settings. When running via a Jamf Policy you're modifying the system settings, and Google Drive may not recognize those. Try the following script instead:

 

#!/bin/bash

runAsUser() {  
	currentUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }' )
	currentUserID=$(id -u "$currentUser")

  if [ "$currentUser" != "loginwindow" ]; then
    /bin/launchctl asuser "$currentUserID" sudo -u "$currentUser" "$@"
  fi
}

runAsUser defaults write com.google.drivefs.settings BandwidthRxKBPS 100
runAsUser defaults write com.google.drivefs.settings BandwidthTxKBPS 100

exit 0

Note: A Configuration Profile is probably a better way to enforce these settings, but if the defaults write approach works for you...

 

malexander
New Contributor II

thank you! that worked perfectly. Appreciate it!

talkingmoose
Moderator
Moderator

Offering an alternative solution — not that it's better than a script but to raise awareness for a Jamf Pro feature that can accomplish the same thing.

Those details of the defaults commands Google provided can be use to create configuration profiles to do the same thing. Jamf Pro supports custom manifests and the manifest below exposes the same controls plus more options for Google Drive.

Here's the manifest:
https://github.com/Jamf-Custom-Profile-Schemas/ProfileManifestsMirror/blob/main/manifests/ManagedPre...

And here are instructions for using it:
https://github.com/Jamf-Custom-Profile-Schemas/jamf-manifests/wiki

that's great. I was toying with the idea of doing a config profile, but Ive never used them before and am a little afraid to use them. But this is great information. Appreciate it.