File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -1016,8 +1016,8 @@ def default_for(
1016
1016
1017
1017
.. code-block:: python
1018
1018
1019
- # rank hosts by cpu_percent
1020
- cpu_percent()
1019
+ # rank hosts by cpu_percent over a 1 second interval
1020
+ cpu_percent(1) # Note: monitors CPU for 1 second
1021
1021
1022
1022
# rank hosts by 15min average of server load
1023
1023
getloadavg()[2]
@@ -1040,7 +1040,7 @@ def default_for(
1040
1040
.. code-block:: python
1041
1041
1042
1042
# filter out hosts with a CPU utilisation of 70% or above
1043
- cpu_percent() < 70
1043
+ cpu_percent(1 ) < 70
1044
1044
1045
1045
# filter out hosts with less than 1GB of RAM available
1046
1046
virtual_memory().available > 1000000000
@@ -1057,14 +1057,14 @@ def default_for(
1057
1057
.. code-block:: python
1058
1058
1059
1059
# filter hosts
1060
- cpu_percent() < 70
1060
+ cpu_percent(1 ) < 70
1061
1061
disk_usage('/').free > 1000000000
1062
1062
1063
1063
# rank hosts by CPU count
1064
1064
1 / cpu_count()
1065
1065
# if two hosts have the same CPU count
1066
1066
# then rank them by CPU usage
1067
- cpu_percent()
1067
+ cpu_percent(1 )
1068
1068
1069
1069
.. versionchanged:: 8.0.0
1070
1070
Original file line number Diff line number Diff line change @@ -185,14 +185,14 @@ def select_host(
185
185
186
186
# only consider hosts with less than 70% cpu usage
187
187
# and a server load of less than 5
188
- cpu_percent() < 70
188
+ cpu_percent(1 ) < 70
189
189
getloadavg()[0] < 5
190
190
191
191
And or Python statements to rank hosts by e.g::
192
192
193
193
# rank by used cpu, then by load average as a tie-break
194
194
# (lower scores are better)
195
- cpu_percent()
195
+ cpu_percent(1 )
196
196
getloadavg()
197
197
198
198
Comments are allowed using `#` but not inline comments.
You can’t perform that action at this time.
0 commit comments