Hello.. what is the query to calculate total disk ...
# general
g
Hello.. what is the query to calculate total disk space on a linux machine. The queries i am using are not matching with the data brought in by other tools. The query i used are: 1. SELECT ROUND(SUM(blocks * blocks_size) / (1024 * 1024 * 1024), 2) AS a_total_disk_space_gb, ROUND(SUM((blocks - blocks_free - blocks_available) * blocks_size) / (1024 * 1024 * 1024), 2) AS b_total_all_gb FROM mounts; 2. SELECT ROUND(CAST(SUM(blocks_size) AS DECIMAL) / (1024 * 1024), 2) AS disk_space_gb FROM mounts; Note: The query for Windows disk space is working fine: (SELECT round(SUM(disk_size)/1073741824.0,0) AS total_disk_space_in_gb FROM disk_info) as total_disk_space_in_gb,
General slack tip is to learn how to use its code formatting. Like this:
Copy code
SELECT
 ROUND(SUM(blocks * blocks_size) / (1024 * 1024 * 1024), 2) AS a_total_disk_space_gb,
 ROUND(SUM((blocks - blocks_free - blocks_available) * blocks_size) / (1024 * 1024 * 1024), 2) AS b_total_all_gb
FROM mounts;
g
Thanks for the input John. I tried the query and the result shows 'available disk space'. Do you know what i need to do to get 'total disk size' Thanks in advance 🤝
j
No, sorry.
d