This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11063|Reply: 1

[linux] Linux uses lookbusy to simulate CPU usage

[Copy link]
Posted on 2/21/2022 1:32:08 PM | | | |
Requirements: To test the monitoring alarm rules, you can use lookbusy to simulate CPU usage when the server CPU occupies a set threshold to trigger an alarm rule.

Lookbusy is a simple application for generating synthetic payloads on Linux systems. It can generate a fixed, predictable load on the CPU, keep a selected amount of memory active, and generate as much disk traffic as you need.

Official address:The hyperlink login is visible.

This article takes the CentOS 7 system as an example, and the installation script is as follows:

After the script is saved, give it execution permission and install it with the following command:



The parameters used are as follows:

usage: lookbusy [ -h ] [ options ]
General options:
  -h, --help           Commandline help (you're reading it)
  -v, --verbose        Verbose output (may be repeated)
  -q, --quiet          Be quiet, produce output on errors only
CPU usage options:
  -c, --cpu-util=PCT,  Desired utilization of each CPU, in percent (default
      --cpu-util=RANGE   50%).  If 'curve' CPU usage mode is chosen, a range
                         of the form MIN-MAX should be given.
  -n, --ncpus=NUM      Number of CPUs to keep busy (default: autodetected)
  -r, --cpu-mode=MODE  Utilization mode ('fixed' or 'curve', see lookbusy(1))
  -p, --cpu-curve-peak=TIME
                       Offset of peak utilization within curve period, in
                         seconds (append 'm', 'h', 'd' for other units)
  -P, --cpu-curve-period=TIME
                       Duration of utilization curve period, in seconds (append
                       'm', 'h', 'd' for other units)
Memory usage options:
  -m, --mem-util=SIZE   Amount of memory to use (in bytes, followed by KB, MB,
                         or GB for other units; see lookbusy(1))
  -M, --mem-sleep=TIME Time to sleep between iterations, in usec (default 1000)
Disk usage options:
  -d, --disk-util=SIZE Size of files to use for disk churn (in bytes,
                         followed by KB, MB, GB or TB for other units)
  -b, --disk-block-size=SIZE
                       Size of blocks to use for I/O (in bytes, followed
                         by KB, MB or GB)
  -D, --disk-sleep=TIME
                       Time to sleep between iterations, in msec (default 100)
  -f, --disk-path=PATH Path to a file/directory to use as a buffer (default
                         /tmp); specify multiple times for additional paths
Common commands are as follows:

TestOccupying all CPU cores fluctuates around 80%-90%, the renderings are as follows:



(End)





Previous:[Actual combat]. NET/C# uses SemaphoreSlim to limit concurrent execution methods
Next:[Practical Training] Network Link Detection Tracert and TraceRoute tutorials
 Landlord| Posted on 8/6/2022 2:31:22 PM |
Linux stress testing software Stress installation and use

Installation

yum install -y epel-release
yum install stress -y

Example of a test scenario

1、stress -c 4

Add 4 CPU processes to handle the sqrt() function to increase the CPU load on the system

2. Memory test

stress –i 4 –vm 10 –vm-bytes 1G –vm-hang 100 –timeout 100s

Add 4 io processes and 10 memory allocation processes, each time allocating a size of 1G, which is not released after allocation, and test 100S

3. Disk I/O test

stress –d 1 --hdd-bytes 3G

Added 1 write process, each time writing 3G file blocks

Enter the command: stress –i 1 –d 10 --hdd-bytes 3G –hdd-noclean

Add 1 IO process and 10 write processes, and each time a 3G file block is written, the hard disk will gradually be exhausted if it is not cleared.
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com