## Not run:
# # user authentication
# #####################
# ZabbixAPI('http://localhost/zabbix',
# body = list(method = "user.login",
# params = jsonlite::unbox(
# data.frame(user = "Admin",
# password = "zabbix")))) -> auth
#
# # request to get histoy of an item of 'item_id' number
# ######################################################
# ZabbixAPI('http://localhost/zabbix',
# body = list(method = "history.get",
# params = jsonlite::unbox(
# data.frame(output = "extend",
# itemids = "item_id",
# history = 0,
# sortfield = "clock",
# sortorder = "DESC",
# limit = 10)
# ),
# auth = auth))
#
# # API info
# ##########
# ZabbixAPI('http://localhost/zabbix',
# body = list(method = "apiinfo.version"))
#
# # fromJSON example for get event data fo object with 'object_id' number
# #######################################################################
# library(jsonlite)
# paste0('{
# "method": "event.get",
# "params": {
# "output": "extend",
# "select_acknowledges": "extend",
# "objectids": "object_id",
# "sortfield": ["clock", "eventid"],
# "sortorder": "DESC"
# },
# "auth": "', auth, '"
# }') -> json_rpc
#
# ZabbixAPI('http://localhost/zabbix',
# body = fromJSON(json_rpc)) -> event.info
# # colnames - https://www.zabbix.com/documentation/3.0/manual/api/reference/event/object
#
# event.info %>%
# select(value, clock) %>%
# mutate(clock =
# as.POSIXct(as.numeric(clock),
# tz = "GMT",
# origin = "1970-01-01")) -> clock2viz
#
# list2bind <- list()
# for(i in 1:(nrow(clock2viz)-1)) {
# data.frame(
# times =
# seq(from = clock2viz$clock[i+1],
# to = clock2viz$clock[i],
# by = "min") %>%
# head(-1),
# status = clock2viz$value[i+1],
# stringsAsFactors = FALSE) ->
# list2bind[[i]]
# }
#
# library(ggplot2)
# do.call(bind_rows, list2bind) %>%
# ggplot(aes(x=times, y = status)) +
# geom_point(size = 0.1)
# ## End(Not run)
Run the code above in your browser using DataLab