Monitor Windows via WMI from Cacti on Linux

  • Get the wmi.php script
cd /var/www/cacti/scripts
wget http://svn.parkingdenied.com/CactiWMI/trunk/wmi.php

  • Install the wmi client
cd /usr/local/src
wget http://dev.zenoss.org/svn/trunk/inst/externallibs/wmi-1.3.7.tar.bz2
tar -jxvf wmi-1.3.7.tar.bz2
cd wmi-1.3.7/Samba/source
./autogen.sh
./configure
make
make install

  • After make, it will have /usr/local/bin/wmic, if not exti
mv /usr/local/src/wmi-1.3.7/Samba/source/bin/wmic /usr/local/bin/wmic

  • Configure cactiwmi log
mkdir -p /etc/cacti
mkdir -p /var/log/cacti/wmi
chown cacti:cacti /etc/cacti -R
chown cacti:cacti /var/log/cacti/wmi -R
chmod 700 /etc/cacti -R
chmod 700 /var/log/cacti/wmi -R

  • Create authentication-file for wmic
vi /etc/cacti/cactiwmi.pw

  • Add username, password, domain
username=user
password=password
domain=domain

  • Test if wmic and wmi.php worked?, please change the 192.168.2.1 to a windows server ip address, please confirm the firewall allow wmi command.
/usr/bin/php -q /var/www/cacti/scripts/wmi.php -h 192.168.2.1 -u /etc/cacti/cactiwmi.pw -w Win32_ComputerSystem -c Name -n 'root\cimv2'
/usr/local/bin/wmic --namespace='root\cimv2' --authentication-file=/etc/cacti/cactiwmi.pw //192.168.2.1 "SELECT Name FROM Win32_ComputerSystem"

posted @ 2010-03-10 23:25  kevinzx  阅读(3079)  评论(0编辑  收藏  举报