Skip to content

Commit ffcfc55

Browse files
tanguyvdasdepassio
authored andcommitted
avoid for loop for hg/sg when there is none in the cache
1 parent 7124133 commit ffcfc55

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

centreon-certified/canopsis/canopsis2x-events-apiv2.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,12 @@ end
275275
function EventQueue:list_hostgroups()
276276
local hostgroups = {}
277277

278-
for _, hg in pairs(self.sc_event.event.cache.hostgroups) do
279-
table.insert(hostgroups, hg.group_name)
278+
if type(self.sc_event.event.cache.hostgroups) == "table" then
279+
for _, hg in pairs(self.sc_event.event.cache.hostgroups) do
280+
table.insert(hostgroups, hg.group_name)
281+
end
280282
end
281-
283+
282284
if self.sc_params.params.canopsis_sort_list_hostgroups == 1 then
283285
table.sort(hostgroups)
284286
end

0 commit comments

Comments
 (0)