인터페이스에서 소비하는 데이터의 양을 추적하기 위해 slurm 명령을 설치했습니다.apt install slurm
내 금은 출력을 파일에 저장하는 것입니다. 그렇게 할 수 있도록 이 스크립트를 작성했지만 예상한 결과를 얻지 못했습니다.
#!/bin/bash
echo "#####################################"
date "+%F %H:%M:%S :: snapshot on interface"
timeout 5s slurm -s -i eno1 >> /home/trackeNIC.log;
스크립트를 실행하기 위해 이 작업을 추가했습니다.
* * * * * bash /home/trackeNIC.sh >> /home/trackeNIC.log
내가 얻는 결과는 다음과 같습니다.
#####################################
2020-05-15 15:02:01 :: snapshot on interface
#####################################
2020-05-15 15:03:01 :: snapshot on interface
#####################################
나는 다음과 같은 것을 기대했습니다.
#####################################
2020-05-15 15:02:01 :: snapshot on interface
-= slurm 0.4.3 =-
x
x
x
x x
xxxx
xxxx
xx x
x x
x
x
Active Interface: eno1 Interface Speed: unknown
Current RX Speed: 141.12 KB/s Current TX Speed: 17.63 KB/s
Graph Top RX Speed: 876.31 KB/s Graph Top TX Speed: 32.47 KB/s
Overall Top RX Speed: 876.31 KB/s Overall Top TX Speed: 32.47 KB/s
Received Packets: 24045657 Transmitted Packets: 14187466
GBytes Received: 21.377 GB GBytes Transmitted: 1.381 GB
Errors on Receiving: 0 Errors on Transmission: 0
#####################################
2020-05-15 15:03:01 :: snapshot on interface
-= slurm 0.4.3 =-
x
x
x
x x
xxxx
xxxx
xx x
x x
x
x
Active Interface: eno1 Interface Speed: unknown
Current RX Speed: 141.12 KB/s Current TX Speed: 17.63 KB/s
Graph Top RX Speed: 876.31 KB/s Graph Top TX Speed: 32.47 KB/s
Overall Top RX Speed: 876.31 KB/s Overall Top TX Speed: 32.47 KB/s
Received Packets: 24045657 Transmitted Packets: 14187466
GBytes Received: 26.377 GB GBytes Transmitted: 2.381 GB
Errors on Receiving: 0 Errors on Transmission: 0
#####################################
어떤 도움이라도 대단히 감사하겠습니다.
답변1
믿을 수 있는 유일한 방법은 screen이나 tmux와 같은 프로그램을 사용하는 것이라고 생각합니다.
따라서 화면에서 slurm을 실행하고 화면 세션에서 분리한 다음 실행할 수 있습니다.
screen -X hardcopy /tmp/tmpfile
cat /tmp/tmpfile >> final_destionation.txt
크론에서
여러 세션을 캡처해야 하는 경우 더 많은 옵션으로 화면을 수정할 수 있으며 맨 화면이 도움이 될 수 있습니다.
결과는 다음과 같습니다.
-= slurm 0.4.3 on catscrash-desktop =-
x
x
x
x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x x x xx xx xx
x x x x
x x x x
Active Interface: enp3s0 Interface Speed: unknown
Current RX Speed: 0.73 KB/s Current TX Speed: 1.08 KB/s
Graph Top RX Speed: 211.54 KB/s Graph Top TX Speed: 15.46 KB/s
Overall Top RX Speed: 236.80 KB/s Overall Top TX Speed: 22.95 KB/s
Received Packets: 15711309 Transmitted Packets: 8187879
GBytes Received: 14.754 GB GBytes Transmitted: 1.586 GB
Errors on Receiving: 0 Errors on Transmission: 0
-= slurm 0.4.3 on catscrash-desktop =-
x
x
x
x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x x x x x
x x x
x x
x
Active Interface: enp3s0 Interface Speed: unknown
Current RX Speed: 2.15 KB/s Current TX Speed: 0.57 KB/s
Graph Top RX Speed: 226.49 KB/s Graph Top TX Speed: 18.00 KB/s
Overall Top RX Speed: 14187.07 KB/s Overall Top TX Speed: 870.02 KB/s
Received Packets: 15760792 Transmitted Packets: 8215865
GBytes Received: 14.810 GB GBytes Transmitted: 1.590 GB
Errors on Receiving: 0 Errors on Transmission: 0
빈 줄이 많아서 grep을 사용해도 문제가 없지만 시작입니다.