广告
返回顶部
首页 > 资讯 > 后端开发 > Python >python raid monitor
  • 795
分享到

python raid monitor

pythonraidmonitor 2023-01-31 02:01:09 795人浏览 泡泡鱼

Python 官方文档:入门教程 => 点击学习

摘要

#!/usr/bin/env python#-*-coding:utf8-*-"""    FUN: Monitor Raid Stat"""import os ,time ,sys, traceback,commands,subproce

#!/usr/bin/env python

#-*-coding:utf8-*-

"""

   FUN: Monitor Raid Stat

"""



import os ,time ,sys, traceback,commands,subprocess




def oper_log(log_name,item,info):

   path  = '/tmp/'

   stime = time.strftime('%Y-%m-%d %H:%M:%S')

   fORMats= '[%s] %s:: %s \n' % (stime,item,info)

   if not os.path.exists(path):

       os.mkdir(path)

   try:

       if log_name.split('.')[1] == 'log':

           fp = open(path + log_name,'a')

       elif log_name.split('.')[1] == 'info':

           fp = open(path + log_name,'w')

       else:

           fp = open(path + log_name,'a')

       fp.write(formats)

       fp.close()

   except Exception,e:

       pass


def _exec(cmds):

   try:

       sps = subprocess.Popen(cmds, stdin = subprocess.PIPE,

                                   stdout = subprocess.PIPE,

                                   stderr = subprocess.PIPE,

                                   shell = True)

       sps.wait()

       return sps.stdout.read().strip()

   except:

       oper_log('raid_monitor.log','_exec',traceback.format_exc())

       return ''




def disk_online():

   ''' Getting raid online stat '''

   try:

       cmds = 'megacli  -PDList -aALL | grep Online | wc -l'

       return  _exec(cmds)

   except:

       oper_log('raid_monitor.log','disk_online',traceback.format_exc())

       return ''


def disk_failed():

   try:

       cmds = "megacli -AdpAllInfo -a0 |grep 'Failed Disks'|awk '{print $4}'"

       res = _exec(cmds)

       return res

   except:

       print traceback.format_exc()

       #oper_log('raid_monitor.log','disk_failed',traceback.format_exc())

       return ''


def disk_badSectors():

   turl_num = []

   fail_num = []

   try:

       cmds = "megacli  -PDList -aALL|grep Other|awk '{print $4}'"

       res =  _exec(cmds).split('\n')

       for  i in res:

           i = int(i)

           if i != 0:

               fail_num.append(i)

           else:

               turl_num.append(i)

       return len(fail_num)

   except:

       oper_log('raid_monitor.log','disk_badSectors',traceback.format_exc())

       return ''


def work():


   try:

       if sys.argv[1] == 'disk_online':

           print disk_online()

       elif sys.argv[1] == 'disk_failed':

           print disk_failed()

       elif sys.argv[1] == 'disk_badSectors':


           print disk_badSectors()

       elif sys.argv[1] == 'all':

           print disk_online(),disk_failed(),disk_badSectors()

       else:

           print "Please enter the correct parameters, thank you!"

   except IndexError,e:

       print "Please enter the correct parameters, thank you: --- --- --- "




if __name__ == "__main__":

   st = work()


--结束END--

本文标题: python raid monitor

本文链接: https://www.lsjlt.com/news/185357.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • python raid monitor
    #!/usr/bin/env python#-*-coding:utf8-*-"""    FUN: Monitor Raid Stat"""import os ,time ,sys, traceback,commands,subproce...
    99+
    2023-01-31
    python raid monitor
  • oracle sql monitor
    动态性能视图V$SQL_MONITOR,该视图用以显示Oracle监视的SQL语句信息。V$SQL_MONITOR、v$sql_plan_monitor中的信息将被实时刷新,频率为每秒1次。SQL语句执行完...
    99+
    2022-10-18
  • Goldengate monitor v11.1
    JAVA 版本大于1.6以上即可[root@cwogg ~]# rpm -ivh jre-8u65-linux-x64.rpm Preparing...     &n...
    99+
    2022-10-18
  • 【SQL】Oracle SQL monitor
    据说,在Oracle企业版数据库中有一个免费的工具,乃SQL优化之利器,那就是Oracle SQL monitor。下面,由DBA+社群原创专家周俊,给大家科普一下这一被埋没的神器。专家简介周俊DBA+社群原创专家具有14年以上Oracle...
    99+
    2022-10-18
  • Oracle 11g Health Monitor Checks
    说明:Health Monitor是11g引入的用于检查数据库的各个组件(包括文件、内存、事务处理完整性、元数据和进程使用情况)。这些检查器将生成检查结果报表以及解决问题的建议。可在数据库脱机(nomoun...
    99+
    2022-10-18
  • android monitor怎么查看
    要查看Android Monitor,您可以按照以下步骤操作:1. 打开Android Studio。2. 在主界面的右下角,点击"...
    99+
    2023-10-18
    android
  • TIMED OUT WAITING FOR OHASD MONITOR
    RHEL 7.2安装Oracle 11g RAC在启动时ohasd日志报“Created alert : (:OHAS00117:) : TIMED OUT WAITING FOR OHASD MONIT...
    99+
    2022-10-18
  • SQL Monitor Report怎么用
    这篇文章主要为大家展示了“SQL Monitor Report怎么用”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“SQL Monitor Report怎么用”这...
    99+
    2022-10-18
  • RAID 3
      概念      RAID 3是把数据分成多个“块”,按照一定的容错算法,存放在N+1个硬盘上,实际数据占用的有效空间为N个硬盘的空间总和,而第N+1个硬盘上存储的数据是校验容错信息,当这N+1个硬盘中的其中一个硬盘出现故障时,从其它N...
    99+
    2023-01-31
    RAID
  • Oracle Cluster Health Monitor(CHM)简介
     Oracle Cluster Health Monitor(CHM)简介 概述Cluster Health Monitor(以下简称CHM)是一个Orac...
    99+
    2022-10-18
  • 启动android monitor报错解
     再这汇总一下这段时间使用android monitor新遇到的问题,特汇总对应问题解决办法如下: 1、确保JDK和Android studio位数相同,比如JDK使用的是64位,studio也要是64位,否则会报错; 2、直接在命令窗口...
    99+
    2023-01-30
    报错 android monitor
  • .NET 6中的dotnet monitor讲解
    目录一.什么是dotnetmonitor二.入门.NETCLI工具容器镜像三.HTTPAPI四.触发器五.反馈一.什么是 dotnet monitor 在不同的环境中运行 .NET ...
    99+
    2022-11-12
  • OEM sql monitor 报错java.sql.SQLException: ORA-31011
    打开OEM -sql 监视页面,出现如下报错: java.sql.SQLException: ORA-31011: XML 语法分析失败ORA-19202: XML 处理 LPX-00225: 结束元素标记 "sql" 与起始元素标记 "a...
    99+
    2022-01-15
    OEM sql monitor 报错java.sql.SQLException: ORA-31011 数据库入门 数据库基础教程 数据库 mysql
  • MySQL Enterprise Monitor有什么作用
    本篇内容主要讲解“MySQL Enterprise Monitor有什么作用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“MySQL Enterprise Mo...
    99+
    2022-10-19
  • Oracle 健康监控器(Health Monitor)
    健康监控器(Health Monitor)ORACLE 11G 中引入了免费的数据库健康监控器,通过DBMS_HM程序包来完成。检查项目:1.DB结构完整性检查2.数据块及完整性检查3.中做日志完整性检查4...
    99+
    2022-10-18
  • Postman的Monitor功能有哪些
    本篇内容介绍了“Postman的Monitor功能有哪些”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!Postman的Monitor功能Po...
    99+
    2023-06-05
  • RAID server check (R
    hard raid VS soft raid :there is no much merit in build soft raid on production enviromentit is very rare for enterprise...
    99+
    2023-01-31
    RAID server check
  • 为什么Activity Monitor无法使用
    Activity Monitor可能无法使用的原因有以下几种可能性:1. 权限问题:请确保您具备足够的权限来访问和使用Activit...
    99+
    2023-09-27
    Activity
  • .NET 6中的dotnet monitor是什么
    本篇内容主要讲解“.NET 6中的dotnet monitor是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“.NET 6中的dotnet monit...
    99+
    2023-06-22
  • 华为RH2288 V3 服务器 配置raid & 删除raid配置
    华为RH2288 V3 服务器的RAID 1设置已经设置的raid 如何删除 第一次安装系统时,需要做raid配置新增盘才能使用,以下是配置raid流程 1、首先启动服务器,当在出现以下界面时,按Ctrl+C 2、按下Ctrl+C后等待一...
    99+
    2023-08-31
    服务器 运维
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作