1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
|
### Copyright (C) 1996,97 Per Zacho
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
proc limits {} {
# System<->Bash interface / System limits
Desc "This configuration page will help you to setup system limits (e.g. how much disk space"\
"a user file may allocate, how much memory and CPU-time a user process can allocate, etc.).\n"\
"NOTE: You cannot raise limits above those sysop has set: if in doubt, try \"ulimit -a\"."
ShortDesc "System limits"
set brdwdth 4
set skip 16
### Memory management ###
Header head1 -text "Memory management"\
-background gray\
-help "Setup of limits concerning memory management."
#labels
Label dataSegLabel -text "Data segment"\
-help "Data- and stack segments have to do with dynamic memory allocations, i.e.,"\
"memory for which a process asks the operating system at runtime. Usually you will"\
"not have to limit process data segment."\
-borderwidth $brdwdth
Label stackSegLabel -text "Stack segment"\
-help "Data- and stack segments have to do with dynamic memory allocations, i.e.,"\
"memory for which a process asks the operating system at runtime. Usually you will"\
"not have to limit process stack segment."\
-borderwidth $brdwdth
Label mainMemLabel -text "Main memory"\
-help "Virtual- and main memory options are similar to the two above. This option"\
"limits the amount of physical memory that a process is allowed to allocate. Usually"\
"you will not have to put a limit on this unless your system suffers severe memory"\
"constraints or you want to avoid thrashing."\
-borderwidth $brdwdth
Label virtualMemLabel -text "Virtual memory"\
-help "Virtual- and main memory options are similar to the two above. This option"\
"limits all uses of memory. You normally will not have to put a limit on this unless"\
"your system suffers severe memory constraints or you want to avoid thrashing."\
-borderwidth $brdwdth
Label lockMemLabel -text "Locked memory"\
-help "Locked memory option restrict the maximum amount of memory a process is"\
"allowed to lock. This option is only available from version 2.0 of Bash"\
-borderwidth $brdwdth
Frame memLabels -entries {dataSegLabel stackSegLabel mainMemLabel virtualMemLabel lockMemLabel}\
-orient top
#radios
foreach elm {dataSeg stackSeg mainMem lockMem} {
Radio ${elm}Radio -text ""\
-entries {"unlimited" "limited"}
}
Radio virtualMemRadio -text ""\
-entries {"maximum" "limited"}
Frame memRadios -entries {dataSegRadio stackSegRadio mainMemRadio virtualMemRadio lockMemRadio}\
-orient top
#ints
foreach elm {dataSeg stackSeg virtualMem mainMem lockMem} {
Int ${elm}Int -text ""\
-textafter "kilobytes"\
-labelAfter:width 15
}
Frame memInts -entries {dataSegInt stackSegInt mainMemInt virtualMemInt lockMemInt}\
-orient top
#currentvalues
foreach elm {dataSeg stackSeg mainMem virtualMem lockMem} {
Label ${elm}Current -text ""\
-help "This is the current setting--increasing value beyond this may not"\
"be legal."\
-borderwidth $brdwdth
}
Frame memCurrents -entries {dataSegCurrent stackSegCurrent mainMemCurrent virtualMemCurrent lockMemCurrent}\
-orient top
Frame mem -entries {memLabels memRadios memInts memCurrents}\
-orient left\
-packFrame:fill x
### File system ###
Header head2 -text "File system"\
-background gray\
-help "Setup of limits concerning file system."
#labels
Label fileSizeLabel -text "File size"\
-help "Put a limit on how much diskspace a file can allocate (often huge files are"\
"the work of buggy programs). This is useful if you have constraints on disk space."\
-borderwidth $brdwdth
Label coreSizeLabel -text "Core-dump size"\
-help "If a program halts abruptly--either by user or due to a program bug, the system"\
"makes a core-dump (memory dump). These files are often quite large and, unless you intend"\
"to debug the failing program, of no interest."\
-borderwidth $brdwdth
Label fileDescLabel -text "File descriptors"\
-help "Put a limit on how many files to have open at the same time per process."\
Usually you will not have to limit this number. Do not set the number too low,"\
"many programs and commands opens several files at the same time (e.g. performing"\
"a \"ls\" require at least five file descriptors). Some older versions of"\
"UNIX will not let you alter this number--they have a fixed limit of 20 file"\
"descriptors per process."\
-borderwidth $brdwdth
Label pipeSizeLabel -text "Pipe size"\
-help "Sets the size for a pipe between two commands/programs. A pipe (|) is to be"\
"considered as a fifo (first-in-first-out) queue, where information from"\
"sender (command/program) is stored until receiver reads it. You can specify"\
"how much memory Bash is to allocate for this buffer, in 512-byte increments"\
"(default is 8, i.e. 4 kilobytes).\nTHIS OPTION MAY NOT BE ALTERED"\
-borderwidth $brdwdth
Frame fileLabels -entries {fileSizeLabel coreSizeLabel fileDescLabel pipeSizeLabel}\
-orient top
#radios
Radio fileSizeRadio -text ""\
-entries {"unlimited" "limited"}
Radio coreSizeRadio -text ""\
-entries {"unlimited" "limited"}\
-defaultIndex 1
Frame fileRadios -entries {fileSizeRadio coreSizeRadio}\
-orient top\
-packFrame:anchor n\
-packFrame:expand 0\
-packFrame:fill none
#ints
Int fileSizeInt -text ""\
-textafter "blocks"\
-labelAfter:width 15
Int coreSizeInt -text ""\
-textafter "blocks"\
-default 0\
-labelAfter:width 15
Int pipeSizeInt -text ""\
-textafter "512-byte blocks"\
-default 8\
-labelAfter:width 15
Int fileDescInt -text ""\
-textafter "files"\
-default 256\
-labelAfter:width 15
Frame fileInts -entries {fileSizeInt coreSizeInt fileDescInt pipeSizeInt}\
-orient top
#currentvalues
foreach elm {fileSize coreSize pipeSize fileDesc} {
Label ${elm}Current -text ""\
-help "This is the current setting--increasing value beyond this may not"\
"be legal."\
-borderwidth $brdwdth
}
Frame fileCurrents -entries {fileSizeCurrent coreSizeCurrent fileDescCurrent pipeSizeCurrent}\
-orient top
Frame file -entries {fileLabels fileRadios fileInts fileCurrents}\
-orient left\
-packFrame:fill x
### Process management ###
Header head3 -text "Process management"\
-background gray\
-help "Setup of limits concerning process management."
#labels
Label cpuTimeLabel -text "CPU time"\
-help "Limit amount of CPU-time a process can use. This is a possible guard"\
"against infinite loops, although it also limits how long a non-buggy program"\
"is allowed to run. You are probably better off, leaving this option unlimited."\
-borderwidth $brdwdth\
-padx $skip
Label maxProcsLabel -text "\# of procs."\
-help "Limit number of processes a user can start. Useful if you have"\
"system memory constraints."\
-borderwidth $brdwdth\
-padx $skip
Frame procLabels -entries {cpuTimeLabel maxProcsLabel}\
-orient top
#radios
Radio cpuTimeRadio -text ""\
-entries {"unlimited" "limited"}
Radio maxProcsRadio -text ""\
-entries {"unlimited" "limited"}\
-defaultIndex 1
Frame procRadios -entries {cpuTimeRadio maxProcsRadio}\
-orient top\
-packFrame:anchor n
#ints
Int cpuTimeInt -text ""\
-textafter "seconds"\
-labelAfter:width 15
Int maxProcsInt -text ""\
-textafter "procs."\
-default 256\
-labelAfter:width 15
Frame procInts -entries {cpuTimeInt maxProcsInt}\
-orient top
#currentvalues
foreach elm {cpuTime maxProcs} {
Label ${elm}Current -text ""\
-help "This is the current setting--increasing value beyond this may not"\
"be legal."\
-borderwidth $brdwdth
}
Frame procCurrents -entries {cpuTimeCurrent maxProcsCurrent}\
-orient top
Frame proc -entries {procLabels procRadios procInts procCurrents}\
-orient left\
-packFrame:fill x
Line linie1
Command readPath -setvalue {$widget configure -text "Load current system limits"}\
-invoke {
### Reading system limits ###
set temp ""
catch {set temp [exec bash -c "ulimit -a"]}
set sysopLimits {}
if {$temp != ""} {
### Parse input
### Parser depend (completely) on how information is listed
### Parser build on output from ulimit -a (10 lines), Bash version 1.14.5(1)
### Parser build on output from ulimit -a (11 lines), Bash version 2.00.0(1)-release
set inList [split $temp "\n"]
if {[llength $inList] == 11} {
foreach elm $inList {
lappend sysopLimits [string range $elm 28 end]
}
} else {
if {[llength $inList] == 10} {
foreach elm $inList {
lappend sysopLimits [string range $elm 25 end]
}
}
}
if {[llength $inList] == 11} {
### I guess you use Bash version 2.0+
set temp {coreSize dataSeg fileSize lockMem mainMem fileDesc pipeSize stackSeg cpuTime maxProcs virtualMem}
} else {
### I guess you use a Bash version prior to 2.0
set temp {coreSize dataSeg fileSize mainMem stackSeg cpuTime maxProcs pipeSize fileDesc virtualMem}
}
if {$sysopLimits != {}} {
set line 0
foreach elm $temp {
set ${elm}Current "([lindex $sysopLimits $line])"
incr line
}
} {
set line 0
foreach elm $temp {
set ${elm}Current "n/a"
incr line
}
}
}
}
ShowPage {
### Memory management ###
Disable dataSegInt stackSegInt virtualMemInt mainMemInt
### File system ###
Disable fileSizeInt
### Process management ###
Disable cpuTimeInt
### Disable pipe-size configuration ###
Disable pipeSizeLabel pipeSizeInt
}
Change {
### Enable/disable entries ###
if {[string first "Radio" $changeElm] != -1} {
set temp [string trimright $changeElm "Radio"]
if {[set ${changeElm}(index)]} {
Enable ${temp}Int
} {
Disable ${temp}Int
}
}
}
PageEnd {
### Memory management ###
foreach elm {dataSeg stackSeg virtualMem mainMem} {
if {[set ${elm}Radio(index)]} {
if {[set ${elm}Int] < 1} {
error "Illegal value specified in Memory management ($elm)."
}
}
}
### File system ###
foreach elm {fileSize coreSize} {
if {[set ${elm}Radio(index)]} {
if {[set ${elm}Int] < 0} {
error "Illegal value specified in File system ($elm)."
}
}
}
foreach elm {pipeSizeInt fileDescInt} {
if {[set $elm] < 1} {
error "Illegal value specified in File system ($elm)."
}
}
### Process management ###
foreach elm {cpuTime maxProcs} {
if {[set ${elm}Radio(index)]} {
if {[set ${elm}Int] < 1} {
error "Illegal value specified in Process management ($elm)."
}
}
}
}
Save {
### Memory management ###
if {$dataSegRadio(index) || $generateDefault} {
print "ulimit -d [pick $dataSegRadio(index) $dataSegInt unlimited]"
}
if {$stackSegRadio(index) || $generateDefault} {
print "ulimit -s [pick $stackSegRadio(index) $stackSegInt unlimited]"
}
if {$virtualMemRadio(index) || $generateDefault} {
print "ulimit -v [pick $virtualMemRadio(index) $virtualMemInt 4194302]"
}
if {$mainMemRadio(index) || $generateDefault} {
print "ulimit -m [pick $mainMemRadio(index) $mainMemInt unlimited]"
}
if {$lockMemRadio(index) || $generateDefault} {
print "ulimit -l [pick $lockMemRadio(index) $lockMemInt unlimited]"
}
### File system ###
if {$fileSizeRadio(index) || $generateDefault} {
print "ulimit -f [pick $fileSizeRadio(index) $fileSizeInt unlimited]"
}
if {$coreSizeRadio(index) != 1 || ($coreSizeRadio(index) && $coreSizeInt != 0) || $generateDefault} {
print "ulimit -c [pick $coreSizeRadio(index) $coreSizeInt unlimited]"
}
if {$fileDescInt != 256 || $generateDefault} {
print "ulimit -n $fileDescInt"
}
### This configuration option cannot be altered ###
### if {$pipeSizeInt != 8 || $generateDefault} {
### print "ulimit -p $pipeSizeInt"
### }
### Process management ###
if {$cpuTimeRadio(index) || $generateDefault} {
print "ulimit -t [pick $cpuTimeRadio(index) $cpuTimeInt unlimited]"
}
if {$maxProcsRadio(index) != 1 || ($maxProcsRadio(index) && $maxProcsInt != 256) || $generateDefault} {
print "ulimit -u [pick $maxProcsRadio(index) $maxProcsInt unlimited]"
}
}
}
|