home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
developer.apple.com
/
developer.apple.com.tar
/
developer.apple.com
/
appleapplications
/
SystemReport.dmg
/
main.command
< prev
next >
Wrap
Text File
|
2007-04-16
|
3KB
|
67 lines
#!/bin/bash
#
# systemreport.sh
#
# systemreport runs the system_profiler utility on each remote machine.
# It then transforms the system_profiler data into an HTML report using XSLT.
#
# The list of remote machines is provided, one per line, on stdin.
# Each remote machine is specified using the [user@]address format used by ssh.
# ssh cannot prompt for passwords, so each remote machine must be configured for
# password-less ssh access (see man ssh, authorized_keys).
#
# The script's support files are expected to be in the same directory
cd "$(dirname "${0}")"
# Custom Shell Script Action parameters are passed as environment variables.
# If the parameter is not choosen or empty, the variable is missing.
# Establish empty values for parameters that are omitted.
if [[ ! "${reportTitle}" ]]; then reportTitle='System Inventory Report'; fi
if [[ ! "${showSpeed}" ]]; then showSpeed=0; fi
if [[ ! "${showKernel}" ]]; then showKernel=0; fi
if [[ ! "${showSerialNumber}" ]]; then showSerialNumber=0; fi
# HTML prolog (be careful with syntax; this text is preprocessed by the shell)
cat << _HEAD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Macintosh System Inventory</title><style type="text/css">
/*<![CDATA[*/
body { text-align: left; font-family: "Lucida Grande", Lucida, Verdana, sans-serif; }
h1 { font-size: 16px; text-align: center; }
h2 { font-size: 13px; text-align: center; }
table { width: 94%; font-size: 10px; background-color: #eee; margin-left: 12px; border-style: dotted; border-width: 1px; }
table td { padding: 4px; border-top: 1px dotted #777; }
table tr:first-child { font-size: 12px; font-weight: bold; font-style: italic; background-color: #fee; }
table tr:first-child td { border: none; }
/*]]>*/</style></head><body><h1>${reportTitle}</h1><h2>Generated $(date '+%v %R')</h2>
<table>
_HEAD
# reportheaders.xml contains a property list that produces the column headers
xsltproc --stringparam ShowSpeed ${showSpeed} \
--stringparam ShowKernel ${showKernel} \
--stringparam ShowSerialNumber ${showSerialNumber} \
sysinfo2inventory.xsl reportheaders.xml
# Add a report record for each machine read from stdin
while read m
do
# Execute system_profiler on the remote computer and capture the results.
# Pipe the XML from system_profiler through an XML transform to produce an HTML table row
# Action choices appear as environment variables; pass to the XSL as parameters
ssh -n ${m} system_profiler -xml SPHardwareDataType SPSoftwareDataType |
xsltproc flattenplist.xsl - |
xsltproc --stringparam NetworkAddress ${m} \
--stringparam ShowSpeed ${showSpeed} \
--stringparam ShowKernel ${showKernel} \
--stringparam ShowSerialNumber ${showSerialNumber} \
sysinfo2inventory.xsl -
done
# HTML epilog
cat << _END
</table></body></html>
_END