# this program was written by Philip Greenspun (philg@mit.edu) # it is free to everyone under the standard GNU Public License # park this in a file named monitor.tcl somewhere that AOLserver # can access it (note that you must have enabled Tcl pages to # have this work) set connections [ns_server active] # let's build an ns_set just to figure out how many distinct elts; kind of a kludge # but I don't see how it would be faster in raw Tcl set scratch [ns_set new scratch] foreach connection $connections { ns_set cput $scratch [lindex $connection 1] 1 } set distinct [ns_set size $scratch] # run standard Unix uptime command to get load average (crude measure of # system health) set uptime_output [exec uptime] ns_write $conn "HTTP/1.0 200 OK MIME-Version: 1.0 Content-Type: text/html
Here's what uptime has to say about the box:
$uptime_output
conn # | client IP | state | method | url | n seconds |
---|---|---|---|---|---|
[join $connection | ]" } ns_write $conn " |