use PVE::DataCenterConfig;
use PVE::INotify;
use PVE::RPCEnvironment;
+use PVE::Notify;
use PVE::HA::Tools ':exit_codes';
use PVE::HA::Env;
syslog($level, $msg);
}
-sub sendmail {
- my ($self, $subject, $text) = @_;
+sub send_notification {
+ my ($self, $subject, $text, $properties) = @_;
- # Leave it to postfix to append the correct hostname
- my $mailfrom = 'root';
- # /root/.forward makes pvemailforward redirect the
- # mail to the address configured in the datacenter
- my $mailto = 'root';
+ eval {
+ my $dc_config = PVE::Cluster::cfs_read_file('datacenter.cfg');
+ my $target = $dc_config->{notify}->{'target-fencing'} // PVE::Notify::default_target();
+ my $notify = $dc_config->{notify}->{fencing} // 'always';
+
+ if ($notify eq 'always') {
+ PVE::Notify::error($target, $subject, $text, $properties);
+ }
+ };
- PVE::Tools::sendmail($mailto, $subject, $text, undef, $mailfrom);
+ $self->log("warning", "could not notify: $@") if $@;
}
my $last_lock_status_hash = {};