From 179c6002e6b53f2507d83b20806b8a03bcb9cc5d Mon Sep 17 00:00:00 2001 From: lchrdn <89968908+lchrdn@users.noreply.github.com> Date: Tue, 23 Aug 2022 13:07:39 +0200 Subject: [PATCH] add support for azcli and lookback option (#3859) --- centreon-plugins/cloud/azure/custom/azcli.pm | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/centreon-plugins/cloud/azure/custom/azcli.pm b/centreon-plugins/cloud/azure/custom/azcli.pm index 5c7126967..e2fc01c12 100644 --- a/centreon-plugins/cloud/azure/custom/azcli.pm +++ b/centreon-plugins/cloud/azure/custom/azcli.pm @@ -149,6 +149,30 @@ sub convert_duration { return $duration; } +sub convert_iso8601_to_epoch { + my ($self, %options) = @_; + + if ($options{time_string} =~ /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).(\d.*)[Z+]/) { + my $dt = DateTime->new( + year => $1, + month => $2, + day => $3, + hour => $4, + minute => $5, + second => $6, + nanosecond => $7 + ); + + my $epoch_time = $dt->epoch; + return $epoch_time; + + } + + $self->{output}->add_option_msg(short_msg => "Wrong date format: $options{time_string}"); + $self->{output}->option_exit(); + +} + sub azure_get_metrics_set_cmd { my ($self, %options) = @_;