Limit process check to a user
authorJamie Cameron <jcameron@webmin.com>
Wed, 21 May 2008 18:07:55 +0000 (18:07 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 21 May 2008 18:07:55 +0000 (18:07 +0000)
status/CHANGELOG
status/lang/en
status/proc-monitor.pl

index 2fbb6fc..d03eaea 100644 (file)
@@ -51,3 +51,5 @@ Failure to run a command on a remote system is now properly detected.
 Added T-COM, Skytel, Vodaphone and several more as a carriers for SMS.
 ---- Changes since 1.400 ----
 Email, SMS and SNMP messages sent by Webmin can be customized, with multiple message templates defined and a different one selected for each monitor.
+---- Changes since 1.410 ----
+The process check monitor can now be limited to a particular user.
index 627a22d..2080ffe 100644 (file)
@@ -204,6 +204,9 @@ proc_not1=Running
 proc_ecmd=Missing command
 proc_thresh=Number of process that must exist for<br>monitor to consider them running
 proc_ethresh=Missing or invalid number of processes
+proc_asuser=Running as user
+proc_anyuser=Any user
+proc_easuser=User for process to run as does not exist
 
 exec_cmd=Command to check exit status of
 exec_ecmd=Missing command
index 3a530a2..91dc734 100644 (file)
@@ -7,7 +7,8 @@ local (@found, $count);
 return { 'up' => -1 } if (!&foreign_check("proc"));
 &foreign_require("proc", "proc-lib.pl");
 foreach $p (&foreign_call("proc", "list_processes")) {
-       if ($p->{'args'} =~ /$_[0]->{'cmd'}/i) {
+       if ($p->{'args'} =~ /$_[0]->{'cmd'}/i &&
+           (!$_[0]->{'asuser'} || $_[0]->{'asuser'} eq $p->{'user'})) {
                push(@found, $p->{'pid'});
                $count++;
                }
@@ -44,6 +45,11 @@ print &ui_table_row($text{'proc_not'},
 
 print &ui_table_row($text{'proc_thresh'},
        &ui_textbox("thresh", $_[0]->{'thresh'} || 1, 5));
+
+print &ui_table_row($text{'proc_asuser'},
+       &ui_opt_textbox("asuser", $_[0]->{'asuser'}, 13,
+                       $text{'proc_anyuser'})." ".
+       &user_chooser_button("asuser"));
 }
 
 sub parse_proc_dialog
@@ -54,6 +60,13 @@ $_[0]->{'cmd'} = $in{'cmd'};
 $_[0]->{'not'} = $in{'not'};
 $in{'thresh'} =~ /^\d+$/ || &error($text{'proc_ethresh'});
 $_[0]->{'thresh'} = $in{'thresh'};
+if ($in{'asuser_def'}) {
+       delete($_[0]->{'asuser'});
+       }
+else {
+       defined(getpwnam($in{'asuser'})) || &error($text{'proc_easuser'});
+       $_[0]->{'asuser'} = $in{'asuser'};
+       }
 }
 
 1;