From 6e9383635cd8202f90881d5e456f77c834b71977 Mon Sep 17 00:00:00 2001 From: THEPAUT Date: Fri, 19 Jan 2024 04:34:44 -0500 Subject: [PATCH 1/2] Enhance notification look - MON-24756 (#4735) --- .../deb.json | 3 +- .../rpm.json | 3 +- src/notification/email/mode/alert.pm | 1056 +++++++---------- src/notification/email/templates/bam.pm | 359 ++++++ src/notification/email/templates/host.pm | 415 +++++++ .../email/templates/metaservice.pm | 408 +++++++ src/notification/email/templates/resources.pm | 18 + src/notification/email/templates/service.pm | 461 +++++++ src/notification/email/templates/style.pm | 204 ++++ 9 files changed, 2280 insertions(+), 647 deletions(-) create mode 100644 src/notification/email/templates/bam.pm create mode 100644 src/notification/email/templates/host.pm create mode 100644 src/notification/email/templates/metaservice.pm create mode 100644 src/notification/email/templates/resources.pm create mode 100644 src/notification/email/templates/service.pm create mode 100644 src/notification/email/templates/style.pm diff --git a/packaging/centreon-plugin-Notification-Email/deb.json b/packaging/centreon-plugin-Notification-Email/deb.json index 15206f567e..679eedd74f 100644 --- a/packaging/centreon-plugin-Notification-Email/deb.json +++ b/packaging/centreon-plugin-Notification-Email/deb.json @@ -1,6 +1,7 @@ { "dependencies": [ "libemail-sender-perl", - "libemail-mime-perl" + "libemail-mime-perl", + "libhtml-template-perl" ] } diff --git a/packaging/centreon-plugin-Notification-Email/rpm.json b/packaging/centreon-plugin-Notification-Email/rpm.json index 2e53d426a4..5ada9436bf 100644 --- a/packaging/centreon-plugin-Notification-Email/rpm.json +++ b/packaging/centreon-plugin-Notification-Email/rpm.json @@ -2,6 +2,7 @@ "dependencies": [ "perl(Email::MIME)", "perl(Email::Simple)", - "perl(Email::Sender)" + "perl(Email::Sender)", + "perl(HTML::Template)" ] } diff --git a/src/notification/email/mode/alert.pm b/src/notification/email/mode/alert.pm index ec0839c5c8..374104814f 100644 --- a/src/notification/email/mode/alert.pm +++ b/src/notification/email/mode/alert.pm @@ -30,9 +30,12 @@ use Email::Sender::Simple qw(sendmail); use Email::Sender::Transport::SMTP; use JSON::XS; use URI::Escape; +use HTML::Template; use centreon::plugins::http; +use notification::email::templates::resources; -my %color_host = ( + +my %color = ( up => { background => '#88B922', text => '#FFFFFF' @@ -41,29 +44,6 @@ my %color_host = ( background => '#FF4A4A', text => '#FFFFFF' }, - unreachable => { - background => '#E0E0E0', - text => '#666666' - }, - acknowledgement => { - background => '#F5F1E9', - text => '#666666' - }, - downtimestart => { - background => '#F0E9F8', - text => '#666666' - }, - downtimeend => { - background => '#F0E9F8', - text => '#666666' - }, - downtimecanceled => { - background => '#F0E9F8', - text => '#666666' - } -); - -my %color_service = ( ok => { background => '#88B922', text => '#FFFFFF' @@ -80,20 +60,24 @@ my %color_service = ( background => '#E0E0E0', text => '#FFFFFF' }, - acknowledgement => { - background => '#F5F1E9', - text => '#666666' + unreachable => { + background => '#E0E0E0', + text => '#666666' }, - downtimestart => { - background => '#F0E9F8', + acknowledgement => { + background => '#F5F1E9', text => '#666666' }, - downtimeend => { - background => '#F0E9F8', + downtimestart => { + background => '#F0E9F8', + text => '#666666' + }, + downtimeend => { + background => '#F0E9F8', text => '#666666' }, - downtimecanceled => { - background => '#F0E9F8', + downtimecanceled => { + background => '#F0E9F8', text => '#666666' } ); @@ -123,6 +107,7 @@ sub new { 'host-duration:s' => { name => 'host_duration' }, 'service-id:s' => { name => 'service_id' }, 'service-description:s' => { name => 'service_description' }, + 'service-displayname:s' => { name => 'service_displayname' }, 'service-state:s' => { name => 'service_state' }, 'service-output:s' => { name => 'service_output' }, 'service-longoutput:s' => { name => 'service_longoutput' }, @@ -178,50 +163,53 @@ sub host_message { my $host_id = $self->{option_results}->{host_id}; - my $details = { - id => $host_id, - resourcesDetailsEndpoint => "/centreon/api/latest/monitoring/resources/hosts/$host_id", - tab => "details" - }; - - my $author_html = ''; + my $event_type = ''; + my $author = ''; my $author_alt = ''; - my $comment_html = ''; + my $comment = ''; my $comment_alt = ''; + my $include_author = 0; + my $include_comment = 0; + if (defined($self->{option_results}->{notif_author}) && $self->{option_results}->{notif_author} ne '') { + $author = $self->{option_results}->{notif_author}; + $include_author = 1; if ($self->{option_results}->{type} =~ /^downtime.*$/i) { - $author_html = '

Scheduled Downtime by:

-

' . $self->{option_results}->{notif_author} . '

'; + $event_type = 'Scheduled Downtime'; $author_alt = 'Scheduled Downtime by: ' . $self->{option_results}->{notif_author}; - } elsif ($self->{option_results}->{type} =~ /^acknowledgement$/i) { - $author_html = '

Acknowledged Author:

-

' . $self->{option_results}->{notif_author} . '

'; - $author_alt = 'Acknowledged Author: ' . $self->{option_results}->{notif_author}; - } elsif ($self->{option_results}->{type} =~ /^flaping.*$/i) { - $author_html = '

Flapping Author:

-

' . $self->{option_results}->{notif_author} . '

'; - $author_alt = 'Flapping Author: ' . $self->{option_results}->{notif_author}; + } elsif($self->{option_results}->{type} =~ /^acknowledgement$/i) { + $event_type = 'Acknowledged'; + $author_alt = 'Acknowledged by: ' . $self->{option_results}->{notif_author}; + } elsif($self->{option_results}->{type} =~ /^flaping.*$/i) { + $event_type = 'Flapping'; + $author_alt = 'Flapping by: ' . $self->{option_results}->{notif_author}; } } - + if (defined($self->{option_results}->{notif_comment}) && $self->{option_results}->{notif_comment} ne '') { - if ($self->{option_results}->{type} =~ /^downtime.*$/i){ - $comment_html = '

Scheduled Downtime Comment:

-

' . $self->{option_results}->{notif_comment} . '

'; + $comment = $self->{option_results}->{notif_comment}; + $include_comment = 1; + if ($self->{option_results}->{type} =~ /^downtime.*$/i) { + $event_type = 'Scheduled Downtime'; $comment_alt = 'Scheduled Downtime Comment: ' . $self->{option_results}->{notif_comment}; - } elsif ($self->{option_results}->{type} =~ /^acknowledgement$/i) { - $comment_html = '

Acknowledged Comment:

-

' . $self->{option_results}->{notif_comment} . '

'; + } elsif($self->{option_results}->{type} =~ /^acknowledgement$/i) { + $event_type = 'Acknowledged'; $comment_alt = 'Acknowledged Comment: ' . $self->{option_results}->{notif_comment}; - } elsif ($self->{option_results}->{type} =~ /^flaping.*$/i) { - $comment_html = '

Flapping Comment:

-

' . $self->{option_results}->{notif_comment} . '

'; + } elsif($self->{option_results}->{type} =~ /^flaping.*$/i) { + $event_type = 'Flapping'; $comment_alt = 'Flapping Comment: ' . $self->{option_results}->{notif_comment}; } } + my $details = { + id => $host_id, + resourcesDetailsEndpoint => "/centreon/api/latest/monitoring/resources/hosts/$host_id", + tab => "details" + }; + my $json_data = encode_json($details); my $encoded_data = uri_escape($json_data); + my $dynamic_href = $self->{option_results}->{centreon_url} .'/centreon/monitoring/resources?details=' . $encoded_data; $self->{payload_attachment}->{subject} = '*** ' . $self->{option_results}->{type} . ' : Host: ' . $self->{option_results}->{host_name} . ' ' . $self->{option_results}->{host_state} . ' ***'; $self->{payload_attachment}->{alt_message} = ' @@ -245,284 +233,51 @@ sub host_message { Info: ' .$self->{option_results}->{host_output}; - $self->{payload_attachment}->{html_message} = ' - - - - - ' . $self->{option_results}->{host_name} . ' - - - - - - - - - - - - -
- -
- [' .$self->{option_results}->{type} . '] Host: ' . $self->{option_results}->{host_alias} . ' (' . $self->{option_results}->{host_name} . ') is ' . $self->{option_results}->{host_state} . '. *************************************************************************************************************************************** -
- - - -
- - - '; } sub service_message { @@ -531,38 +286,40 @@ sub service_message { my $host_id = $self->{option_results}->{host_id}; my $service_id = $self->{option_results}->{service_id}; - my $author_html = ''; + my $event_type = ''; + my $author = ''; my $author_alt = ''; - my $comment_html = ''; + my $comment = ''; my $comment_alt = ''; + my $include_author = 0; + my $include_comment = 0; + if (defined($self->{option_results}->{notif_author}) && $self->{option_results}->{notif_author} ne '') { + $author = $self->{option_results}->{notif_author}; + $include_author = 1; if ($self->{option_results}->{type} =~ /^downtime.*$/i) { - $author_html = '

Scheduled Downtime by:

-

' . $self->{option_results}->{notif_author} . '

'; + $event_type = 'Scheduled Downtime'; $author_alt = 'Scheduled Downtime by: ' . $self->{option_results}->{notif_author}; } elsif($self->{option_results}->{type} =~ /^acknowledgement$/i) { - $author_html = '

Acknowledged Author:

-

' . $self->{option_results}->{notif_author} . '

'; - $author_alt = 'Acknowledged Author: ' . $self->{option_results}->{notif_author}; + $event_type = 'Acknowledged'; + $author_alt = 'Acknowledged by: ' . $self->{option_results}->{notif_author}; } elsif($self->{option_results}->{type} =~ /^flaping.*$/i) { - $author_html = '

Flapping Author:

-

' . $self->{option_results}->{notif_author} . '

'; - $author_alt = 'Flapping Author: ' . $self->{option_results}->{notif_author}; + $event_type = 'Flapping'; + $author_alt = 'Flapping by: ' . $self->{option_results}->{notif_author}; } } - + if (defined($self->{option_results}->{notif_comment}) && $self->{option_results}->{notif_comment} ne '') { + $comment = $self->{option_results}->{notif_comment}; + $include_comment = 1; if ($self->{option_results}->{type} =~ /^downtime.*$/i) { - $comment_html = '

Scheduled Downtime Comment:

-

' . $self->{option_results}->{notif_comment} . '

'; + $event_type = 'Scheduled Downtime'; $comment_alt = 'Scheduled Downtime Comment: ' . $self->{option_results}->{notif_comment}; } elsif($self->{option_results}->{type} =~ /^acknowledgement$/i) { - $comment_html = '

Acknowledged Comment:

-

' . $self->{option_results}->{notif_comment} . '

'; + $event_type = 'Acknowledged'; $comment_alt = 'Acknowledged Comment: ' . $self->{option_results}->{notif_comment}; } elsif($self->{option_results}->{type} =~ /^flaping.*$/i) { - $comment_html = '

Flapping Comment:

-

' . $self->{option_results}->{notif_comment} . '

'; + $event_type = 'Flapping'; $comment_alt = 'Flapping Comment: ' . $self->{option_results}->{notif_comment}; } } @@ -578,14 +335,14 @@ sub service_message { warning_status => '', critical_status => '' ); - + if ($self->{http}->get_code() !~ /200/ || $content =~ /^OK/) { - $graph_html = '

No graph

'; + $graph_html = '

No graph found

'; } elsif ($content =~ /Access denied|Resource not found|Invalid token/) { - $graph_html = '

Cannot retrieve graph: ' . $content . '

'; + $graph_html = '

Cannot retrieve graph: ' . $content . '

'; } else { $self->{payload_attachment}->{graph_png} = $content; - $graph_html = '\n"; + $graph_html = '\"Service\n"; } } @@ -595,13 +352,12 @@ sub service_message { tab => 'details' }; + my $line_break = '
'; my $json_data = encode_json($details); my $encoded_data = uri_escape($json_data); + my $dynamic_href = $self->{option_results}->{centreon_url} .'/centreon/monitoring/resources?details=' . $encoded_data; - my $line_break = '
'; - - $self->{option_results}->{service_longoutput} =~ s/\\n/
/g; - + $self->{payload_attachment}->{subject} = '*** ' . $self->{option_results}->{type} . ' : ' . $self->{option_results}->{service_description} . ' '. $self->{option_results}->{service_state} . ' on ' . $self->{option_results}->{host_name} . ' ***'; $self->{payload_attachment}->{alt_message} = ' ***** Centreon ***** @@ -626,309 +382,315 @@ sub service_message { ' . $self->{option_results}->{service_output} . ' ' . $self->{option_results}->{service_longoutput}; - $self->{payload_attachment}->{html_message} = ' - - - - - ' . $self->{option_results}->{host_name} . ' / ' . $self->{option_results}->{service_description} .' - - - - - - - - - - - - -
- -
[' . $self->{option_results}->{type} . '] Service: ' . $self->{option_results}->{service_description} . ' on Host: ' . $self->{option_results}->{host_name} . ' (' . $self->{option_results}->{host_alias} . ') is '. $self->{option_results}->{service_state} . '. *************************************************************************************************************************************** -
- - -
- - - '; + + my $dynamic_css = HTML::Template->new( + scalarref => \$notification::email::templates::resources::get_css + ); + $dynamic_css->param( + backgroundColor => $background_color, + textColor => $text_color, + stateColor => $color{lc($self->{option_results}->{service_state})}->{background} + ); + + + my $html_part = HTML::Template->new( + scalarref => \$notification::email::templates::resources::get_metaservice_template); + $html_part->param( + dynamicCss => $dynamic_css->output, + type => $self->{option_results}->{type}, + attempts => $self->{option_results}->{service_attempts}, + maxAttempts => $self->{option_results}->{max_service_attempts}, + serviceDescription => $self->{option_results}->{service_displayname}, + status => $self->{option_results}->{service_state}, + duration => $self->{option_results}->{service_duration}, + date => $self->{option_results}->{date}, + dynamicHref => $dynamic_href, + eventType => $event_type, + author => $author, + comment => $comment, + output => $self->{option_results}->{service_output}, + graphHtml => $graph_html, + includeAuthor => $include_author, + includeComment => $include_comment + ); + + $self->{payload_attachment}->{html_message} = $html_part->output + } sub set_payload { my ($self, %options) = @_; - if (defined($self->{option_results}->{service_description}) && $self->{option_results}->{service_description} ne '') { + if ($self->{option_results}->{host_name} =~ /^_Module_BAM.*/) { + $self->bam_message(); + } elsif ($self->{option_results}->{host_name} =~ /^_Module_Meta/ ) { + $self->metaservice_message(); + } elsif ( defined($self->{option_results}->{service_description}) && $self->{option_results}->{service_description} ne '' ) { $self->service_message(); } else { $self->host_message(); @@ -1041,7 +803,7 @@ centreon_plugins.pl --plugin=notification::email::plugin --mode=alert --to-addre Example for Centreon configuration: -centreon_plugins.pl --plugin=notification::email::plugin --mode=alert --to-address='$CONTACTEMAIL$' --host-address='$HOSTADDRESS$' --host-name='$HOSTNAME$' --host-alias='$HOSTALIAS$' --host-state='$HOSTSTATE$' --host-output='$HOSTOUTPUT$' --host-attempts='$HOSTATTEMPT$' --max-host-attempts='$MAXHOSTATTEMPTS$' --host-duration='$HOSTDURATION$' --date='$SHORTDATETIME$' --type='$NOTIFICATIONTYPE$' --service-description='$SERVICEDESC$' --service-state='$SERVICESTATE$' --service-output='$SERVICEOUTPUT$' --service-longoutput='$LONGSERVICEOUTPUT$' --service-attempts=''$SERVICEATTEMPT$ --max-service-attempts='$MAXSERVICEATTEMPTS$' --service-duration='$SERVICEDURATION$' --host-id='$HOSTID$' --service-id='$SERVICEID$' --notif-author='$NOTIFICATIONAUTHOR$' --notif-comment='$NOTIFICATIONCOMMENT$' --smtp-nossl --centreon-url='https://your-centreon-server' --smtp-address=your-smtp-server --smtp-port=your-smtp-port --from-address='centreon-engine@centreon.com' --centreon-user='your-centreon-username' --centreon-token='your-centreon-autologin-key' --smtp-user='your-smtp-username' --smtp-password='your-smtp-password' +centreon_plugins.pl --plugin=notification::email::plugin --mode=alert --to-address='$CONTACTEMAIL$' --host-address='$HOSTADDRESS$' --host-name='$HOSTNAME$' --host-alias='$HOSTALIAS$' --host-state='$HOSTSTATE$' --host-output='$HOSTOUTPUT$' --host-attempts='$HOSTATTEMPT$' --max-host-attempts='$MAXHOSTATTEMPTS$' --host-duration='$HOSTDURATION$' --date='$SHORTDATETIME$' --type='$NOTIFICATIONTYPE$' --service-description='$SERVICEDESC$' --service-displayname='$SERVICEDISPLAYNAME$' --service-state='$SERVICESTATE$' --service-output='$SERVICEOUTPUT$' --service-longoutput='$LONGSERVICEOUTPUT$' --service-attempts='$SERVICEATTEMPT$' --max-service-attempts='$MAXSERVICEATTEMPTS$' --service-duration='$SERVICEDURATION$' --host-id='$HOSTID$' --service-id='$SERVICEID$' --notif-author='$NOTIFICATIONAUTHOR$' --notif-comment='$NOTIFICATIONCOMMENT$' --smtp-nossl --centreon-url='https://your-centreon-server' --smtp-address=your-smtp-server --smtp-port=your-smtp-port --from-address='centreon-engine@centreon.com' --centreon-user='your-centreon-username' --centreon-token='your-centreon-autologin-key' --smtp-user='your-smtp-username' --smtp-password='your-smtp-password' =over 8 @@ -1121,6 +883,10 @@ ID of the service. Description of the service. +=item B<--service-displayname> + +Display BA name. + =item B<--service-state> State of the service. diff --git a/src/notification/email/templates/bam.pm b/src/notification/email/templates/bam.pm new file mode 100644 index 0000000000..cb3ad2205a --- /dev/null +++ b/src/notification/email/templates/bam.pm @@ -0,0 +1,359 @@ +package notification::email::templates::bam; + +use strict; +use warnings; + +use Exporter qw(import); + +our @EXPORT_OK = qw(get_bam_template); + +sub get_bam_template { +return q{ + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + +
+ +
+ +
+ + + + + + +
+ +
+
+
+
+ + + + + + +
+ + + + +
+
+
+
+
+
+
+ + + + + + +
+ +
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Business Activity:

+

+ + is + + + + for: + + + +

+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ +
+ + + + + + +
+ + + + +
+
+

Date:

+

+ +

+
+
+
+
+
+ + + + + + +
+ +
+
+
+
+ + + + + + +
+ + + + +
+ + + + +
+ More Information
+
+
+
+
+
+
+ + +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

+ by: +

+

+ +

+
+
+
+
+
+
+
+ + +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

+ Comment: +

+

+ +

+
+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Status information:

+

+ +

+
+
+
+
+
+
+
+
+
+ + + +}; +} + +1; \ No newline at end of file diff --git a/src/notification/email/templates/host.pm b/src/notification/email/templates/host.pm new file mode 100644 index 0000000000..fc8b3fba9d --- /dev/null +++ b/src/notification/email/templates/host.pm @@ -0,0 +1,415 @@ +package notification::email::templates::host; + +use strict; +use warnings; + +use Exporter qw(import); + +our @EXPORT_OK = qw(get_host_template); + +sub get_host_template { +return q{ + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + +
+ +
+ +
+ + + + + + +
+ +
+
+
+
+ + + + + + +
+ + + + +
+
+
+
+
+
+
+ + + + + + +
+ + + + +
+
+ / +
+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Host:

+

+ + is + + + + for: + + + +

+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Host Alias:

+

+ +

+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ +
+ + + + + + +
+ + + + +
+
+

Host Address:

+

+ +

+
+
+
+
+
+ + + + + + +
+ + + + +
+
+

Date:

+

+ +

+
+
+
+
+
+ + + + + + +
+ + + + +
+ + + + +
+ More Information
+
+
+
+
+
+
+ + +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

+ by: +

+

+ +

+
+
+
+
+
+
+
+ + +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

+ Comment: +

+

+ +

+
+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Status information:

+

+ +

+
+
+
+
+
+
+
+
+
+ + + +}; +} + +1; \ No newline at end of file diff --git a/src/notification/email/templates/metaservice.pm b/src/notification/email/templates/metaservice.pm new file mode 100644 index 0000000000..1c3af6efe9 --- /dev/null +++ b/src/notification/email/templates/metaservice.pm @@ -0,0 +1,408 @@ +package notification::email::templates::metaservice; + +use strict; +use warnings; + +use Exporter qw(import); + +our @EXPORT_OK = qw(get_metaservice_template); + +sub get_metaservice_template { +return q{ + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + +
+ +
+ +
+ + + + + + +
+ +
+
+
+
+ + + + + + +
+ + + + +
+
+
+
+
+
+
+ + + + + + +
+ + + + +
+
+ / +
+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Meta Service:

+

+ + is + + + + for: + + + +

+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ +
+ + + + + + +
+ + + + +
+
+

Date:

+

+ +

+
+
+
+
+
+ + + + + + +
+ +
+
+
+
+ + + + + + +
+ + + + +
+ + + + +
+ More Information
+
+
+
+
+
+
+ + +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

+ by: +

+

+ +

+
+
+
+
+
+
+
+ + +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

+ Comment: +

+

+ +

+
+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Status information:

+

+ +

+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+ + + + + + +
+ +
+
+
+
+
+
+
+
+
+ + + +}; +} + +1; \ No newline at end of file diff --git a/src/notification/email/templates/resources.pm b/src/notification/email/templates/resources.pm new file mode 100644 index 0000000000..f763eb5bb8 --- /dev/null +++ b/src/notification/email/templates/resources.pm @@ -0,0 +1,18 @@ +package notification::email::templates::resources; + +use strict; +use warnings; + +use notification::email::templates::style qw(get_css); +use notification::email::templates::host qw(get_host_template); +use notification::email::templates::service qw(get_service_template); +use notification::email::templates::bam qw(get_bam_template); +use notification::email::templates::metaservice qw(get_metaservice_template); + +our $get_service_template = get_service_template(); +our $get_host_template = get_host_template(); +our $get_bam_template = get_bam_template(); +our $get_metaservice_template = get_metaservice_template(); +our $get_css = get_css(); + +1; diff --git a/src/notification/email/templates/service.pm b/src/notification/email/templates/service.pm new file mode 100644 index 0000000000..c7dc7b1942 --- /dev/null +++ b/src/notification/email/templates/service.pm @@ -0,0 +1,461 @@ +package notification::email::templates::service; + +use strict; +use warnings; + +use Exporter qw(import); + +our @EXPORT_OK = qw(get_service_template); + +sub get_service_template { + return q{ + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + +
+ +
+ +
+ + + + + + +
+ +
+
+
+
+ + + + + + +
+ + + + +
+
+ +
+
+
+
+
+ + + + + + +
+ + + + +
+
+ / +
+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Host:

+

+ +

+

Service:

+

+ + + is + + + for: + + +

+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Host Alias:

+

+ +

+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ +
+ + + + + + +
+ + + + +
+
+

Host Address:

+

+ +

+
+
+
+
+
+ + + + + + +
+ + + + +
+
+

Date:

+

+ +

+
+
+
+
+
+ + + + + + +
+ + + + +
+ + + + +
More Information
+
+
+
+
+
+
+ + +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

+ by: +

+

+ +

+
+
+
+
+
+
+
+ + +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

+ Comment: +

+

+

+
+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+

Status information:

+

+ +

+
+
+
+
+
+
+ +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+ + + + + + +
+ +
+
+
+
+
+
+
+
+
+ + + +}; +} + +1; diff --git a/src/notification/email/templates/style.pm b/src/notification/email/templates/style.pm new file mode 100644 index 0000000000..7e6a97a1dc --- /dev/null +++ b/src/notification/email/templates/style.pm @@ -0,0 +1,204 @@ +package notification::email::templates::style; + +use strict; +use warnings; + +use Exporter qw(import); + +our @EXPORT_OK = qw(get_css); + +sub get_css { +return q{ + + + + + + + +}; +} + +1; \ No newline at end of file From e856a05984916e70dafceefd4bc9663b650882d9 Mon Sep 17 00:00:00 2001 From: Dalfo <106170240+DalfoCentreon@users.noreply.github.com> Date: Fri, 19 Jan 2024 17:11:15 +0100 Subject: [PATCH 2/2] Enh collection zxtm pool (#4634) --- src/contrib/collection/snmp/zxtm-pool.json | 84 +++++++++++++++++++ .../collection/snmp/zxtm-virtualserver.json | 64 ++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 src/contrib/collection/snmp/zxtm-pool.json create mode 100644 src/contrib/collection/snmp/zxtm-virtualserver.json diff --git a/src/contrib/collection/snmp/zxtm-pool.json b/src/contrib/collection/snmp/zxtm-pool.json new file mode 100644 index 0000000000..d82b2c8619 --- /dev/null +++ b/src/contrib/collection/snmp/zxtm-pool.json @@ -0,0 +1,84 @@ +{ + "constants": { + "okState": "active", + "criticalState": "disabled", + "criticalConnSecond": null, + "criticalCurrConn": null + }, + "mapping": { + "poolState": { + "1": "active", + "2": "disabled", + "3": "draining", + "4": "unused", + "5": "unknown" + } + }, + "snmp": { + "tables": [ + { + "name": "poolEntry", + "oid": ".1.3.6.1.4.1.7146.1.2.3.2.1", + "used_instance": "\\.1\\.3\\.6\\.1\\.4\\.1\\.7146\\.1\\.2\\.3\\.2\\.1\\.\\d+\\.(\\d+(\\.\\d+)+)", + "entries": [ + { + "name": "poolName", + "oid": ".1.3.6.1.4.1.7146.1.2.3.2.1.1" + }, + { + "name": "poolState", + "oid": ".1.3.6.1.4.1.7146.1.2.3.2.1.14", + "map": "poolState" + }, + { + "name": "poolTotalConn", + "oid": ".1.3.6.1.4.1.7146.1.2.3.2.1.10", + "sampling": 1 + }, + { + "name": "poolCurrentConn", + "oid": ".1.3.6.1.4.1.7146.1.2.3.2.1.48" + } + ] + } + ] + }, + "selection_loop": [ + { + "name": "Pool ZXTM", + "source": "%(snmp.tables.poolEntry)", + "expand_table": { + "poolEntry": "%(snmp.tables.poolEntry.[%(poolEntry.instance)])" + }, + "critical": "%(poolEntry.poolState) =~ /%(constants.criticalState)/ or (defined(%(constants.criticalConnSecond)) and %(poolEntry.poolTotalConnPerSeconds) >= %(constants.criticalConnSecond)) or (defined(%(constants.criticalCurrConn)) and %(poolEntry.poolCurrentConn) >= %(constants.criticalCurrConn))", + "perfdatas": [ + { + "nlabel": "connS", + "instances": ["%(poolEntry.poolName)"], + "value": "%(poolEntry.poolTotalConnPerSeconds)", + "critical": "%(constants.criticalConnSecond)", + "unit": "conn/s", + "min": 0 + }, + { + "nlabel": "conn", + "instances": ["%(poolEntry.poolName)"], + "value": "%(poolEntry.poolCurrentConn)", + "critical": "%(constants.criticalConn)", + "unit": "conn", + "min": 0 + } + ], + "formatting": { + "printf_msg": "Device '%s' state is '%s', current connetions are '%d', with conn/s '%.2f'", + "printf_var": [ + "%(poolEntry.poolName)", + "%(poolEntry.poolState)", + "%(poolEntry.poolCurrentConn)", + "%(poolEntry.poolTotalConnPerSeconds)" + ], + "display_ok": true + } + } + ] +} diff --git a/src/contrib/collection/snmp/zxtm-virtualserver.json b/src/contrib/collection/snmp/zxtm-virtualserver.json new file mode 100644 index 0000000000..fdf24fec21 --- /dev/null +++ b/src/contrib/collection/snmp/zxtm-virtualserver.json @@ -0,0 +1,64 @@ +{ + "constants": { + "criticalCurrConn": null + }, + "mapping": { + }, + "snmp": { + "tables": [ + { + "name": "virtualserverEntry", + "oid": ".1.3.6.1.4.1.7146.1.2.2.2.1", + "used_instance": "\\.1\\.3\\.6\\.1\\.4\\.1\\.7146\\.1\\.2\\.2\\.2\\.1\\.\\d+\\.(\\d+(\\.\\d+)+)", + "entries": [ + { + "name": "virtualserverName", + "oid": ".1.3.6.1.4.1.7146.1.2.2.2.1.1" + }, + { + "name": "virtualserverCurrentConn", + "oid": ".1.3.6.1.4.1.7146.1.2.2.2.1.9" + }, + { + "name": "virtualServerMaxConnections", + "oid": ".1.3.6.1.4.1.7146.1.2.2.2.1.10" + }, + { + "name": "virtualserverTotalHTTPRequests", + "oid": ".1.3.6.1.4.1.7146.1.2.2.2.1.43" + } + ] + } + ] + }, + "selection_loop": [ + { + "name": "Virtual Server ZXTM", + "source": "%(snmp.tables.virtualserverEntry)", + "expand_table": { + "virtualserverEntry": "%(snmp.tables.virtualserverEntry.[%(virtualserverEntry.instance)])" + }, + "critical": "defined(%(constants.criticalCurrConn)) and %(virtualserverEntry.virtualserverCurrentConn) >= %(constants.criticalCurrConn)", + "perfdatas": [ + { + "nlabel": "conn", + "instances": ["%(virtualserverEntry.virtualserverName)"], + "value": "%(virtualserverEntry.virtualserverCurrentConn)", + "critical": "%(constants.criticalConn)", + "unit": "conn", + "min": 0 + } + ], + "formatting": { + "printf_msg": "Device '%s' current connections are '%d', max connections are '%d', total HTTP requests are '%d'", + "printf_var": [ + "%(virtualserverEntry.virtualserverName)", + "%(virtualserverEntry.virtualserverCurrentConn)", + "%(virtualserverEntry.virtualServerMaxConnections)", + "%(virtualserverEntry.virtualserverTotalHTTPRequests)" + ], + "display_ok": true + } + } + ] +}