我正在使用check_mk作为监控解决方案,我禁用了WMI服务,因为当check_mk查询信息时会创建超时。
Get-WmiObject
/ Get-Disk
/ Get-PSDrive
使用WMI服务获取信息,我想获得磁盘信息,如总空间,已用空间等,而不使用WMI,因为我不能。
你知道任何解决方法吗?
(echo select disk=0 & echo list partition & (for /l %A in (1,1,10) do @echo select disk=next &@echo list partition)) | diskpart | findstr /i /v /r "^$ > microsoft ^reached ^select ^there ^the\ start"
'diskpart.exe'命令可以帮助您获得所需内容。它需要管理员权限,但由于您提到禁用服务,这听起来不是问题。
这个例子不是与DISKPART独特的菜单系统交互,而是盲目地请求前11个磁盘上的分区列表(并过滤掉不必要的行......)。应该够了。 :-)
(echo select disk=0 & echo list partition & (for /l %A in (1,1,10) do @echo select disk=next &@echo list partition)) | diskpart | findstr /i /v /r "^$ > microsoft ^reached ^select ^there ^the\ start"
Disk 0 is now the selected disk.
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Primary 1863 GB 1024 KB
Disk 1 is now the selected disk.
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Primary 350 MB 1024 KB
Partition 2 Primary 270 GB 351 MB
Partition 3 Recovery 845 MB 271 GB
Partition 4 Primary 204 GB 272 GB
Disk 2 is now the selected disk.
Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Primary 931 GB 1024 KB