監(jiān)控Linux服務器的工具、組件和程序網(wǎng)上有很多,但是一臺服務器上會有很多進程同時運行,特別是做性能測試的時候,可能一臺服務器上部署多個服務,如果只監(jiān)控整個服務器的CPU和內(nèi)存,當某個服務出現(xiàn)性能問題時,并不能有效準確的定位出(當然通過其他工具也可以實現(xiàn)),因此,很有必要只監(jiān)控指定的進程。需求明確了,于是動手擼了一個性能監(jiān)控腳本。
創(chuàng)新互聯(lián)公司專注于唐縣網(wǎng)站建設服務及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供唐縣營銷型網(wǎng)站建設,唐縣網(wǎng)站制作、唐縣網(wǎng)頁設計、唐縣網(wǎng)站官網(wǎng)定制、微信平臺小程序開發(fā)服務,打造唐縣網(wǎng)絡公司原創(chuàng)品牌,更為您提供唐縣網(wǎng)站排名全網(wǎng)營銷落地服務。一、整體思路1、為了方便的啟動監(jiān)控和停止監(jiān)控,在想查看監(jiān)控結果的時候隨時查看監(jiān)控結果,用flask開啟了一個服務,通過發(fā)送get請求可以隨時啟停監(jiān)控和查看監(jiān)控結果。
2、針對控制是否監(jiān)控cpu、內(nèi)存、IO,開啟多線程監(jiān)控。
3、為了減少對其他組件的依賴,將監(jiān)控結果寫到日志中。
4、為了方便查看監(jiān)控結果,直接將結果以html方式返回。
config.py
IP = '127.0.0.1' PORT = '5555' LEVEL = 'INFO' # log level BACKUP_COUNT = 9 # log backup counter LOG_PATH = 'logs' # log path INTERVAL = 1 # interval, run command interval. SLEEPTIME = 3 # interval, when stopping monitor, polling to start monitor when satisfying condition. ERROR_TIMES = 5 # times, number of running command. When equal, automatically stopped monitor. IS_JVM_ALERT = True # Whether to alert when the frequency of Full GC is too high. IS_MONITOR_SYSTEM = True # Whether to monitor system's CPU and Memory. IS_MEM_ALERT = True # Whether to alert when memory is too low. Alert by sending email. MIN_MEM = 2 # Minxium memory, uint: G # 0: don't clear cache, 1: clear page caches, 2: clear dentries and inodes caches, 3: include 1 and 2; # echo 1 >/proc/sys/vm/drop_caches ECHO = 0 SMTP_SERVER = 'smtp.sina.com' # SMTP server SENDER_NAME = '張三' # sender name SENDER_EMAIL = 'zhangsan@qq.com' # sender's email PASSWORD = 'UjBWYVJFZE9RbFpIV1QwOVBUMDlQUT09' # email password, base64 encode. RECEIVER_NAME = 'baidu_all' # receiver name RECEIVER_EMAIL = ['zhangsan@qq.com', 'zhangsi@qq.com'] # receiver's email DISK = 'device1' # Which disk your application runs START_TIME = 'startTime.txt' # Store the time of start monitoring. FGC_TIMES = 'FullGC.txt' # Store the time of every FullGC time. # html HTML = '<html><body>{}</body><html>' ERROR = '<p >{}</p>' HEADER = '<div id="header"><h3 align="center">Performance Monitor (pid={})</h3></div>' ANALYSIS = '<div id="container" >{}</div>'
標題名稱:基于python的Linux系統(tǒng)指定進程性能監(jiān)控思路詳解-創(chuàng)新互聯(lián)
分享URL:http://m.rwnh.cn/article36/dsdppg.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供手機網(wǎng)站建設、企業(yè)網(wǎng)站制作、自適應網(wǎng)站、微信公眾號、關鍵詞優(yōu)化、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容