dnaeon / py-vpoller

Distributed vSphere API Proxy
Other
84 stars 31 forks source link

Problem with Calculated item Free Space of {#VSPHERE.VM.DISKPATH} filesystem (percentage) #189

Closed Lem3xcol closed 8 years ago

Lem3xcol commented 8 years ago

Hi Marin, here again asking for your valuable help.

Here is a new issue I have found using vpoller integrated with zabbix.:

This item prototype works fine in all the discovered VmWare virtual machines:

vpoller-zabbix["-m", "vm.disk.get", "-V", "{$VSPHERE.HOST}", "-n", "{HOST.HOST}", "-k", {#VSPHERE.VM.DISKPATH}, "-p", "capacity"]

This item comes in the template "Template VMware vSphere Virtual Machine - vPoller" by default, and as I have said before, is working well.

But if I try to use the same key as well but inside a calculated item, as an item prototype, in this way:

last("vpoller-zabbix[\"-m\", \"vm.disk.get\", \"-V\", \"{$VSPHERE.HOST}\", \"-n\", \"{HOST.HOST}\", \"-k\", {#VSPHERE.VM.DISKPATH}, \"-p\", \"capacity\"]")

Zabbix returns me the following error message:

Cannot evaluate function "last()": item "ANEMONA:vpoller-zabbix["-m", "vm.disk.get", "-V", "{$VSPHERE.HOST}", "-n", "{HOST.HOST}", "-k", C:\, "-p", "capacity"]" does not exist.

By default in the template "Template VMware vSphere Virtual Machine - vPoller" comes an item prototype named "Free space of{#VSPHERE.VM.DISKPATH} filesystem (percentege)", which returned the error message I showed above. Trying to find why the problem exists, I debbuged this item prototype and have found that the problem comes when I use the zabbix function "last" and the property "capacity". As I told before, my goal is get a calculated item working which returns me the free space in percentage, and in a calculated item I have to use a function such "last". I have checked the expresion and when I change the property "capacity" for another like "freeSpace" in the calculated item prototype, it works.

Rigth now, I have no item to get the free space expressed in percentage using vpoller. Without the use of the property "capacity" in a calculated item prototype, I can't build a calculated item to get the free space of my filesystems expressed in percentage. What can I do?

Thanks alot for your always kind help,

Best Regards,

Luis Morales

dnaeon commented 8 years ago

Hey Luis,

I cannot test this myself right now, as I don't have my test zabbix environment up and running, but looking at the results you've posted it seems that the item you've used in your last() expression is different than the actual item in Zabbix.

In your original item the {#VSPHERE.VM.DISKPATH} is not enclosed in quotes, while in your prototype item you have "{#VSPHERE.VM.DISKPATH}" with quotes, so it appears because of that Zabbix complains about a not-found item.

Can you double check that?

Thanks, Marin

Lem3xcol commented 8 years ago

Marin, Hi Thanks for answering. I made the following checks from the prototype item:

First one:

last("vpoller-zabbix[\"-m\", \"vm.disk.get\", \"-V\", \"{$VSPHERE.HOST}\", \"-n\", \"{HOST.HOST}\", \"-k\", \"{#VSPHERE.VM.DISKPATH}\", \"-p\", \"capacity\"]")

First Result:

Cannot evaluate function "last()": item "ANEMONA:vpoller-zabbix["-m", "vm.disk.get", "-V", "{$VSPHERE.HOST}", "-n", "{HOST.HOST}", "-k", "C:\", "-p", "capacity"]" does not exist.

Second:

last("vpoller-zabbix[\"-m\", \"vm.disk.get\", \"-V\", \"{$VSPHERE.HOST}\", \"-n\", \"{HOST.HOST}\", \"-k\", "{#VSPHERE.VM.DISKPATH}", \"-p\", \"capacity\"]")

Second Result:

Invalid first parameter in function [last("vpoller-zabbix[\"-m\", \"vm.disk.get\", \"-V\", \"{$VSPHERE.HOST}\", \"-n\", \"{HOST.HOST}\", \"-k\", "C:\", \"-p\", \"capacity\"]")].

Third:

last("vpoller-zabbix["-m", "vm.disk.get", "-V", "{$VSPHERE.HOST}", "-n", "{HOST.HOST}", "-k", "{#VSPHERE.VM.DISKPATH}", "-p", "capacity"]")

Third Result:

Invalid first parameter in function [last("vpoller-zabbix["-m", "vm.disk.get", "-V", "{$VSPHERE.HOST}", "-n", "{HOST.HOST}", "-k", "C:\", "-p", "capacity"]")].

Fourth:

last("vpoller-zabbix[-m, vm.disk.get, -V, {$VSPHERE.HOST}, -n, {HOST.HOST}, -k, {#VSPHERE.VM.DISKPATH}, -p, capacity]")

Fourth Result:

Cannot evaluate function "last()": item "ANEMONA:vpoller-zabbix[-m, vm.disk.get, -V, {$VSPHERE.HOST}, -n, {HOST.HOST}, -k, C:\, -p, capacity]" does not exist.

As you can see, I focused in the diferent uses of the quotes, but with none I have the desired result. What I find weird is the fact that the following prototype works like a charm (please notice the lack of quotes in {#VSPHERE.VM.DISKPATH}):

last("vpoller-zabbix[\"-m\", \"vm.disk.get\", \"-V\", \"{$VSPHERE.HOST}\", \"-n\", \"{HOST.HOST}\", \"-k\", {#VSPHERE.VM.DISKPATH}, \"-p\", \"freeSpace\"]")

And this item prototype shows me the free space for every discovered drive or filesystem, depending of the operating system. If my knowledge is not wrong, if I clone this item prototype, and in the clone I replace "freeSpace" with "capacity" it should work, which hasn't happened. So, Why I thinking about cloning item prototypes for build an item prototype to get de free space of a filesystem or drive expresed in percentage?. Because, as I told you in my first post of this issue, the defaul item for this in the template "Template VMware vSphere Virtual Machine - vPoller", which I have downloaded and imported as-is, also reports me "Cannot evaluate function "last()": item "Virtual_Machine:vpoller-zabbix[-m, vm.disk.get, -V, {$VSPHERE.HOST}, -n, {HOST.HOST}, -k, C:\, -p, capacity]" does not exist."

More over, if I use this item prototype:

vpoller-zabbix["-m", "vm.disk.get", "-V", "{$VSPHERE.HOST}", "-n", "{HOST.HOST}", "-k", {#VSPHERE.VM.DISKPATH}, "-p", "capacity"]

Exactly as you can see it here, works perfect (notice the lack of quotes in {#VSPHERE.VM.DISKPATH}. If I put quotes, the item prototype stops working) . But this same expresion with "last" before it, for its use in a calculated item, reports the zabbix complain that we are discussing here, unlike when use "freeSpace" instead "capacity" in the same statement, which works. This mystifies me.

I Hope have checked properly the requested things, and I'll be very aware about any comment from you.

Thanks again,

Best regards,

Luis Morales

P.S. The zabbix version I'm ussing is 2.4.7

dnaeon commented 8 years ago

Hey Luis,

Thanks for the details you've provided!

That is strange indeed. I've noticed now that the item that you are you using is 'vpoller-zabbix' - are you using vpoller with external scripts in your Zabbix environment?

If that is so, can you please switch over to the native vpoller integration and try out the new items?

Thanks, Marin

Lem3xcol commented 8 years ago

Hi Marin,

Thanks for your advice. Using native vpoller integration solved the issue. My Zabbix environment started with an early version some years ago and have received upgrades through the time. Vpoller also was updated once, but apparently had been working fine with external scripts until this issue. I'm going to switch all the monitoring for the vmware infrastructure to native vpoller intergation, although it means a lot of manual job, because I have to keep the historic data.

Thanks again and have a nice day!

Luis Morales

pedroourique commented 1 year ago

Hi!

How do you fix the problem? I'm having the same problem.

Lem3xcol commented 1 year ago

Pedro, Hi, nice to meet you. I'm glad you write. It surprises me to see that a thread from almost 6 years ago is still usefull nowadays. Back in those days I was using Zabbix 2.4.7, and today I'm using Zabbix 6.0.7 and I can confirm Vpoller still works like a charm despite sadly Marin left the project and it hasn't get further develpoment. I'm guessing you are following the steps described in vpoller documentation at https://vpoller.readthedocs.io/en/latest/index.html, section "vPoller Integration with Zabbix". I suppose you followed the steps acording the use of the template vpoller-templates-externalchecks. Don't do that, follow the steps to use vpoller-templates-native template. Personally, I find that procedure quite easier. I'm going to try to resume the steps, asuming you already have installed and working both zabbix and vpoller, but please, check the detailed documentation at https://vpoller.readthedocs.io/en/latest/index.html:

  1. Download vpoller sources (https://github.com/dnaeon/py-vpoller/archive/refs/heads/master.zip)
  2. Download Zabbix sources acording the version you have
  3. unpack both vpoller sources and zabbix sources
  4. go to unpacked zabbix source directory and make ./configure. Make sure it finishes right
  5. go to unpacked vpoller source, go to /extra/zabbix/vpoller-module subdirectory and copy the full content there to the unpacked zabbix source directory in src/modules subdirectory
  6. go to /src/modules/vpoller-module subdirectory inside the unpacked zabbix source directory and run make command. You will get a file called vpoller.so.
  7. Take the vpoller.so file and copy it in the modules directory you have configured in zabbix_server.conf or zabbix_proxy.conf and in the same conf file add the following line: LoadModule=vpoller.so
  8. Restart zabbix server or zabbix proxy and make use of the vpoller-templates-native template

As I told you before that was a brief description of the steps yo have to do in order to use vpoller as a module inside of zabbix instead an external script and in this way you will get your issue solved. Again, please check the detailed steps at https://vpoller.readthedocs.io/en/latest/index.html, section "vPoller Integration with Zabbix".

Have a nice day!