Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding History API #24

Merged
merged 1 commit into from
Jun 26, 2019
Merged

Adding History API #24

merged 1 commit into from
Jun 26, 2019

Conversation

sconwayubb
Copy link
Contributor

I haven't been able to test the Event Log History, since we don't use those in our environment. Also, the history.get endpoint doesn't return the ValueType like item.get does, so I left it as a string.

Usage:

sevenDaysAgo := time.Now().AddDate(0, 0, -7)

for _, i := range items {
	histories, err := api.GetHistories(zabbix.HistoryGetParams{
		ItemIDs:  []string{strconv.Itoa(i.ItemID)},
		TimeFrom: float64(sevenDaysAgo.Unix())})
	if len(histories) == 0 {
		fmt.Printf("%s - No history found\n", i.ItemName)
		continue
	}
        // do stuff with histories
}

@cavaliercoder cavaliercoder merged commit 7dad99f into zabbix-tools:master Jun 26, 2019
@cavaliercoder
Copy link
Collaborator

Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants