zabbix-utils
TypeScript icon, indicating that this package has built-in type declarations

2.0.2-patch.1 • Public • Published

TypeScript Zabbix Utils

tests api sender get zabbix_50 zabbix_60 zabbix_70 zabbix_72

License: MIT npm version

A TypeScript port of the official zabbix-utils Python library for working with Zabbix API, Zabbix sender, and Zabbix getter protocols.

Author: Han Yong Lim hanyong.lim@gmail.com
Original Python Library: Zabbix SIA

Features

  • Complete Feature Parity: One-to-one port of the Python library maintaining identical API
  • TypeScript Support: Full type safety with comprehensive type definitions
  • Synchronous & Asynchronous: Both sync and async implementations for all components
  • Zabbix API: Dynamic method creation with full API coverage
  • Zabbix Sender: Send values to Zabbix server/proxy with cluster support
  • Zabbix Getter: Retrieve values from Zabbix agents
  • Version Compatibility: Supports Zabbix 5.0+ (tested up to 7.2)

Installation

npm install zabbix-utils

Quick Start

Zabbix API (Synchronous)

import { ZabbixAPI } from 'zabbix-utils';

const api = new ZabbixAPI({
    url: 'https://zabbix.example.com',
    user: 'Admin',
    password: 'zabbix'
});

// Get all hosts
const hosts = api.host.get({
    output: ['hostid', 'name']
});

console.log(hosts);
api.logout();

Zabbix API (Asynchronous)

import { AsyncZabbixAPI } from 'zabbix-utils';

async function main() {
    const api = new AsyncZabbixAPI({
        url: 'https://zabbix.example.com',
        token: 'your-api-token'
    });

    const hosts = await api.host.get({
        output: ['hostid', 'name']
    });

    console.log(hosts);
}

Zabbix Sender

import { Sender, ItemValue } from 'zabbix-utils';

const sender = new Sender({
    server: '127.0.0.1',
    port: 10051
});

// Send single value
const response = sender.sendValue('host1', 'item.key', 'value', Date.now());

// Send multiple values
const items = [
    new ItemValue('host1', 'item.key1', 10),
    new ItemValue('host1', 'item.key2', 'test message'),
    new ItemValue('host2', 'item.key1', -1, Date.now())
];

const bulkResponse = sender.send(items);
console.log(bulkResponse);

Zabbix Getter

import { Getter } from 'zabbix-utils';

const agent = new Getter({
    host: '127.0.0.1',
    port: 10050
});

const response = agent.get('system.uname');
console.log(response.value);

Documentation

API Reference

Examples

See the examples directory for comprehensive usage examples:

  • Basic Usage: Simple API, sender, and getter examples
  • API Examples: Authentication, template export, context management
  • Sender Examples: Single sending, bulk sending, cluster usage
  • Getter Examples: Agent data retrieval

Environment Variables

The library supports the following environment variables:

  • ZABBIX_URL - Zabbix server URL
  • ZABBIX_USER - Username for authentication
  • ZABBIX_PASSWORD - Password for authentication
  • ZABBIX_TOKEN - API token for authentication (Zabbix 5.4+)

Version Compatibility

Zabbix Version Support Status
5.0 LTS ✅ Supported
6.0 LTS ✅ Supported
7.0 ✅ Supported
7.2 ✅ Supported

Testing

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run specific test suite
npm test -- tests/api.test.ts

# Watch mode for development
npm run test:watch

Current test coverage: 103 tests across 9 test suites, all passing.

Building

# Build TypeScript to JavaScript
npm run build

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

Upstream Synchronization

This TypeScript port maintains feature parity with the upstream Python library through automated monitoring and synchronization processes.

Current Status

  • TypeScript Version: 2.0.2
  • Upstream Version: 2.0.2 (Latest)
  • Feature Parity: ✅ Complete

Monitoring

# Check for upstream changes
npm run sync:check

# Generate detailed sync report
npm run sync:report

# Full analysis with diff files
npm run sync:full

For detailed information about maintaining upstream parity, see UPSTREAM_SYNC.md.

License

This project is licensed under the MIT License - the same license as the upstream Python library.

MIT License

Copyright (C) 2001-2023 Zabbix SIA (Original Python library)
Copyright (C) 2024-2025 Han Yong Lim <hanyong.lim@gmail.com> (TypeScript adaptation)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Maintain feature parity with upstream Python library
  • Follow TypeScript best practices
  • Add tests for new functionality
  • Update documentation as needed
  • Run the full test suite before submitting

Acknowledgments

  • Original Python Library: zabbix/python-zabbix-utils
  • Zabbix SIA: For creating and maintaining the original library
  • TypeScript Adaptation: Han Yong Lim hanyong.lim@gmail.com
  • Contributors: All contributors to both the original and TypeScript versions

Links


Note: This is an unofficial TypeScript port created by Han Yong Lim. For the official Python library, please visit zabbix/python-zabbix-utils.

Package Sidebar

Install

npm i zabbix-utils

Weekly Downloads

33

Version

2.0.2-patch.1

License

MIT

Unpacked Size

228 kB

Total Files

52

Last publish

Collaborators

  • leroylim