For a simple check to make sure no one has stolen or disconnected a lab computer we have setup a custom sensor.
Simple batch file:
---------------------------------- @ECHO OFF set host=%1 c:\progra~2\PRTGNE~1\custom~1\exe\remotecontrol.exe -p -user admin -pass abc!123AB http://%host%:16992/RemoteControlService |find.exe "SystemPowerstate" IF NOT errorlevel=1 ECHO 200:AMT On Exit 0 IF errorlevel=1 ECHO 100:No Connection Exit 1 -----------------------------------
We pulled Remotecontrol.exe and the required library StatusStrings.dll out of Intel's SDK files found at http://software.intel.com/en-us/articles/download-the-latest-intel-amt-software-development-kit-sdk/
It works to monitor individual lab computers attached to the network when they are powered off (if the PC supports Intel Vpro / AMT and is configured correctly).
Just wondering if anyone had a better way or had something already cooked up. I'd love to get more information then just "connected / not connected" but at the moment thats all my customer sensor will do.
Any thoughts would be great.
Cheers! - Andrew
Article Comments
I have attached some .asp code that can be used with a web page. It also uses RemoteControl.exe to query the remote AMT client. It will print out the power state including sleep and hibernate. Just create a form on a webpage that calls this .asp and passes along the 'hostname' tag with the fqdn or ip address of the client.
<%@ Language=VBScript %>
<%
dim strFQDN
strFQDN = Request.Form("HostName")
%>
<HTML>
<HEAD>
<TITLE>vPro Demo Administration</TITLE>
</HEAD>
<BODY BGCOLOR = FFFFFF>
<%
' Program constants and variables
const strUser = "admin"
const strPass = "P@ssw0rd"
const ForReading = 1, ForWriting = 2, ForAppending = 8
const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
dim objShell : Set objShell = nothing
dim objFSO : Set objFSO = nothing
dim objOutFile : Set objOutFile = nothing
dim objTextStream : Set objTextStream = nothing
dim strCMD
dim strLine, strTMP
dim strMessage
dim strPhysPath
' Initialize the shell to run a command and to access the file system
Set objShell = CreateObject("WScript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Make sure there is a HostName
if strFQDN = "" then
ErrorExit("No Host Name supplied")
end if
' Set variable with path to iso_launcher
strPhysPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "iso_launcher\"
objShell.CurrentDirectory = strPhysPath
' Setup command line string to execute, starts remotecontrol.exe query to see if client is powered off
strCMD = "%COMSPEC% /c remotecontrol.exe -p -user " & strUser & " -pass " & strPass & " http://" & strFQDN & ":16992/RemoteControlService >out.txt"
objShell.Run strCmd, 0, True
' Read in a stream of text from remotecontrol.exe
Set objOutFile = objFSO.GetFile("out.txt")
Set objTextStream = objOutfile.OpenAsTextStream(ForReading, TristateUseDefault)
do until objTextStream.AtEndOfStream
strLine = objTextStream.ReadLine
if (InStr(strLine, "SOAP failure") <> 0) then
strMessage = strFQDN & " is unreachable.<br><br>"
strMessage = strMessage & "The host name you entered may not be valid<br>"
strMessage = strMessage & "or the remote client may be unable to respond.<br>"
ErrorExit(strMessage)
elseif (InStr(strLine, "SystemPowerstate is:") <> 0) then
if (InStr(strLine, "0") <> 0) or (InStr(strLine, "512") <> 0) then
strTMP = MyMessage(strFQDN & " is powered on...<br><br>",0,strDialogTitle,64 + 1)
elseif (InStr(strLine, "1") <> 0) then
ErrorExit(strLine)
elseif (InStr(strLine, "2") <> 0) then
ErrorExit(strLine)
elseif (InStr(strLine, "3") <> 0) then
ErrorExit(strFQDN & " is in sleep state...<br><br>")
elseif (InStr(strLine, "4") <> 0) then
ErrorExit(strFQDN & " is suspended...<br><br>")
elseif (InStr(strLine, "5") <> 0) then
strTMP = MyMessage(strFQDN & " is powered off...<br><br>",0,strDialogTitle,64 + 1)
else
ErrorExit(strLine)
end if
end if
loop
%>
</BODY>
</HTML>
<%
function MyMessage(strMessage,intTimeOut,strTitle,intButton)
Response.Write(strTitle & "<br>")
Response.Write(strMessage & "<br>")
ccsleep(intTimeOut)
MyMessage = 0
end function
function ErrorExit(strMessage)
if strMessage <> "" then
strTMP = MyMessage(strMessage,0,strDialogTitle & " - Error",16)
end if
' Unsuccessful end of script, exit the script
Response.End
end function
function ccSleep(seconds)
cmd = "%COMSPEC% /c ping -n " & 1 + seconds & " 127.0.0.1>nul"
objShell.Run cmd,0,1
end function
%>
Oct, 2010 - Permalink
Guys,
These are terrific posts.
I've had great success with the small batch file but it only detects the presence of the device. I'm going to play around with some of your suggestions to see if I can start collecting better data. We have several computers labs and polling power states would be a huge plus towards our Greening IT initiative. We have tried to stay away from additional software because we like centralizing our statistic collection and we don't like adding additional software to lab images.
Thanks for the info both of you.
- Andrew
Oct, 2010 - Permalink
There are many ways to monitor AMT systems via a script.
I'm sure there are loads of other "do it yourself" options.
BTW - did you figure out, yet, that I work for Intel and am called the "vPro Uber Geek"?
Oct, 2010 - Permalink