2015年11月20日星期五

[SCOM]另辟蹊径获取SCOM监控的磁盘空间数据

本邮件内容由第三方提供,如果您不想继续收到该邮件,可 点此退订
[SCOM]另辟蹊径获取SCOM监控的磁盘空间数据  阅读原文»

[SCOM]另辟蹊径获取SCOM监控的磁盘空间数据

核心:SCOM几乎所有的数据都是存放在DB中;
难点:DB表结构、字段关联、多表关联;
方案:从DB中获取;

一般情况下,如果仅仅是为了查看数据,由于管理包自带了这些监视器,只需通过SCOM控制台直接查看相应的仪表板,树状图节点路径如下:"监视�DMicrosoftWindows 服务器�D运行状况监视�D磁盘运行状况"即可在展示台中看到逻辑磁盘容量大小。(当然也自带了操作系统、群集、网络的运行状况等仪表板,本文只针对逻辑磁盘空间进行说明。)如下图

wKioL1ZNZETAEdvTAAEn9Nz3sHk732.png

如果第三方工具要实时从SCOM中获取到数据,并进行处理时会发现第三方工具存在无法直接调用监视器的情况,这时也许会采取另外一个办法:创建规则(而规则是利用WMI进行获取数据的,第三方工具可以直接调用WMI工作)。

不过会存一些问题,比如SCOM是否重复监控:如果磁盘容量发生警报,自带的监视器会告警,另外自定义的规则是否存在同时告警。

SCOM警报规则需要手动关闭,这是警报监视器最大的区别,在实际环境中多数推崇能使用监视器的就尽可能使用监视器。采用监视器一来是可实时反馈对象的正异常情况,二来可减轻运维人员的工作负担。

由于SCOM监控获取到的数据均存放到OperationsManager这个数据库中的,这时可以考虑让第三方工具直接从数据库获取需要的数据。OperationsManager数据表结构不清楚,是否存在某些表和字段存放逻辑磁盘大小的呢?

这时可通过SQL语句进行查询和了解表结构和字段间的关联

获取所有表名

  SELECT Name FROM DatabaseName..SysObjects Where XType='U' ORDER BY Name  

XType='U':表示所有用户表;
XType='S':表示所有系统表;

获取所有字段名

  SELECT Name FROM SysColumns WHERE id=Object_Id('TableName')  

获取主键字段

  SELECT  name FROM SysColumns WHERE id=Object_Id('表名') and colid=(select top 1 keyno from sysindexkeys where id=Object_Id('表名'))  

通过分析发现SCOM的DB中存在以下列表

总结通式:MT_Microsoft$操作系统类型$版本$LogicalDisk

注:微软和开源操作系统表存在差异

  MT_Microsoft$AIX$5$3$LogicalDisk  MT_Microsoft$AIX$6$1$LogicalDisk  MT_Microsoft$AIX$7$LogicalDisk  MT_Microsoft$Linux$RHEL$4$LogicalDisk  MT_Microsoft$Linux$RHEL$5$LogicalDisk  MT_Microsoft$Linux$RHEL$6$LogicalDisk  MT_Microsoft$Linux$SLES$10$LogicalDisk  MT_Microsoft$Linux$SLES$11$LogicalDisk  MT_Microsoft$Linux$SLES$9$LogicalDisk  MT_Microsoft$Linux$Universal$LogicalDisk  MT_Microsoft$Windows$Server$2000$LogicalDisk  MT_Microsoft$Windows$Server$2003$LogicalDisk  MT_Microsoft$Windows$Server$2008$LogicalDisk  MT_Microsoft$Windows$Server$6$2$LogicalDisk  

涉及到表:

  [OperationsManager].[dbo].  [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$2000$LogicalDisk]  

SQL核心语句:

  SELECT    T1.Path      ,T2000.[FileSystem_0D653B7C_3F9D_0EA1_6FF0_3CEF476DBED5] as '  文件系统'     ,T2000.[DeviceID_DF2FF114_783D_E8EC_DC76_0FC98EF70DB4] as '逻辑分区'     ,T2000. as '大小(字节)'    into #TempTB1  FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$2000$LogicalDisk] T2000  ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = T2000.BaseManagedEntityId  

效果图:

wKioL1ZNZGbQy4ebAAB5-TPqL3o015.png附SQL语句:

  USE OperationsManager  SELECT    T1.Path      ,T2000.[FileSystem_0D653B7C_3F9D_0EA1_6FF0_3CEF476DBED5] as '  文件系统'     ,T2000.[DeviceID_DF2FF114_783D_E8EC_DC76_0FC98EF70DB4] as '逻辑分区'     ,T2000. as '大小(字节)'    into #TempTB1  FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$2000$LogicalDisk] T2000  ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = T2000.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,T2003.[FileSystem_0D653B7C_3F9D_0EA1_6FF0_3CEF476DBED5]      ,T2003.[DeviceID_DF2FF114_783D_E8EC_DC76_0FC98EF70DB4]      ,T2003.  FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$2003$LogicalDisk] T2003    ,[OperationsManager].[dbo]. T1  WHERE T1.BaseManagedEntityId = T2003.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,T2008.[FileSystem_0D653B7C_3F9D_0EA1_6FF0_3CEF476DBED5]      ,T2008.[DeviceID_DF2FF114_783D_E8EC_DC76_0FC98EF70DB4]      ,T2008.  FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$2008$LogicalDisk] T2008    ,[OperationsManager].[dbo]. T1  WHERE T1.BaseManagedEntityId = T2008.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,T2012.[FileSystem_0D653B7C_3F9D_0EA1_6FF0_3CEF476DBED5]      ,T2012.[DeviceID_DF2FF114_783D_E8EC_DC76_0FC98EF70DB4]      ,T2012.    FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$6$2$LogicalDisk] T2012    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = T2012.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TAIX53.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C]      ,TAIX53.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF]      ,TAIX53.    FROM [OperationsManager].[dbo].[MT_Microsoft$AIX$5$3$LogicalDisk] TAIX53    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = TAIX53.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TAIX61.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C]      ,TAIX61.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF]      ,TAIX61.    FROM [OperationsManager].[dbo].[MT_Microsoft$AIX$6$1$LogicalDisk] TAIX61    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = TAIX61.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TAIX7.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C]      ,TAIX7.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF]      ,TAIX7.    FROM [OperationsManager].[dbo].[MT_Microsoft$AIX$7$LogicalDisk] TAIX7    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = TAIX7.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TRHEL4.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C]      ,TRHEL4.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF]      ,TRHEL4.    FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$RHEL$4$LogicalDisk] TRHEL4    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = TRHEL4.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TRHEL5.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C]      ,TRHEL5.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF]      ,TRHEL5.    FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$RHEL$5$LogicalDisk] TRHEL5    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = TRHEL5.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TRHEL6.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C]      ,TRHEL6.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF]      ,TRHEL6.    FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$RHEL$6$LogicalDisk] TRHEL6    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = TRHEL6.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TRHEL6.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C]      ,TRHEL6.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF]      ,TRHEL6.    FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$RHEL$6$LogicalDisk] TRHEL6    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = TRHEL6.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TSLES9.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C]      ,TSLES9.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF]      ,TSLES9.    FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$SLES$9$LogicalDisk] TSLES9    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = TSLES9.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TSLES10.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C]      ,TSLES10.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF]      ,TSLES10.    FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$SLES$10$LogicalDisk] TSLES10    ,[OperationsManager].[dbo]. T1    WHERE T1.BaseManagedEntityId = TSLES10.BaseManagedEntityId  insert into #TempTB1  SELECT    T1.Path      ,TSLES11.[FileSystem_33C79158_2D36_06FA_F

阅读更多内容

没有评论:

发表评论