* Updated all methods to add (or fix) logging the method entry.

* More work done on Email->send_email() to, well, actually send email (which it isn't doing yet, but it's close).
* Updated Words->key() to include the bad key name when no entry for the requested key exists in the words.xml file.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 911523dfce
commit fe7cdb18fb
  1. 1
      Anvil/Tools.pm
  2. 8
      Anvil/Tools/Account.pm
  3. 5
      Anvil/Tools/Alert.pm
  4. 7
      Anvil/Tools/Convert.pm
  5. 6
      Anvil/Tools/DRBD.pm
  6. 23
      Anvil/Tools/Database.pm
  7. 71
      Anvil/Tools/Email.pm
  8. 11
      Anvil/Tools/Get.pm
  9. 6
      Anvil/Tools/Job.pm
  10. 5
      Anvil/Tools/Network.pm
  11. 5
      Anvil/Tools/Remote.pm
  12. 8
      Anvil/Tools/Server.pm
  13. 27
      Anvil/Tools/Storage.pm
  14. 8
      Anvil/Tools/System.pm
  15. 4
      Anvil/Tools/Template.pm
  16. 14
      Anvil/Tools/Validate.pm
  17. 9
      Anvil/Tools/Words.pm
  18. 4
      cgi-bin/striker
  19. 6
      html/skins/alteeve/email.html
  20. 25
      share/words.xml
  21. 6
      tools/test.pl

@ -1192,6 +1192,7 @@ sub _set_paths
lvchange => "/usr/sbin/lvchange",
lvs => "/usr/sbin/lvs",
lvscan => "/usr/sbin/lvscan",
mailx => "/usr/bin/mailx",
man => "/usr/bin/man",
md5sum => "/usr/bin/md5sum",
'mkdir' => "/usr/bin/mkdir",

@ -120,6 +120,7 @@ sub encrypt_password
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Account->encrypt_password()" }});
my $algorithm = defined $parameter->{algorithm} ? $parameter->{algorithm} : "";
my $hash_count = defined $parameter->{hash_count} ? $parameter->{hash_count} : "";
@ -253,6 +254,7 @@ sub login
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Account->login()" }});
if ((not $anvil->data->{cgi}{username}{value}) or (not $anvil->data->{cgi}{password}{value}))
{
@ -393,6 +395,7 @@ sub logout
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Account->logout()" }});
# Delete the user's cookie data. Sending nothing to '_write_cookies' does this.
$anvil->Account->_write_cookies({debug => $debug});
@ -487,6 +490,7 @@ sub read_cookies
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Account->read_cookies()" }});
# Read in any cookies
if (defined $ENV{HTTP_COOKIE})
@ -645,6 +649,7 @@ sub read_details
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Account->read_details()" }});
my $user_uuid = defined $parameter->{user_uuid} ? $parameter->{user_uuid} : $anvil->data->{cookie}{anvil_user_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { user_uuid => $user_uuid }});
@ -762,6 +767,7 @@ sub validate_password
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Account->validate_password()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $user = defined $parameter->{user} ? $parameter->{user} : "";
@ -922,6 +928,7 @@ sub _build_cookie_hash
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Account->_build_cookie_hash()" }});
my $offset = defined $parameter->{offset} ? $parameter->{offset} : 0;
my $user_agent = defined $parameter->{user_agent} ? $parameter->{user_agent} : $ENV{HTTP_USER_AGENT};
@ -997,6 +1004,7 @@ sub _write_cookies
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Account->_write_cookies()" }});
my $hash = defined $parameter->{hash} ? $parameter->{hash} : "";
my $uuid = defined $parameter->{uuid} ? $parameter->{uuid} : "";

@ -114,6 +114,7 @@ sub check_alert_sent
my $parameter = shift;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $anvil = $self->parent;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Alert->check_alert_sent()" }});
my $modified_date = defined $parameter->{modified_date} ? $parameter->{modified_date} : $anvil->data->{sys}{database}{timestamp};
my $name = defined $parameter->{name} ? $parameter->{name} : "";
@ -367,6 +368,7 @@ sub register
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Alert->register()" }});
my $alert_level = defined $parameter->{alert_level} ? $parameter->{alert_level} : 0;
my $clear_alert = defined $parameter->{clear_alert} ? $parameter->{clear_alert} : 0;
@ -523,6 +525,9 @@ sub error
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Alert->error()" }});
}
1;

@ -103,6 +103,7 @@ sub add_commas
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Convert->add_commas()" }});
# Now see if the user passed the values in a hash reference or directly.
my $number = defined $parameter->{number} ? $parameter->{number} : "";
@ -190,6 +191,7 @@ sub bytes_to_human_readable
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Convert->bytes_to_human_readable()" }});
# Now see if the user passed the values in a hash reference or directly.
my $size = defined $parameter->{'bytes'} ? $parameter->{'bytes'} : 0;
@ -519,6 +521,7 @@ sub cidr
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Convert->cidr()" }});
my $cidr = defined $parameter->{cidr} ? $parameter->{cidr} : "";
my $subnet_mask = defined $parameter->{subnet_mask} ? $parameter->{subnet_mask} : "";
@ -623,6 +626,7 @@ sub host_name_to_ip
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Convert->host_name_to_ip()" }});
my $host_name = defined $parameter->{host_name} ? $parameter->{host_name} : "";
my $ip = 0;
@ -693,6 +697,7 @@ sub human_readable_to_bytes
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Convert->human_readable_to_bytes()" }});
my $base2 = defined $parameter->{base2} ? $parameter->{base2} : 0;
my $base10 = defined $parameter->{base10} ? $parameter->{base10} : 0;
@ -882,6 +887,7 @@ sub round
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Convert->round()" }});
# Setup my numbers.
my $number = $parameter->{number} ? $parameter->{number} : 0;
@ -1007,6 +1013,7 @@ sub time
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Convert->time()" }});
my $time = defined $parameter->{'time'} ? $parameter->{'time'} : 0;
my $long = defined $parameter->{long} ? $parameter->{long} : 0;

@ -118,6 +118,7 @@ sub allow_two_primaries
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "DRBD->allow_two_primaries()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -261,6 +262,7 @@ sub get_devices
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "DRBD->get_devices()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -549,6 +551,7 @@ sub get_status
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "DRBD->get_status()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -806,6 +809,7 @@ sub manage_resource
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "DRBD->manage_resource()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -903,6 +907,7 @@ sub reload_defaults
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "DRBD->reload_defaults()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -993,6 +998,7 @@ sub update_global_common
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "DRBD->update_global_common()" }});
my $usage_count = defined $parameter->{usage_count} ? $parameter->{usage_count} : 1;
my $use_flushes = defined $parameter->{use_flushes} ? $parameter->{use_flushes} : 0;

@ -1476,7 +1476,7 @@ sub get_alerts
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_manifests()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_alerts()" }});
my $all_hosts = defined $parameter->{all_hosts} ? $parameter->{all_hosts} : 0;
my $include_processed = defined $parameter->{include_processed} ? $parameter->{include_processed} : 0;
@ -1629,7 +1629,7 @@ sub get_anvils
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_manifests()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_anvils()" }});
my $include_deleted = defined $parameter->{include_deleted} ? $parameter->{include_deleted} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
@ -2079,7 +2079,7 @@ sub get_hosts_info
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_hosts()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_hosts_info()" }});
my $query = "
SELECT
@ -2180,6 +2180,7 @@ sub get_ip_addresses
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_ip_addresses()" }});
# Make sure we've loaded host data.
$anvil->Database->get_hosts({debug => $debug});
@ -2410,6 +2411,7 @@ sub get_job_details
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_job_details()" }});
my $return = "";
my $job_uuid = defined $parameter->{job_uuid} ? $parameter->{job_uuid} : "";
@ -2747,7 +2749,7 @@ sub get_mail_servers
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->initialize()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_mail_servers()" }});
if (exists $anvil->data->{mail_servers})
{
@ -3005,7 +3007,7 @@ sub get_notifications
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->initialize()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_notifications()" }});
my $query = "
SELECT
@ -3176,7 +3178,7 @@ sub get_ssh_keys
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->initialize()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_ssh_keys()" }});
# Delete any data from past scans.
delete $anvil->data->{ssh_keys}{ssh_key_uuid};
@ -3271,7 +3273,7 @@ sub get_upses
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_host_from_uuid()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->get_upses()" }});
my $include_deleted = defined $parameter->{include_deleted} ? $parameter->{include_deleted} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
@ -9070,7 +9072,7 @@ sub insert_or_update_users
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->insert_or_update_states()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->insert_or_update_users()" }});
my $uuid = defined $parameter->{uuid} ? $parameter->{uuid} : "";
my $file = defined $parameter->{file} ? $parameter->{file} : "";
@ -10019,7 +10021,7 @@ sub log_connections
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->locking()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->log_connections()" }});
# Log how many connections there are.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, secure => 0, key => "log_0132"});
@ -10722,7 +10724,6 @@ sub quote
my $self = shift;
my $string = shift;
my $anvil = $self->parent;
my $debug = 2;
$string = "" if not defined $string;
my $quoted = $anvil->Database->read->quote($string);
@ -10910,7 +10911,7 @@ sub refresh_timestamp
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->_test_access()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->refresh_timestamp()" }});
my $query = "SELECT cast(now() AS timestamp with time zone);";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});

@ -361,8 +361,10 @@ sub send_alerts
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Email->send_alerts()" }});
# Load the alerts
$anvil->Database->get_recipients({debug => 2});
$anvil->Database->get_alerts({debug => 2});
$anvil->Database->get_recipients({debug => 2});
my $host_uuid = $anvil->Get->host_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host_uuid => $host_uuid }});
foreach my $alert_uuid (keys %{$anvil->data->{alerts}{alert_uuid}})
{
my $alert_host_uuid = $anvil->data->{alerts}{alert_uuid}{$alert_uuid}{alert_host_uuid};
@ -376,6 +378,7 @@ sub send_alerts
my $unix_modified_date = $anvil->data->{alerts}{alert_uuid}{$alert_uuid}{unix_modified_date};
my $modified_date = $anvil->data->{alerts}{alert_uuid}{$alert_uuid}{modified_date};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
alert_uuid => $alert_uuid,
alert_host_uuid => $alert_host_uuid,
alert_set_by => $alert_set_by,
alert_level => $alert_level,
@ -388,6 +391,10 @@ sub send_alerts
modified_date => $modified_date,
}});
# We should never have a processed alert or an alert for another host here, but just in case;
next if $alert_processed;
next if $alert_host_uuid ne $host_uuid;
# Walk through the recipients to see who wants to hear about this.
foreach my $recipient_uuid (keys %{$anvil->data->{recipients}{recipient_uuid}})
{
@ -407,7 +414,7 @@ sub send_alerts
# 2 - warning
# 3 - notice
# 4 - info
if ($recipient_level <= $alert_level)
if ($recipient_level >= $alert_level)
{
# The user wants it.
my $message = $anvil->Words->parse_banged_string({
@ -549,20 +556,70 @@ sub send_alerts
}});
# Ready!
my $email_body = "
From: ".$from."
To: ".$recipient_name." <".$recipient_email.">
my $to = $recipient_name." <".$recipient_email.">";
my $email_body = "From: ".$from."
To: ".$to."
Subject: ".$subject."
Reply-To: ".$reply_to."
".$body."
".$footer."
";
".$footer;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { email_body => $email_body }});
# Write it to a file.
my $file_time = $anvil->Get->date_and_time({file_name => 1});
my $short_uuid = $anvil->Get->uuid({short => 1});
my $file_name = $anvil->data->{path}{directories}{alert_emails}."/alert_email.".$file_time.".".$short_uuid;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0541", variables => { file => $file_name }});
my $problem = $anvil->Storage->write_file({
debug => 3,
file => $file_name,
body => $email_body,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { problem => $problem }});
# Call mailx to read it in
if ($problem)
{
# Something went wrong
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0143", variables => { file => $file_name }});
}
else
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0542", variables => { to => $to }});
my $shell_call = $anvil->data->{path}{exe}{mailx}." -t < ".$file_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
output => $output,
return_code => $return_code,
}});
}
}
### NOTE: We don't block setting this alert to processed because some alerts may have gotten out and
### we don't want to risk whatever went wrong leading to a flood or alert email files being
### generated or dispatched.
# Update the database to mark that the alerts have been processed
foreach my $alert_uuid (keys %{$anvil->data->{alerts}{alert_uuid}})
{
my $alert_processed = $anvil->data->{alerts}{alert_uuid}{$alert_uuid}{alert_processed};
my $alert_host_uuid = $anvil->data->{alerts}{alert_uuid}{$alert_uuid}{alert_host_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
alert_uuid => $alert_uuid,
alert_host_uuid => $alert_host_uuid,
alert_processed => $alert_processed,
}});
# We should never have a processed alert or an alert for another host here, but just in case;
next if $alert_processed;
next if $alert_host_uuid ne $host_uuid;
my $query = "UPDATE alerts SET alert_processed = 1 WHERE alert_uuid = ".$anvil->Database->quote($alert_uuid).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
}
return(0);

@ -127,6 +127,7 @@ sub anvil_version
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->anvil_version()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -462,6 +463,7 @@ sub cgi
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->cgi()" }});
# This will store all of the CGI variables.
$anvil->data->{sys}{cgi_string} = "?";
@ -740,6 +742,7 @@ sub host_name
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->host_name()" }});
my $host_name = "";
my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : "";
@ -954,6 +957,7 @@ sub host_uuid
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->host_uuid()" }});
my $set = defined $parameter->{set} ? $parameter->{set} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
@ -1059,6 +1063,7 @@ sub md5sum
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->md5sum()" }});
my $sum = "";
my $file = defined $parameter->{file} ? $parameter->{file} : "";
@ -1237,7 +1242,7 @@ sub trusted_hosts
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->uptime()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->trusted_hosts()" }});
my $local_host_uuid = $anvil->Get->host_uuid;
my $in_anvil = $anvil->data->{hosts}{host_uuid}{$local_host_uuid}{anvil_name};
@ -1320,6 +1325,7 @@ sub users_home
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->users_home()" }});
my $home_directory = 0;
@ -1388,6 +1394,7 @@ sub uuid
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->uuid()" }});
my $short = defined $parameter->{short} ? $parameter->{short} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
@ -1426,6 +1433,7 @@ sub _salt
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->_salt()" }});
my $salt = "";
my $salt_length = $anvil->data->{sys}{password}{salt_length} =~ /^\d+$/ ? $anvil->data->{sys}{password}{salt_length} : 16;
@ -1485,6 +1493,7 @@ sub _wrap_to
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Get->_wrap_to()" }});
# Get the column width
my ($columns, $return_code) = $anvil->System->call({debug => $debug, redirect_stderr => 0, shell_call => $anvil->data->{path}{exe}{tput}." cols" });

@ -97,6 +97,7 @@ sub clear
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Job->clear()" }});
my $job_uuid = defined $parameter->{job_uuid} ? $parameter->{job_uuid} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { job_uuid => $job_uuid }});
@ -157,6 +158,7 @@ sub get_job_details
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Job->get_job_details()" }});
my $check = defined $parameter->{check} ? $parameter->{check} : "";
my $job_uuid = defined $parameter->{job_uuid} ? $parameter->{job_uuid} : "";
@ -323,6 +325,7 @@ sub get_job_uuid
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Job->get_job_uuid()" }});
my $job_uuid = "";
my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : $anvil->Get->host_uuid;
@ -386,6 +389,7 @@ sub running
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Job->running()" }});
my $query = "
SELECT
@ -427,6 +431,7 @@ sub html_list
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Job->html_list()" }});
my $ended_within = defined $parameter->{ended_within} ? $parameter->{ended_within} : 300;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
@ -541,6 +546,7 @@ sub update_progress
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Job->update_progress()" }});
my $job_uuid = defined $parameter->{job_uuid} ? $parameter->{job_uuid} : "";
my $message = defined $parameter->{message} ? $parameter->{message} : "";

@ -1143,7 +1143,7 @@ sub load_ips
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Network->find_matches()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Network->load_ips()" }});
my $clear = defined $parameter->{clear} ? $parameter->{clear} : 1;
my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : $anvil->data->{sys}{host_uuid};
@ -1872,6 +1872,7 @@ sub get_network
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Network->get_network()" }});
my $network = "";
my $ip = defined $parameter->{ip} ? $parameter->{ip} : "";
@ -1923,6 +1924,7 @@ sub is_local
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Network->is_local()" }});
my $host = $parameter->{host} ? $parameter->{host} : "";
return(1) if not $host;
@ -1995,6 +1997,7 @@ sub is_ip_in_network
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Network->is_ip_in_network()" }});
my $ip = defined $parameter->{ip} ? $parameter->{ip} : "";
my $network = defined $parameter->{network} ? $parameter->{network} : "";

@ -115,6 +115,7 @@ sub add_target_to_known_hosts
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Remote->add_target_to_known_hosts()" }});
my $delete_if_found = defined $parameter->{delete_if_found} ? $parameter->{delete_if_found} : 0;
my $port = defined $parameter->{port} ? $parameter->{port} : 22;
@ -272,6 +273,7 @@ sub call
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Remote->call()" }});
# Get the target and port so that we can create the ssh_fh key
my $port = $parameter->{port} ? $parameter->{port} : 22;
my $target = defined $parameter->{target} ? $parameter->{target} : "";
@ -747,6 +749,7 @@ sub test_access
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Remote->test_access()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : 22;
@ -824,6 +827,7 @@ sub _call_ssh_keyscan
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Remote->_call_ssh_keyscan()" }});
my $known_hosts = defined $parameter->{known_hosts} ? $parameter->{known_hosts} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -912,6 +916,7 @@ sub _check_known_hosts_for_target
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Remote->_check_known_hosts_for_target()" }});
my $delete_if_found = defined $parameter->{delete_if_found} ? $parameter->{delete_if_found} : 0;
my $known_hosts = defined $parameter->{known_hosts} ? $parameter->{known_hosts} : "";

@ -105,6 +105,7 @@ sub boot
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Server->boot()" }});
my $server = defined $parameter->{server} ? $parameter->{server} : "";
my $definition = defined $parameter->{definition} ? $parameter->{definition} : "";
@ -206,6 +207,7 @@ sub find
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Server->find()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -323,6 +325,7 @@ sub get_status
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Server->get_status()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -473,6 +476,7 @@ sub map_network
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Server->map_network()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -572,6 +576,7 @@ sub provision
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Server->provision()" }});
=cut
Provision order:
@ -619,6 +624,7 @@ sub migrate
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Server->migrate()" }});
my $server = defined $parameter->{server} ? $parameter->{server} : "";
my $source = defined $parameter->{source} ? $parameter->{source} : "";
@ -770,6 +776,7 @@ sub shutdown
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Server->shutdown()" }});
my $server = defined $parameter->{server} ? $parameter->{server} : "";
my $force = defined $parameter->{force} ? $parameter->{force} : 0;
@ -968,6 +975,7 @@ sub _parse_definition
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Server->_parse_definition()" }});
# Source is required.
my $server = defined $parameter->{server} ? $parameter->{server} : "";

@ -140,6 +140,7 @@ sub backup
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 2;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->backup()" }});
my $fatal = defined $parameter->{fatal} ? $parameter->{fatal} : 1;
my $port = defined $parameter->{port} ? $parameter->{port} : "";
@ -363,6 +364,7 @@ sub change_mode
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->change_mode()" }});
my $mode = defined $parameter->{mode} ? $parameter->{mode} : "";
my $path = defined $parameter->{path} ? $parameter->{path} : "";
@ -479,6 +481,7 @@ sub change_owner
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->change_owner()" }});
my $group = defined $parameter->{group} ? $parameter->{group} : getgrgid($();
my $path = defined $parameter->{path} ? $parameter->{path} : "";
@ -582,6 +585,7 @@ sub check_md5sums
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->check_md5sums()" }});
# We'll set this if anything has changed.
my $exit = 0;
@ -716,6 +720,7 @@ sub compress
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->compress()" }});
my $file = defined $parameter->{file} ? $parameter->{file} : 0;
my $keep = defined $parameter->{keep} ? $parameter->{keep} : 0;
@ -1049,6 +1054,7 @@ sub copy_file
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->copy_file()" }});
my $overwrite = defined $parameter->{overwrite} ? $parameter->{overwrite} : 0;
my $password = defined $parameter->{password} ? $parameter->{password} : "";
@ -1250,6 +1256,14 @@ This creates a logical volume on the local host.
=cut
sub create_lv
{
my $self = shift;
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->create_lv()" }});
return(0);
}
=head2 find
@ -1374,6 +1388,7 @@ sub make_directory
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $test = defined $parameter->{test} ? $parameter->{test} : 0;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->make_directory()" }});
my $directory = defined $parameter->{directory} ? $parameter->{directory} : "";
my $group = defined $parameter->{group} ? $parameter->{group} : getgrgid($();
@ -1582,6 +1597,7 @@ sub move_file
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->move_file()" }});
my $overwrite = defined $parameter->{overwrite} ? $parameter->{overwrite} : 0;
my $password = defined $parameter->{password} ? $parameter->{password} : "";
@ -1833,6 +1849,7 @@ sub read_config
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->read_config()" }});
# Setup default values
my $file = defined $parameter->{file} ? $parameter->{file} : $anvil->data->{path}{configs}{'anvil.conf'};
@ -1972,6 +1989,7 @@ sub read_file
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->read_file()" }});
my $body = "";
my $cache = defined $parameter->{cache} ? $parameter->{cache} : 1;
@ -2153,6 +2171,7 @@ sub read_mode
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 1;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->read_mode()" }});
my $target = defined $parameter->{target} ? $parameter->{target} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { target => $target }});
@ -2201,6 +2220,7 @@ sub record_md5sums
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->record_md5sums()" }});
# Record the caller's MD5 sum
my $caller = $0;
@ -2287,6 +2307,7 @@ sub rsync
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->rsync()" }});
# Check my parameters.
my $destination = defined $parameter->{destination} ? $parameter->{destination} : "";
@ -2517,6 +2538,7 @@ sub scan_directory
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->scan_directory()" }});
# Set a default if nothing was passed.
my $directory = defined $parameter->{directory} ? $parameter->{directory} : "";
@ -2661,6 +2683,7 @@ sub search_directories
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->search_directories()" }});
# Set a default if nothing was passed.
my $array = defined $parameter->{directories} ? $parameter->{directories} : "";
@ -2789,6 +2812,7 @@ sub update_config
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->update_config()" }});
my $password = defined $parameter->{password} ? $parameter->{password} : "";
my $port = defined $parameter->{port} ? $parameter->{port} : 22;
@ -2957,6 +2981,7 @@ sub update_file
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->update_file()" }});
my $backup = defined $parameter->{backup} ? $parameter->{backup} : 1;
my $body = defined $parameter->{body} ? $parameter->{body} : "";
@ -3151,6 +3176,7 @@ sub write_file
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->write_file()" }});
my $backup = defined $parameter->{backup} ? $parameter->{backup} : 1;
my $body = defined $parameter->{body} ? $parameter->{body} : "";
@ -3472,6 +3498,7 @@ sub _create_rsync_wrapper
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Storage->_create_rsync_wrapper()" }});
# Check my parameters.
my $target = defined $parameter->{target} ? $parameter->{target} : "";

@ -126,7 +126,7 @@ sub activate_lv
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->call()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->activate_lv()" }});
my $path = defined $parameter->{path} ? $parameter->{path} : "";
my $activated = 0;
@ -658,7 +658,7 @@ sub check_ssh_keys
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->check_memory()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->check_ssh_keys()" }});
# We do a couple things here. First we make sure our user's keys are up to date and stored in the
# 'ssh_keys' table. Then we look through the 'Get->trusted_hosts' array any other users@hosts we're
@ -3546,6 +3546,7 @@ sub reload_daemon
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->reload_daemon()" }});
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }});
@ -3669,6 +3670,7 @@ sub restart_daemon
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->restart_daemon()" }});
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }});
@ -4112,7 +4114,7 @@ sub update_hosts
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->stty_echo()" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->update_hosts()" }});
# Get the list of hosts we trust.
my $trusted_host_uuids = $anvil->Get->trusted_hosts({debug => $debug});

@ -121,7 +121,7 @@ sub get
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $test = defined $parameter->{test} ? $parameter->{test} : 0;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Template->get()" }});
my $file = defined $parameter->{file} ? $parameter->{file} : "";
my $language = defined $parameter->{language} ? $parameter->{language} : $anvil->Words->language({debug => $debug});
@ -350,6 +350,7 @@ sub select_form
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Template->select_form()" }});
my $name = defined $parameter->{name} ? $parameter->{name} : "";
my $blank = defined $parameter->{blank} ? $parameter->{blank} : 0; # Add a blank/null entry?
@ -576,6 +577,7 @@ sub skin
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Template->skin()" }});
my $fatal = defined $parameter->{fatal} ? $parameter->{fatal} : 1;
my $set = defined $parameter->{set} ? $parameter->{set} : "";

@ -117,6 +117,7 @@ sub alphanumeric
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->alphanumeric()" }});
my $valid = 1;
my $string = defined $parameter->{string} ? $parameter->{string} : "";
@ -161,6 +162,7 @@ sub domain_name
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->domain_name()" }});
my $valid = 1;
my $name = $parameter->{name} ? $parameter->{name} : "";
@ -241,6 +243,7 @@ sub form_field
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->form_field()" }});
my $valid = 1;
my $name = defined $parameter->{name} ? $parameter->{name} : "";
@ -355,6 +358,7 @@ sub hex
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->hex()" }});
my $sloppy = defined $parameter->{sloppy} ? $parameter->{sloppy} : "";
my $string = defined $parameter->{string} ? $parameter->{string} : "";
@ -409,6 +413,7 @@ sub host_name
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->host_name()" }});
my $valid = 1;
my $name = $parameter->{name} ? $parameter->{name} : "";
@ -481,6 +486,7 @@ sub email
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->email()" }});
my $email = defined $parameter->{email} ? $parameter->{email} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { email => $email }});
@ -516,6 +522,7 @@ sub ip
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->ip()" }});
my $ip = defined $parameter->{ip} ? $parameter->{ip} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ip => $ip }});
@ -561,6 +568,7 @@ sub ipv4
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->ipv4()" }});
my $ip = defined $parameter->{ip} ? $parameter->{ip} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ip => $ip }});
@ -599,6 +607,7 @@ sub ipv6
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->ipv6()" }});
my $ip = defined $parameter->{ip} ? $parameter->{ip} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ip => $ip }});
@ -631,6 +640,7 @@ sub mac
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->mac()" }});
my $mac = defined $parameter->{mac} ? $parameter->{mac} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { mac => $mac }});
@ -666,6 +676,7 @@ sub port
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->port()" }});
my $port = defined $parameter->{port} ? $parameter->{port} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { port => $port }});
@ -717,6 +728,7 @@ sub positive_integer
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->positive_integer()" }});
my $valid = 1;
my $number = defined $parameter->{number} ? $parameter->{number} : "";
@ -763,6 +775,7 @@ sub subnet_mask
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->subnet_mask()" }});
my $valid = 0;
my $subnet_mask = defined $parameter->{subnet_mask} ? $parameter->{subnet_mask} : 0;
@ -827,6 +840,7 @@ sub uuid
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Validate->uuid()" }});
my $uuid = defined $parameter->{uuid} ? $parameter->{uuid} : 0;
my $valid = 0;

@ -111,6 +111,7 @@ sub clean_spaces
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Words->clean_spaces()" }});
# Setup default values
my $string = defined $parameter->{string} ? $parameter->{string} : "";
@ -128,7 +129,7 @@ NOTE: This is likely not the method you want. This method does no parsing at all
This returns a string by its key name. Optionally, a language and/or a source file can be specified. When no file is specified, loaded files will be search in alphabetical order (including path) and the first match is returned.
If the requested string is not found, 'C<< #!not_found!# >>' is returned.
If the requested string is not found, 'C<< #!not_found - <bad_key>!# >>' is returned.
Example to retrieve 'C<< t_0001 >>';
@ -180,7 +181,7 @@ sub key
my $key = defined $parameter->{key} ? $parameter->{key} : "";
my $language = defined $parameter->{language} ? $parameter->{language} : $anvil->Words->language;
my $file = defined $parameter->{file} ? $parameter->{file} : "";
my $string = "#!not_found!#";
my $string = "#!not_found - ".$key."!#";
my $error = 0;
### NOTE: Don't call Log->entry or Log->variable in here, it'll cause a recursive loop! Use 'test' when needed
print $THIS_FILE." ".__LINE__."; [ Debug ] - key: [$key], language: [$language], file: [$file]\n" if $test;
@ -333,6 +334,7 @@ sub parse_banged_string
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Words->parse_banged_string()" }});
# Setup default values
my $out_string = "";
@ -531,6 +533,7 @@ sub read
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Words->read()" }});
# Setup default values
my $return_code = 0;
@ -613,6 +616,7 @@ sub shorten_string
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Words->shorten_string()" }});
# Setup default values
my $short_string = "";
@ -1033,6 +1037,7 @@ sub _wrap_string
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Words->_wrap_string()" }});
# Get the string to wrap.
my $string = defined $parameter->{string} ? $parameter->{string} : "";

@ -717,11 +717,13 @@ WHERE
my $recipient_level_select = $anvil->Template->select_form({
name => "recipient_level",
options => [
"0#!#".$anvil->Words->string({key => "unit_0023"}),
"1#!#".$anvil->Words->string({key => "unit_0024"}),
"2#!#".$anvil->Words->string({key => "unit_0025"}),
"3#!#".$anvil->Words->string({key => "unit_0026"}),
"4#!#".$anvil->Words->string({key => "unit_0027"}),
"0#!#".$anvil->Words->string({key => "unit_0023"}),
],
'sort' => 0,
blank => 0,
selected => $recipient_level,
class => $anvil->data->{cgi}{recipient_level}{alert} ? "input_alert" : "input_clear",

@ -536,12 +536,6 @@
#!variable!language!#
</td>
</tr>
<tr>
<td colspan="2">
#!string!striker_0199!#<br />
#!variable!units!#
</td>
</tr>
<tr>
<td colspan="2">
#!string!striker_0200!#<br />

@ -12,17 +12,18 @@ Author: Madison Kelly <mkelly@alteeve.ca>
<language name="en_CA" long_name="Canadian English" description="Anvil! language file.">
<!-- Alert titles -->
<key name="alert_title_0001">Critical</key>
<key name="alert_title_0002">Warning</key>
<key name="alert_title_0003">Notice</key>
<key name="alert_title_0004">Info</key>
<key name="alert_title_0005">Critical Cleared!</key>
<key name="alert_title_0006">Warning Cleared!</key>
<key name="alert_title_0007">Notice Cleared!</key>
<key name="alert_title_0008">Info Cleared!</key>
<key name="alert_title_0001">- Critical</key>
<key name="alert_title_0002">- Warning</key>
<key name="alert_title_0003">- Notice</key>
<key name="alert_title_0004">- Info</key>
<key name="alert_title_0005">- Critical Cleared!</key>
<key name="alert_title_0006">- Warning Cleared!</key>
<key name="alert_title_0007">- Notice Cleared!</key>
<key name="alert_title_0008">- Info Cleared!</key>
<!-- Alert messages -->
<key name="alert_message_0001">The scan agent: [#!variable!agent_name!#] timed out! It was given: [#!variable!timeout!#] seconds to run, but it didn't return, so it was terminated.</key>
<key name="alert_message_0002">ScanCore has started.</key>
<!-- Branded strings reskinners may wish to change. -->
<key name="brand_0001">Alteeve</key>
@ -47,7 +48,7 @@ This alert email was sent from the machine:
It was generated by #!string!brand_0004!#, which is part of the #!string!brand_0002!# Intelligent Availability platform running on the host above.
This email was *not* sent by #!string!scancore_brand_0001!#. If you do not know why you are receiving this email, please speak to your system's administrator.
This email was *not* sent by #!string!brand_0001!#. If you do not know why you are receiving this email, please speak to your system's administrator.
If you need any assistance, please feel free to contact #!string!brand_0001!# (https://alteeve.com) and we will do our best to assist.
</key>
@ -228,6 +229,7 @@ The error was:
</key>
<key name="error_0141">There appears to be no mail server in the database with the UUID: [#!variable!uuid!#].</key>
<key name="error_0142">There alert level: [#!variable!alert_level!#] is invalid. Valid values are '1' / 'critical', '2' / 'warning, '3' / 'notice', and '4' / 'info'.</key>
<key name="error_0143">Failed to write the email alert file: [#!variable!file!#]! Unable to process the alert. Check the logs above for possible reasons for the error.</key>
<!-- Table headers -->
<key name="header_0001">Current Network Interfaces and States</key>
@ -1038,6 +1040,8 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0538">This IS the database queries are read from.</key>
<key name="log_0539">This is NOT the database queries are read from.</key>
<key name="log_0540">This host UUID is: [#!variable!uuid!#] and the database identifier is: [#!variable!identifier!#].</key>
<key name="log_0541">Writing out alert email to: [#!variable!file!#].</key>
<key name="log_0542">Sending email to: [#!variable!to!#].</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>
@ -1307,7 +1311,6 @@ About to try to download aproximately: [#!variable!packages!#] packages needed t
#############################################################################################################
</key> <!-- Translation note: System->update_hosts() looks for '##] anvil-daemon [##' to know if this alert was added to /etc/hosts. As such, please retain that exact string in your translation. -->
<key name="message_0178">Hosts added or updated by the #!string!brand_0002!# on: [#!variable!date!#]:</key>
<key name="message_0179">ScanCore has started.</key>
<!-- Success messages shown to the user -->
<key name="ok_0001">Saved the mail server information successfully!</key>
@ -1535,7 +1538,7 @@ If you are comfortable that the target has changed for a known reason, you can s
<key name="striker_0196">Recipient's Email</key>
<key name="striker_0197">The email that alerts are sent to.</key>
<key name="striker_0198">The language the user will receive alerts in.</key>
<key name="striker_0199">Does the user want imperial or metric units?</key>
<key name="striker_0199"></key> <!-- free -->
<key name="striker_0200">The alert level used for new (and existing) #!string!brand_0006!# systems.</key>
<key name="striker_0201">Existing alert recipients:</key>
<key name="striker_0202">This puts the host into network mapping mode. In this most, most functions are disabled and the link status of network interfaces are closely monitored.</key>

@ -26,7 +26,7 @@ $anvil->Log->secure({set => 1});
$anvil->Get->switches;
print "Connecting to the database(s);\n";
$anvil->Database->connect({debug => 2});
$anvil->Database->connect({debug => 3});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, secure => 0, key => "log_0132"});
if (0)
@ -34,11 +34,13 @@ if (0)
$anvil->Alert->register({
debug => 2,
alert_level => "warning",
message => "message_0179",
title => "alert_title_0002",
message => "alert_message_0002",
set_by => $THIS_FILE,
});
}
if (1)
{
### TODO: Left off here. Remove 'alert_title_X' keys and continue testing email body generation.
$anvil->Email->send_alerts({debug => 2});
}

Loading…
Cancel
Save