2 # Check the free memory
6 return { 'up' => -1 } if (!&foreign_check("proc"));
7 &foreign_require("proc", "proc-lib.pl");
9 eval "\@mem = &proc::get_memory_info()";
11 return { 'up' => -1 };
13 elsif ($mem[1] < $_[0]->{'min'}) {
15 'desc' => &text('memory_freelow', &nice_size($mem[1]*1024)) };
17 elsif ($mem[2] && $mem[3] < $_[0]->{'minswap'}) {
19 'desc' => &text('memory_freelowswap',
20 &nice_size($mem[3]*1024)) };
23 my @desc = ( &text('memory_free2', &nice_size($mem[1]*1024)) );
25 push(@desc, &text('memory_freeswap', &nice_size($mem[2]*1024)));
28 'desc' => join(", ", @desc) };
32 sub show_memory_dialog
34 print &ui_table_row($text{'memory_min2'},
35 &ui_bytesbox("min", $_[0]->{'min'}*1024));
37 print &ui_table_row($text{'memory_minswap'},
38 &ui_bytesbox("minswap", $_[0]->{'minswap'}*1024));
41 sub parse_memory_dialog
43 &depends_check($_[0], "proc");
44 &foreign_require("proc", "proc-lib.pl");
45 defined(&proc::get_memory_info) || &error($text{'memory_eproc'});
46 $in{'min'} =~ /^[0-9\.]+$/ || &error($text{'memory_emin'});
47 $_[0]->{'min'} = $in{'min'}*$in{'min_units'}/1024;
48 $in{'minswap'} =~ /^[0-9\.]+$/ || &error($text{'memory_eminswap'});
49 $_[0]->{'minswap'} = $in{'minswap'}*$in{'minswap_units'}/1024;