Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/western/zix
Zabbix api caller
https://github.com/western/zix
perl zabbix
Last synced: 18 days ago
JSON representation
Zabbix api caller
- Host: GitHub
- URL: https://github.com/western/zix
- Owner: western
- Created: 2020-04-21T01:38:49.000Z (over 4 years ago)
- Default Branch: dev
- Last Pushed: 2020-04-24T07:39:03.000Z (over 4 years ago)
- Last Synced: 2024-10-24T09:25:22.364Z (2 months ago)
- Topics: perl, zabbix
- Language: Perl
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# :zap:ix
Yet:smiling_imp: another zabbix perl:camel: api engine ;)
# Examples
Make some constructor:
```perl
#!/usr/bin/perluse strict;
use warnings;
use Data::Dumper;use lib 'lib';
use Zix;my $z = new Zix(
home => 'https://domain.tld/zabbix',
user => 'Admin',
password => '***password',
#basic_user => 'userlogin',
#basic_password => '***password',
);```
Then call api version. There is non auth :)
```perl
warn 'apiinfo.version: '.$z->apiinfo_version->{result};
```Auth check wrapper
```perlif( $z->is_auth ){
# get all hosts
my $hosts = $z->host_get;
for my $h ( @$hosts ){
warn 'hostid: '.$h->hostid;
warn 'name: '.$h->host;
}
# get one host object
my $h = $z->host_get('media');
warn $h->hostid;
warn Dumper($h->application);
warn Dumper($h->item);
warn Dumper($h->item(applicationids => 498));
warn Dumper($h->hostgroup);
warn Dumper($h->hostinterface);
warn Dumper($h->template);
}```
Use this universal method (theatrical pause) **->universal** :smiley: It's flexible:
```perl
$z->universal(
'application.get',
hostids => 10107,
);
$z->universal(
'item.get',
hostid => 10114,
);
$z->universal(
'item.create',
name => $it.'['.$dev.']',
key_ => $it.'['.$dev.']',
hostid => 10107,
interfaceid => 3,
type => 0,
value_type => 3, # 3 - numeric unsigned; 0 - numeric float;
applications => [506],
delay => 30,
delta => 1, # 1 - Delta, speed per second; # 2 - Delta, simple change.
);
$z->universal(
'host.create',
host => 'host name 1',
groups => [
{
groupid => 2,
}
],
interfaces => [
{
type => 1,
main => 1,
useip => 1,
ip => 'x.x.x.x',
port => 10050,
dns => '',
}
],
templates => [
{
templateid => 10001,
}
],
);
```