Link to home
Start Free TrialLog in
Avatar of llarava
llaravaFlag for Afghanistan

asked on

Need assistance with Linux script to calculate free space on drive

Hello,

I am running into some limitations (...by design) with the XenCenter and Xenserver (Citrix Hypervisor) the issue I am facing is that when I am using GFS2 with the shares storage drives the XenCenter (mananagement console) doesn't seem to calculate the free space that's available for that particular shared storage drive.

That being said, I am looking to get some assistance writing a quick script to check the available space on a drive or file system and email if the system free space is below 20%. I will run the script a chron job every hour.
Avatar of Alex [***Alex140181***]
Alex [***Alex140181***]
Flag of Germany image

Just run the following...

df -h
df -h -i

Open in new window


Both these will produce human (-h) output, then you can trigger an email if any mount point grows past a certain usage amount.
Best check both space (df -h) + inode usage (df -h -i).

Checking inode usage will normally only be required if you have many small files, like running an IMAP server.
Avatar of llarava

ASKER

Hello,

With df -h I don't see any of the storage repositories (file systems) that are block only the NFS ones.
Post your df -h output, along with name of mount point of interest.
Avatar of llarava

ASKER

I am looking for

XS_BG_VDI_SR_01
Hardware HBA SR [3PARdata - CZ3737SC4J]  ---- This is running over FC/Block

The below only shows the FS using NFS not block/FC

[root@bem3813xs ~]# df -h
Filesystem                                                                                                                                                  Size  Used Avail Use% Mounted on
devtmpfs                                                                                                                                                    2.0G  564K  2.0G   1% /dev
tmpfs                                                                                                                                                       2.0G   37M  1.9G   2% /dev/shm
tmpfs                                                                                                                                                       2.0G  7.9M  2.0G   1% /run
tmpfs                                                                                                                                                       2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/sda1                                                                                                                                                    18G  2.2G   15G  13% /
xenstore                                                                                                                                                    2.0G     0  2.0G   0% /var/lib/xenstored
/dev/loop0                                                                                                                                                   45M   45M     0 100% /var/xen/xc-install
/dev/sda5                                                                                                                                                   3.9G  1.5G  2.2G  41% /var/log
10.220.218.79:/BG_FPG_NFS_TEST/vfs3879fp3/fs3879_01/xs_bg_test/14f61cc2-f431-b41                                                       1-6ae8-f458b93368e1  1.0T   59G  966G   6% /run/sr-mount/14f61cc2-f431-b411-6ae8                                                       -f458b93368e1
10.220.218.79:/BG_FPG_NFS_TEST/vfs3879fp3/fs3879_01/xs_bg_test/128bf047-3ed3-cd5                                                       1-3270-26f1ed0574eb  1.0T   59G  966G   6% /run/sr-mount/128bf047-3ed3-cd51-3270                                                       -26f1ed0574eb
10.220.218.79:/BG_FPG_NFS_TEST/vfs3879fp3/fs3879_01/xs_bg_test/55c95283-457d-bd7                                                       0-2b05-569691a35cdd  1.0T   59G  966G   6% /run/sr-mount/55c95283-457d-bd70-2b05                                                       -569691a35cdd
10.220.218.73:/FPG_NFS_3/vfs3873fp0/fs3873fp0/xs_trn_04/11ba4248-d8a7-02e0-edd3-                                                       83309f0746c6         2.2T  334G  1.9T  16% /run/sr-mount/11ba4248-d8a7-02e0-edd3                                                       -83309f0746c6
10.220.218.79:/BG_FPG_NFS_TEST/vfs3879fp3/fs3879_01/xs_bg_test/7b5111a9-e46f-38d                                                       2-70cf-57e9161a0e4f  1.0T   59G  966G   6% /run/sr-mount/7b5111a9-e46f-38d2-70cf                                                       -57e9161a0e4f
10.220.218.74:/FPG_NFS_0/vfs3848fp3/home/xs_trn_01/703953d0-4ab6-4f0e-d041-71ec5                                                       1ebad3f              3.0T  288G  2.7T  10% /run/sr-mount/703953d0-4ab6-4f0e-d041                                                       -71ec51ebad3f
10.220.218.79:/BG_FPG_NFS_TEST/vfs3879fp3/fs3879_01/xs_bg_test/bb1073b3-bc78-a11                                                       b-409c-3d7785601afd  1.0T   59G  966G   6% /run/sr-mount/bb1073b3-bc78-a11b-409c                                                       -3d7785601afd
10.220.218.71:/FPG_NFS_1/vfs3871fp1/fs3871_01/xs_exam_02/496fe72e-0268-7e4a-13c8                                                       -3f14c404ec5b        1.2T  264G  911G  23% /run/sr-mount/496fe72e-0268-7e4a-13c8                                                       -3f14c404ec5b
10.220.218.74:/FPG_NFS_0/vfs3848fp3/home/xs_bb_01/5aed789e-3a13-6e69-f657-a6f93b                                                       b15149               3.0T  288G  2.7T  10% /run/sr-mount/5aed789e-3a13-6e69-f657                                                       -a6f93bb15149
/dev/mapper/360002ac00000000001018e760001f149                                                                                                               2.0T  1.6T  377G  82% /run/sr-mount/8dd29938-3b6a-8bec-12ca                                                       -afa3526391b0
10.220.218.74:/FPG_NFS_0/vfs3848fp3/home/xs_exam_01/720e6397-002e-93fd-f666-cd19                                                       629363c6             3.0T  288G  2.7T  10% /run/sr-mount/720e6397-002e-93fd-f666                                                       -cd19629363c6
10.220.218.73:/FPG_NFS_3/vfs3873fp0/fs3873fp0/xs_bb_04/a41fff50-ee96-2721-b23a-8                                                       898f11c4679          2.2T  334G  1.9T  16% /run/sr-mount/a41fff50-ee96-2721-b23a                                                       -8898f11c4679
10.220.218.72:/FPG_NFS_2/vfs3872fp2/fs3872_01/xs_trn_03/fb486741-c55e-610f-d2f1-                                                       fed2d2ec37ea         2.2T  314G  1.9T  15% /run/sr-mount/fb486741-c55e-610f-d2f1                                                       -fed2d2ec37ea
//10.120.114.242/temp                                                                                                                                        90G   72G   19G  80% /run/sr-mount/e81dc93e-722d-e29a-dc08                                                       -9ad0c4e73443
10.220.218.72:/FPG_NFS_2/vfs3872fp2/fs3872_01/xs_exam_03/85b1d959-b5da-8930-05bf                                                       -062a4b58c29a        2.2T  314G  1.9T  15% /run/sr-mount/85b1d959-b5da-8930-05bf                                                       -062a4b58c29a
10.220.218.71:/FPG_NFS_1/vfs3871fp1/fs3871_01/xs_trn_02/763a6e29-098b-f73e-b80d-                                                       3ae51426bc3e         1.2T  264G  911G  23% /run/sr-mount/763a6e29-098b-f73e-b80d                                                       -3ae51426bc3e
10.220.218.73:/FPG_NFS_3/vfs3873fp0/fs3873fp0/xs_exam_04/87856ea7-82a1-8c12-5d75                                                       -de2d50d5dc8c        2.2T  334G  1.9T  16% /run/sr-mount/87856ea7-82a1-8c12-5d75                                                       -de2d50d5dc8c
10.220.218.77:/FPG_NFS_6/vfs3877fp3/fs3877_01/xs_trn_05/53f9b8c0-b5e9-7207-bc56-                                                       cc3a22caa897         1.0T  309G  716G  31% /run/sr-mount/53f9b8c0-b5e9-7207-bc56                                                       -cc3a22caa897
10.220.218.79:/BG_FPG_NFS_TEST/vfs3879fp3/fs3879_01/xs_bg_test/27f5d9b7-c501-1ef                                                       f-414a-c88eb49e5f43  1.0T   59G  966G   6% /run/sr-mount/27f5d9b7-c501-1eff-414a                                                       -c88eb49e5f43
10.220.218.72:/FPG_NFS_2/vfs3872fp2/fs3872_01/xs_bb_03/d6b2ab75-69ee-180c-bd0e-1                                                       dee890c8b89          2.2T  314G  1.9T  15% /run/sr-mount/d6b2ab75-69ee-180c-bd0e                                                       -1dee890c8b89
10.220.218.79:/BG_FPG_NFS_TEST/vfs3879fp3/fs3879_01/xs_bg_test/8de0e630-4bea-733                                                       a-0ed1-4770a08fe38d  1.0T   59G  966G   6% /run/sr-mount/8de0e630-4bea-733a-0ed1                                                       -4770a08fe38d
10.220.218.71:/FPG_NFS_1/vfs3871fp1/fs3871_01/xs_bb_02/e17044a6-05c8-d4bf-4ce7-3                                                       fb8b128ab01          1.2T  264G  911G  23% /run/sr-mount/e17044a6-05c8-d4bf-4ce7                                                       -3fb8b128ab01
10.220.218.77:/FPG_NFS_6/vfs3877fp3/fs3877_01/xs_bb_05/b955ce20-94ce-6402-6c47-7                                                       e62bd6320df          1.0T  309G  716G  31% /run/sr-mount/b955ce20-94ce-6402-6c47                                                       -7e62bd6320df
10.220.218.77:/FPG_NFS_6/vfs3877fp3/fs3877_01/xs_exam_05/49044c1e-020f-26d0-28ec                                                       -622555db27a3        1.0T  309G  716G  31% /run/sr-mount/49044c1e-020f-26d0-28ec                                                       -622555db27a3
10.220.218.79:/BG_FPG_NFS_TEST/vfs3879fp3/fs3879_01/xs_bg_test/5ad8b8b8-991b-23b                                                       9-6dfe-c7634808a599  1.0T   59G  966G   6% /run/sr-mount/5ad8b8b8-991b-23b9-6dfe                                                       -c7634808a599
10.220.218.79:/BG_FPG_NFS_TEST/vfs3879fp3/fs3879_01/xs_bg_test/d1227ee7-fd69-e80                                                       a-7a7f-e693156b0515  1.0T   59G  966G   6% /run/sr-mount/d1227ee7-fd69-e80a-7a7f                                                       -e693156b0515

Open in new window

Maybe automounting is in the mix...

Post the output of mount, something like /gfs (absolute path of mount point).
Avatar of llarava

ASKER

Sorry, what command would like to run to show the auto mounting?
ASKER CERTIFIED SOLUTION
Avatar of Pierre François
Pierre François
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
either look in /etc/fstab
or it's done via autofs
@Pierre: no need for the fancy sed stuff ;-)
df -h --output=pcent ...

Open in new window

will just print the percentage, so you just need to cut off the "%"
df -h --output=pcent <path> | tail -1 | cut -d"%" -f1

Open in new window

To list mount points run...

mount

Open in new window


And post output.
Avatar of noci
noci

FC is handled as a kind of SCSI, so your FC disk could very well be /dev/sda

fdisk -l /dev/sda    - might show more info to determine this.
dmesg   (shortly after booting, sometimes in /var/log/dmesg, search for the discovery recordss of the sda disk)