uptime
在Linux中,我們常常用$(uptime)去看看系統的運行時間,它與一個文件有關,就是/proc/uptime
$(cat /proc/uptime) -> 6447032.12 48185264.69
$(cat /proc/cpuinfo | grep processor | wc -l) -> 8
第一列輸出的是,系統啟動到現在的時間(以秒為單位), t1 第二列輸出的是,系統空閒的時間(以秒為單位), t2
注意,很多很多人都知道第二個是系統空閒的時間,但是可能你不知道是,在SMP系統裡,系統空閒的時間有時會是系統運行時間的幾倍,這是怎麼回事呢? 因為系統空閒時間的計算,是把SMP算進去的,就是所你有幾個邏輯的CPU(包括超線程)
系統的空閒率(%) = t2/(t1*N) 其中N是SMP系統中的CPU個數
從上面我的一台機器上的數據可知, 本機啟動到現在的時間長度為:6447032.12 seconds = 74.6 days 空閒率為:48185264.69/(6447032.12*8)=93.4%
系統空閒率越大,說明系統比較閒,可以加重一些負載;而系統空閒率很小,則可能考慮升級本機器硬件或者遷移部分負載到其他機器上
Some docs from Redhat: The first number is the total number of seconds the system has been up. The second number is how much of that time the machine has spent idle, in seconds. (Jay's comments: Please pay attention to SMP system.)
Last updated
Was this helpful?