-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SentinelOne for Linux support (#531)
Co-authored-by: Guillaume Bougard <[email protected]>
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/Sentinelone.pm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package GLPI::Agent::Task::Inventory::Linux::AntiVirus::Sentinelone; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use parent 'GLPI::Agent::Task::Inventory::Module'; | ||
|
||
use UNIVERSAL::require; | ||
|
||
use GLPI::Agent::Tools; | ||
|
||
sub isEnabled { | ||
return canRun('/opt/sentinelone/bin/sentinelctl'); | ||
} | ||
|
||
sub doInventory { | ||
my (%params) = @_; | ||
|
||
my $inventory = $params{inventory}; | ||
my $logger = $params{logger}; | ||
|
||
my $antivirus = _getSentineloneInfo(logger => $logger); | ||
if ($antivirus) { | ||
$inventory->addEntry( | ||
section => 'ANTIVIRUS', | ||
entry => $antivirus | ||
); | ||
|
||
$logger->debug2("Added $antivirus->{NAME}" . ($antivirus->{VERSION} ? " v$antivirus->{VERSION}" : "")) | ||
if $logger; | ||
} | ||
} | ||
|
||
sub _getSentineloneInfo { | ||
my (%params) = @_; | ||
|
||
my $cmd = '/opt/sentinelone/bin/sentinelctl'; | ||
|
||
my @output = getAllLines( | ||
command => "$cmd version && $cmd engines status && $cmd control status && $cmd management status", | ||
%params | ||
) | ||
or return; | ||
|
||
my $av = { | ||
NAME => 'SentinelAgent', | ||
COMPANY => 'SentinelOne', | ||
ENABLED => 0, | ||
UPTODATE => 0, | ||
}; | ||
|
||
foreach my $line (@output) { | ||
my ($key, $value) = $line =~ /(.+)(?:: |(?<!\s)\s{2,})(.*)/ | ||
or next; | ||
if ($key eq "Agent version") { | ||
$av->{VERSION} = $value; | ||
} elsif ($key eq "DFI library version") { | ||
$av->{BASE_VERSION} = $value; | ||
} elsif ($key eq "Agent state") { | ||
$av->{ENABLED} = $value eq "Enabled" ? 1 : 0; | ||
} elsif ($key eq "Connectivity") { | ||
# SentinelAgent does not directly report "uptodate" status but we can assume it is updated if the cloud connectivity is working. | ||
$av->{UPTODATE} = $value eq "On" ? 1 : 0; | ||
} | ||
} | ||
|
||
return $av; | ||
} | ||
|
||
1; |