dav3860 / vmbix

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

NullPointerException #37

Open sysHate opened 7 years ago

sysHate commented 7 years ago

Hi. vmbix was running good for ~1 month. Now are mostly Items unsupported & vmbix.log is full of NPE Errors:

Exception in thread "Thread-405" java.lang.NullPointerException
        at net.dav3860.VmBix$Connection.getManagedEntityByUuid(VmBix.java:1204)
        at net.dav3860.VmBix$Connection.getManagedEntity(VmBix.java:1113)
        at net.dav3860.VmBix$Connection.getVmPerfCounterValue(VmBix.java:2360)
        at net.dav3860.VmBix$Connection.checkAllPatterns(VmBix.java:1030)
        at net.dav3860.VmBix$Connection.run(VmBix.java:3415)

There is allso a Problem with object script.

[2016-09-28 16:55:07,755] - INFO - Action for extra hosts : simulate
[2016-09-28 16:55:07,755] - INFO - Connecting to Zabbix server at http://zabbix-webpage.com
[2016-09-28 16:55:07,821] - INFO - [vsphere_object_vm] Importing objects of type [vsphere_object_vm] into Zabbix
[2016-09-28 16:55:14,347] - INFO - [vsphere_object_vm] Number of objects to be checked: 223
[2016-09-28 16:55:14,348] - DEBUG - [vsphere_object_vm] Processing host 'Server1' [1/223]
[2016-09-28 16:55:14,348] - DEBUG - [vsphere_object_vm] Checking inclusion rules for host 'Server2'
[2016-09-28 16:55:14,348] - DEBUG - [vsphere_object_vm] Checking exclusion rules for host 'Server3'

Then i have to break a script because nothing is happening.

Do you have any idea, where i have to look? Thank you! Regards!

dav3860 commented 7 years ago

Hi, What version do you use ? Please upgrade to the latest version, the error handling was improved.

sysHate commented 7 years ago

I installed vmbix_2.4.0.80-1_amd64.deb on zabbix_proxy 3.0.3 OS: Ubuntu 16.04.1 LTS I tryed vmbix 2.5 out, thats what i became while testing:

vmbix -P 12050 -u "user@domain" -p "psw" -s "https://vcenter2/sdk"
Exception in thread "main" java.lang.NullPointerException
        at net.dav3860.VmBix.main(VmBix.java:224)
13:15:06.511 [Thread-0] INFO net.dav3860.VmBix - Shutting down
13:15:06.516 [Thread-0] ERROR net.dav3860.VmBix - Error disconnecting: null
13:15:06.516 [Thread-0] INFO net.dav3860.VmBix - Shutted down
dav3860 commented 7 years ago

It may be a connection error to the vcenter. Please upgrade to v2.5, the error handling was improved. Have a look at the CHANGELOG as a few things changed.

dav3860 commented 7 years ago

There is a bug when you start VmBix 2.5 in CLI but it works with a config file. It will be fixed in v2.6. Or I can give you the fixed development package.

sysHate commented 7 years ago

Ah ok, you are right. Thats what i see in Log now:

log4j:WARN No appenders could be found for logger (com.vmware.vim25.ws.XmlGenDom).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
java.rmi.RemoteException: An error occurred getting a response from the connection at url https://vcenter2/sdk; nested exception is:
        java.net.SocketTimeoutException: Read timed out
        at com.vmware.vim25.ws.WSClient.getInputStreamFromConnection(WSClient.java:197)
        at com.vmware.vim25.ws.WSClient.post(WSClient.java:171)
        at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:91)
        at com.vmware.vim25.ws.VimStub.login(VimStub.java:1732)
        at com.vmware.vim25.mo.SessionManager.login(SessionManager.java:153)
        at com.vmware.vim25.mo.ServiceInstance.login(ServiceInstance.java:238)
        at com.vmware.vim25.mo.ServiceInstance.constructServiceInstance(ServiceInstance.java:131)
        at com.vmware.vim25.mo.ServiceInstance.<init>(ServiceInstance.java:104)
        at com.vmware.vim25.mo.ServiceInstance.<init>(ServiceInstance.java:94)
        at net.dav3860.VmBix.updateConnection(VmBix.java:435)
        at net.dav3860.VmBix.server(VmBix.java:487)
        at net.dav3860.VmBix.main(VmBix.java:234)
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
        at java.net.SocketInputStream.read(SocketInputStream.java:170)
        at java.net.SocketInputStream.read(SocketInputStream.java:141)
        at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
        at sun.security.ssl.InputRecord.read(InputRecord.java:503)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
        at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:930)
        at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:704)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1536)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at com.vmware.vim25.ws.WSClient.getInputStreamFromConnection(WSClient.java:184)
        ... 11 more
2016-09-30 16:03:22,807 INFO  [main] [VmBix.java:489] starting server on 127.0.0.1/12050
2016-09-30 16:03:22,817 INFO  [main] [VmBix.java:496] server started

I'll check the connection now. Thank you a lot!

dav3860 commented 7 years ago

There is an error in the default configuration file. The read and connect timeouts must be set in ms. So update their values to 30000.

sysHate commented 7 years ago

Thats what i get now:

log4j:WARN No appenders could be found for logger (com.vmware.vim25.ws.XmlGenDom).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2016-10-04 13:07:27,860 INFO  [main] [VmBix.java:489] starting server on 127.0.0.1/12050
2016-10-04 13:07:27,862 INFO  [main] [VmBix.java:496] server started
2016-10-04 13:16:57,527 ERROR [Thread-8] [VmBix.java:2603] An error occurred : null
2016-10-04 13:16:57,649 ERROR [Thread-7] [VmBix.java:3452] An error occurred : null
2016-10-04 13:16:57,813 ERROR [Thread-8] [VmBix.java:2603] An error occurred : null
2016-10-04 13:16:57,933 ERROR [Thread-7] [VmBix.java:3452] An error occurred : null
2016-10-04 13:16:58,288 ERROR [Thread-7] [VmBix.java:2603] An error occurred : null
2016-10-04 13:16:58,408 ERROR [Thread-8] [VmBix.java:3452] An error occurred : null
2016-10-04 13:16:58,602 ERROR [Thread-8] [VmBix.java:2603] An error occurred : null
2016-10-04 13:16:58,724 ERROR [Thread-7] [VmBix.java:3452] An error occurred : null
2016-10-04 13:17:00,207 ERROR [Thread-8] [VmBix.java:2603] An error occurred : null
2016-10-04 13:17:00,328 ERROR [Thread-7] [VmBix.java:3452] An error occurred : null
2016-10-04 13:17:00,512 ERROR [Thread-7] [VmBix.java:2603] An error occurred : null
2016-10-04 13:17:00,621 ERROR [Thread-7] [VmBix.java:3452] An error occurred : null
...
2016-10-05 09:35:38,679 ERROR [Thread-9] [VmBix.java:3769] An error occurred : null
2016-10-05 09:35:38,679 ERROR [Thread-10] [VmBix.java:2742] An error occurred : null
2016-10-05 09:35:38,707 ERROR [Thread-3] [VmBix.java:2742] An error occurred : null
2016-10-05 09:35:38,747 ERROR [Thread-12] [VmBix.java:2742] An error occurred : null
2016-10-05 09:35:38,756 ERROR [Thread-8] [VmBix.java:2742] An error occurred : null
2016-10-05 09:35:39,714 INFO  [Thread-6] [VmBix.java:1136] String 'ZBXD<vm.guest.tools.status[422d40ac-1c1c-c5c0-cf87-02da06727bbd]' not supported
2016-10-05 09:35:39,773 ERROR [Thread-9] [VmBix.java:2742] An error occurred : null
2016-10-05 09:35:39,775 ERROR [Thread-8] [VmBix.java:2657] An error occurred : null
2016-10-05 09:35:39,776 ERROR [Thread-11] [VmBix.java:2657] An error occurred : null
2016-10-05 09:35:39,783 ERROR [Thread-3] [VmBix.java:1739] An error occurred : null
2016-10-05 09:35:39,785 ERROR [Thread-5] [VmBix.java:2742] An error occurred : null
2016-10-05 09:35:39,786 ERROR [Thread-4] [VmBix.java:3302] An error occurred : null
2016-10-05 09:35:39,794 ERROR [Thread-12] [VmBix.java:2467] An error occurred : null
2016-10-05 09:35:39,843 ERROR [Thread-6] [VmBix.java:1739] An error occurred : null
2016-10-05 09:35:39,844 ERROR [Thread-7] [VmBix.java:1739] An error occurred : null
...
sysHate commented 7 years ago

I deleted all Hosts and runed vmbix-object-sync script again. Now it seems to work for ESX & Datastores but not vor VM's

dav3860 commented 7 years ago

Is the parameter useUUID set to true in the configuration file ? I fixed your former issues with the new version 2.6. You can download it. Can you use zabbix_get to query a few VMs and see if it works ?

sysHate commented 7 years ago

Yes, useUUID is set to true. event.latest[] and vm.discovery[] do works, datastore checks to:

zabbix_get -s 127.0.0.1 -p 12050 -k 'datastore.size[50c05703-90916ee4-e8e5-441ea15267c8,free]'
85033222144

But if i'm asking about specific VM:

zabbix_get -s 127.0.0.1 -p 12050 -k 'vm.guest.os[422dfb39-a8cb-78e6-6e77-9020a04a3465]'
zabbix_get [30248]: Check access restrictions in Zabbix agent configuration
dav3860 commented 7 years ago

These kinds of checks only work if the VM is running VM tools. Is it the same for the vm.status method ? What version of vcenter do you have ?

sysHate commented 7 years ago

Yes, its the same for vm.status. I tried on machine with updated VM tools running. We have Vcenter 6.0.0 installed (Build 3634793).

dav3860 commented 7 years ago

Please try the version I just compiled, v2.6.157 : https://bintray.com/dav3860/generic/vmbix#files/2.6 The log messages should me more verbose.

sysHate commented 7 years ago
zabbix_get -s 127.0.0.1 -p 12050 -k vm.status[422dd24f-a8b6-eda6-2b75-96f619461efb]
zabbix_get [12522]: Check access restrictions in Zabbix agent configuration

Log:

13:37:00.933 [main] INFO net.dav3860.VmBix - creating pid file /var/run/vmbix.pid 12579
log4j:WARN No appenders could be found for logger (com.vmware.vim25.ws.XmlGenDom).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Okt. 11, 2016 1:37:06 NACHM. sun.util.PropertyResourceBundleCharset$PropertiesFileDecoder decodeLoop
INFO: Invalid or unmappable UTF-8 sequence detected. Switching encoding from UTF-8 to ISO-8859-1
13:37:06.838 [main] INFO net.dav3860.VmBix - starting server on 127.0.0.1/12050
13:37:06.839 [main] INFO net.dav3860.VmBix - server started
13:37:19.607 [Thread-2] DEBUG net.dav3860.VmBix - Thread created, collecting data in 1 threads
13:37:19.608 [Thread-2] DEBUG net.dav3860.VmBix - Parsing this request : ZBXD0vm.status[422dd24f-a8b6-eda6-2b75-96f619461efb]
13:37:19.818 [Thread-2] ERROR net.dav3860.VmBix - An error occurred : java.lang.NullPointerException
13:37:19.818 [Thread-2] DEBUG net.dav3860.VmBix - Request took 210 ms
13:37:21.841 [Thread-2] DEBUG net.dav3860.VmBix - Thread closed, collecting data in 0 threads
sysHate commented 7 years ago

After i changed useUUID to false it works fine with servernames. Unfortunately we do have many Hosts with names Zabbix doesn't accept.
And there is one more strange thing (its still useruuid = false):

zabbix_get -s 127.0.0.1 -p 12050 -k 'vm.status[422d7658-128a-ddeb-b22a-ca8ebe80178e]'
4

So i get an false answer. Here is a log file:

15:49:06.982 [Thread-48] DEBUG net.dav3860.VmBix - Thread created, collecting data in 1 threads
15:49:06.982 [Thread-48] DEBUG net.dav3860.VmBix - Parsing this request : ZBXD0vm.status[422d7658-128a-ddeb-b22a-ca8ebe80178e]
15:49:07.118 [Thread-48] WARN net.dav3860.VmBix - No vm named '422d7658-128a-ddeb-b22a-ca8ebe80178e' found
15:49:07.119 [Thread-48] DEBUG net.dav3860.VmBix - Request took 137 ms
15:49:09.141 [Thread-48] DEBUG net.dav3860.VmBix - Thread closed, collecting data in 0 threads

Any ideas?