dav3860 / vmbix

Fork of vmbix, a TCP proxy for querying a VMWare infrastucture with Zabbix
53 stars 19 forks source link

No UUID with NAS Datastores #32

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi, Today I upgraded a very old VmBix server to the current version 2.3.0.59. At the moment I use Low Level Discovery for Datastore and ESXi servers. The vsphere environment is 6.0. I enabled the useuuid=true setting in the vmbix.conf.

I noticed that only VMFS datastores where discovered, the NAS datastores not. I noticed a "{#UUID}":"N/A" with all the NAS datastores. The UUID of VMFS datastores are correct.

I looked at the code and changed the following in de getDatastores function to make it work:

                if (d != null) {
                    //Correction by Andrea for trap the NasDatastoreInfo
                    if (d.getInfo() instanceof NasDatastoreInfo)
                    {
                        NasDatastoreInfo dsInfo = (NasDatastoreInfo) d.getInfo();
                        if ( dsInfo != null ) {
                            HostNasVolume naaName = dsInfo.getNas();
                            JsonObject jObject = new JsonObject();
                            jObject.addProperty("{#DATASTORE}", d.getName());
                            //jObject.addProperty("{#UUID}", uuid);
                            jObject.addProperty("{#UUID}", "N/A");
                            jObject.addProperty("{#CLUSTER}", d.getParent().getName());
                            jObject.addProperty("{#LOCAL}", !d.getSummary().multipleHostAccess);
                            jObject.addProperty("{#NAA}", naaName.getName());
                            jArray.add(jObject);
                        }
                    }

to:

                if (d != null) {
                    //Correction by Andrea for trap the NasDatastoreInfo
                    if (d.getInfo() instanceof NasDatastoreInfo)
                    {
                        NasDatastoreInfo dsInfo = (NasDatastoreInfo) d.getInfo();
                        if ( dsInfo != null ) {
                            HostNasVolume naaName = dsInfo.getNas();
                            JsonObject jObject = new JsonObject();
                            jObject.addProperty("{#DATASTORE}", d.getName());
                            //jObject.addProperty("{#UUID}", uuid);
                            jObject.addProperty("{#UUID}", dsInfo.url.substring(19, dsInfo.url.length() - 1) );
                            jObject.addProperty("{#CLUSTER}", d.getParent().getName());
                            jObject.addProperty("{#LOCAL}", !d.getSummary().multipleHostAccess);
                            jObject.addProperty("{#NAA}", naaName.getName());
                            jArray.add(jObject);
                        }
                    }

I was inspired by the function getManagedEntityByUuid where the following is coded:

                switch (meType) {
                    case "HostSystem":
                        HostSystem host = (HostSystem) ent;
                        HostListSummary hs = host.getSummary();
                        HostHardwareSummary hd = hs.getHardware();
                        meUuid = hd.getUuid();
                        break;
                    case "VirtualMachine":
                        VirtualMachine vm = (VirtualMachine) ent;
                        VirtualMachineConfigInfo vmcfg = vm.getConfig();
                        meUuid = vmcfg.getUuid();
                        break;
                    case "Datastore":
                        Datastore ds = (Datastore) ent;
                        DatastoreInfo dinfo = ds.getInfo();
                        meUuid = dinfo.url.substring(19, dinfo.url.length() - 1);
                        break;
                }
dav3860 commented 8 years ago

Hi, Thank you. I'll add your fix to the next release.

dav3860 commented 8 years ago

This was implemented in VmBix 2.4, just released.