问题:
有必要使用 Windows Management Instrumentation (WMI) 从 Linux 查询 Windows 服务器。
解决方案:
在 Linux 中安装 wmi 客户端,请按照以下步骤操作
1. 从 www.atomicorp.com 下载 wmi
wget http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/wmi-1.3.14-4.el7.art.x86_64.rpm
--2019-02-06 18:36:16-- http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/wmi-1.3.14-4.el7.art.x86_64.rpm
Connecting to 10.64.114.5:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 8075232 (7.7M) [application/x-rpm]
Saving to: ‘wmi-1.3.14-4.el7.art.x86_64.rpm’
100%[======================================================================================================================================================================>] 8,075,232 6.72MB/s in 1.1s
2019-02-06 18:36:17 (6.72 MB/s) - ‘wmi-1.3.14-4.el7.art.x86_64.rpm’ saved [8075232/8075232]
2. 使用 yum 安装 wmi:
yum install wmi-1.3.14-4.el7.art.x86_64.rpm
Loaded plugins: fastestmirror
Examining wmi-1.3.14-4.el7.art.x86_64.rpm: wmi-1.3.14-4.el7.art.x86_64
Marking wmi-1.3.14-4.el7.art.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package wmi.x86_64 0:1.3.14-4.el7.art will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================================================================
Installing:
wmi x86_64 1.3.14-4.el7.art /wmi-1.3.14-4.el7.art.x86_64 36 M
Transaction Summary
================================================================================================================================================================================================================
Install 1 Package
Total size: 36 M
Installed size: 36 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wmi-1.3.14-4.el7.art.x86_64 1/1
Verifying : wmi-1.3.14-4.el7.art.x86_64 1/1
Installed:
wmi.x86_64 0:1.3.14-4.el7.art
Complete!
3. 测试它
[root@aurlenserver ~]# wmic ?
Usage: [-?|--help] [--usage] [-d|--debuglevel DEBUGLEVEL] [--debug-stderr]
[-s|--configfile CONFIGFILE] [--option=name=value]
[-l|--log-basename LOGFILEBASE] [--leak-report] [--leak-report-full]
[-R|--name-resolve NAME-RESOLVE-ORDER]
[-O|--socket-options SOCKETOPTIONS] [-n|--netbiosname NETBIOSNAME]
[-W|--workgroup WORKGROUP] [--realm=REALM] [-i|--scope SCOPE]
[-m|--maxprotocol MAXPROTOCOL] [-U|--user [DOMAIN\]USERNAME[%PASSWORD]]
[-N|--no-pass] [--password=STRING] [-A|--authentication-file FILE]
[-S|--signing on|off|required] [-P|--machine-pass]
[--simple-bind-dn=STRING] [-k|--kerberos STRING]
[--use-security-mechanisms=STRING] [-V|--version] [--namespace=STRING]
[--delimiter=STRING]
//host query
Example: wmic -U [domain/]adminuser%password //host "select * from Win32_ComputerSystem"
用法:
wmic -U user%password //主机“查询”
例子:
远程获取Windows服务器的RAM:
Windows服务器IP:192.168.123.58
Windows用户名:zabbixmonitor
Windows密码:SuperPassword
wmic -U zabbixmonitor%SuperPassword //192.168.123.58 "select TotalPhysicalMemory from Win32_ComputerSystem"
CLASS: Win32_ComputerSystem
Name|TotalPhysicalMemory
Windows2008R2srv|17179336704
这篇博客指导如何在Linux中通过wmi工具从Windows服务器获取信息,包括下载wmi rpm包、安装、测试,并展示了远程获取Windows RAM的例子。
3万+

被折叠的 条评论
为什么被折叠?



