** Copyright (C) 2001-2023 Zabbix SIA
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"git.zabbix.com/ap/plugin-support/zbxerr"
Class string `json:"device_class"`
Name string `json:"name"`
Type string `json:"type"`
Children []int64 `json:"children"`
Nodes []node `json:"nodes"`
OSDName string `json:"{#OSDNAME}"`
Class string `json:"{#CLASS}"`
Host string `json:"{#HOST}"`
// osdDiscoveryHandler returns list of OSDs in LLD format.
func osdDiscoveryHandler(data map[command][]byte) (interface{}, error) {
lld := make([]osdEntity, 0)
err := json.Unmarshal(data[cmdOSDCrushTree], &tree)
return nil, zbxerr.ErrorCannotUnmarshalJSON.Wrap(err)
for i, n := range tree.Nodes {
for _, cid := range host.Children {
lld = append(lld, osdEntity{
OSDName: strconv.FormatInt(n.ID, 10),
jsonLLD, err := json.Marshal(lld)
return nil, zbxerr.ErrorCannotMarshalJSON.Wrap(err)