return $proc;
}
+=head2 find_virtualmin_cron_job(command, [&jobs], [user])
+
+Returns the cron job object that runs some command (perhaps with redirection)
+
+=cut
+sub find_virtualmin_cron_job
+{
+my ($cmd, $jobs, $user) = @_;
+if (!$jobs) {
+ $jobs = [ &list_cron_jobs() ];
+ }
+$user ||= "root";
+my @rv = grep { $_->{'user'} eq $user &&
+ $_->{'command'} =~ /(^|[ \|\&;\/])\Q$cmd\E($|[ \|\&><;])/ } @$jobs;
+return wantarray ? @rv : $rv[0];
+}
+
=head2 extract_input(command)
Given a line formatted like I<command%input>, returns the command and input
BEGIN { push(@INC, ".."); };
eval "use WebminCore;";
&init_config();
+$systeminfo_cron_cmd = "$module_config_directory/systeminfo.pl";
+&foreign_require("cron", "cron-lib.pl");
# collect_system_info()
# Returns a hash reference containing system information
}
# setup_collectinfo_job()
-# Creates or updates the collectinfo.pl cron job, based on the schedule
+# Creates or updates the systeminfo.pl cron job, based on the schedule
# set in the module config.
sub setup_collectinfo_job
{
for(my $i=$offset; $i<60; $i+= $step) {
push(@mins, $i);
}
-local $job = &find_virtualmin_cron_job($collect_cron_cmd);
+local $job = &cron::find_cron_job($systeminfo_cron_cmd);
+
if (!$job && $config{'collect_interval'} ne 'none') {
# Create, and run for the first time
$job = { 'mins' => join(',', @mins),
'weekdays' => '*',
'user' => 'root',
'active' => 1,
- 'command' => $collect_cron_cmd };
+ 'command' => $systeminfo_cron_cmd };
&cron::create_cron_job($job);
}
elsif ($job && $config{'collect_interval'} ne 'none') {
# No longer wanted, so delete
&cron::delete_cron_job($job);
}
-&cron::create_wrapper($collect_cron_cmd, $module_name, "collectinfo.pl");
+&cron::create_wrapper($systeminfo_cron_cmd, $module_name, "systeminfo.pl");
}
# get_current_drive_temps()
sub get_current_drive_temps
{
local @rv;
-if (!$config{'collect_notemp'} && $virtualmin_pro &&
+if (!$config{'collect_notemp'} &&
&foreign_installed("smart-status")) {
&foreign_require("smart-status");
foreach my $d (&smart_status::list_smart_disks_partitions()) {
sub get_current_cpu_temps
{
local @rv;
-if (!$config{'collect_notemp'} && $virtualmin_pro &&
+if (!$config{'collect_notemp'} &&
$gconfig{'os_type'} =~ /-linux$/ && &has_command("sensors")) {
&open_execute_command(SENSORS, "sensors </dev/null 2>/dev/null", 1);
while(<SENSORS>) {
--- /dev/null
+#!/usr/local/bin/perl
+# Collect various pieces of general system information, for display by themes
+# on their status pages. Run every 5 mins from Cron.
+
+package system_status;
+$main::no_acl_check++;
+require './system-status-lib.pl';
+$start = time();
+
+# Make sure we are not already running
+if (&test_lock($collected_info_file)) {
+ print "Already running\n";
+ exit(0);
+ }
+
+# Don't diff collected file
+$gconfig{'logfiles'} = 0;
+$gconfig{'logfullfiles'} = 0;
+$WebminCore::gconfig{'logfiles'} = 0;
+$WebminCore::gconfig{'logfullfiles'} = 0;
+$no_log_file_changes = 1;
+&lock_file($collected_info_file);
+
+$info = &collect_system_info();
+if ($info) {
+ &save_collected_info($info);
+ &add_historic_collected_info($info, $start);
+ }
+&unlock_file($collected_info_file);
+