We are currently running Zabbix server 4.0.4 on Centos 7. One of our customers has a reporting requirement. They would like a report produced each month shown total size of each drive on each server and free space on each drive on each server.
Is there a report I can setup to do this?
On our old zabbix server we use the following sql command to pull the necessary information
<form action="./index.php" method="post" >
Group Name:<br>
<input type="text" name="groupname" value="Enter Group Name"><br>
<input type="submit" value="Submit">
</form>
<?php
}else{
echo "Zabbix Trigger Report ".$_POST['groupname']."<br>";
$output= "Zabbix Trigger Report ".$_POST['groupname']."<br>";
include 'db.php';
if(strpos($_POST['groupname'],"DISK") > 0){
$groupname = explode(",",$_POST['groupname'])[0];
$sql = "SELECT host, g.name,i.key_ , (Select value_avg from zabbix.trends_uint where itemid = i.itemid order by clock desc LIMIT 1 )/1024/1024/1024 as avg_value
FROM items i
INNER JOIN hosts h ON ( i.hostid = h.hostid )
INNER JOIN hosts_groups hg ON ( hg.hostid = h.hostid )
INNER JOIN groups g ON ( g.groupid = hg.groupid )
WHERE g.name = '".$groupname."' AND i.key_ like 'vfs.fs.size%' AND i.key_ not like '%#%' and i.key_ not like '%pfree%'
ORDER BY host asc";
echo "Host,Group,Key,Size(GB)<br>".PHP_EOL;
$result = $conn->query($sql);
$count = 0;
if ($result->num_rows > 0) {
// output data of each row
$count++;
$hosts_triggers = "";
while($row = $result->fetch_assoc()) {
echo $row['host'].",".$row['name'].",".$row['key_'].",".round($row['avg_value'],2)."<br>".PHP_EOL;
}
} else {
echo "0 results";
}
The problem is on zabbix 4.0.4 the table "groups" no longer exists. I am not sure how to convert the sql command to get it to work with version 4.0.4
Is there a report I can setup to do this?
On our old zabbix server we use the following sql command to pull the necessary information
<form action="./index.php" method="post" >
Group Name:<br>
<input type="text" name="groupname" value="Enter Group Name"><br>
<input type="submit" value="Submit">
</form>
<?php
}else{
echo "Zabbix Trigger Report ".$_POST['groupname']."<br>";
$output= "Zabbix Trigger Report ".$_POST['groupname']."<br>";
include 'db.php';
if(strpos($_POST['groupname'],"DISK") > 0){
$groupname = explode(",",$_POST['groupname'])[0];
$sql = "SELECT host, g.name,i.key_ , (Select value_avg from zabbix.trends_uint where itemid = i.itemid order by clock desc LIMIT 1 )/1024/1024/1024 as avg_value
FROM items i
INNER JOIN hosts h ON ( i.hostid = h.hostid )
INNER JOIN hosts_groups hg ON ( hg.hostid = h.hostid )
INNER JOIN groups g ON ( g.groupid = hg.groupid )
WHERE g.name = '".$groupname."' AND i.key_ like 'vfs.fs.size%' AND i.key_ not like '%#%' and i.key_ not like '%pfree%'
ORDER BY host asc";
echo "Host,Group,Key,Size(GB)<br>".PHP_EOL;
$result = $conn->query($sql);
$count = 0;
if ($result->num_rows > 0) {
// output data of each row
$count++;
$hosts_triggers = "";
while($row = $result->fetch_assoc()) {
echo $row['host'].",".$row['name'].",".$row['key_'].",".round($row['avg_value'],2)."<br>".PHP_EOL;
}
} else {
echo "0 results";
}
The problem is on zabbix 4.0.4 the table "groups" no longer exists. I am not sure how to convert the sql command to get it to work with version 4.0.4
Comment