Intro
It may be necessary to reduce CloudSoda bandwidth usage during business hours. This can be achieved by adjusting the agent's cpu-concurrency setting in the soda.conf file. To learn more about cpu-concurrency or other agent configurations, please visit "can I manually configure an agent?".
NOTE: For multi-agent environments it is recommended to stagger cpu concurrency changes by at least two minutes.
Linux & macOS
To schedule bandwidth throttling on macOS or Linux, you can use cron. To do this, open /etc/crontab as root and add entries similar to the following: throttle performance down at 7 AM and return it to full speed at 9 PM. These times/days of the week can be adjusted to fit your schedule. The cpu-concurrency value is based on the amount of CPU the agent uses, which correlates with its performance. The lower the number, the slower the jobs will run on that agent.
0 7 * * * root (echo "cpu-concurrency: 10" >> /etc/soda/soda.conf && soda restart) >> /var/log/soda_task.log 2>&1
0 21 * * * root (sed -i '/cpu-concurrency/d' /etc/soda/soda.conf && soda restart) >> /var/log/soda_task.log 2>&1
Windows
On Windows you can use Task Scheduler. Here is a step-by-step guide on how to achieve this:
1. Write the Scripts
First, you'll need to create two scripts: one for adding the line to your configuration file and restarting the service, and another for removing the line and restarting the service.
Add Line and Restart Service (cloudsoda_morning_task.ps1)
Add-Content "C:\Path\To\soda\soda.conf" "cpu-concurrency: 10"
Restart-Service -Name soda
Remove Line and Restart Service (cloudsoda_evening_task.ps1)
(Get-Content "C:\Path\To\soda\soda.conf") | Where-Object {$_ -notmatch "cpu-concurrency"} | Set-Content "C:\Path\To\soda\soda.conf"
Restart-Service -Name soda
2. Create Scheduled Tasks
You'll need to create two scheduled tasks in Windows Task Scheduler: one for the morning operation and one for the evening.
For the Morning Task:
- Open Task Scheduler.
- Choose "Create Basic Task" or "Create Task" for more options.
- Name the task (e.g., "Morning Soda Task").
- Set the trigger to Daily and set the start time to 7:00 AM.
- For the action, choose "Start a Program" and browse to your morning script.
- Finish the wizard.
For the Evening Task:
- Repeat the steps above, but set the time to 9:00 PM and choose the evening script.
3. Logging (Optional)
To log the output as you do in Linux with >> /var/log/soda_task.log 2>&1, you can modify your PowerShell script to redirect the output to a log file. An example of this is:
$LogFile = "C:\Path\To\soda_task.log"
# Adding the line and restarting the service
Add-Content "C:\Path\To\soda\soda.conf" "cpu-concurrency: 10"
Restart-Service -Name soda 2>&1 | Out-File $LogFile -Append
Windows Notes
- Replace C:\Path\To\soda\soda.conf with the actual path to your soda.conf file. Depending on how the CloudSoda Agent was installed the soda.conf would be located in %ProgramData%\soda or %LocalAppData%\soda
- For PowerShell scripts, ensure that execution policies allow the script to run. You might need to run Set-ExecutionPolicy RemoteSigned or a similar command, depending on your security requirements.
- You may need to run the Task Scheduler with administrative privileges to have the necessary permissions to stop and start services.
- Make sure the user account under which the task runs has the appropriate permissions to modify the configuration file and to stop/start services.
- Test your scripts manually to ensure they perform as expected before scheduling them.
Comments
0 comments
Please sign in to leave a comment.