\[Editor's Note: Email your scripting solutions (400 words or less) to Reader to Reader at firstname.lastname@example.org. Please include your script and phone number. We edit submissions for style, grammar, and length. If we print your contribution, you receive $100.\]
With the downturn in the economy, I've been doing a lot of metrics reporting. I devised the script that Listing 1, page 16, shows, which uses uptime.exe from the Microsoft Windows NT Server 4.0 Resource Kit (or at http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/winntas/downloads/uptime.asp) to report on server uptime and csv2html.exe from http://joncombe.future.easyspace.com to convert the Comma Separated Value (CSV) data into HTML for posting on a Web site. Figure 1, page 16, shows sample results.
Many Csv2html-type programs exist; I chose this one because it didn't require me to install Perl. Search for "CSV to HTML" at http://google.com to find utilities with other options.
Remember that you need proper rights to use the Uptime utility to pull events from the event log. You also need to modify the script with your environment's pathnames. The /s switch returns system statistics. The /f switch lets you specify the name of a file that lists the names of all the servers that you want to report on. The /t switch lets you specify the number of threads Uptime can use (the maximum is 25). You could also use the /v switch to collect all events, including shutdowns, restarts, OS failures, and service pack installations.
When your input is a list of servers, the standard output is a .csv file. After the script runs Csv2html to convert this file to HTML, the script copies the HTML file to a Web-publishing directory for everyone to view.
Alternatively, you could name the servers in the script and produce text output, which might be easier to read. You can then use the txt2html.pl utility from http://www.aigeek.com/txt2html to convert the text file to HTML for posting on the Web. Listing 2 shows a script that takes this approach and produces results like those that Web Figure 1 (http://www.winscriptingsolutions.com, InstantDoc ID 25646) shows. On an NT 4.0 workstation that's in the domain, use an AT command to schedule these scripts and let them run under Administrator permissions.