du

How to monitor the size of a directory via Telegraf

好久不见. 提交于 2020-12-28 07:58:06
问题 We need to monitor the size of a directory (for example the data directory of InfluxDB) to set up alerts in Grafana. As mentioned here: How to configure telegraf to send a folder-size to influxDB , there is no built-in plugin for this. We don't mind using the inputs.exec section of Telegraf. The directories are not huge (low filecount + dircount), so deep scanning (like the use of du ) is fine by us. One of the directories we need to monitor is /var/lib/influxdb/data . What would be a simple

How to monitor the size of a directory via Telegraf

為{幸葍}努か 提交于 2020-12-28 07:57:33
问题 We need to monitor the size of a directory (for example the data directory of InfluxDB) to set up alerts in Grafana. As mentioned here: How to configure telegraf to send a folder-size to influxDB , there is no built-in plugin for this. We don't mind using the inputs.exec section of Telegraf. The directories are not huge (low filecount + dircount), so deep scanning (like the use of du ) is fine by us. One of the directories we need to monitor is /var/lib/influxdb/data . What would be a simple

How to monitor the size of a directory via Telegraf

心不动则不痛 提交于 2020-12-28 07:53:58
问题 We need to monitor the size of a directory (for example the data directory of InfluxDB) to set up alerts in Grafana. As mentioned here: How to configure telegraf to send a folder-size to influxDB , there is no built-in plugin for this. We don't mind using the inputs.exec section of Telegraf. The directories are not huge (low filecount + dircount), so deep scanning (like the use of du ) is fine by us. One of the directories we need to monitor is /var/lib/influxdb/data . What would be a simple

How to monitor the size of a directory via Telegraf

三世轮回 提交于 2020-12-28 07:53:32
问题 We need to monitor the size of a directory (for example the data directory of InfluxDB) to set up alerts in Grafana. As mentioned here: How to configure telegraf to send a folder-size to influxDB , there is no built-in plugin for this. We don't mind using the inputs.exec section of Telegraf. The directories are not huge (low filecount + dircount), so deep scanning (like the use of du ) is fine by us. One of the directories we need to monitor is /var/lib/influxdb/data . What would be a simple

How to calculate the total size of certain files only, recursive, in linux

≡放荡痞女 提交于 2020-06-22 07:29:30
问题 I've got a bunch of files scattered across folders in a layout, e.g.: dir1/somefile.gif dir1/another.mp4 dir2/video/filename.mp4 dir2/some.file dir2/blahblah.mp4 And I need to find the total disk space used for the MP4 files only . This means it's gotta be recursive somehow. I've looked at du and fiddling with piping things to grep but can't seem to figure out how to calculate just the MP4 files no matter where they are. A human readable total disk space output is a must too, preferably in GB

du查看的目录大小与df查看的大小不同的时候用lsof查找

家住魔仙堡 提交于 2020-03-01 03:18:57
首先MAN一下俩个命令,看一下解释的区别: du - estimate file space usage df - report file system disk space usage du估计文件空间占用情况,df报告文件系统磁盘空间使用情况。两个命令所要获取的对象时不同的。在linux下,几乎所有东西都可以称为文件,常规文件,二进制文件,socket流。所以,通常情况下,使用du得到到的根路径文件空间占用情况应当与df得到的文件系统磁盘占用的情况是一直的或者说相差无几。但是在某些情况下却会出现du得到的空间占用情况要远小于df得到的。 后通过查询,发现问题出现在deleted文件上。 root下lsof | grep deleted会发现多多少少有些文件状态出于deleted状态。 [root@eb152 ~]# lsof |grep deleted 进程名 PID USER FD 文件类型 大小(字节) 索引节点 文件名 [(状态)] java 3311 AuSP 8w REG 253,0 778 10879268 ***.log (deleted) java 3311 AuSP 9w REG 253,0 3275 10879269 ***.log (deleted) java 3311 AuSP 10w REG 253,0 0 10879815 ***.log

python Mac OS : os.path.getsize returns different value than du -ks?

强颜欢笑 提交于 2020-01-04 09:42:09
问题 When comparing the size of a directory with Unix and python, I have slightly different results (5% smaller with "disk usage"). Why ? (all my subfolders are readable; I work under Mac OSX Mountain lion, python version 2.7.2) Here is my code : import os, sys from commands import getstatusoutput def get_size(start_path = '.'): total_size = 0 for dirpath, dirnames, filenames in os.walk(start_path): for f in filenames: fp = os.path.join(dirpath, f) total_size += os.path.getsize(fp) return total

Fast(er) way to get folder size with batch script

时光毁灭记忆、已成空白 提交于 2019-12-31 00:30:27
问题 PLEASE SEE BELOW THE ORIGINAL QUESTION FOR SOME TEST COMPARISONS OF DIFFERENT WAYS: So I tried 2 ways so far: 1.Iterate through directory using the code from Get Folder Size from Windows Command Line : @echo off set size=0 for /r %%x in (folder\*) do set /a size+=%%~zx echo %size% Bytes 2.Save output of a 'dir %folder% /s /a' into a text file, and then read in the size at the bottom 3.The last way I am trying right now is using du (disk utility tool from MS - https://technet.microsoft.com/en

Size() vs ls -la vs du -h which one is correct size?

偶尔善良 提交于 2019-12-28 04:31:06
问题 I was compiling a custom kernel, and I wanted to test the size of the image file. These are the results: ls -la | grep vmlinux -rwxr-xr-x 1 root root 8167158 May 21 12:14 vmlinux du -h vmlinux 3.8M vmlinux size vmlinux text data bss dec hex filename 2221248 676148 544768 3442164 3485f4 vmlinux Since all of them show different sizes, which one is closest to the actual image size? Why are they different? 回答1: They are all correct, they just show different sizes. ls shows size of the file (when

Why does “find . -name *.txt | xargs du -hc” give multiple totals?

半腔热情 提交于 2019-12-18 13:21:34
问题 I have a large set of directories for which I'm trying to calculate the sum total size of several hundred .txt files. I tried this, which mostly works: find . -name *.txt | xargs du -hc But instead of giving me one total at the end, I get several. My guess is that the pipe will only pass on so many lines of find's output at a time, and du just operates on each batch as it comes. Is there a way around this? Thanks! Alex 回答1: How about using the --files0-from option to du? You'd have to