C# Zabbix Api to retrieve and modify the configuration of Zabbix
This library allows you to make CRUD operations using Zabbix API. You just need to instantiate the context and the service that you want and call the operation.Like that:
On the Package Manager Cosole type this to install:
Install-Package Zabbix
Instantiate the context and the service that you want and call the operation:
using(var context = new Context(url, user, password))
{
var host = context.Hosts.GetByName("myHost");
}
You can make your own query too, like that:
using(var context = new Context(url, user, password))
{
var host = context.Hosts.Get(new {
name = "myHost"
});
}
Or that:
using (var context = new Context(url, user, password))
{
var host2 = context.Hosts.Get(new
{
hostid = "1"
});
}
Instead of specifying the configuration in the constructor the appsettings.json
file can be used like that:
{
"ZabbixApi": {
"url": "http://MyZabbixServer/zabbix/api_jsonrpc.php",
"user": "Admin",
"password": "zabbix"
}
}
The empty constructor can then be used:
using(var context = new Context())
{
// ...
}