Compare commits
4 Commits
fd9b169925
...
18.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da0cbab39b | ||
|
|
3bf8ccfb61 | ||
|
|
1f9a0996c0 | ||
|
|
d0c23d9246 |
92
maintenance_create_requests_from_project_task/README.md
Normal file
92
maintenance_create_requests_from_project_task/README.md
Normal file
@@ -0,0 +1,92 @@
|
||||
============================================
|
||||
maintenance_create_requests_from_project_task
|
||||
============================================
|
||||
|
||||
This module allows the bulk creation of maintenance requests directly from a
|
||||
project task. It is particularly useful when a task requires maintenance
|
||||
actions on multiple equipment items simultaneously.
|
||||
|
||||
Key features:
|
||||
|
||||
- **Bulk creation**: Create multiple maintenance requests at once from a task
|
||||
- **Equipment filtering**: Use domain filters to select target equipment
|
||||
- **Smart defaults**: Pre-fills equipment from the task's project
|
||||
- **Request tracking**: View all maintenance requests linked to a task
|
||||
|
||||
# Installation
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
`maintenance_create_requests_from_project_task`.
|
||||
|
||||
This module depends on:
|
||||
- `maintenance`
|
||||
- `maintenance_project`
|
||||
- `project`
|
||||
|
||||
# Configuration
|
||||
|
||||
No specific configuration is required.
|
||||
|
||||
# Usage
|
||||
|
||||
## Creating Maintenance Requests from a Task
|
||||
|
||||
1. Go to Project > Tasks
|
||||
2. Open a task
|
||||
3. In the action menu (or via the server action), click "Create maintenance requests"
|
||||
4. A wizard opens with:
|
||||
- **Task**: The source task (read-only)
|
||||
- **Title**: The name for all created maintenance requests
|
||||
- **Equipment Domain**: Filter to select which equipment to target
|
||||
- By default, shows equipment linked to the task's project
|
||||
- Use the domain builder to refine the selection
|
||||
- **Technician**: Assign a technician to all requests
|
||||
- **Maintenance Type**: Corrective or Preventive
|
||||
- **Priority**: From Very Low to High
|
||||
- **Duration**: Estimated duration in hours
|
||||
- **Scheduled Date**: When the maintenance should occur
|
||||
- **Description**: Details about the maintenance work
|
||||
5. Click "Create"
|
||||
6. All matching equipment will have a maintenance request created
|
||||
7. You are redirected to the list of created requests
|
||||
|
||||
## Viewing Linked Maintenance Requests
|
||||
|
||||
On the task form:
|
||||
- A smart button shows the count of open (not done) maintenance requests
|
||||
- Click it to view all maintenance requests linked to this task
|
||||
|
||||
## Equipment Domain Examples
|
||||
|
||||
- All equipment in the project: `[('project_id', '=', project_id)]`
|
||||
- Only servers: `[('category_id.name', '=', 'Server')]`
|
||||
- Equipment needing backup: `[('backup_activated', '=', True)]`
|
||||
- Combine conditions: `[('project_id', '=', project_id), ('category_id.name', '=', 'Server')]`
|
||||
|
||||
# Known issues / Roadmap
|
||||
|
||||
- Add template support for common maintenance scenarios
|
||||
- Add option to create a single request for multiple equipment
|
||||
|
||||
# Bug Tracker
|
||||
|
||||
Bugs are tracked on
|
||||
[our issues website](https://git.elabore.coop/Elabore/maintenance-tools/issues). In
|
||||
case of trouble, please check there if your issue has already been reported. If you
|
||||
spotted it first, help us smashing it by providing a detailed and welcomed feedback.
|
||||
|
||||
# Credits
|
||||
|
||||
## Contributors
|
||||
|
||||
- Stéphan Sainléger
|
||||
|
||||
## Funders
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
- Elabore (https://elabore.coop)
|
||||
|
||||
## Maintainer
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -1,48 +0,0 @@
|
||||
=============================================
|
||||
maintenance_create_requests_from_project_task
|
||||
=============================================
|
||||
|
||||
Allow the creation of multiple maintenance requests from a projet task.
|
||||
|
||||
When user click on the button "Create maintenance requests", a wizard appears.
|
||||
The wizard allows the user to configure the requests and to select the maintenance equipments concerned.
|
||||
At wizard validation, one or several maintenance requests are created, one for each equipement selected.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
``maintenance_create_requests_from_project_task``.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
None yet.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/maintenance-tools/issues>`_. In case of
|
||||
trouble, please check there if your issue has already been
|
||||
reported. If you spotted it first, help us smashing it by providing a
|
||||
detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Stéphan Sainléger
|
||||
|
||||
Funders
|
||||
-------
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
* Elabore (https://elabore.coop)
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "maintenance_create_requests_from_project_task",
|
||||
"version": "16.0.1.0.0",
|
||||
"version": "18.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"website": "https://elabore.coop",
|
||||
"maintainer": "Stéphan Sainléger",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<button
|
||||
name="action_view_maintenance_request_ids"
|
||||
type="object"
|
||||
attrs="{'invisible': [('maintenance_request_count', '=', 0)]}"
|
||||
invisible="maintenance_request_count == 0"
|
||||
class="oe_stat_button"
|
||||
icon="fa-tasks"
|
||||
>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
|
||||
|
||||
@@ -77,7 +78,10 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
|
||||
)
|
||||
if len(equipment_list) == 0:
|
||||
raise UserError(
|
||||
"No equipment is matching the domain. Maintenance request creation is not possible."
|
||||
_(
|
||||
"No equipment is matching the domain. "
|
||||
"Maintenance request creation is not possible."
|
||||
)
|
||||
)
|
||||
|
||||
vals_list = []
|
||||
@@ -104,7 +108,7 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
|
||||
|
||||
def _get_action(self, maintenance_requests):
|
||||
"""
|
||||
Provide the action to go to the tree view of the maintenance requests created.
|
||||
Provide the action to go to the list view of the maintenance requests created.
|
||||
"""
|
||||
search_view_ref = self.env.ref(
|
||||
"maintenance.hr_equipment_request_view_search", False
|
||||
@@ -112,7 +116,7 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
|
||||
form_view_ref = self.env.ref(
|
||||
"maintenance.hr_equipment_request_view_form", False
|
||||
)
|
||||
tree_view_ref = self.env.ref(
|
||||
list_view_ref = self.env.ref(
|
||||
"maintenance.hr_equipment_request_view_tree", False
|
||||
)
|
||||
|
||||
@@ -121,6 +125,6 @@ class CreateMaintenanceRequestsWizard(models.TransientModel):
|
||||
"name": "Maintenance Requests",
|
||||
"res_model": "maintenance.request",
|
||||
"type": "ir.actions.act_window",
|
||||
"views": [(tree_view_ref.id, "tree"), (form_view_ref.id, "form")],
|
||||
"views": [(list_view_ref.id, "list"), (form_view_ref.id, "form")],
|
||||
"search_view_id": search_view_ref and [search_view_ref.id],
|
||||
}
|
||||
|
||||
89
maintenance_server_data/README.md
Normal file
89
maintenance_server_data/README.md
Normal file
@@ -0,0 +1,89 @@
|
||||
=======================
|
||||
maintenance_server_data
|
||||
=======================
|
||||
|
||||
This module extends the maintenance equipment model to store detailed server
|
||||
information, enabling comprehensive server infrastructure management within Odoo.
|
||||
|
||||
It adds several new models and fields to track:
|
||||
|
||||
- **Server specifications**: IP address, CPU cores, RAM, disk storage
|
||||
- **Operating system**: Distribution name and version
|
||||
- **Services**: Track services running on each server with their versions and URLs
|
||||
- **Backup information**: Backup server, activation status, and health
|
||||
|
||||
# Installation
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
`maintenance_server_data`.
|
||||
|
||||
This module depends on `maintenance`.
|
||||
|
||||
# Configuration
|
||||
|
||||
No specific configuration is required. After installation, new fields will be
|
||||
available on the maintenance equipment form.
|
||||
|
||||
# Usage
|
||||
|
||||
## Managing Server Equipment
|
||||
|
||||
1. Go to Maintenance > Equipments
|
||||
2. Create or edit an equipment record
|
||||
3. Fill in the server-specific fields:
|
||||
- **Server IP Address**: The server's IP address
|
||||
- **Distribution**: Select or create an OS distribution
|
||||
- **Hosting City**: Physical location of the server
|
||||
- **Nb Cores**: Number of CPU cores
|
||||
- **RAM (Go)**: Amount of RAM in gigabytes
|
||||
- **Disk Storage (Go)**: Disk capacity in gigabytes
|
||||
- **Backup Activated**: Whether backups are enabled
|
||||
- **Backup Server**: The backup destination server
|
||||
- **Backup OK**: Current backup health status
|
||||
|
||||
## Managing OS Distributions
|
||||
|
||||
1. Go to Maintenance > Configuration > OS Distributions
|
||||
2. Create distributions with name and version (e.g., "Ubuntu", "22.04")
|
||||
3. The display name is automatically computed from name + version
|
||||
|
||||
## Managing Services
|
||||
|
||||
1. Go to Maintenance > Configuration > Services
|
||||
2. Create service definitions (e.g., "PostgreSQL", "Nginx", "Odoo")
|
||||
3. Create service versions for each service
|
||||
4. Mark the latest version with "Is Last Version?"
|
||||
|
||||
## Managing Service Instances
|
||||
|
||||
1. Go to Maintenance > Configuration > Service Instances
|
||||
2. Link services to equipment with their specific version and URL
|
||||
3. Service instances are automatically archived when their equipment is archived
|
||||
|
||||
# Known issues / Roadmap
|
||||
|
||||
- Add monitoring integration for automated backup status checks
|
||||
- Add service version upgrade tracking
|
||||
|
||||
# Bug Tracker
|
||||
|
||||
Bugs are tracked on
|
||||
[our issues website](https://github.com/elabore-coop/maintenance-tools/issues). In
|
||||
case of trouble, please check there if your issue has already been reported. If you
|
||||
spotted it first, help us smashing it by providing a detailed and welcomed feedback.
|
||||
|
||||
# Credits
|
||||
|
||||
## Contributors
|
||||
|
||||
- Stéphan Sainléger
|
||||
|
||||
## Funders
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
- Elabore (https://elabore.coop)
|
||||
|
||||
## Maintainer
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -1,44 +0,0 @@
|
||||
======================================
|
||||
maintenance_server_data
|
||||
======================================
|
||||
|
||||
Gather several identification data about the servers to maintain.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
``maintenance_server_data``.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
None yet.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/maintenance-tools/issues>`_. In case of
|
||||
trouble, please check there if your issue has already been
|
||||
reported. If you spotted it first, help us smashing it by providing a
|
||||
detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Stéphan Sainléger
|
||||
|
||||
Funders
|
||||
-------
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
* Elabore (https://elabore.coop)
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "maintenance_server_data",
|
||||
"version": "16.0.1.0.0",
|
||||
"version": "18.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"website": "https://git.elabore.coop/elabore/maintenance-tools",
|
||||
"maintainer": "Stéphan Sainléger",
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
<xpath expr="//notebook" position="inside">
|
||||
<page name="services" string="Services">
|
||||
<field name="service_ids" nolabel="1">
|
||||
<tree create="true" delete="true" editable="top">
|
||||
<list create="true" delete="true" editable="top">
|
||||
<field name="service_id" />
|
||||
<field
|
||||
name="version_id"
|
||||
domain="[('service_id', '=', service_id)]"
|
||||
/>
|
||||
<field name="service_url" />
|
||||
</tree>
|
||||
</list>
|
||||
</field>
|
||||
</page>
|
||||
</xpath>
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
|
||||
<record id="equipment_view_tree_server_inherit" model="ir.ui.view">
|
||||
<field name="name">equipment.tree.server.inherit</field>
|
||||
<field name="name">equipment.list.server.inherit</field>
|
||||
<field name="model">maintenance.equipment</field>
|
||||
<field name="inherit_id" ref="maintenance.hr_equipment_view_tree" />
|
||||
<field name="arch" type="xml">
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="os_distribution_view_tree" model="ir.ui.view">
|
||||
<field name="name">os.distribution.view.tree</field>
|
||||
<field name="name">os.distribution.view.list</field>
|
||||
<field name="model">os.distribution</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="OS Distributions" editable="top">
|
||||
<list editable="top">
|
||||
<field name="distrib_name" />
|
||||
<field name="distrib_version" />
|
||||
</tree>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="os_distribution_action" model="ir.actions.act_window">
|
||||
<field name="name">OS Distribution</field>
|
||||
<field name="res_model">os.distribution</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_mode">list</field>
|
||||
<field name="view_id" ref="os_distribution_view_tree" />
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
|
||||
@@ -2,46 +2,46 @@
|
||||
<odoo>
|
||||
<!-- VIEWS -->
|
||||
<record id="service_view_tree" model="ir.ui.view">
|
||||
<field name="name">service.view.tree</field>
|
||||
<field name="name">service.view.list</field>
|
||||
<field name="model">service</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Services" editable="top">
|
||||
<list editable="top">
|
||||
<field name="name" />
|
||||
</tree>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="service_version_view_tree" model="ir.ui.view">
|
||||
<field name="name">service.version.view.tree</field>
|
||||
<field name="name">service.version.view.list</field>
|
||||
<field name="model">service.version</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Service versions" editable="top">
|
||||
<list editable="top">
|
||||
<field name="service_id" />
|
||||
<field name="name" />
|
||||
<field name="is_last_version" />
|
||||
</tree>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="backup_server_view_tree" model="ir.ui.view">
|
||||
<field name="name">backup.server.view.tree</field>
|
||||
<field name="name">backup.server.view.list</field>
|
||||
<field name="model">backup.server</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Backup Servers" editable="top">
|
||||
<list editable="top">
|
||||
<field name="name" />
|
||||
</tree>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="service_instance_view_tree" model="ir.ui.view">
|
||||
<field name="name">service.instance.view.tree</field>
|
||||
<field name="name">service.instance.view.list</field>
|
||||
<field name="model">service.instance</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<list>
|
||||
<field name="equipment_id" />
|
||||
<field name="service_id" />
|
||||
<field name="version_id" />
|
||||
</tree>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
<record id="service_action" model="ir.actions.act_window">
|
||||
<field name="name">Service</field>
|
||||
<field name="res_model">service</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_mode">list</field>
|
||||
<field name="view_id" ref="service_view_tree" />
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
@@ -98,7 +98,7 @@
|
||||
<record id="service_version_action" model="ir.actions.act_window">
|
||||
<field name="name">Service Version</field>
|
||||
<field name="res_model">service.version</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_mode">list</field>
|
||||
<field name="view_id" ref="service_version_view_tree" />
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
@@ -110,7 +110,7 @@
|
||||
<record id="backup_server_action" model="ir.actions.act_window">
|
||||
<field name="name">Backup server</field>
|
||||
<field name="res_model">backup.server</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_mode">list</field>
|
||||
<field name="view_id" ref="backup_server_view_tree" />
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
@@ -122,7 +122,7 @@
|
||||
<record id="service_instance_action" model="ir.actions.act_window">
|
||||
<field name="name">Services</field>
|
||||
<field name="res_model">service.instance</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_mode">list</field>
|
||||
<field name="view_id" ref="service_instance_view_tree" />
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
|
||||
151
maintenance_service_http_monitoring/README.md
Normal file
151
maintenance_service_http_monitoring/README.md
Normal file
@@ -0,0 +1,151 @@
|
||||
===================================
|
||||
maintenance_service_http_monitoring
|
||||
===================================
|
||||
|
||||
This module provides automated HTTP availability monitoring for services
|
||||
defined on maintenance equipment. It periodically checks the HTTP status of
|
||||
service URLs and automatically creates maintenance requests when services
|
||||
are detected as unavailable.
|
||||
|
||||
Key features:
|
||||
|
||||
- **Automated HTTP checks**: Scheduled cron job checks all active services
|
||||
- **Maintenance mode**: Temporarily disable monitoring during planned maintenance
|
||||
- **Automatic maintenance requests**: Creates corrective maintenance requests
|
||||
when services fail HTTP checks
|
||||
- **Status tracking**: Records last HTTP status code and check date per service
|
||||
|
||||
# Installation
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
`maintenance_service_http_monitoring`.
|
||||
|
||||
This module depends on:
|
||||
- `maintenance`
|
||||
- `maintenance_server_data`
|
||||
|
||||
**Python dependencies**: This module requires the `requests` library.
|
||||
|
||||
# Configuration
|
||||
|
||||
## Maintenance Mode Duration
|
||||
|
||||
By default, maintenance mode lasts 4 hours. To change this:
|
||||
|
||||
1. Go to Settings > Technical > System Parameters
|
||||
2. Create or edit the parameter:
|
||||
- Key: `maintenance_service_http_monitoring.maintenance_mode_duration`
|
||||
- Value: Duration in hours (e.g., `8`)
|
||||
|
||||
## Cron Jobs
|
||||
|
||||
Two scheduled actions are installed:
|
||||
|
||||
1. **HTTP Service Monitoring: check all services**
|
||||
- Runs every 15 minutes
|
||||
- Checks HTTP status of all active service instances with URLs
|
||||
|
||||
2. **HTTP Service Monitoring: deactivate expired maintenance mode**
|
||||
- Runs every 15 minutes
|
||||
- Automatically disables maintenance mode when the end time is reached
|
||||
|
||||
## Webhook Notifications
|
||||
|
||||
Go to **Settings > Technical > Parameters > System Parameters** and configure:
|
||||
|
||||
+--------------------------------------------------------+----------------------------------------+
|
||||
| Key | Description |
|
||||
+========================================================+========================================+
|
||||
| ``maintenance_service_http_monitoring.webhook_url`` | Webhook URL (POST endpoint) |
|
||||
+--------------------------------------------------------+----------------------------------------+
|
||||
| ``maintenance_service_http_monitoring.webhook_user`` | Basic Auth username (optional) |
|
||||
+--------------------------------------------------------+----------------------------------------+
|
||||
| ``maintenance_service_http_monitoring.webhook_password``| Basic Auth password (optional) |
|
||||
+--------------------------------------------------------+----------------------------------------+
|
||||
|
||||
|
||||
# Usage
|
||||
|
||||
## Monitoring Services
|
||||
|
||||
Services are automatically monitored if they have:
|
||||
- A service URL defined
|
||||
- An associated equipment
|
||||
- The equipment is not in maintenance mode
|
||||
- The service instance is active
|
||||
|
||||
The monitoring checks HTTPS availability (HTTP URLs are automatically
|
||||
upgraded to HTTPS). A service is considered OK if it returns HTTP 200.
|
||||
|
||||
## Using Maintenance Mode
|
||||
|
||||
When performing planned maintenance on a server:
|
||||
|
||||
1. Go to Maintenance > Equipments
|
||||
2. Open the equipment record
|
||||
3. Click "Activer le mode maintenance" (Activate maintenance mode)
|
||||
4. HTTP monitoring is suspended for this equipment
|
||||
5. The mode automatically expires after the configured duration
|
||||
6. Or click "Désactiver le mode maintenance" to end it manually
|
||||
|
||||
## Viewing HTTP Status
|
||||
|
||||
On service instances, you can see:
|
||||
- **Last HTTP Status Code**: The last received HTTP status (200, 404, 500, etc.)
|
||||
- **Last HTTP Check Date**: When the last check was performed
|
||||
- **HTTP Status OK**: Quick visual indicator of service health
|
||||
|
||||
## Automatic Maintenance Requests
|
||||
|
||||
When a service fails HTTP checks:
|
||||
- A corrective maintenance request is created with prefix "[HTTP KO]"
|
||||
- The request is linked to the equipment
|
||||
- Only one request per equipment per day is created
|
||||
- The request description lists all failing services
|
||||
|
||||
## Webhook notifications
|
||||
|
||||
When a new maintenance request is created (HTTP check failure), the module can
|
||||
send a webhook notification to an external service (e.g., n8n, Rocket.Chat, Slack).
|
||||
|
||||
The webhook sends a JSON POST with the following structure::
|
||||
|
||||
{
|
||||
"id": 42,
|
||||
"name": "[HTTP KO] Server Name",
|
||||
"priority": "2",
|
||||
"description": "Service KO: https://example.com",
|
||||
"equipment": "Server Name",
|
||||
"link": "https://odoo.example.com/web#id=42&model=maintenance.request&view_type=form"
|
||||
}
|
||||
|
||||
|
||||
# Known issues / Roadmap
|
||||
|
||||
- Add configurable alert thresholds (e.g., alert after N consecutive failures)
|
||||
- Add email/notification on service failure
|
||||
- Support custom HTTP check endpoints (e.g., /health)
|
||||
- Add support for basic authentication
|
||||
|
||||
# Bug Tracker
|
||||
|
||||
Bugs are tracked on
|
||||
[our issues website](https://github.com/elabore-coop/maintenance-tools/issues). In
|
||||
case of trouble, please check there if your issue has already been reported. If you
|
||||
spotted it first, help us smashing it by providing a detailed and welcomed feedback.
|
||||
|
||||
# Credits
|
||||
|
||||
## Contributors
|
||||
|
||||
- Stéphan Sainléger
|
||||
|
||||
## Funders
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
- Elabore (https://elabore.coop)
|
||||
|
||||
## Maintainer
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -1,58 +0,0 @@
|
||||
======================================
|
||||
maintenance_service_http_monitoring
|
||||
======================================
|
||||
|
||||
Module that allows monitoring of different services by checking their HTTP 200 responses:
|
||||
|
||||
- Uses the `maintenance_server_data` service for each device.
|
||||
|
||||
If the service has a URL, a request is made.
|
||||
- Adds maintenance mode for a device:
|
||||
|
||||
- Allows disabling HTTP checks for a specified time (defined in the cron job).
|
||||
|
||||
## Logic:
|
||||
If a request fails and a maintenance task has already been created for the same day,
|
||||
no new task is added.
|
||||
|
||||
The default values for the cron jobs are located in `data/cron.xml`.
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
Use Odoo normal module installation procedure to install
|
||||
``maintenance_service_http_monitoring``.
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
|
||||
None yet.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `our issues website <https://github.com/elabore-coop/maintenance-tools/issues>`_. In case of
|
||||
trouble, please check there if your issue has already been
|
||||
reported. If you spotted it first, help us smashing it by providing a
|
||||
detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Boris Gallet
|
||||
|
||||
Funders
|
||||
-------
|
||||
|
||||
The development of this module has been financially supported by:
|
||||
* Elabore (https://elabore.coop)
|
||||
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
This module is maintained by Elabore.
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "maintenance_service_http_monitoring",
|
||||
"version": "16.0.1.0.0",
|
||||
"version": "18.0.1.0.0",
|
||||
"author": "Elabore",
|
||||
"license": "AGPL-3",
|
||||
"category": "Tools",
|
||||
@@ -8,6 +8,7 @@
|
||||
"depends": ["base", "maintenance", "maintenance_server_data"],
|
||||
"external_dependencies": {"python": ["requests"]},
|
||||
"data": [
|
||||
"data/ir_config_parameter.xml",
|
||||
"data/cron.xml",
|
||||
"views/service_instance_views.xml",
|
||||
"views/maintenance_equipment_views.xml",
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
<field name="code">model.cron_check_http_services()</field>
|
||||
<field name="interval_number">15</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doall">False</field>
|
||||
</record>
|
||||
<record id="ir_cron_maintenance_mode_expiry" model="ir.cron">
|
||||
<field
|
||||
@@ -22,7 +20,5 @@
|
||||
<field name="code">model.cron_deactivate_expired_maintenance_mode()</field>
|
||||
<field name="interval_number">15</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doall">False</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo noupdate="1">
|
||||
<record id="config_param_webhook_url" model="ir.config_parameter">
|
||||
<field name="key">maintenance_service_http_monitoring.webhook_url</field>
|
||||
<field name="value"></field>
|
||||
</record>
|
||||
<record id="config_param_webhook_user" model="ir.config_parameter">
|
||||
<field name="key">maintenance_service_http_monitoring.webhook_user</field>
|
||||
<field name="value"></field>
|
||||
</record>
|
||||
<record id="config_param_webhook_password" model="ir.config_parameter">
|
||||
<field name="key">maintenance_service_http_monitoring.webhook_password</field>
|
||||
<field name="value"></field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -1,8 +1,18 @@
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
try:
|
||||
import requests as http_requests
|
||||
except ImportError:
|
||||
http_requests = None
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
WEBHOOK_TIMEOUT = 10 # seconds
|
||||
|
||||
class MaintenanceEquipment(models.Model):
|
||||
_inherit = "maintenance.equipment"
|
||||
|
||||
@@ -103,8 +113,51 @@ class MaintenanceEquipment(models.Model):
|
||||
vals["maintenance_team_id"] = team.id
|
||||
request = self.env["maintenance.request"].create(vals)
|
||||
self.http_maintenance_request = request.id
|
||||
self._notify_webhook(request, ko_services)
|
||||
return request
|
||||
|
||||
def _notify_webhook(self, request, ko_services):
|
||||
"""Send a webhook notification when a new maintenance request is created."""
|
||||
ICP = self.env['ir.config_parameter'].sudo()
|
||||
webhook_url = ICP.get_param(
|
||||
'maintenance_service_http_monitoring.webhook_url', ''
|
||||
)
|
||||
if not webhook_url:
|
||||
return
|
||||
webhook_user = ICP.get_param(
|
||||
'maintenance_service_http_monitoring.webhook_user', ''
|
||||
)
|
||||
webhook_password = ICP.get_param(
|
||||
'maintenance_service_http_monitoring.webhook_password', ''
|
||||
)
|
||||
base_url = ICP.get_param('web.base.url', '')
|
||||
link = (
|
||||
f"{base_url}/web#id={request.id}"
|
||||
f"&model=maintenance.request&view_type=form"
|
||||
)
|
||||
payload = {
|
||||
'id': request.id,
|
||||
'name': request.name,
|
||||
'description': request.description or '',
|
||||
'equipment': self.name,
|
||||
'link': link,
|
||||
}
|
||||
auth = None
|
||||
if webhook_user and webhook_password:
|
||||
auth = (webhook_user, webhook_password)
|
||||
try:
|
||||
http_requests.post(
|
||||
webhook_url,
|
||||
json=payload,
|
||||
auth=auth,
|
||||
timeout=WEBHOOK_TIMEOUT,
|
||||
)
|
||||
except Exception as e:
|
||||
_logger.warning(
|
||||
"Webhook notification failed for maintenance request %s: %s",
|
||||
request.id, e,
|
||||
)
|
||||
|
||||
def _build_ko_services_description(self, ko_services):
|
||||
lines = [f"Service KO: {s.service_url or s.name}" for s in ko_services]
|
||||
return "\n".join(lines)
|
||||
|
||||
@@ -42,7 +42,7 @@ class ServiceInstance(models.Model):
|
||||
now = fields.Datetime.now()
|
||||
url = rec.service_url
|
||||
if not url.lower().startswith("https://"):
|
||||
url = "https://" + url.lstrip("http://")
|
||||
url = "https://" + url.removeprefix("http://").removeprefix("HTTP://")
|
||||
try:
|
||||
response = requests.get(url, timeout=HTTP_CHECK_TIMEOUT)
|
||||
status_code = response.status_code
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<div
|
||||
class="alert alert-warning"
|
||||
role="alert"
|
||||
attrs="{'invisible': [('maintenance_mode', '=', False)]}"
|
||||
invisible="not maintenance_mode"
|
||||
>
|
||||
Mode maintenance actif — Vérifications HTTP désactivées.<br />
|
||||
Fin prévue : <field name="maintenance_mode_end" readonly="1" />
|
||||
@@ -20,14 +20,14 @@
|
||||
name="action_activate_maintenance_mode"
|
||||
type="object"
|
||||
string="Activer le mode maintenance"
|
||||
attrs="{'invisible': [('maintenance_mode', '=', True)]}"
|
||||
invisible="maintenance_mode"
|
||||
class="oe_highlight"
|
||||
/>
|
||||
<button
|
||||
name="action_deactivate_maintenance_mode"
|
||||
type="object"
|
||||
string="Désactiver le mode maintenance"
|
||||
attrs="{'invisible': [('maintenance_mode', '=', False)]}"
|
||||
invisible="not maintenance_mode"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath expr="//notebook" position="inside">
|
||||
@@ -43,11 +43,11 @@
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_equipment_tree_http_monitoring" model="ir.ui.view">
|
||||
<field name="name">maintenance.equipment.tree.http.monitoring</field>
|
||||
<field name="name">maintenance.equipment.list.http.monitoring</field>
|
||||
<field name="model">maintenance.equipment</field>
|
||||
<field name="inherit_id" ref="maintenance.hr_equipment_view_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//tree" position="inside">
|
||||
<xpath expr="//list" position="inside">
|
||||
<field name="maintenance_mode" optional="hide" />
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<!-- Inherit from base tree view to add HTTP monitoring fields -->
|
||||
<!-- Inherit from base list view to add HTTP monitoring fields -->
|
||||
<record id="service_instance_http_monitoring_tree" model="ir.ui.view">
|
||||
<field name="name">service.instance.http.monitoring.tree</field>
|
||||
<field name="name">service.instance.http.monitoring.list</field>
|
||||
<field name="model">service.instance</field>
|
||||
<field
|
||||
name="inherit_id"
|
||||
ref="maintenance_server_data.service_instance_view_tree"
|
||||
/>
|
||||
<field name="arch" type="xml">
|
||||
<tree position="attributes">
|
||||
<list position="attributes">
|
||||
<attribute name="decoration-danger">http_status_ok == False</attribute>
|
||||
</tree>
|
||||
</list>
|
||||
<field name="version_id" position="after">
|
||||
<field name="service_url" />
|
||||
<field name="last_http_check_date" />
|
||||
|
||||
Reference in New Issue
Block a user