top資訊監控
下面是指令碼的一些引數說明,紅色部分對應修改成自己需要的查詢內容就可以了:
#!/bin/sh
logpath="$HOME/toplogs";#指定輸出日誌的目錄
sleeptime=5; #執行top的間隔時間
headline=" PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND ";
iter=0; #迭代器初始化
maxiter=5; #設定多少行輸出一次對應的headline的內容
while [ 1 ];do
logdate=`date +%Y-%m-%d`;
oldlogfile="$logfile";
logfile=${logpath}/top${logdate}.log;
if [ "$oldlogfile" != "$logfile" -o $iter -eq "$maxiter" ];then
echo "$headline" >> $logfile;
iter=0;
fi;
iter=`expr $iter + 1`;
synctime=`date '+DATE:%Y-%m-%d %H:%M:%S'`;
echo -n $synctime '>>' >> $logfile;
/usr/bin/top -b -n 1 | grep init | grep -v grep | cut -c1-96 2>&1 >> $logfile;
sleep $sleeptime;
done
輸出資訊如下:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
DATE:2009-03-13 11:54:32 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:54:38 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:54:43 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:54:49 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:54:54 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
DATE:2009-03-13 11:55:00 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:05 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:11 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:16 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:22 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
DATE:2009-03-13 11:55:27 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:33 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:38 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:44 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:49 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
DATE:2009-03-13 11:55:55 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:56:00 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:56:06 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:56:11 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:56:17 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:54:32 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:54:38 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:54:43 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:54:49 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:54:54 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
DATE:2009-03-13 11:55:00 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:05 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:11 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:16 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:22 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
DATE:2009-03-13 11:55:27 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:33 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:38 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:44 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:55:49 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
DATE:2009-03-13 11:55:55 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:56:00 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:56:06 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:56:11 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
DATE:2009-03-13 11:56:17 >> 1 root 16 0 2404 592 504 S 0 0.0 0:02.27 init
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12932950/viewspace-567154/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- JvmTop監控JVM的TOP命令JVM
- linux 效能監控分析以及調優(top)Linux
- MongoDB如何使用top命令監控資料庫MongoDB資料庫
- Redis 常用監控資訊命令總結Redis
- 將Nagios監控資訊存入MySQLiOSMySql
- Shell 系統資訊監控指令碼指令碼
- SQL Server 監控統計阻塞指令碼資訊SQLServer指令碼
- java獲取redis的日誌資訊和動態監控資訊JavaRedis
- 黑盒監控、日誌監控
- Sigar java 伺服器資訊探針、監控Java伺服器
- 社交媒體資訊監控新領域:圖片–資料資訊圖
- 6.prometheus監控--監控dockerPrometheusDocker
- Skywalking-04:擴充套件Metric監控資訊套件
- Windows下安裝Cacti流量與系統資訊監控Windows
- 監控系統是資訊資源管理的基礎
- top linux 實時監控命令 檢視CPU使用率(轉)Linux
- TiDB監控實現--存活監控TiDB
- 聊聊前端監控——錯誤監控篇前端
- nagios監控例項 -- PostgreSQL監控iOSSQL
- APM效能監控軟體的監控型別服務及監控流程型別
- 專案實戰:zabbix監控MySQL狀態、服務資訊MySql
- Facebook運用人工智慧監控直播 篩選不良資訊人工智慧
- 透過itm UA實現的Tuxedo監控資訊說明UX
- 【SQL監控】SQL完全監控的指令碼SQL指令碼
- 伺服器監控之 ping 監控伺服器
- 3-主機監控、應用監控
- Redis監控Redis
- 批量監控
- index 監控Index
- nginx監控Nginx
- centos 監控CentOS
- zabbix監控
- 夜鶯監控
- mysql 的一個監控指令碼,監控heartbeatMySql指令碼
- 三維模擬智慧伺服器 —— 資訊保安監控平臺伺服器
- 數字孿生智慧伺服器:資訊保安監控平臺伺服器
- KPI企業綜合監控系統--資訊系統之綱KPI
- top命令資訊詳解