| 5 | 1/1 | 返回列表 |
| 查看: 1433 | 回復(fù): 17 | ||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | ||
wuy069鐵桿木蟲 (正式寫手)
|
[求助]
請(qǐng)教:用Shell, awk, perl等語(yǔ)言實(shí)現(xiàn)監(jiān)視SGE集群節(jié)點(diǎn)和任務(wù)
|
|
|
請(qǐng)教:用Shell, awk, perl等語(yǔ)言實(shí)現(xiàn)監(jiān)視SGE集群節(jié)點(diǎn)和任務(wù) 簡(jiǎn)單的bash shell和awk語(yǔ)言會(huì)點(diǎn),但弄個(gè)復(fù)雜的腳本,功底還是不夠 下面的格式有點(diǎn)錯(cuò)位,我把相應(yīng)的內(nèi)容以附件粘貼了。 [wuy@cluster test]$ qhost -j HOSTNAME ARCH NCPU LOAD MEMTOT MEMUSE SWAPTO SWAPUS ------------------------------------------------------------------------------- global - - - - - - - compute-0-0 lx26-amd64 4 2.97 3.9G 3.5G 4.0G 2.9G job-ID prior name user state submit/start at queue master ja-task-ID ---------------------------------------------------------------------------------------------- 6 0.50500 test1.sh wuy r 12/09/2012 14:47:26 all.q@comp MASTER 7 0.60500 test4.sh wuy r 12/09/2012 14:47:26 all.q@comp MASTER all.q@comp SLAVE all.q@comp SLAVE compute-0-1 lx26-amd64 4 3.56 3.9G 3.8G 4.0G 3.1G job-ID prior name user state submit/start at queue master ja-task-ID ---------------------------------------------------------------------------------------------- 8 0.60500 test2.sh tester r 12/09/2012 14:48:52 all.q@comp MASTER all.q@comp SLAVE all.q@comp SLAVE 9 0.60500 test3.sh tester r 12/09/2012 14:48:52 all.q@comp MASTER all.q@comp SLAVE all.q@comp SLAVE 在compute-0-0節(jié)點(diǎn)上有兩個(gè)任務(wù)6和7,所用的cpu分別為1和2;在compute-0-1節(jié)點(diǎn)上有兩個(gè)任務(wù)8和9,所用的cpu分別為2和2. 使用Shell, awk, perl等語(yǔ)言獲得的命令腳本打印輸出下面所示: ------------------------------------------------------------------------------------------------ node state load ncpu mem memuse swapto swapus tasks jobids/users ------------------------------------------------------------------------------------------------ compute-0-0 free 2.97 4 3.9G 3.5G 4.0G 2.9G 3 6/wuy 7/wuy compute-0-1 busy 3.56 4 3.9G 3.8G 4.0G 3.1G 4 8/tester 9/tester 其中,當(dāng)node的LOAD為“-”時(shí),相應(yīng)node的state為down. 下面是根據(jù)qstat命令編寫腳本監(jiān)視任務(wù)的申請(qǐng)時(shí)間和逝去時(shí)間 [wuy@cluster test]$ qstat -u '*' job-ID prior name user state submit/start at queue slots ja-task-ID ----------------------------------------------------------------------------------------------------------------- 6 0.50500 test1.sh wuy r 12/09/2012 14:47:26 all.q@compute-0-0.local 1 7 0.60500 test4.sh wuy r 12/09/2012 14:47:26 all.q@compute-0-0.local 2 8 0.60500 test2.sh tester r 12/09/2012 14:48:52 all.q@compute-0-1.local 2 9 0.60500 test3.sh tester r 12/09/2012 14:48:52 all.q@compute-0-1.local 2 [wuy@cluster test]$ qstat -j 6 |grep h_rt hard resource_list: h_rt=3600 得到的申請(qǐng)時(shí)間(reqtime)為3600s,改為小時(shí)制:1:00:00 逝去的時(shí)間(elaptime)為現(xiàn)在的時(shí)間`date`減去任務(wù)開始的時(shí)間 使用Shell, awk, perl等語(yǔ)言獲得的命令腳本打印輸出下面所示 job-ID name user state submit/start at queue slots reqtime elaptime -------------------------------------------------------------------------------------------------------------------- 6 test1.sh wuy r 12/09/2012 14:47:26 all.q@compute-0-0.local 1 1:00:00 00:50:00 7 test4.sh wuy r 12/09/2012 14:47:26 all.q@compute-0-0.local 2 2:00:00 00:50:00 8 test2.sh tester r 12/09/2012 14:48:52 all.q@compute-0-1.local 2 5:00:00 00:48:34 9 test3.sh tester r 12/09/2012 14:48:52 all.q@compute-0-1.local 2 12:00:00 00:48:34[ Last edited by wuy069 on 2012-12-9 at 18:30 ] |
木蟲 (小有名氣)
木蟲 (正式寫手)
鐵桿木蟲 (正式寫手)
|
嗯,shell+awk應(yīng)該是能實(shí)現(xiàn)的,awk學(xué)的不咋好,一時(shí)半會(huì)整不出來(lái) 根據(jù)qhost -j命令輸出的結(jié)果,編寫一個(gè)腳本打印出: ------------------------------------------------------------------------------------------------ node state load ncpu mem memuse swapto swapus tasks jobids/users ------------------------------------------------------------------------------------------------ compute-0-0 free 2.97 4 3.9G 3.5G 4.0G 2.9G 3 6/wuy 7/wuy compute-0-1 busy 3.56 4 3.9G 3.8G 4.0G 3.1G 4 8/tester 9/tester 這是第一個(gè)腳本 第二個(gè): 根據(jù)qstat -u ’*'和qstat -j jobid輸出的結(jié)果,編一個(gè)腳本輸出以下部分: job-ID name user state submit/start at queue slots reqtime elaptime -------------------------------------------------------------------------------------------------------------------- 6 test1.sh wuy r 12/09/2012 14:47:26 all.q@compute-0-0.local 1 1:00:00 00:50:00 7 test4.sh wuy r 12/09/2012 14:47:26 all.q@compute-0-0.local 2 2:00:00 00:50:00 8 test2.sh tester r 12/09/2012 14:48:52 all.q@compute-0-1.local 2 5:00:00 00:48:34 9 test3.sh tester r 12/09/2012 14:48:52 all.q@compute-0-1.local 2 12:00:00 00:48:34 如果你覺得很容易,我可以給你提供個(gè)賬號(hào),你在機(jī)器上可以編寫;方便的話,可把你的QQ號(hào)用站內(nèi)消息發(fā)我,謝謝! |
木蟲 (小有名氣)
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 328求調(diào)劑,英語(yǔ)六級(jí)551,有科研經(jīng)歷 +6 | 生物工程調(diào)劑 2026-03-17 | 10/500 |
|
|---|---|---|---|---|
|
[考研] 311求調(diào)劑 +6 | 冬十三 2026-03-18 | 6/300 |
|
|
[考研] 一志愿武理材料工程348求調(diào)劑 +5 |  ̄^ ̄゜汗 2026-03-19 | 7/350 |
|
|
[考研] 求調(diào)劑 +6 | 十三加油 2026-03-21 | 6/300 |
|
|
[考研] 269專碩求調(diào)劑 +6 | 金恩貝 2026-03-21 | 6/300 |
|
|
[考研] 291 求調(diào)劑 +3 | 化工2026屆畢業(yè)?/a> 2026-03-21 | 3/150 |
|
|
[考研] 318求調(diào)劑 +4 | plum李子 2026-03-21 | 7/350 |
|
|
[考研] 求調(diào)劑 +7 | Auroracx 2026-03-22 | 7/350 |
|
|
[考研]
|
酥酥魚.. 2026-03-21 | 3/150 |
|
|
[考研] 384求調(diào)劑 +3 | 子系博 2026-03-22 | 4/200 |
|
|
[考研] 廣西大學(xué)材料導(dǎo)師推薦 +3 | 夏夏夏小正 2026-03-17 | 5/250 |
|
|
[考研] 297求調(diào)劑 +3 | 喜歡還是不甘心 2026-03-20 | 3/150 |
|
|
[考研] 268求調(diào)劑 +9 | 簡(jiǎn)單點(diǎn)0 2026-03-17 | 9/450 |
|
|
[考研] 機(jī)械專碩299求調(diào)劑至材料 +3 | kkcoco25 2026-03-16 | 4/200 |
|
|
[考研] 一志愿武理材料305分求調(diào)劑 +6 | 想上岸的鯉魚 2026-03-18 | 7/350 |
|
|
[考研] 一志愿西南交大,求調(diào)劑 +5 | 材化逐夢(mèng)人 2026-03-18 | 5/250 |
|
|
[考研] 274求調(diào)劑 +10 | S.H1 2026-03-18 | 10/500 |
|
|
[考研] 330求調(diào)劑 +4 | 小材化本科 2026-03-18 | 4/200 |
|
|
[考研] 298-一志愿中國(guó)農(nóng)業(yè)大學(xué)-求調(diào)劑 +9 | 手機(jī)用戶 2026-03-17 | 9/450 |
|
|
[考博] 26博士申請(qǐng) +3 | 1042136743 2026-03-17 | 3/150 |
|