标签:linux sql windows 操作系统 scom
核心:SCOM几乎所有的数据都是存放在DB中;
难点:DB表结构、字段关联、多表关联;
方案:从DB中获取;
一般情况下,如果仅仅是为了查看数据,由于管理包自带了这些监视器,只需通过SCOM控制台直接查看相应的仪表板,树状图节点路径如下:“监视—MicrosoftWindows 服务器—运行状况监视—磁盘运行状况“即可在展示台中看到逻辑磁盘容量大小。(当然也自带了操作系统、群集、网络的运行状况等仪表板,本文只针对逻辑磁盘空间进行说明。)如下图
如果第三方工具要实时从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].[BaseManagedEntity] [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.[Size_F703D24D_CD51_EAFE_9356_70A323192928] as ‘大小(字节)‘ into #TempTB1 FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$2000$LogicalDisk] T2000 ,[OperationsManager].[dbo].[BaseManagedEntity] T1 WHERE T1.BaseManagedEntityId = T2000.BaseManagedEntityId
效果图:
USE OperationsManager SELECT T1.Path ,T2000.[FileSystem_0D653B7C_3F9D_0EA1_6FF0_3CEF476DBED5] as ‘ 文件系统‘ ,T2000.[DeviceID_DF2FF114_783D_E8EC_DC76_0FC98EF70DB4] as ‘逻辑分区‘ ,T2000.[Size_F703D24D_CD51_EAFE_9356_70A323192928] as ‘大小(字节)‘ into #TempTB1 FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$2000$LogicalDisk] T2000 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_F703D24D_CD51_EAFE_9356_70A323192928] FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$2003$LogicalDisk] T2003 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_F703D24D_CD51_EAFE_9356_70A323192928] FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$2008$LogicalDisk] T2008 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_F703D24D_CD51_EAFE_9356_70A323192928] FROM [OperationsManager].[dbo].[MT_Microsoft$Windows$Server$6$2$LogicalDisk] T2012 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$AIX$5$3$LogicalDisk] TAIX53 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$AIX$6$1$LogicalDisk] TAIX61 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$AIX$7$LogicalDisk] TAIX7 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$RHEL$4$LogicalDisk] TRHEL4 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$RHEL$5$LogicalDisk] TRHEL5 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$RHEL$6$LogicalDisk] TRHEL6 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$RHEL$6$LogicalDisk] TRHEL6 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$SLES$9$LogicalDisk] TSLES9 ,[OperationsManager].[dbo].[BaseManagedEntity] 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.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$SLES$10$LogicalDisk] TSLES10 ,[OperationsManager].[dbo].[BaseManagedEntity] T1 WHERE T1.BaseManagedEntityId = TSLES10.BaseManagedEntityId insert into #TempTB1 SELECT T1.Path ,TSLES11.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C] ,TSLES11.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF] ,TSLES11.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$SLES$11$LogicalDisk] TSLES11 ,[OperationsManager].[dbo].[BaseManagedEntity] T1 WHERE T1.BaseManagedEntityId = TSLES11.BaseManagedEntityId insert into #TempTB1 SELECT T1.Path ,TUniversal.[FileSystem_33C79158_2D36_06FA_FAF1_27BB8F983A0C] ,TUniversal.[DeviceID_76FE57D8_F808_15E1_EDC0_E929FBA69DEF] ,TUniversal.[Size_57A31D54_6A9D_8AE2_087A_9563C8508A5D] FROM [OperationsManager].[dbo].[MT_Microsoft$Linux$Universal$LogicalDisk] TUniversal ,[OperationsManager].[dbo].[BaseManagedEntity] T1 WHERE T1.BaseManagedEntityId = TUniversal.BaseManagedEntityId ----输出数据 select * from #TempTB1 ORDER by ‘PATH‘ ----删除临时表 drop table #TempTB1
本文出自 “随心” 博客,转载请与作者联系!
标签:linux sql windows 操作系统 scom
原文地址:http://bennychen.blog.51cto.com/6323894/1714660