misc(dynamics/ax): force new perfdata + indent (#3296)

This commit is contained in:
qgarnier 2021-12-06 09:42:19 +01:00 committed by GitHub
parent f44d8e2177
commit 1ae3404f4e
1 changed files with 32 additions and 31 deletions

View File

@ -60,16 +60,15 @@ sub set_counters {
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'timeframe:s' => { name => 'timeframe', default => 14400 },
"timeframe:s" => { name => 'timeframe', default => '14400' }, 'filter-module:s' => { name => 'filter_module' },
"filter-module:s" => { name => 'filter_module' }, 'filter-company:s' => { name => 'filter_company' },
"filter-company:s" => { name => 'filter_company' }, 'filter-portname:s' => { name => 'filter_portname' }
"filter-portname:s" => { name => 'filter_portname' } });
});
return $self; return $self;
} }
@ -80,29 +79,30 @@ sub manage_selection {
# $options{sql} = sqlmode object # $options{sql} = sqlmode object
$self->{sql} = $options{sql}; $self->{sql} = $options{sql};
my $query = " SELECT my $query = "
[AIFEXCEPTIONMAP].[MESSAGEID], SELECT
[SYSEXCEPTIONTABLE].[EXCEPTION], [AIFEXCEPTIONMAP].[MESSAGEID],
[SYSEXCEPTIONTABLE].[DESCRIPTION], [SYSEXCEPTIONTABLE].[EXCEPTION],
[SYSEXCEPTIONTABLE].[MODULE], [SYSEXCEPTIONTABLE].[DESCRIPTION],
convert(char(19), [SYSEXCEPTIONTABLE].[CREATEDDATETIME], 120) CREATEDDATETIME, [SYSEXCEPTIONTABLE].[MODULE],
[AIFEXCEPTIONMAP].[PORTNAME], convert(char(19), [SYSEXCEPTIONTABLE].[CREATEDDATETIME], 120) CREATEDDATETIME,
[AIFMESSAGELOG].[COMPANY] [AIFEXCEPTIONMAP].[PORTNAME],
FROM [MicrosoftDynamicsAX].[dbo].[SYSEXCEPTIONTABLE] [AIFMESSAGELOG].[COMPANY]
Inner join [MicrosoftDynamicsAX].[dbo].[AIFEXCEPTIONMAP] on SYSEXCEPTIONTABLE.RECID = AIFEXCEPTIONMAP.EXCEPTIONID FROM [MicrosoftDynamicsAX].[dbo].[SYSEXCEPTIONTABLE]
Inner join [MicrosoftDynamicsAX].[dbo].[AIFDOCUMENTLOG] on AIFEXCEPTIONMAP.MESSAGEID = AIFDOCUMENTLOG.MESSAGEID Inner join [MicrosoftDynamicsAX].[dbo].[AIFEXCEPTIONMAP] on SYSEXCEPTIONTABLE.RECID = AIFEXCEPTIONMAP.EXCEPTIONID
Inner join [MicrosoftDynamicsAX].[dbo].[AIFMESSAGELOG] on AIFDOCUMENTLOG.MESSAGEID = AIFMESSAGELOG.MESSAGEID Inner join [MicrosoftDynamicsAX].[dbo].[AIFDOCUMENTLOG] on AIFEXCEPTIONMAP.MESSAGEID = AIFDOCUMENTLOG.MESSAGEID
WHERE [SYSEXCEPTIONTABLE].[CREATEDDATETIME] > (DATEADD(SECOND,-" . $self->{option_results}->{timeframe} . ",SYSDATETIME()))"; Inner join [MicrosoftDynamicsAX].[dbo].[AIFMESSAGELOG] on AIFDOCUMENTLOG.MESSAGEID = AIFMESSAGELOG.MESSAGEID
WHERE [SYSEXCEPTIONTABLE].[CREATEDDATETIME] > (DATEADD(SECOND,-" . $self->{option_results}->{timeframe} . ",SYSDATETIME()))";
if(defined($self->{option_results}->{filter_module}) && $self->{option_results}->{filter_module} ne '') { if(defined($self->{option_results}->{filter_module}) && $self->{option_results}->{filter_module} ne '') {
$query = $query . " AND [SYSEXCEPTIONTABLE].[MODULE] LIKE '$self->{option_results}->{filter_module}'"; $query = $query . " AND [SYSEXCEPTIONTABLE].[MODULE] LIKE '$self->{option_results}->{filter_module}'";
} }
if(defined($self->{option_results}->{filter_company}) && $self->{option_results}->{filter_company} ne '') { if(defined($self->{option_results}->{filter_company}) && $self->{option_results}->{filter_company} ne '') {
$query = $query . " AND [AIFMESSAGELOG].[COMPANY] LIKE '$self->{option_results}->{filter_company}'"; $query = $query . " AND [AIFMESSAGELOG].[COMPANY] LIKE '$self->{option_results}->{filter_company}'";
} }
if(defined($self->{option_results}->{filter_portname}) && $self->{option_results}->{filter_portname} ne '') { if(defined($self->{option_results}->{filter_portname}) && $self->{option_results}->{filter_portname} ne '') {
$query = $query . " AND [AIFEXCEPTIONMAP].[PORTNAME] LIKE '$self->{option_results}->{filter_portname}'"; $query = $query . " AND [AIFEXCEPTIONMAP].[PORTNAME] LIKE '$self->{option_results}->{filter_portname}'";
} }
$query = $query . " ORDER BY [AIFEXCEPTIONMAP].[MESSAGEID] "; $query = $query . " ORDER BY [AIFEXCEPTIONMAP].[MESSAGEID] ";
$self->{sql}->connect(); $self->{sql}->connect();
$self->{sql}->query(query => $query ); $self->{sql}->query(query => $query );
@ -161,6 +161,7 @@ Thresholds.
Can be: 'order-critical', 'order-warning'. Can be: 'order-critical', 'order-warning'.
=item B<--timeframe> =item B<--timeframe>
Set the timeframe to query in seconds (Default: 14400). Set the timeframe to query in seconds (Default: 14400).
=item B<--filter-module> =item B<--filter-module>