tcl-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Buhr" <pb...@vision-systems.de>
Subject problems with child processes
Date Thu, 27 Jun 2002 15:49:56 GMT

Hello,

I wrote a tcl-Skript, what runs command-line processes to get
informations which are used. Sometime it works, sometimes it crashes.
When it crashes, I get the following error:

 5:44pm  up 2 days,  9:28,  0 users,  load average: 0.05, 0.06, 0.08
error waiting for process to exit: child process lost (is SIGCHLD
ignored or trapped?)
    while executing
"exec uptime"


followed by the code of the script. When I run the script using tclsh, I
never receive an error message like this... what do I wrong?


Here the source....



 # Last auslesen
set uptime [exec uptime]
set last [string trim [string range $uptime [expr [string last ","
$uptime] + 1] end]]

# Hostnamen auslesen
set thishost [exec hostname]

# Arbeitsspeicher
set mem [exec free | grep "Mem"]
set memtemp  [string trim [string range $mem [expr [string first " "
$mem] + 1] end]]
set totalmem  [string trim [string range $memtemp 0 [expr [string first
" " $memtemp] + 1]]]
set memtemp  [string trim [string range $memtemp [expr [string first " "
$memtemp] + 1] end]]
set usedmem [string trim [string range $memtemp 0 [expr [string first "
" $memtemp] + 1]]]
set memtemp  [string trim [string range $memtemp [expr [string first " "
$memtemp] + 1] end]]
set freemem [string trim [string range $memtemp 0 [expr [string first "
" $memtemp] + 1]]]

# Swap-Speicher
set swap [exec free | grep "Swap"]
set swaptemp  [string trim [string range $swap [expr [string first " "
$swap] + 1] end]]
set totalswap  [string trim [string range $swaptemp 0 [expr [string
first " " $swaptemp] + 1]]]
set swaptemp  [string trim [string range $swaptemp [expr [string first "
" $swaptemp] + 1] end]]
set usedswap [string trim [string range $swaptemp 0 [expr [string first
" " $swaptemp] + 1]]]
set freeswap  [string trim [string range $swaptemp [expr [string first "
" $swaptemp] + 1] end]]

# Prozessorinformation
set procinfo [exec cat /proc/cpuinfo]


### AUSGABE ###
puts "<HTML><HEAD>"
puts "<TITLE>System-Monitor</TITLE>"
puts "<META HTTP-EQUIX=\"REFRESH\" CONTENT=\"60\">"
puts "</HEAD><BODY BGCOLOR=\"#1929FF\" TEXT=\"#FFFF00\" FACE=\"COURIER\">"
puts "<B><U>Hostname:</U></B> $thishost<BR>"
puts "<B><U>durchschnittliche CPU-Last:</U></B> $last<BR>"
puts "<BR><BR><BR>"
puts "<FONT COLOR=\"#FFFFFF\"><H2>Speicherauslastung</H2></FONT>"
puts "<TABLE BORDER=\"2\" BORDERCOLOR=\"#1111EE\" BGCOLOR=\"#800000\">"
puts "<TR>"
puts "<TD BGCOLOR=\"#008000\"><B><I>Speichertyp</I></B></TD>"
puts "<TD BGCOLOR=\"#008000\"><B><I>gesamt</I></B></TD>"
puts "<TD BGCOLOR=\"#008000\"><B><I>belegt</I></B></TD>"
puts "<TD BGCOLOR=\"#008000\"><B><I>frei</I></B></TD>"
puts "</TR>"
puts "<TR>"
puts "<TD BGCOLOR=\"#000080\"><FONT
COLOR=\"#FFFFFF\">psysikalisch</FONT></TD>"
puts "<TD>$totalmem</TD>"
puts "<TD>$usedmem</TD>"
puts "<TD>$freemem</TD>"
puts "</TR>"
puts "<TR>"
puts "<TD BGCOLOR=\"#000080\"><FONT
COLOR=\"#FFFFFF\">Auslagerung</FONT></TD>"
puts "<TD>$totalswap</TD>"
puts "<TD>$usedswap</TD>"
puts "<TD>$freeswap</TD>"
puts "</TR>"
puts "</TABLE>"
puts "<BR><BR><BR>"
puts "<FONT COLOR=\"#FFFFFF\"><H2>Prozessorinformation</H2></FONT>"
puts "<TABLE BORDER=\"0\" BGCOLOR=\"#FFFF00\"><TR><TD><FONT
COLOR=\"#000000\"><PRE>$procinfo</PRE></FONT></TD></TR></TABLE>"
puts "<BR><BR><BR>"
puts "<FONT COLOR=\"#FFFFFF\"><H2>Massenspeicher</H2></FONT>"


# Massenspeicher
puts "<TABLE BORDER=\"2\" BORDERCOLOR=\"#1111EE\" BGCOLOR=\"#800000\">"
puts "<TR>"
puts "<TD BGCOLOR=\"#008000\"><B><I>Device</I></B></TD>"
puts "<TD BGCOLOR=\"#008000\"><B><I>Gr&ouml;&szlig;e</I></B></TD>"
puts "<TD BGCOLOR=\"#008000\"><B><I>belegt</I></B></TD>"
puts "<TD BGCOLOR=\"#008000\"><B><I>frei</I></B></TD>"
puts "<TD BGCOLOR=\"#008000\"><B><I>in %</I></B></TD>"
puts "<TD BGCOLOR=\"#008000\"><B><I>Mountpoint</I></B></TD>"
puts "</TR>"

set mass [exec df | grep "dev"]
foreach drive [split $mass "\n"] {
set drivename [string trim [string range $drive 0 [expr [string first "
" $drive] + 1]]]
set drivetemp [string trim [string range $drive [expr [string first " "
$drive] + 1] end]]
set drivetotal [string trim [string range $drivetemp 0 [expr [string
first " " $drivetemp] + 1]]]
set drivetemp [string trim [string range $drivetemp [expr [string first
" " $drivetemp] + 1] end]]
set driveused [string trim [string range $drivetemp 0 [expr [string
first " " $drivetemp] + 1]]]
set drivetemp [string trim [string range $drivetemp [expr [string first
" " $drivetemp] + 1] end]]
set drivefree [string trim [string range $drivetemp 0 [expr [string
first " " $drivetemp] + 1]]]
set drivetemp [string trim [string range $drivetemp [expr [string first
" " $drivetemp] + 1] end]]
set drivefull [string trim [string range $drivetemp 0 [expr [string
first " " $drivetemp]]]]
set drivemount [string trim [string range $drivetemp [expr [string first
" " $drivetemp] + 1] end]]

puts "<TR>"
puts "<TD><I>$drivename</I></TD>"
puts "<TD>$drivetotal</TD>"
puts "<TD>$driveused</TD>"
puts "<TD>$drivefree</TD>"
puts "<TD><B>$drivefull</B></TD>"
puts "<TD><I>$drivemount</I></TD>"
puts "</TR>"

}
puts "</TABLE>"
puts "</BODY></HTML>"

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@tcl.apache.org
For additional commands, e-mail: general-help@tcl.apache.org


Mime
View raw message