給你的Linux系統上點stress

2021-06-03 02:46:42 字數 1769 閱讀 7747

from: 

這本書介紹了非常多的除錯手段和工具, 其中提到了stress這個簡單的工具,在我們的日常工作中很有用。利用它可以給我們的系統施加cpu,記憶體,io和磁碟的壓力,在模擬極端場景給應用系統造成的壓力方面很有幫助。

主頁見這裡:

stress is a deliberately ****** workload generator for posix systems. it imposes a configurable amount of cpu, memory, i/o, and disk stress on the system. it is written in c, and is free software licensed under the gplv2.

這個stress實現非常的簡單,所有的功能在乙個.c檔案裡面實現, 系統執行的時候會fork多個子程序,分別進行cpu,記憶體,io方面的折磨。

$ stress –cpu 2 –io 1 –vm 1 –vm-bytes 128m –timeout 10s –verbose

stress: info: [9372] dispatching hogs: 2 cpu, 1 io, 1 vm, 0 hdd

stress: dbug: [9372] (243) using backoff sleep of 12000us

stress: dbug: [9372] (262) setting timeout to 10s

stress: dbug: [9372] (285) –> hogcpu worker 9373 forked

stress: dbug: [9372] (305) –> hogio worker 9374 forked

stress: dbug: [9372] (325) –> hogvm worker 9375 forked

stress: dbug: [9372] (243) using backoff sleep of 3000us

stress: dbug: [9372] (262) setting timeout to 10s

stress: dbug: [9372] (285) –> hogcpu worker 9376 forked

stress: dbug: [9375] (466) hogvm worker malloced 134217728 bytes

stress: dbug: [9372] (382)

stress: dbug: [9372] (382)

stress: dbug: [9372] (382)

stress: dbug: [9372] (382)

stress: info: [9372] successful run completed in 10s

$stress --cpu 8 --io 4 --vm 2 --vm-bytes 128m --timeout 10dstress: info: [23176] dispatching hogs: 8 cpu, 4 io, 2 vm, 0 hddpstree可以看到:

nmon可以看到:

具體使用可以參考man stress!

給你們講講我自己是怎麼學習Linux系統的

我是乙個理工男,本科是搞電子的,但是一直對計算機的一些東西感興趣,自己在課下喜歡學一些程式語言,後來進入了實驗室,看到師兄在弄linux,我才接觸到了linux,在電腦上裝了個系統,便開始了一番探索,當然開始也是很迷茫的,也走了一些彎路,下面就談談我是怎麼學習linux的。大一的時候當上了班長,忙的...

給你的LINUX程式加個文字畫LOGO

經常看到很多的程式尤其linux程式有文字對應的那種logo,好酷炫啊。研究了好久試了各種方法,後來在google中搜尋到乙個軟體叫 figlet github 使用方法,linux下 tar xvf figlet 2.2.5.tar.gz cd figlet 2.2.5 make figlet 然...

在linux中給你的應用做壓力測試

wget tar zxvf webbench 1.5.tar.gz cd webbench 1.5 make make installwebbench t 5 c 2 2個併發使用者共同請求5秒benchmarking get get方法請求谷歌 2clients,running 5sec.2個使用...