public bool ZabbixAPILogin(string _username, string _password) { this.Username = _username; this.Password = _password; ZabbixLogin zabbixLogin = new ZabbixLogin() { Username = this.Username, Password = this.Password }; ZabbixRequest zabbixRequest = new ZabbixRequest() { JsonRPC = "2.0", Method = "user.login", Params = zabbixLogin, Id = Count++ }; byte[] postBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(zabbixRequest)); ZabbixResponse zabbixResponse = JsonConvert.DeserializeObject <ZabbixResponse>(Request(postBytes)); if (!string.IsNullOrEmpty(zabbixResponse.Result.ToString())) { ZabbixAPILoginAuthStr = zabbixResponse.Result.ToString(); return(true); } else { ZabbixAPILoginAuthStr = string.Empty; return(false); } }
public string ZabbixVersion() { ZabbixRequest zabbixRequest = new ZabbixRequest() { JsonRPC = "2.0", Method = "apiinfo.version", Params = Array.Empty <Object>(), Id = Count++ }; byte[] postBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(zabbixRequest)); ZabbixResponse zabbixResponse = JsonConvert.DeserializeObject <ZabbixResponse>(Request(postBytes)); return(zabbixResponse.Result.ToString()); }
public bool ZabbixAPILogout() { ZabbixRequestAuth zabbixRequest = new ZabbixRequestAuth() { JsonRPC = "2.0", Method = "user.logout", Params = Array.Empty <object>(), Id = Count++, Auth = ZabbixAPILoginAuthStr }; byte[] postBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(zabbixRequest)); ZabbixResponse zabbixResponse = JsonConvert.DeserializeObject <ZabbixResponse>(Request(postBytes)); return(Boolean.Parse(zabbixResponse.Result.ToString())); }