Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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());
        }