Add guest counter for PVE cluster and node
Also update the Zabbix template to handle those new counters GLPI #47604
This commit is contained in:
parent
43914cd61d
commit
bc0edccfa0
|
@ -51,6 +51,12 @@ if ($cluster){
|
|||
read => 0,
|
||||
write => 0
|
||||
};
|
||||
$json->{guests} = {
|
||||
qemu => 0,
|
||||
qemu_running => 0,
|
||||
lxc => 0,
|
||||
lxc_running => 0
|
||||
};
|
||||
my @nodes = ();
|
||||
foreach my $item (@{$cluster}){
|
||||
if ($item->{type} eq 'cluster'){
|
||||
|
@ -79,11 +85,27 @@ if ($cluster){
|
|||
$json->{network}->{out} += $guest->{netout} || 0;
|
||||
$json->{disk}->{read} += $guest->{diskread} || 0;
|
||||
$json->{disk}->{write} += $guest->{diskwrite} || 0;
|
||||
my $type = $guest->{type};
|
||||
$json->{guests}->{$type}++;
|
||||
$json->{guests}->{$type . '_running'}++ if ($guest->{status} eq 'running');
|
||||
}
|
||||
} elsif ($node){
|
||||
$json->{guests} = {
|
||||
qemu => 0,
|
||||
qemu_running => 0,
|
||||
lxc => 0,
|
||||
lxc_running => 0
|
||||
};
|
||||
foreach my $item (qw(status version subscription)){
|
||||
$json->{$item} = get_api_data("/nodes/$node/$item");
|
||||
}
|
||||
my $guests = get_api_data('/cluster/resources', '--type=vm');
|
||||
foreach my $guest (@{$guests}){
|
||||
next if ($guest->{node} ne $node);
|
||||
my $type = $guest->{type};
|
||||
$json->{guests}->{$type}++;
|
||||
$json->{guests}->{$type . '_running'}++ if ($guest->{status} eq 'running');
|
||||
}
|
||||
} elsif ($guest){
|
||||
my $guests = get_api_data('/cluster/resources', '--type=vm');
|
||||
foreach my $g (@{$guests}){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<zabbix_export>
|
||||
<version>4.4</version>
|
||||
<date>2020-03-02T15:26:38Z</date>
|
||||
<version>5.0</version>
|
||||
<date>2021-01-08T12:03:11Z</date>
|
||||
<groups>
|
||||
<group>
|
||||
<name>Templates</name>
|
||||
|
@ -200,6 +200,50 @@
|
|||
</master_item>
|
||||
<request_method>POST</request_method>
|
||||
</item>
|
||||
<item>
|
||||
<name>PVE Cluster: Number of LXC guests</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>pve.check[cluster,lxc]</key>
|
||||
<delay>0</delay>
|
||||
<trends>1825d</trends>
|
||||
<units>!container(s)</units>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Vitualization</name>
|
||||
</application>
|
||||
</applications>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<params>$.guests.lxc</params>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<master_item>
|
||||
<key>pve.check.all[cluster]</key>
|
||||
</master_item>
|
||||
</item>
|
||||
<item>
|
||||
<name>PVE Cluster: Number of running LXC guests</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>pve.check[cluster,lxc_running]</key>
|
||||
<delay>0</delay>
|
||||
<trends>1825d</trends>
|
||||
<units>!container(s)</units>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Vitualization</name>
|
||||
</application>
|
||||
</applications>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<params>$.guests.lxc_running</params>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<master_item>
|
||||
<key>pve.check.all[cluster]</key>
|
||||
</master_item>
|
||||
</item>
|
||||
<item>
|
||||
<name>PVE Cluster: Free memory</name>
|
||||
<type>DEPENDENT</type>
|
||||
|
@ -367,6 +411,50 @@
|
|||
</trigger>
|
||||
</triggers>
|
||||
</item>
|
||||
<item>
|
||||
<name>PVE Cluster: Number of QEMU guests</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>pve.check[cluster,qemu]</key>
|
||||
<delay>0</delay>
|
||||
<trends>1825d</trends>
|
||||
<units>!vm</units>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Vitualization</name>
|
||||
</application>
|
||||
</applications>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<params>$.guests.qemu</params>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<master_item>
|
||||
<key>pve.check.all[cluster]</key>
|
||||
</master_item>
|
||||
</item>
|
||||
<item>
|
||||
<name>PVE Cluster: Number of running QEMU guests</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>pve.check[cluster,qemu_running]</key>
|
||||
<delay>0</delay>
|
||||
<trends>1825d</trends>
|
||||
<units>!vm</units>
|
||||
<applications>
|
||||
<application>
|
||||
<name>Vitualization</name>
|
||||
</application>
|
||||
</applications>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<params>$.guests.qemu_running</params>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<master_item>
|
||||
<key>pve.check.all[cluster]</key>
|
||||
</master_item>
|
||||
</item>
|
||||
<item>
|
||||
<name>PVE Cluster: Quorate</name>
|
||||
<type>DEPENDENT</type>
|
||||
|
@ -963,6 +1051,40 @@
|
|||
</master_item>
|
||||
<request_method>POST</request_method>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<name>PVE Node: {#PVE_NODE_NAME} LXC guests</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>pve.check[node,{#PVE_NODE_NAME},lxc]</key>
|
||||
<delay>0</delay>
|
||||
<trends>1825d</trends>
|
||||
<units>!container(s)</units>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<params>$.guests.lxc</params>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<master_item>
|
||||
<key>pve.check.all[node,{#PVE_NODE_NAME}]</key>
|
||||
</master_item>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<name>PVE Node: {#PVE_NODE_NAME} running LXC guests</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>pve.check[node,{#PVE_NODE_NAME},lxc_running]</key>
|
||||
<delay>0</delay>
|
||||
<trends>1825d</trends>
|
||||
<units>!container(s)</units>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<params>$.guests.lxc_running</params>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<master_item>
|
||||
<key>pve.check.all[node,{#PVE_NODE_NAME}]</key>
|
||||
</master_item>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<name>PVE Node: {#PVE_NODE_NAME} free memory</name>
|
||||
<type>DEPENDENT</type>
|
||||
|
@ -1054,6 +1176,40 @@
|
|||
</master_item>
|
||||
<request_method>POST</request_method>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<name>PVE Node: {#PVE_NODE_NAME} QEMU guests</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>pve.check[node,{#PVE_NODE_NAME},qemu]</key>
|
||||
<delay>0</delay>
|
||||
<trends>1825d</trends>
|
||||
<units>!vm</units>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<params>$.guests.qemu</params>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<master_item>
|
||||
<key>pve.check.all[node,{#PVE_NODE_NAME}]</key>
|
||||
</master_item>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<name>PVE Node: {#PVE_NODE_NAME} running QEMU guests</name>
|
||||
<type>DEPENDENT</type>
|
||||
<key>pve.check[node,{#PVE_NODE_NAME},qemu_running]</key>
|
||||
<delay>0</delay>
|
||||
<trends>1825d</trends>
|
||||
<units>!vm</units>
|
||||
<preprocessing>
|
||||
<step>
|
||||
<type>JSONPATH</type>
|
||||
<params>$.guests.qemu_running</params>
|
||||
</step>
|
||||
</preprocessing>
|
||||
<master_item>
|
||||
<key>pve.check.all[node,{#PVE_NODE_NAME}]</key>
|
||||
</master_item>
|
||||
</item_prototype>
|
||||
<item_prototype>
|
||||
<name>PVE Node: {#PVE_NODE_NAME} uptime</name>
|
||||
<type>DEPENDENT</type>
|
||||
|
@ -1500,6 +1656,28 @@
|
|||
</item_prototype>
|
||||
</item_prototypes>
|
||||
<graph_prototypes>
|
||||
<graph_prototype>
|
||||
<name>PVE: Pool: {#PVE_POOL_ID}: Disk I/O</name>
|
||||
<graph_items>
|
||||
<graph_item>
|
||||
<drawtype>GRADIENT_LINE</drawtype>
|
||||
<color>00BB00</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[pool,{#PVE_POOL_ID},diskread]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
<graph_item>
|
||||
<sortorder>1</sortorder>
|
||||
<drawtype>GRADIENT_LINE</drawtype>
|
||||
<color>EE0000</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[pool,{#PVE_POOL_ID},diskwrite]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
</graph_items>
|
||||
</graph_prototype>
|
||||
<graph_prototype>
|
||||
<name>PVE: Pool: {#PVE_POOL_ID}: Disk space allocation</name>
|
||||
<type>STACKED</type>
|
||||
|
@ -1522,6 +1700,29 @@
|
|||
</graph_item>
|
||||
</graph_items>
|
||||
</graph_prototype>
|
||||
<graph_prototype>
|
||||
<name>PVE: Pool: {#PVE_POOL_ID}: Memory usage</name>
|
||||
<ymin_type_1>FIXED</ymin_type_1>
|
||||
<graph_items>
|
||||
<graph_item>
|
||||
<drawtype>GRADIENT_LINE</drawtype>
|
||||
<color>00AA00</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[pool,{#PVE_POOL_ID},mem]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
<graph_item>
|
||||
<sortorder>1</sortorder>
|
||||
<drawtype>BOLD_LINE</drawtype>
|
||||
<color>EE0000</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[pool,{#PVE_POOL_ID},maxmem]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
</graph_items>
|
||||
</graph_prototype>
|
||||
<graph_prototype>
|
||||
<name>PVE: Pool: {#PVE_POOL_ID}: Trafic réseau</name>
|
||||
<graph_items>
|
||||
|
@ -1568,51 +1769,6 @@
|
|||
</graph_item>
|
||||
</graph_items>
|
||||
</graph_prototype>
|
||||
<graph_prototype>
|
||||
<name>PVE: Pool: {#PVE_POOL_ID} Disk I/O</name>
|
||||
<graph_items>
|
||||
<graph_item>
|
||||
<drawtype>GRADIENT_LINE</drawtype>
|
||||
<color>00BB00</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[pool,{#PVE_POOL_ID},diskread]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
<graph_item>
|
||||
<sortorder>1</sortorder>
|
||||
<drawtype>GRADIENT_LINE</drawtype>
|
||||
<color>EE0000</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[pool,{#PVE_POOL_ID},diskwrite]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
</graph_items>
|
||||
</graph_prototype>
|
||||
<graph_prototype>
|
||||
<name>PVE: Pool: {#PVE_POOL_ID} Memory usage</name>
|
||||
<ymin_type_1>FIXED</ymin_type_1>
|
||||
<graph_items>
|
||||
<graph_item>
|
||||
<drawtype>GRADIENT_LINE</drawtype>
|
||||
<color>00AA00</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[pool,{#PVE_POOL_ID},mem]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
<graph_item>
|
||||
<sortorder>1</sortorder>
|
||||
<drawtype>BOLD_LINE</drawtype>
|
||||
<color>EE0000</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[pool,{#PVE_POOL_ID},maxmem]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
</graph_items>
|
||||
</graph_prototype>
|
||||
</graph_prototypes>
|
||||
<request_method>POST</request_method>
|
||||
</discovery_rule>
|
||||
|
@ -1823,6 +1979,28 @@
|
|||
</graph_item>
|
||||
</graph_items>
|
||||
</graph>
|
||||
<graph>
|
||||
<name>PVE Cluster: Guests</name>
|
||||
<type>STACKED</type>
|
||||
<graph_items>
|
||||
<graph_item>
|
||||
<sortorder>1</sortorder>
|
||||
<color>F63100</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[cluster,lxc_running]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
<graph_item>
|
||||
<sortorder>2</sortorder>
|
||||
<color>1A7C11</color>
|
||||
<item>
|
||||
<host>Template_App_PVE_Cluster</host>
|
||||
<key>pve.check[cluster,qemu_running]</key>
|
||||
</item>
|
||||
</graph_item>
|
||||
</graph_items>
|
||||
</graph>
|
||||
<graph>
|
||||
<name>PVE Cluster: KSM shared memory</name>
|
||||
<graph_items>
|
||||
|
|
Loading…
Reference in New Issue