×

微信扫一扫,快捷登录!

nagios 监控windows 的磁盘

标签: windows监控
来自:网络
disk = wmi.WMI(moniker='//./root/cimv2:Win32_LogicalDisk.DeviceID="%s:"' %drive)        
nagios安装
   
#    for disk in c.Win32_LogicalDisk (DriveType=3):  
    data_dict['total_available'] += round(float(disk.FreeSpace) / (1024*1024*1024), 2)  
    data_dict['total_capacity'] += round(float(disk.Size) / (1024*1024*1024), 2)  
    data_dict['total_free'] += round(float(disk.FreeSpace) / (1024*1024*1024), 2)  
   
    dev_tmp = {}  
    dev_tmp['dev'] = disk.DeviceID  
    dev_tmp['available'] = {'volume':round(float(disk.FreeSpace) / (1024*1024*1024), 2), 'unit':'GB'}         
开源监控软件

    dev_tmp['capacity'] = {'volume':round(float(disk.Size) / (1024*1024*1024), 2), 'unit':'GB'}  
    dev_tmp['free'] = {'volume':round(float(disk.FreeSpace) / (1024*1024*1024), 2), 'unit':'GB'}   
nagios配置

    dev_tmp['fstype'] = disk.FileSystem  
    dev_tmp['mnt'] = ''  
    dev_tmp['used'] = round(long(disk.FreeSpace) / long(disk.Size), 2)  
   
    data_dict[disk.DeviceID] = dev_tmp  
   
    com = win32com.client.Dispatch("WbemScripting.SWbemRefresher")  
    obj = win32com.client.GetObject('''winmgmts:\\root\cimv2''')  
    diskitems = com.AddEnum(obj, "Win32_PerfFormattedData_PerfDisk_LogicalDisk").objectSet   
监控软件

      
    com.Refresh()  
    for item in diskitems:  
        if item.Name in data_dict:  
            data_dict[item.Name]['io_stat'] = {}  
            data_dict[item.Name]['io_stat']['r/s'] = {'volume':float(item.DiskReadsPerSec), 'unit':''}  
            data_dict[item.Name]['io_stat']['w/s'] = {'volume':float(item.DiskWritesPerSec), 'unit':''}  
            data_dict[item.Name]['io_stat']['rkB/s'] = {'volume':(float(item.DiskReadBytesPerSec) / 1024), 'unit':'KB/s'}  
            data_dict[item.Name]['io_stat']['wkB/s'] = {'volume':(float(item.DiskWriteBytesPerSec) / 1024), 'unit':'KB/s'}  
#    return {'data':data_dict, 'timestamp':time.asctime(time.localtime())}
    return data_dict

#print DISK('C')['C:']['io_stat']['wkB/s']['volume'],DISK('C')['C:']['io_stat']['rkB/s']['volume']   
nagios实施

def printr():
    disk = DISK(options.partion)
    diskw = disk[options.partion+':']['io_stat']['wkB/s']['volume']
    diskr = disk[options.partion+':']['io_stat']['rkB/s']['volume']        
nagios培训

    print "Partion %s IO: READ %2.f KB/s Write %2.f KB/s | READ=%2.fKB WRITE=%2.fKB" %(options.partion,diskr,diskw,diskr,diskw)

if __name__ == '__main__':
    printr()


想做Nagios Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流  QQ群号 476809427




上一篇:能源行业IT企业招聘“项目经理”(工作地点:北京,待遇优厚)
下一篇:nagios 特定用户权限管理
monicazhang

写了 2297 篇文章,拥有财富 12859,被 21 人关注

您需要登录后才可以回帖 登录 | 立即注册
B Color Link Quote Code Smilies

成为第一个吐槽的人

Powered by IT 运维管理
返回顶部