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(); } }
private void Connect() { if (zApi != null) { zApi.stop(); } Debug("Creating API connection"); zApi = new ZabbixAPI(apiURL, apiUsername, apiPassword); zApi.onUpdate += updateInfo; this.Cursor = Cursors.WaitCursor; zApi.setMinSeverity(minPriority.ToString()); zApi.setInterval(checkInterval); if (showAck) { zApi.setHideAck(0); } else { zApi.setHideAck(1); } zApi.connect(); lblAPIVersion.Text = "API Version: " + zApi.ApiVersion(); }
private void loadSettings() { if (!File.Exists(exePath + "\\ZabbixTray.ini")) { return; } IniFile ini = new IniFile(exePath + "\\ZabbixTray.ini"); apiURL = ini.IniReadValue("Options", "apiURL"); apiUsername = ini.IniReadValue("Options", "apiUsername"); apiPassword = ini.IniReadValue("Options", "apiPassword"); try { checkInterval = Int32.Parse(ini.IniReadValue("Options", "checkInterval")); if (zApi != null) { zApi.setInterval(checkInterval); } } catch (Exception ex) { Debug("Error parsing checkInterval: " + ex.Message); } try { minPriority = Int32.Parse(ini.IniReadValue("Options", "minPriority")); if (zApi != null) { zApi.setMinSeverity(minPriority.ToString()); } } catch (Exception ex) { Debug("Error parsing minPriority: " + ex.Message); } try { showAck = bool.Parse(ini.IniReadValue("Options", "showAck")); if (zApi != null) { if (showAck) { zApi.setHideAck(0); } else { zApi.setHideAck(1); } } } catch (Exception ex) { Debug("Error parsing showAck: " + ex.Message); } try { showPopup = bool.Parse(ini.IniReadValue("Options", "showPopup")); } catch (Exception ex) { Debug("Error parsing showPopup: " + ex.Message); } }