diff --git a/lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/DrWeb.pm b/lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/DrWeb.pm new file mode 100644 index 000000000..df7d4cf8b --- /dev/null +++ b/lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/DrWeb.pm @@ -0,0 +1,83 @@ +package GLPI::Agent::Task::Inventory::Linux::AntiVirus::DrWeb; + +use strict; +use warnings; +use parent 'GLPI::Agent::Task::Inventory::Module'; + +use GLPI::Agent::Tools; + +sub isEnabled { + return canRun('drweb-ctl'); +} + +sub doInventory { + my (%params) = @_; + + my $inventory = $params{inventory}; + my $logger = $params{logger}; + + my $antivirus = _getDrWebInfo(logger => $logger); + if ($antivirus) { + $inventory->addEntry( + section => 'ANTIVIRUS', + entry => $antivirus + ); + + $logger->debug2("Added $antivirus->{NAME}" . + ($antivirus->{VERSION} ? " v$antivirus->{VERSION}" : "") . + ($antivirus->{ENABLED} ? " [ENABLED]" : " [DISABLED]")) + if $logger; + } +} + +sub _getDrWebInfo { + my (%params) = @_; + + my $av = { + NAME => 'Dr.Web', + COMPANY => 'Doctor Web', + ENABLED => 0, + UPTODATE => 0, + }; + + my $version_output = getFirstLine( + command => 'drweb-ctl --version', + %params + ); + + if ($version_output && $version_output =~ /drweb-ctl\s+([\d.]+)/) { + $av->{VERSION} = $1; + } + + my $service_status = getFirstLine( + command => 'systemctl is-active drweb-configd.service', + %params + ); + $av->{ENABLED} = $service_status && $service_status eq 'active' ? 1 : 0; + + my @baseinfo = getAllLines( + command => 'drweb-ctl baseinfo', + %params + ); + + foreach my $line (@baseinfo) { + if ($line =~ /^Virus database timestamp:\s+(\S+)/) { + $av->{BASE_VERSION} = $1; + } + } + + my $expiration = getFirstMatch( + command => 'drweb-ctl license', + pattern => qr/expires (\d+-\w+-\d+)/, + %params + ); + if ($expiration && $expiration =~ /^(\d+)-(\w+)-(\d+)$/) { + my $m = month($2); + $av->{EXPIRATION} = sprintf("%d-%02d-%02d", $1, $m, $3) if $m; + } + + + return $av; +} + +1; diff --git a/lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/KESL.pm b/lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/KESL.pm new file mode 100644 index 000000000..efb40e8ee --- /dev/null +++ b/lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/KESL.pm @@ -0,0 +1,76 @@ +package GLPI::Agent::Task::Inventory::Linux::AntiVirus::KESL; + +use strict; +use warnings; +use parent 'GLPI::Agent::Task::Inventory::Module'; + +use GLPI::Agent::Tools; + +sub isEnabled { + return canRun('kesl-control'); +} + +sub doInventory { + my (%params) = @_; + + my $inventory = $params{inventory}; + my $logger = $params{logger}; + + my $antivirus = _getKESLInfo(logger => $logger); + if ($antivirus) { + $inventory->addEntry( + section => 'ANTIVIRUS', + entry => $antivirus + ); + + $logger->debug2("Added $antivirus->{NAME}" . + ($antivirus->{VERSION} ? " v$antivirus->{VERSION}" : "") . + ($antivirus->{ENABLED} ? " [ENABLED]" : " [DISABLED]") . + ($antivirus->{EXPIRATION} ? " Expires: $antivirus->{EXPIRATION}" : "")) + if $logger; + } +} + +sub _getKESLInfo { + my (%params) = @_; + + my $av = { + NAME => 'Kaspersky Endpoint Security for Linux', + COMPANY => 'Kaspersky Lab', + ENABLED => 0, + UPTODATE => 0, + }; + + my $service_status = getFirstLine( + command => 'systemctl is-active kesl.service', + %params + ); + $av->{ENABLED} = $service_status && $service_status eq 'active' ? 1 : 0; + + my @app_info = getAllLines( + command => 'kesl-control --app-info', + %params + ); + + foreach my $line (@app_info) { + + if (!$av->{VERSION} && $line =~ /^Version:\s+([\d.]+)/) { + $av->{VERSION} = $1; + next; + } + + if (!$av->{EXPIRATION} && $line =~ /license expiration date:\s+([\d-]+)/i) { + $av->{EXPIRATION} = $1; + next; + } + + if (!$av->{BASE_VERSION} && $line =~ /^Last release date of databases:\s+([\d-]+)/) { + $av->{BASE_VERSION} = $1; + next; + } + } + + return $av; +} + +1;