Google Drive

The function of this plugin is to monitor the occupied space and the last change of a file.

Introduction

Ver. 26-03-2024

This plugin is intended to monitor the space and the date of the last change of a Google Drive file.

Tipo: Plug-in server

Compatibility matrix

Systems where tested Rocky linux, Fedora 34
Systems where it works     Any linux system

Pre requisites

 

Enable Google Drive API:
Go to the Google Developer Console.
Create a new project or select an existing one.
In the left pane, click "Library."
Search for "Google Drive API" in the list of available APIs.
Click "Google Drive API".
Click "enable" to enable the API for your project.

Create API credentials:
After enabling the API, click "Credentials" in the left pane.
Click "Create credentials" and select "Service account".
Complete the form with the required information (service account name, roles, etc.).
Click "Create".
Select the type of service account key you want (JSON recommended).
Click "Create" and a JSON file with the service credentials will be downloaded.

Parameters

Meraki connection parameters

--creds_json json file with google credentials
--creds_base64 Base 64 of json file with google credentials
--file_name Name of the file, which is to be monitored and the date of its last change
--log_file Log file path

Pandora configuration parameters

--agent_prefix
Prefix for all agents created by the plugin
--module_prefix Prefix for all modules created by the plugin
--interval Agent monitoring interval
--temporal PandoraFMS temporary directory
--data_dir
PandoraFMS Data Directory
--transfer_mode
Data transfer mode, local or tentacle
--tentacle_client
Tentacle client path, by default "tentacle_client".
--tentacle_opts
Additional tentacle options
--tentacle_port
Tentacle Port
--tentacle_address
Tentacle IP

Manual execution

The plugin execution format is as follows :

./pandora_googledrive --creds_json/creds_base64 <file credentials> \
[--file_name <file_name>] \
[--module_prefix <module_prefix>] \
[--agent_prefix <agent_prefix>] \
[--group <group>] \
[--interval <interval>] \
[--temporal <temporal>] \
[--data_dir <data_dir>] \
[--transfer_mode <transfer_mode>] \
[--tentacle_client <tentacle_client>] \
[--tentacle_opts <tentacle_opts>] \
[--tentacle_port <tentacle_port>] \
[--tentacle_address <tentacle_address>] \
[--log_file <log_file>]

Example:

./pandora_google_drive --creds_json "creds.json" --tentacle_address 174.42.42.123 --file_name "sistema_de_alertas.mp4"

 

Configuration in PandoraFMS

To configure the plugin in PandoraFMS, the following steps must be followed :

1. Upload the plugin to PandoraFMS, for example in the following path:

/usr/share/pandora_server/util/plugin

2. Go to the plugins section and create a new one:

image.png

   3. Name, description and timeout are added:

image.png

4. The path of the plugin is added to the command and the necessary parameters for its execution. 

For each parameter a macro must be configured, the syntax of this macro being the following : _fieldx_, where x is the positional number of the parameter.

image.png

5. The previous macros are configured, adding the value of the parameter in each one:

image.png

6. Once configured, we should create a module in an agent that executes the plugin. In the modules menu of an agent we create a new plugin type module:

image.png

7. In the module configuration menu, give it a name, select the plugin configured before and click on "create".

image.png

8. The agent will be created with the modules or the modules in the selected agent in the next execution of the plugin:

image.png

 

Agent and modules generated by the plugin

The plugin will create an agent named <Prefix>Google Drive, with the following modules:

< Prefix > < Google Drive Used >
< Prefix > < File name >