Monitor_数据分析篇(字段解释)

监控程序:

# !/usr/bin/env python
#
-*- coding: cp936 -*-
import  threading,os,time

class  Config_th:
    
    
def  Config_m(self):
        
        
# global set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday
        path  =   " monitor_config. "
        monitor_config_path 
=  open(path, ' r ' )
        config_list 
=  monitor_config_path.readlines()
        
# Set WorkPath Config 
        set_workpath  =  config_list[ 1 ][ 10 : - 1 ]
        
# set CommandPath Config
        set_commandpath  =  config_list[ 2 ][ 13 : - 1 ]
        
# set looptime Config
        set_looptime  =  config_list[ 3 ][ 17 : - 1 ]
        
# set loopdata Config
        set_loophour  =  config_list[ 4 ][ 14 : - 1 ]
        
# set loopday Config
        set_loopday  =  config_list[ 5 ][ 14 : - 1 ]
        
# test(os.system("echo %s" % (set_loopday)))
         return  set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday

class  Cpuinfo_th(threading.Thread,Config_th):
    
    
def   __init__ (self):
        threading.Thread.
__init__ (self)
    
def  run(self):
        
# global set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday
        set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday  =  self.Config_m()
        os.system(
" %s/iostat -t -c 1 1 >> %s/cpu_info.txt "   %  (set_commandpath,set_workpath))
            
class  Memoryinfo_th(threading.Thread,Config_th):
    
    
def   __init__ (self):
        threading.Thread.
__init__ (self)
    
def  run(self):
        
# global set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday
        set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday  =  self.Config_m()
        os.system(
" /usr/bin/vmstat -S K 1 1 >> %s/memory_info.txt "   %  (set_workpath))
        
class  Deciveinfo_th(threading.Thread,Config_th):
    
    
def   __init__ (self):
        threading.Thread.
__init__ (self)
    
def  run(self):
        
# global set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday
        set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday  =  self.Config_m()
        os.system(
" %s/iostat -d 1 1 >> %s/decive_io_info.txt "   %  (set_commandpath,set_workpath))

class  Totalinfo_th(threading.Thread,Config_th):
    
    
def   __init__ (self):
        threading.Thread.
__init__ (self)
    
def  run(self):
        
# global set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday
        set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday  =  self.Config_m()
        os.system(
" %s/sar -u 1 1 >> %s/total_info.txt "   %  (set_commandpath,set_workpath))
        
class  Control(Config_th):
    
    
def  console(self):
        
# application object
         global  set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday
        cpuinfo_th 
=  Cpuinfo_th()
        memoryinfo_th 
=  Memoryinfo_th()
        deciveinfo_th 
=  Deciveinfo_th()
        totalinfo_th 
=  Totalinfo_th()
        set_workpath,set_commandpath,set_looptime,set_loophour,set_loopday 
=  self.Config_m()
        
# loop control main()
         for  i  in  range(float(str(set_loopday))):
            
for  i  in  range(float(str(set_loophour))):
                time.sleep(float(str(set_looptime)))
                
print   " Execute OK!,run cpuinfo,%d "   %  (i)
                cpuinfo_th.run()
                time.sleep(
0.001 )
                
print   " Execute OK!,run memoryinfo,%d "   %  (i)
                memoryinfo_th.run()
                time.sleep(
0.001 )
                
print   " Execute OK!,run deciveinfo,%d "   %  (i)
                deciveinfo_th.run()
                time.sleep(
0.001 )
                
print   " Execute OK!,run totalinfo,%d "   %  (i)
                totalinfo_th.run()
                time.sleep(
0.001 )
                
print   " Total Execute %d...... "   %  (i)
   
if   __name__   ==   " __main__ " :
    
    control 
=  Control()
    control.console()
        
        

 参数配置:

[Config]
work_path=/home/data
command_path=/usr/local/bin
loop_time_second=10
loop_day_hour=224
loop_week_day=7

[ Cpu ]
%usr:CPU处在用户模式下的时间百分比。 
%sys:CPU处在系统模式下的时间百分比。  
%wio:CPU等待输入输出完成时间的百分比。
%idle:CPU空闲时间百分比。
在所有的显示中,我们应主要注意%wio和%idle,%wio的值过高,表示硬盘存在I/O瓶颈, 
%idle值高,表示CPU较空闲,如果%idle值高但系统响应慢时,有可能是CPU等待分配内存, 
此时应加大内存容量。%idle值如果持续低于10,那么系统的CPU处理能力相对较低,表 
明系统中最需要解决的资源是CPU.

[ Decive ]
bread/s: 每秒从硬盘读入系统缓冲区buffer的物理块数。 
lread/s: 平均每秒从系统buffer读出的逻辑块数。 
%rcache: 在buffer cache中进行逻辑读的百分比。 
bwrit/s: 平均每秒从系统buffer向磁盘所写的物理块数。 
lwrit/s: 平均每秒写到系统buffer逻辑块数。 
%wcache: 在buffer cache中进行逻辑读的百分比。 
pread/s: 平均每秒请求物理读的次数。 
pwrit/s: 平均每秒请求物理写的次数。
在显示的内容中,最重要的是%cache和%wcache两列,它们的值体现着buffer的使用效 
率,%rcache的值小于90或者%wcache的值低于65,应适当增加系统buffer的数量,buffer 
数量由核心参数NBUF控制,使%rcache达到90左右,%wcache达到80左右。但buffer参数 
值的多少影响I/O效率,增加buffer,应在较大内存的情况下,否则系统效率反而得不到 
提高。

[ Memory ]
procs: 
r-->
; 在运行队列中等待的进程数 
b--> ; 在等待io的进程数 
w--> ; 可以进入运行队列但被替换的进程 
memoy 
swap-->
; 现时可用的交换内存(k表示) 
free--> ; 空闲的内存(k表示) 
pages 
re--》回收的页面 
mf--》非严重错误的页面 
pi--》进入页面数(k表示) 
po--》出页面数(k表示) 
fr--》空余的页面数(k表示) 
de--》提前读入的页面中的未命中数 
sr--》通过时钟算法扫描的页面 
disk 显示每秒的磁盘操作。 s表示scsi盘,0表示盘号 
fault 显示每秒的中断数 
in--》设备中断 
sy--》系统中断 
cy--》cpu交换 
cpu 表示cpu的使用状态 
cs--》用户进程使用的时间 
sy--》系统进程使用的时间 
id--》cpu空闲的时间 
 
如果 r经常大于 
4  ,且id经常少于40,表示cpu的负荷很重。 
如果pi,po 长期不等于0,表示内存不足。 
如果disk 经常不等于0, 且在 b中的队列 大于3, 表示 io性能不好。 

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值