Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(network::fortinet::fortigate::restapi) - mode(licenses) : Add counter last_update #4964

Closed

Conversation

chris-mvila
Copy link

Hi,
We have modified the licensing mode by adding the "last_update" option.
With this option, the plugin can monitor the last update of the databases.
By using the options "--unit", "--critical-last-update", and "--critical-status", we will be able to raise an alert if the last_update of the database exceeds xx days.

I remain at your disposal for any further information.

Best regards,

@chris-mvila chris-mvila requested review from a team as code owners March 26, 2024 18:10
@chris-mvila
Copy link
Author

Hi,
Could you please provide us with feedback regarding the addition of the last_update option?
Here is what the plugin returns with the option : last_update :

./centreon_plugins.pl --plugin=network::fortinet::fortigate::restapi::plugin --mode=licenses --hostname='xxxxxxxxxx' --port='xxxxx' --proto='https' --access-token='xxxxxxxx' --curl-opt="CURLOPT_SSL_VERIFYPEER => 0" --filter-name='malicious_urls' --unit='d' --warning-status='' --critical-status='%{status} !~ /licensed/i' --warning-last-update='' --critical-last-update='2'

OK: License 'malicious_urls' status: licensed, expires in 2M 19h 10m 50s, last_update is 15h 5m 25s | 'malicious_urls#license.expires.days'=61d;;;0;

Best regards,

@lucie-dubrunfaut
Copy link
Contributor

Hello :)

This PR is listed and to allow its integration I need to understand its link (or not) with the PR #4801 because I feel that there are “duplicate” files. If this is the case, would it be possible to pull the two PRs into one?

Anyway to allow us to integrate your contribution we would need data sets (anonymized) which would allow us to set up automated tests to ensure non-regression in the future around the plugin project. We can also support you in writing these tests if you wish. If necessary in the case of your PR we would need curls commands as well as JSON returns to correctly simulate the behavior of the API and validate the contribution proposed here.

Best regards.

@chris-mvila
Copy link
Author

Hi,
Thank you for your answer.
The 2 PRs are not linked, it's an error on my part, thank you for the remark
I removed files that were not needed for the fortigate plugin.

Concerning PR #4801, I am having difficulties because the API does not return
all information, pagination is required.
I will rely on the kubernetes plugin to add a request_api_paginate function in the api.pm file

I would like to take this opportunity to ask another question regarding the vmware plugin.
Could you tell me if the steps below are correct to create a vmware plugin.
1)- add a module in ... /src/centreon/script/centreon_vmware.pm, function my @load_modules = (
2)- Create the cmdxxxxx.pm module in ... connectors/vmware/src/centreon/vmware
3)- add the mode in ... src/apps/vmware/connector/plugin.pm
4)- Create the mode file in ... /src/apps/vmware/connector/mode/

In the cmdxxxx.pm file in the ..connectors/vmware/src/centreon/vmware folder
I would like to use two view_types: ClusterComputeResource and VirtualMachine
How should I proceed to use two view types?
Should I write :

my @view_type = ('ClusterComputeResource',VirtualMachine');
my $views = centreon::vmware::common::search_entities(command => $self, view_type => @\view_type, properties => @properties, filter => $filters);

Or should I make two calls :

my $views_cluster = centreon::vmware::common::search_entities(command => $self, view_type => 'ClusterComputeResource', properties => @properties, filter => $filters);
my $views_vm = centreon::vmware::common::search_entities(command => $self, view_type => 'VirtualMachine', properties => @properties, filter => $filters);

Thank you in advance for your feedback.

@chris-mvila
Copy link
Author

Hello, could you please provide me with feedback regarding this contribution? Thank you in advance.

@lucie-dubrunfaut
Copy link
Contributor

Hello :)

Sorry for the delay in replying. I haven't been able to find the data extracts for testing the PR you've proposed (we'd need the API output for testing the correct functioning of the parts of the code you've modified).

For the second part about creating a vmware plugin I'm not sure to understand your needs maybe you should open a dedicated issue to discuss about this.

@chris-mvila
Copy link
Author

chris-mvila commented Nov 18, 2024

Hello @lucie-dubrunfaut ,
Thank you for your feedback.
Here is the output of API
i hid some information such as ip address, e-mail, ...

Output-api.json

@lucie-dubrunfaut lucie-dubrunfaut changed the title Updatefortigatebychrismvila enh(network::fortinet::fortigate::restapi) - mode(licenses) : Add option last_update Dec 4, 2024
@lucie-dubrunfaut lucie-dubrunfaut changed the title enh(network::fortinet::fortigate::restapi) - mode(licenses) : Add option last_update enh(network::fortinet::fortigate::restapi) - mode(licenses) : Add counter last_update Dec 4, 2024
@omercier
Copy link
Contributor

omercier commented Feb 4, 2025

Thanks a lot @chris-mvila !
Your code has been merged through PR #5399

@omercier omercier closed this Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants