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

1.1.0 • Public • Published

📦 zabbix-cli-ts

Zabbix API Client in TypeScript

npm latest version

This is a typescript lib to make calls to the zabbix api.

Validated in version 6.0 of Zabbix API

Getting started

Install this lib:

npm install zabbix-cli-ts

The available methods are:

  • apiinfo.version
  • user.login
  • user.logout
  • user.get
  • problem.get
  • hostgroup.get
  • host.get
  • event.get
  • trigger.get

The parameters used by the constructor in the ZabbixAPI class are respectively:

  • url: zabbix api
  • username: user defined in zabbix
  • password: password defined in zabbix
  • options:
    • authToken: token to login (If completed, the class will not login automatically)
    • timeout: milliseconds to abort the request (default: undefined)

Usage examples

The example below calls the event.get method:

import ZabbixAPI from 'zabbix-cli-ts'

async function getEvent() {
  const zabbix = new ZabbixAPI('[ZBX_URL]', '[ZBX_USER]', '[ZBX_PASS]')

  const item = await zabbix.event({
    limit: 1,
    output: 'extend'
  })

  zabbix.logout()
}

getEvent()

The library has a method to call any method from the zabbix api, it just won't be typed with the same call and return parameters:

import ZabbixAPI from 'zabbix-cli-ts'

async function getResquest() {
  const zabbix = new ZabbixAPI('[ZBX_URL]', '[ZBX_USER]', '[ZBX_PASS]')

  const item = await zabbix.request('history.get', {
    limit: 1,
    output: 'extend'
  })

  zabbix.logout()
}

getRequest()

Using request timeout:

import ZabbixAPI from 'zabbix-cli-ts'

const zabbix = new ZabbixAPI('[ZBX_URL]', '[ZBX_USER]', '[ZBX_PASS]', {
  timeout: 30000
})

Readme

Keywords

Package Sidebar

Install

npm i zabbix-cli-ts

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

70.6 kB

Total Files

64

Last publish

Collaborators

  • fareisv