dnaeon / py-vpoller

Distributed vSphere API Proxy
Other
83 stars 31 forks source link

Performance counter not working with Zabbix module #268

Closed loganobrien closed 5 years ago

loganobrien commented 5 years ago

Hi

I'm trying to receive performance counters via Zabbix loadable module (vpoller.so). Here's my setup:

Zabbix: 4.0.7 vPoller: 0.7.3 (via pip)

For example I can get information for incoming network traffic of a host:

# vpoller-client --method host.perf.metric.info --vsphere-host <vHOST> --name <HOST> --counter net.received.kiloBytesPerSecond.average
{
  "msg": "Successfully retrieved performance metrics",
  "result": [
    {
      "instance": "vmnic4",
      "counterId": "net.received.kiloBytesPerSecond.average"
    },
    {
      "instance": "vmnic5",
      "counterId": "net.received.kiloBytesPerSecond.average"
    },
    {
      "instance": "vmnic2",
      "counterId": "net.received.kiloBytesPerSecond.average"
    },
    {
      "instance": "vmnic3",
      "counterId": "net.received.kiloBytesPerSecond.average"
    },
    {
      "instance": "vmnic0",
      "counterId": "net.received.kiloBytesPerSecond.average"
    },
    {
      "instance": "vmnic1",
      "counterId": "net.received.kiloBytesPerSecond.average"
    },
    {
      "instance": "",
      "counterId": "net.received.kiloBytesPerSecond.average"
    }
  ],
  "success": 0
}

I can also receive performance metrics about a single interface:

# vpoller-client --method host.perf.metric.get --vsphere-host <vHost> --name <HOST> --counter net.received.kiloBytesPerSecond.average --instance vmnic1
{
  "msg": "Successfully retrieved performance metrics",
  "result": [
    {
      "timestamp": "2019-07-25 13:22:40+00:00",
      "counterId": "net.received.kiloBytesPerSecond.average",
      "interval": 20,
      "value": 3844,
      "instance": "vmnic1"
    }
  ],
  "success": 0
}

So in my opinion the key for the Zabbix (simple check) item should be:

vpoller["host.perf.metric.get","<vHOST>","<HOST>","value","","","","net.received.kiloBytesPerSecond.average","vmnic1",""]

Unfortunately this always fails with the following error:

# zabbix_get -s <vPollerHost> -k "vpoller[host.perf.metric.get,<vHOST>,<HOST>,value,,,,net.received.kiloBytesPerSecond.average,vmnic1,]"
Invalid task request

I tried this with different performance counters, all are failing. Looks like the method *.perf.metric.get always fails with the Zabbix loadable module.

Did I miss something?

Thanks

dnaeon commented 5 years ago

Hi,

I'm away from the computer for the next few days and will not be able to look into this one.

At first glance it appears that your zabbix-get command is correct.

In the meantime can you also start the vpoller services in debug mode and let me know of their output when you start sending requests to them?

That way we can narrow down what the actual issue is.

Btw, also please post the result of "pip freeze" and make sure you are running the latest version.

Thanks, Marin

On Thu, Jul 25, 2019, 16:48 Logan notifications@github.com wrote:

Hi

I'm trying to receive performance counters via Zabbix loadable module (vpoller.so). Here's my setup:

Zabbix: 4.0.7 vPoller: 0.7.3 (via pip)

For example I can get information for incoming network traffic of a host:

vpoller-client --method host.perf.metric.info --vsphere-host --name --counter net.received.kiloBytesPerSecond.average

{ "msg": "Successfully retrieved performance metrics", "result": [ { "instance": "vmnic4", "counterId": "net.received.kiloBytesPerSecond.average" }, { "instance": "vmnic5", "counterId": "net.received.kiloBytesPerSecond.average" }, { "instance": "vmnic2", "counterId": "net.received.kiloBytesPerSecond.average" }, { "instance": "vmnic3", "counterId": "net.received.kiloBytesPerSecond.average" }, { "instance": "vmnic0", "counterId": "net.received.kiloBytesPerSecond.average" }, { "instance": "vmnic1", "counterId": "net.received.kiloBytesPerSecond.average" }, { "instance": "", "counterId": "net.received.kiloBytesPerSecond.average" } ], "success": 0 }

I can also receive performance metrics about a single interface:

vpoller-client --method host.perf.metric.get --vsphere-host --name --counter net.received.kiloBytesPerSecond.average --instance vmnic1

{ "msg": "Successfully retrieved performance metrics", "result": [ { "timestamp": "2019-07-25 13:22:40+00:00", "counterId": "net.received.kiloBytesPerSecond.average", "interval": 20, "value": 3844, "instance": "vmnic1" } ], "success": 0 }

So in my opinion the key for the Zabbix (simple check) item should be:

vpoller["host.perf.metric.get","","","value","","","","net.received.kiloBytesPerSecond.average","vmnic1",""]

Unfortunately this always fails with the following error:

zabbix_get -s -k "vpoller[host.perf.metric.get,,,value,,,,net.received.kiloBytesPerSecond.average,vmnic1,]"

Invalid task request

I tried this with different performance counters, all are failing. Looks like the method *.perf.metric.get always fails with the Zabbix loadable module.

Did I miss something?

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dnaeon/py-vpoller/issues/268?email_source=notifications&email_token=AAB3JC245KCGURJ627LZ4VTQBGVKBA5CNFSM4IG225DKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HBPQZFQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB3JC4V7RIDEV2D7Y5WO3TQBGVKBANCNFSM4IG225DA .

loganobrien commented 5 years ago

Thanks Martin for your quick reply.

I enabled the debug mode and sent the same request again. This is what the log says:

[2019-07-26 16:30:24,906 - DEBUG/VPollerProxy-1] Message received on frontend socket
[2019-07-26 16:30:24,907 - DEBUG/VPollerProxy-1] Sending message to backend socket: ▒<▒i
[2019-07-26 16:30:24,907 - DEBUG/VPollerProxy-1] Message received on frontend socket
[2019-07-26 16:30:24,908 - DEBUG/VPollerProxy-1] Sending message to backend socket:
[2019-07-26 16:30:24,909 - DEBUG/VPollerProxy-1] Message received on frontend socket
[2019-07-26 16:30:24,909 - DEBUG/VPollerProxy-1] Sending message to backend socket:
{
   "method":"host.perf.metric.get",
   "hostname":"<vHOST>",
   "name":"<HOST>",
   "properties":[
      "value"
   ],
   "key":"",
   "username":"",
   "password":"",
   "counter-id":"net.received.kiloBytesPerSecond.average",
   "instance":"vmnic1",
   "perf-interval":"",
   "max-sample":"1",
   "helper":"vpoller.helpers.czabbix"
}
[2019-07-26 16:30:24,916 - DEBUG/VPollerProxy-1] Message received on backend socket
[2019-07-26 16:30:24,916 - DEBUG/VPollerProxy-1] Sending message to frontend socket: ▒<▒i
[2019-07-26 16:30:24,917 - DEBUG/VPollerProxy-1] Message received on backend socket
[2019-07-26 16:30:24,917 - DEBUG/VPollerProxy-1] Sending message to frontend socket:
[2019-07-26 16:30:24,918 - DEBUG/VPollerProxy-1] Message received on backend socket
[2019-07-26 16:30:24,918 - DEBUG/VPollerProxy-1] Sending message to frontend socket: Invalid task request

[2019-07-26 16:30:24,910 - DEBUG/VPollerWorker-3] Processing client message: {u'username': u'', u'max-sample': u'1', u'name': u'<HOST>', u'helper': u'vpoller.helpers.czabbix', u'perf-interval': u'', u'hostname': u'<vHOST>', u'method': u'host.perf.metric.get', u'instance': u'vmnic1', u'key': u'', u'counter-id': u'net.received.kiloBytesPerSecond.average', u'password': u'', u'properties': [u'value']}
[2019-07-26 16:30:24,911 - DEBUG/VPollerWorker-3] Validating client message, required to have: ['name', 'counter-name']
[2019-07-26 16:30:24,912 - DEBUG/VPollerWorker-3] Required message keys are missing
[2019-07-26 16:30:24,912 - DEBUG/VPollerWorker-3] Invoking helper module vpoller.helpers.czabbix for processing of data
[2019-07-26 16:30:24,913 - DEBUG/VPollerWorker-3] [zbx-helper]: Initiating data processing
[2019-07-26 16:30:24,913 - DEBUG/VPollerWorker-3] [zbx-helper]: Original client task request: {u'username': u'', u'max-sample': u'1', u'name': u'<HOST>', u'helper': u'vpoller.helpers.czabbix', u'perf-interval': u'', u'hostname': u'<vHOST>', u'method': u'host.perf.metric.get', u'instance': u'vmnic1', u'key': u'', u'counter-id': u'net.received.kiloBytesPerSecond.average', u'password': u'', u'properties': [u'value']}
[2019-07-26 16:30:24,914 - DEBUG/VPollerWorker-3] [zbx-helper]: Received data for processing: {'msg': 'Invalid task request', 'success': 1}
[2019-07-26 16:30:24,914 - DEBUG/VPollerWorker-3] [zbx-helper]: Task request was not successful (exitcode: 1)
[2019-07-26 16:30:24,915 - DEBUG/VPollerWorker-3] [zbx-helper]: No processing will be done by the helper

And here's the output of pip freeze:

backports.ssl-match-hostname==3.5.0.1
certifi==2019.6.16
chardet==3.0.4
configobj==4.7.2
decorator==3.4.0
docopt==0.6.2
idna==2.8
iniparse==0.4
ipaddress==1.0.16
kitchen==1.1.1
perf==0.1
pycurl==7.19.0
pygobject==3.22.0
pygpgme==0.3
pyliblzma==0.5.3
python-dateutil==1.5
python-linux-procfs==0.4.9
pyudev==0.15
pyvmomi==6.7.1.2018.12
pyxattr==0.5.1
PyYAML==3.10
pyzabbix==0.7.5
pyzmq==18.0.2
requests==2.22.0
schedutils==0.4
six==1.12.0
tabulate==0.8.3
urlgrabber==3.10
urllib3==1.25.3
vconnector==0.5.3
vpoller==0.7.3
yum-metadata-parser==1.1.4

Thanks and regards

Logan

dnaeon commented 5 years ago

From the logs it seems that a required key is missing. The counter-name key, while counter-id is provided.

I'm still away from a computer to actually check this, but will do when a get a spare moment.

Marin

On Fri, Jul 26, 2019, 17:43 Logan notifications@github.com wrote:

Thanks Martin for your quick reply.

I enabled the debug mode and sent the same request again. This is what the log says:

[2019-07-26 16:30:24,906 - DEBUG/VPollerProxy-1] Message received on frontend socket

[2019-07-26 16:30:24,907 - DEBUG/VPollerProxy-1] Sending message to backend socket: ▒<▒i

[2019-07-26 16:30:24,907 - DEBUG/VPollerProxy-1] Message received on frontend socket

[2019-07-26 16:30:24,908 - DEBUG/VPollerProxy-1] Sending message to backend socket:

[2019-07-26 16:30:24,909 - DEBUG/VPollerProxy-1] Message received on frontend socket

[2019-07-26 16:30:24,909 - DEBUG/VPollerProxy-1] Sending message to backend socket:

{

"method":"host.perf.metric.get",

"hostname":"",

"name":"",

"properties":[

  "value"

],

"key":"",

"username":"",

"password":"",

"counter-id":"net.received.kiloBytesPerSecond.average",

"instance":"vmnic1",

"perf-interval":"",

"max-sample":"1",

"helper":"vpoller.helpers.czabbix"

}

[2019-07-26 16:30:24,916 - DEBUG/VPollerProxy-1] Message received on backend socket

[2019-07-26 16:30:24,916 - DEBUG/VPollerProxy-1] Sending message to frontend socket: ▒<▒i

[2019-07-26 16:30:24,917 - DEBUG/VPollerProxy-1] Message received on backend socket

[2019-07-26 16:30:24,917 - DEBUG/VPollerProxy-1] Sending message to frontend socket:

[2019-07-26 16:30:24,918 - DEBUG/VPollerProxy-1] Message received on backend socket

[2019-07-26 16:30:24,918 - DEBUG/VPollerProxy-1] Sending message to frontend socket: Invalid task request

[2019-07-26 16:30:24,910 - DEBUG/VPollerWorker-3] Processing client message: {u'username': u'', u'max-sample': u'1', u'name': u'', u'helper': u'vpoller.helpers.czabbix', u'perf-interval': u'', u'hostname': u'', u'method': u'host.perf.metric.get', u'instance': u'vmnic1', u'key': u'', u'counter-id': u'net.received.kiloBytesPerSecond.average', u'password': u'', u'properties': [u'value']}

[2019-07-26 16:30:24,911 - DEBUG/VPollerWorker-3] Validating client message, required to have: ['name', 'counter-name']

[2019-07-26 16:30:24,912 - DEBUG/VPollerWorker-3] Required message keys are missing

[2019-07-26 16:30:24,912 - DEBUG/VPollerWorker-3] Invoking helper module vpoller.helpers.czabbix for processing of data

[2019-07-26 16:30:24,913 - DEBUG/VPollerWorker-3] [zbx-helper]: Initiating data processing

[2019-07-26 16:30:24,913 - DEBUG/VPollerWorker-3] [zbx-helper]: Original client task request: {u'username': u'', u'max-sample': u'1', u'name': u'', u'helper': u'vpoller.helpers.czabbix', u'perf-interval': u'', u'hostname': u'', u'method': u'host.perf.metric.get', u'instance': u'vmnic1', u'key': u'', u'counter-id': u'net.received.kiloBytesPerSecond.average', u'password': u'', u'properties': [u'value']}

[2019-07-26 16:30:24,914 - DEBUG/VPollerWorker-3] [zbx-helper]: Received data for processing: {'msg': 'Invalid task request', 'success': 1}

[2019-07-26 16:30:24,914 - DEBUG/VPollerWorker-3] [zbx-helper]: Task request was not successful (exitcode: 1)

[2019-07-26 16:30:24,915 - DEBUG/VPollerWorker-3] [zbx-helper]: No processing will be done by the helper

And here's the output of pip freeze:

backports.ssl-match-hostname==3.5.0.1

certifi==2019.6.16

chardet==3.0.4

configobj==4.7.2

decorator==3.4.0

docopt==0.6.2

idna==2.8

iniparse==0.4

ipaddress==1.0.16

kitchen==1.1.1

perf==0.1

pycurl==7.19.0

pygobject==3.22.0

pygpgme==0.3

pyliblzma==0.5.3

python-dateutil==1.5

python-linux-procfs==0.4.9

pyudev==0.15

pyvmomi==6.7.1.2018.12

pyxattr==0.5.1

PyYAML==3.10

pyzabbix==0.7.5

pyzmq==18.0.2

requests==2.22.0

schedutils==0.4

six==1.12.0

tabulate==0.8.3

urlgrabber==3.10

urllib3==1.25.3

vconnector==0.5.3

vpoller==0.7.3

yum-metadata-parser==1.1.4

Thanks and regards

Logan

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dnaeon/py-vpoller/issues/268?email_source=notifications&email_token=AAB3JC76ACGNDCBDFGK36YLQBMERXA5CNFSM4IG225DKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD242ANQ#issuecomment-515481654, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB3JC6DWUG7ZKYX4G7SPBDQBMERXANCNFSM4IG225DA .

dnaeon commented 5 years ago

Hi,

I'm back and was able to look into this one.

Can you check what is the version of the vpoller-module as reported in the Zabbix logs?

It does appear that you are using an old version of the vpoller_module.so, which uses counter-id instead of counter-name. Using counter-name was done long ago, so I suspect that you are using an older version of the module.

https://github.com/dnaeon/py-vpoller/commit/a50695daf0aa2a6f21bab528b13f699aec463783#diff-b2e5537b4d5103fdc9c549f5c2776089

Can you try building the module from the latest sources?

Thanks, Marin

loganobrien commented 5 years ago

Thanks Marin, that solved my problem.

I used the "Latest release" from https://github.com/dnaeon/py-vpoller/releases which is v0.5.1. But when I clone directly via git I receive v0.5.7.

Thanks for your help.