- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: verif disk usage
Operating System - Linux
1753502
Members
4954
Online
108794
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2011 04:16 AM
тАО05-25-2011 04:16 AM
verif disk usage
Hello,
i look for script to verify disk usage
on linux server,
i start with ' df -H | grep -vE '^Filesystem|tmpfs|cdrom '
but now i want to extract just
pattern with a "%" in line,
like "13%" for example.
Thanks a lot
i look for script to verify disk usage
on linux server,
i start with ' df -H | grep -vE '^Filesystem|tmpfs|cdrom '
but now i want to extract just
pattern with a "%" in line,
like "13%" for example.
Thanks a lot
Bonjour
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2011 05:42 AM
тАО05-25-2011 05:42 AM
Re: verif disk usage
If I understood correctly what you're looking for, you want just the Use% part of each line.
It's the 5th whitespace-separated "word" on the line, so awk can pick it out nicely.
However, some versions of df will add a line feed after the device name if the name is so long it would push the columns out of alignment. To avoid this, add option -P to the df command:
df -PH | grep -vE '^Filesystem|tmpfs|cdrom ' | awk '{ print $5; }'
You can even pick multiple columns, in any order you wish. For example, to output the name of the mount point and its Use% value only:
df -PH | grep -vE '^Filesystem|tmpfs|cdrom ' | awk '{ print $6, $5; }'
MK
It's the 5th whitespace-separated "word" on the line, so awk can pick it out nicely.
However, some versions of df will add a line feed after the device name if the name is so long it would push the columns out of alignment. To avoid this, add option -P to the df command:
df -PH | grep -vE '^Filesystem|tmpfs|cdrom ' | awk '{ print $5; }'
You can even pick multiple columns, in any order you wish. For example, to output the name of the mount point and its Use% value only:
df -PH | grep -vE '^Filesystem|tmpfs|cdrom ' | awk '{ print $6, $5; }'
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2011 07:44 AM
тАО05-25-2011 07:44 AM
Re: verif disk usage
Hi,
You can also make use of python, use the os module ( i need to search for the exact function), search the python documentation. Then you can generate reports, make a cool ui etc
I prefer python over traditional shell scripts since python scripts tend to be more maintainable. But that's just me!.
--Lucifer
You can also make use of python, use the os module ( i need to search for the exact function), search the python documentation. Then you can generate reports, make a cool ui etc
I prefer python over traditional shell scripts since python scripts tend to be more maintainable. But that's just me!.
--Lucifer
"To Denouce the Evils of Truth and Love. To cause may hem and destruction and necromancy , Lucifer is here"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2011 09:33 AM
тАО05-27-2011 09:33 AM
Re: verif disk usage
df -HP|awk '{if (NR!=1 && $5 == "13%") print $6 "\t" $5}'
This will output the filesystem and its usage only if the usage is exactly 13%.
Is this something you need?
This will output the filesystem and its usage only if the usage is exactly 13%.
Is this something you need?
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP