forked from wriley/ZabbixTray
/
ZabbixServer.cs
63 lines (52 loc) · 1.61 KB
/
ZabbixServer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zabbix;
namespace ZabbixTray
{
public class ZabbixServer
{
#region Properties
public string name;
public string apiURL;
public string apiUsername;
public string apiPassword;
public int checkInterval = 10;
public int minPriority = 3;
public bool showAck = true;
public bool showPopup = true;
public bool enabled = true;
public ZabbixAPI zApi;
#endregion
#region Methods
public ZabbixServer(Hashtable options)
{
this.name = options["name"].ToString();
this.apiURL = options["apiURL"].ToString();
this.apiUsername = options["username"].ToString();
this.apiPassword = options["password"].ToString();
this.zApi = new ZabbixAPI(this.apiURL, this.apiUsername, this.apiPassword, this.name);
if (zApi != null)
{
if(options["minPriority"] != null)
zApi.setMinSeverity(options["minPriority"].ToString());
if(options["pollInterval"] != null)
zApi.setInterval(Convert.ToInt16(options["pollInterval"]));
if(options["showAck"] != null)
zApi.setHideAck(Convert.ToInt16(options["showAck"]));
zApi.connect();
}
}
public void Disconnect()
{
if (zApi != null)
{
zApi.stop();
}
}
#endregion
}
}