Add guest counter for PVE cluster and node

Also update the Zabbix template to handle those new counters

GLPI #47604
tags/zabbix-agent-addons-0.2.136-1
Daniel Berteaud 4 years ago
parent 43914cd61d
commit bc0edccfa0
  1. 22
      zabbix_scripts/check_pve_sudo
  2. 238
      zabbix_templates/Template_App_PVE_Cluster.xml

@ -51,6 +51,12 @@ if ($cluster){
read => 0, read => 0,
write => 0 write => 0
}; };
$json->{guests} = {
qemu => 0,
qemu_running => 0,
lxc => 0,
lxc_running => 0
};
my @nodes = (); my @nodes = ();
foreach my $item (@{$cluster}){ foreach my $item (@{$cluster}){
if ($item->{type} eq 'cluster'){ if ($item->{type} eq 'cluster'){
@ -79,11 +85,27 @@ if ($cluster){
$json->{network}->{out} += $guest->{netout} || 0; $json->{network}->{out} += $guest->{netout} || 0;
$json->{disk}->{read} += $guest->{diskread} || 0; $json->{disk}->{read} += $guest->{diskread} || 0;
$json->{disk}->{write} += $guest->{diskwrite} || 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){ } elsif ($node){
$json->{guests} = {
qemu => 0,
qemu_running => 0,
lxc => 0,
lxc_running => 0
};
foreach my $item (qw(status version subscription)){ foreach my $item (qw(status version subscription)){
$json->{$item} = get_api_data("/nodes/$node/$item"); $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){ } elsif ($guest){
my $guests = get_api_data('/cluster/resources', '--type=vm'); my $guests = get_api_data('/cluster/resources', '--type=vm');
foreach my $g (@{$guests}){ foreach my $g (@{$guests}){

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<zabbix_export> <zabbix_export>
<version>4.4</version> <version>5.0</version>
<date>2020-03-02T15:26:38Z</date> <date>2021-01-08T12:03:11Z</date>
<groups> <groups>
<group> <group>
<name>Templates</name> <name>Templates</name>
@ -201,6 +201,50 @@
<request_method>POST</request_method> <request_method>POST</request_method>
</item> </item>
<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> <name>PVE Cluster: Free memory</name>
<type>DEPENDENT</type> <type>DEPENDENT</type>
<key>pve.check[cluster,mem_free]</key> <key>pve.check[cluster,mem_free]</key>
@ -368,6 +412,50 @@
</triggers> </triggers>
</item> </item>
<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> <name>PVE Cluster: Quorate</name>
<type>DEPENDENT</type> <type>DEPENDENT</type>
<key>pve.check[cluster,quorate]</key> <key>pve.check[cluster,quorate]</key>
@ -964,6 +1052,40 @@
<request_method>POST</request_method> <request_method>POST</request_method>
</item_prototype> </item_prototype>
<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> <name>PVE Node: {#PVE_NODE_NAME} free memory</name>
<type>DEPENDENT</type> <type>DEPENDENT</type>
<key>pve.check[node,{#PVE_NODE_NAME},mem_free]</key> <key>pve.check[node,{#PVE_NODE_NAME},mem_free]</key>
@ -1055,6 +1177,40 @@
<request_method>POST</request_method> <request_method>POST</request_method>
</item_prototype> </item_prototype>
<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> <name>PVE Node: {#PVE_NODE_NAME} uptime</name>
<type>DEPENDENT</type> <type>DEPENDENT</type>
<key>pve.check[node,{#PVE_NODE_NAME},uptime]</key> <key>pve.check[node,{#PVE_NODE_NAME},uptime]</key>
@ -1501,114 +1657,114 @@
</item_prototypes> </item_prototypes>
<graph_prototypes> <graph_prototypes>
<graph_prototype> <graph_prototype>
<name>PVE: Pool: {#PVE_POOL_ID}: Disk space allocation</name> <name>PVE: Pool: {#PVE_POOL_ID}: Disk I/O</name>
<type>STACKED</type>
<ymin_type_1>FIXED</ymin_type_1>
<graph_items> <graph_items>
<graph_item> <graph_item>
<color>2774A4</color> <drawtype>GRADIENT_LINE</drawtype>
<color>00BB00</color>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},maxdisk]</key> <key>pve.check[pool,{#PVE_POOL_ID},diskread]</key>
</item> </item>
</graph_item> </graph_item>
<graph_item> <graph_item>
<sortorder>1</sortorder> <sortorder>1</sortorder>
<color>DD0000</color> <drawtype>GRADIENT_LINE</drawtype>
<color>EE0000</color>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},template_maxdisk]</key> <key>pve.check[pool,{#PVE_POOL_ID},diskwrite]</key>
</item> </item>
</graph_item> </graph_item>
</graph_items> </graph_items>
</graph_prototype> </graph_prototype>
<graph_prototype> <graph_prototype>
<name>PVE: Pool: {#PVE_POOL_ID}: Trafic réseau</name> <name>PVE: Pool: {#PVE_POOL_ID}: Disk space allocation</name>
<type>STACKED</type>
<ymin_type_1>FIXED</ymin_type_1>
<graph_items> <graph_items>
<graph_item> <graph_item>
<drawtype>GRADIENT_LINE</drawtype> <color>2774A4</color>
<color>00AA00</color>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},netin]</key> <key>pve.check[pool,{#PVE_POOL_ID},maxdisk]</key>
</item> </item>
</graph_item> </graph_item>
<graph_item> <graph_item>
<sortorder>1</sortorder> <sortorder>1</sortorder>
<drawtype>GRADIENT_LINE</drawtype> <color>DD0000</color>
<color>FF9999</color>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},netout]</key> <key>pve.check[pool,{#PVE_POOL_ID},template_maxdisk]</key>
</item> </item>
</graph_item> </graph_item>
</graph_items> </graph_items>
</graph_prototype> </graph_prototype>
<graph_prototype> <graph_prototype>
<name>PVE: Pool: {#PVE_POOL_ID} CPU usage</name> <name>PVE: Pool: {#PVE_POOL_ID}: Memory usage</name>
<ymin_type_1>FIXED</ymin_type_1> <ymin_type_1>FIXED</ymin_type_1>
<graph_items> <graph_items>
<graph_item> <graph_item>
<drawtype>GRADIENT_LINE</drawtype> <drawtype>GRADIENT_LINE</drawtype>
<color>000099</color> <color>00AA00</color>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},cpu]</key> <key>pve.check[pool,{#PVE_POOL_ID},mem]</key>
</item> </item>
</graph_item> </graph_item>
<graph_item> <graph_item>
<sortorder>1</sortorder> <sortorder>1</sortorder>
<drawtype>BOLD_LINE</drawtype> <drawtype>BOLD_LINE</drawtype>
<color>EE0000</color> <color>EE0000</color>
<yaxisside>RIGHT</yaxisside>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},maxcpu]</key> <key>pve.check[pool,{#PVE_POOL_ID},maxmem]</key>
</item> </item>
</graph_item> </graph_item>
</graph_items> </graph_items>
</graph_prototype> </graph_prototype>
<graph_prototype> <graph_prototype>
<name>PVE: Pool: {#PVE_POOL_ID} Disk I/O</name> <name>PVE: Pool: {#PVE_POOL_ID}: Trafic réseau</name>
<graph_items> <graph_items>
<graph_item> <graph_item>
<drawtype>GRADIENT_LINE</drawtype> <drawtype>GRADIENT_LINE</drawtype>
<color>00BB00</color> <color>00AA00</color>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},diskread]</key> <key>pve.check[pool,{#PVE_POOL_ID},netin]</key>
</item> </item>
</graph_item> </graph_item>
<graph_item> <graph_item>
<sortorder>1</sortorder> <sortorder>1</sortorder>
<drawtype>GRADIENT_LINE</drawtype> <drawtype>GRADIENT_LINE</drawtype>
<color>EE0000</color> <color>FF9999</color>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},diskwrite]</key> <key>pve.check[pool,{#PVE_POOL_ID},netout]</key>
</item> </item>
</graph_item> </graph_item>
</graph_items> </graph_items>
</graph_prototype> </graph_prototype>
<graph_prototype> <graph_prototype>
<name>PVE: Pool: {#PVE_POOL_ID} Memory usage</name> <name>PVE: Pool: {#PVE_POOL_ID} CPU usage</name>
<ymin_type_1>FIXED</ymin_type_1> <ymin_type_1>FIXED</ymin_type_1>
<graph_items> <graph_items>
<graph_item> <graph_item>
<drawtype>GRADIENT_LINE</drawtype> <drawtype>GRADIENT_LINE</drawtype>
<color>00AA00</color> <color>000099</color>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},mem]</key> <key>pve.check[pool,{#PVE_POOL_ID},cpu]</key>
</item> </item>
</graph_item> </graph_item>
<graph_item> <graph_item>
<sortorder>1</sortorder> <sortorder>1</sortorder>
<drawtype>BOLD_LINE</drawtype> <drawtype>BOLD_LINE</drawtype>
<color>EE0000</color> <color>EE0000</color>
<yaxisside>RIGHT</yaxisside>
<item> <item>
<host>Template_App_PVE_Cluster</host> <host>Template_App_PVE_Cluster</host>
<key>pve.check[pool,{#PVE_POOL_ID},maxmem]</key> <key>pve.check[pool,{#PVE_POOL_ID},maxcpu]</key>
</item> </item>
</graph_item> </graph_item>
</graph_items> </graph_items>
@ -1824,6 +1980,28 @@
</graph_items> </graph_items>
</graph> </graph>
<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> <name>PVE Cluster: KSM shared memory</name>
<graph_items> <graph_items>
<graph_item> <graph_item>

Loading…
Cancel
Save