Zabbix.Api.NET 1.1.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package Zabbix.Api.NET --version 1.1.5
NuGet\Install-Package Zabbix.Api.NET -Version 1.1.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zabbix.Api.NET" Version="1.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zabbix.Api.NET --version 1.1.5
#r "nuget: Zabbix.Api.NET, 1.1.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Zabbix.Api.NET as a Cake Addin
#addin nuget:?package=Zabbix.Api.NET&version=1.1.5

// Install Zabbix.Api.NET as a Cake Tool
#tool nuget:?package=Zabbix.Api.NET&version=1.1.5

Zabbix 6.0 API Library for C#

This is a C# library designed to simplify interactions with the Zabbix API (version 6.0). It provides an intuitive way to perform operations such as creating, updating, deleting and getting entties for Zabbix.

Still in Development

Please note that this library is still under active development, there are probably a lot of bugs. Your assistance in identifying and addressing these issues is greatly appreciated.

Installation

Currently, the library can be used by either cloning this repository or by installing the NuGet package https://www.nuget.org/packages/Zabbix.Api.NET/

Usage

First, let's establish a connection to the Zabbix server using your credentials:

string url = "http://ZABBIX_SERVER/api_jsonrpc.php";
string username = "Admin";
string password = "zabbix";

ZabbixCore core = new ZabbixCore(url, username, password);

Creating Entities

Creating an Entity returns its remote Zabbix id, Zabbix will set every unset value to its default value. <br/> It's important to note that each entity has a set of required properties that must be configured, as indicated by the constructor.

Host serverHost = new Host("Server", new List<HostGroup>() { linuxServers });
string createdServerHostId = core.Hosts.Create(serverHost);

Updating Entities

Updating an entity also returns its Zabbix ID. During the update process, only the properties that are explicitly set (not null) will be sent to Zabbix.

serverHost.Status = 1;
string updatedServerHostId = core.Hosts.Update(serverHost);

Deleting Entities

Deleting a Entity returns its former remote Zabbix id. <br/> When deleting a Entity you need to know the remote Zabbix id.

//By Entity
string updatedServerHostId = core.Hosts.Delete(serverHost);

//Or also by Id
string updatedServerHostId = core.Hosts.Delete(createdServerHostId);

Getting Entities

This is a simple Get, it will return every Host that is configured on Zabbix.<br/>

List<Host> hosts = core.Hosts.Get().ToList();

However, the Get method can also accept a FilterOptions object as its parameter. Every entity has its own FilterOptions object named EntitynameFilterOptions.<br/> The FilterOptions can be initialized directly via the constructor like so:

var hostsWithItems = core.Hosts.Get(new() { SelectItems = "extend"});

if you want to for example query the Hosts items to only return certain properties you can pass it a list of strings like so:

var hostsWithItems = core.Hosts.Get(new() { SelectItems = new List<string>(){"hostid", "itemid"}});
Attention

The count related FilterOptions currently do not work<br/> If you want to set any of the filter properties to "extend" (at least those which support it) do not use a list:

//THIS IS WRONG
var hostsWithItems = core.Hosts.Get(new() { SelectItems = new List<string>(){"extend"}});

//Do this instead
var hostsWithItems = core.Hosts.Get(new() { SelectItems = "extend"});

Use a list if you're Querying for any property. For example:

//This is correct
var hostsWithItems = core.Hosts.Get(new() { SelectItems = new List<string>(){"hostid"}});

The exact meaning and usage of each FilterOption can be found on the Zabbix Docs under the Get section of the entity: https://www.zabbix.com/documentation/6.0/en/manual/api/reference

CRUD operations

Most entities support the CRUD operations and some include some extra Operations. <br/> Every Crud operation can be called with either a single Entity or a List of Entities. <br/>

Contribution

I welcome contributions and improvements to this library. Please feel free to open issues and submit pull requests.

Credit

Lots of Code has been reused from https://github.com/HenriqueCaires/ZabbixApi/tree/master

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.4 113 3/23/2024
1.2.3 151 11/7/2023
1.2.0 112 9/22/2023
1.1.5 96 9/19/2023
1.1.0 119 9/15/2023
1.0.0 123 9/14/2023