2 # Check if some process is running
6 local (@found, $count);
7 return { 'up' => -1 } if (!&foreign_check("proc"));
8 &foreign_require("proc", "proc-lib.pl");
9 foreach $p (&foreign_call("proc", "list_processes")) {
10 if (eval { $p->{'args'} =~ /$_[0]->{'cmd'}/i } &&
11 (!$_[0]->{'asuser'} || $_[0]->{'asuser'} eq $p->{'user'})) {
12 push(@found, $p->{'pid'});
16 local $thresh = $_[0]->{'thresh'} || 1;
18 if ($count >= $thresh) {
26 if ($count >= $thresh) {
27 return { 'up' => 1, 'desc' => &text('proc_pid',
38 print &ui_table_row($text{'proc_cmd'},
39 &ui_textbox("cmd", $_[0]->{'cmd'}, 30));
41 print &ui_table_row($text{'proc_not'},
42 &ui_radio("not", int($_[0]->{'not'}),
43 [ [ 0, $text{'proc_not0'} ],
44 [ 1, $text{'proc_not1'} ] ]));
46 print &ui_table_row($text{'proc_thresh'},
47 &ui_textbox("thresh", $_[0]->{'thresh'} || 1, 5));
49 print &ui_table_row($text{'proc_asuser'},
50 &ui_opt_textbox("asuser", $_[0]->{'asuser'}, 13,
51 $text{'proc_anyuser'})." ".
52 &user_chooser_button("asuser"));
57 &depends_check($_[0], "proc");
58 $in{'cmd'} || &error($text{'proc_ecmd'});
59 $_[0]->{'cmd'} = $in{'cmd'};
60 $_[0]->{'not'} = $in{'not'};
61 $in{'thresh'} =~ /^\d+$/ || &error($text{'proc_ethresh'});
62 $_[0]->{'thresh'} = $in{'thresh'};
63 if ($in{'asuser_def'}) {
64 delete($_[0]->{'asuser'});
67 defined(getpwnam($in{'asuser'})) || &error($text{'proc_easuser'});
68 $_[0]->{'asuser'} = $in{'asuser'};