feat: implement weather sensor extension and enhance device interfaces
This change introduces the Weather Sensor device type which retrieves data from public APIs, and enhances the core Host/Device interfaces to provide consistent access to inventory and items across all specialized device types. It also improves search logic and fixes several bugs identified during implementation. - Weather Sensor Extension: Added schema and recipe for a device retrieving weather data via Zabbix HTTP agent items. - Interface Enhancements: Added inventory and items fields to Host and Device interfaces to ensure all device specialized types have consistent access to monitoring and inventory data. - Search Logic Improvements: Enhanced ParsedArgs to support searchByAny and technical name (host) searches when a name pattern is provided. - Bug Fixes: - Fixed getLocations argument order in the Zabbix API datasource. - Implemented deduplication for groupids and templateids in HostImporter to prevent Zabbix duplicate value errors. - Added missing url field to CreateTemplateItem for HTTP Agent item support. - Testing: - Extended the regression test suite with 4 new automated checks covering the fixed bugs. - Updated Jest tests to accommodate the improved search parameters. - Documentation: Updated cookbook and test specifications to reflect new features and regression testing obligations.
This commit is contained in:
parent
b84e4c0734
commit
5da4a17e36
20 changed files with 438 additions and 98 deletions
|
|
@ -85,7 +85,7 @@ export class ZabbixQueryHostsGenericRequestWithItems<T extends ZabbixResult, A e
|
|||
"hostid",
|
||||
"host",
|
||||
"name",
|
||||
"hostgroup",
|
||||
"hostgroups",
|
||||
"items",
|
||||
"description",
|
||||
"parentTemplates"
|
||||
|
|
@ -183,6 +183,7 @@ class ZabbixCreateHostParams implements ZabbixParams {
|
|||
this.name = inputParams.name;
|
||||
this.description = inputParams.description;
|
||||
if (inputParams.location) {
|
||||
this.inventory_mode = 0;
|
||||
this.inventory = {
|
||||
location: inputParams.location.name,
|
||||
location_lat: inputParams.location.location_lat,
|
||||
|
|
@ -204,6 +205,7 @@ class ZabbixCreateHostParams implements ZabbixParams {
|
|||
host: string
|
||||
name: string
|
||||
description: string
|
||||
inventory_mode?: number
|
||||
|
||||
inventory?: {
|
||||
location: String
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export type ZabbixErrorResult = {
|
|||
export const isZabbixErrorResult = (value: any): value is ZabbixErrorResult => value instanceof Object && "error" in value && !!value.error;
|
||||
|
||||
export interface ZabbixParams {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface ZabbixWithTagsParams extends ZabbixParams {
|
||||
|
|
@ -131,13 +132,12 @@ export class ParsedArgs {
|
|||
}
|
||||
|
||||
if (this.name_pattern) {
|
||||
if ("search" in result) {
|
||||
(<any>result.search).name = this.name_pattern
|
||||
} else {
|
||||
(<any>result).search = {
|
||||
name: this.name_pattern,
|
||||
}
|
||||
if (!("search" in result)) {
|
||||
(<any>result).search = {}
|
||||
}
|
||||
(<any>result).search.name = this.name_pattern;
|
||||
(<any>result).search.host = this.name_pattern;
|
||||
(<any>result).searchByAny = true;
|
||||
}
|
||||
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -81,8 +81,9 @@ export class TemplateHelper {
|
|||
public static async findTemplateIdsByName(templateNames: string[], zabbixApi: ZabbixAPI, zabbixAuthToken?: string, cookie?: string) {
|
||||
let result: number[] = []
|
||||
for (let templateName of templateNames) {
|
||||
// Use name_pattern which now searches both visibility name and technical name (host)
|
||||
let templates = await new ZabbixQueryTemplatesRequest(zabbixAuthToken, cookie).executeRequestReturnError(zabbixApi, new ParsedArgs({
|
||||
filter_name: templateName
|
||||
name_pattern: templateName
|
||||
}))
|
||||
|
||||
if (isZabbixErrorResult(templates) || !templates?.length) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue