Api integration

Dec 15, 2022
3
0
6
Hello,

I need to use discovery rule for file systems in Zabbix and i need an api request which shows me vmid,node name and disk id so i can combine them with agent get-fsinfo request.Is there anyway to do that?

Thanks
 
Hi

Here are a couple of things for you, I hope one of them helps:
  1. pvesh get /cluster/resources
  2. You could also run pvesh get /nodes/ to get all the nodes, then iterate over nodenames, run pvesh get /nodes/<nodename>/qemu/ to get all nodes and ID's, and then iterate over the ID's with pvesh get /nodes/<nodename>/qemu/<ID>/config/ to get the disk info
  3. qm list can also list VM IDs, although not via the API
Both the wiki entry on the pve API and the web explorer might be useful for you as well as the docs for the CLI.

Hope this helps, sorry for the long wait on the reply
 
In Zabbix, to create a discovery rule for file systems, you'll typically use the Zabbix API to automate the process. You can use the Zabbix API to retrieve the necessary information about VMs, nodes, and disk IDs to combine with the agent.get-fsinfo request. Here's a general outline of the steps you can follow:

  1. Retrieve VMs and Nodes Information: You need to first retrieve information about VMs and nodes. The specific API calls to achieve this depend on your Zabbix configuration, such as whether you are using Zabbix with VMware or other virtualization technologies. Here's a generic example:
    • To get a list of VMs: You might use the host.get method and filter by host type or other criteria to get a list of VMs.
    • To get a list of nodes: If your Zabbix setup tracks nodes, you would similarly use the host.get method with appropriate filters.
  2. Retrieve Disk IDs: Once you have the VM and node information, you can proceed to retrieve the disk IDs for each VM or node. You may need to use a different b2b API meaning depending on your setup. For example:
    • For VMware, you might use vmware.getdisks.
    • For other virtualization technologies or physical hosts, you might need to use different API calls or custom scripts to fetch disk information.
  3. Create a Discovery Rule: Using the retrieved information, you can then create a discovery rule in Zabbix. The discovery rule should be configured to execute the agent. get-fsinfo request using the VMID, node name, and disk ID as macros. These macros will be replaced with actual values during discovery.
  4. Associate Discovery Rule with an Item Prototype: After creating the discovery rule, you'll need to associate it with an item prototype. This item prototype should use the agent.get-fsinfo request and specify the macros to be replaced.
  5. Test the Discovery Rule: Once you've configured the discovery rule and item prototype, you can test it to ensure that it discovers file systems correctly.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!