You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.4 KiB
76 lines
2.4 KiB
#!/usr/bin/perl |
|
# |
|
# This is the master daemon that manages all periodically run processes on Striker dashboards and Anvil! |
|
# nodes. |
|
# |
|
use strict; |
|
use warnings; |
|
use AN::Tools; |
|
|
|
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0]; |
|
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0]; |
|
if (($running_directory =~ /^\./) && ($ENV{PWD})) |
|
{ |
|
$running_directory =~ s/^\./$ENV{PWD}/; |
|
} |
|
|
|
# Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete. |
|
$| = 1; |
|
|
|
my $an = AN::Tools->new(); |
|
$an->Log->level(2); |
|
|
|
# Paths |
|
$an->data->{path}{tools}{'scancore-database'} = "/usr/sbin/striker/scancore-database"; |
|
$an->data->{path}{tools}{'scancore-update-states'} = "/usr/sbin/striker/scancore-update-states"; |
|
$an->data->{path}{config}{'striker.conf'} = "/etc/striker/striker.conf"; |
|
|
|
# Read our config. |
|
$an->Storage->read_config({file => $an->data->{path}{config}{'striker.conf'}}); |
|
|
|
# There are some things we only want to run on (re)start and don't need to always run. |
|
run_once($an); |
|
|
|
# These are the things we always want running. |
|
while(1) |
|
{ |
|
update_state_file($an); |
|
|
|
sleep 2; |
|
} |
|
|
|
exit(0); |
|
|
|
############################################################################################################# |
|
# Functions # |
|
############################################################################################################# |
|
|
|
# These are tools that don't need to constantly run. |
|
sub run_once |
|
{ |
|
my ($an) = @_; |
|
|
|
# Check that the database is ready. |
|
my $database_output = $an->System->call({shell_call => $an->data->{path}{tools}{'scancore-database'}, source => $THIS_FILE, line => __LINE__}); |
|
if ($database_output) |
|
{ |
|
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { database_output => $database_output }}); |
|
} |
|
|
|
return(0); |
|
} |
|
|
|
# This calls 'scancore-update-states' which will scan the local machine's state (hardware and software) and |
|
# record write it out to an HTML file |
|
sub update_state_file |
|
{ |
|
my ($an) = @_; |
|
|
|
my $states_output = $an->System->call({shell_call => $an->data->{path}{tools}{'scancore-update-states'}, source => $THIS_FILE, line => __LINE__}); |
|
if ($states_output) |
|
{ |
|
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { states_output => $states_output }}); |
|
} |
|
|
|
return(0); |
|
}
|
|
|