- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- if evaluation doesn't work fine
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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-29-2006 08:52 PM
05-29-2006 08:52 PM
I've following script:
"check_disk2" 10 lines, 330 characters
# ./check_disk2 75 90 /dev/vglabccs/lvol1
DISK CRITICAL - [7926736 used (39%) on /dev/vglabccs/lvol1]
# more check_disk2
FREE="$(bdf $3 | tail -1 | cut -d ' ' -f 21)"
PERC="$(bdf $3 | tail -1 | cut -d ' ' -f 25 | cut -d % -f 1)"
if [ $FREE -gt $2 ] ; then
echo "DISK CRITICAL - [$FREE used ($PERC%) on $3]"
elif [ $FREE -gt $1 ] ; then
echo "DISK WARNING - [$FREE used ($PERC%) on $3]"
else
echo "DISK OK - [$FREE used ($PERC%) on $3]"
fi
PERC is filesystem used percentage (without "%") and $1 and $2 are numbers. Problem is when I check if PERC is greater than $2 or $1 as always show DISK CRITICAL message:
# ./check_disk2 75 90 /dev/vglabccs/lvol1
DISK CRITICAL - [7926736 used (39%) on /dev/vglabccs/lvol1]
# ./check_disk2 20 20 /dev/vglabccs/lvol1
DISK CRITICAL - [7926736 used (39%) on /dev/vglabccs/lvol1]
#
I think problem is script check values as strings instead numbers, so it can evaluate as I need.
How can I evaluate them as numbers?
Thanks in advande for your help.
Regards,
Carles
Solved! Go to Solution.
- Tags:
- bdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2006 09:05 PM
05-29-2006 09:05 PM
Re: if evaluation doesn't work fine
by wrapping a " around your FREE and PERC evaluation you signal strings.
try:
FREE=`bdf $3 | tail -1 | cut -d ' ' -f 21`
PERC=`bdf $3 | tail -1 | cut -d ' ' -f 25 | cut -d % -f 1`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2006 09:12 PM
05-29-2006 09:12 PM
Re: if evaluation doesn't work fine
is there 25. field in bdf's output ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2006 09:39 PM
05-29-2006 09:39 PM
Re: if evaluation doesn't work fine
Both bdf commands has numbers (I already checked it).
About Peter message, I need numbers instead strings in order to evaluate if percentage I get with bdf command is greater than number I pass as parameter.
Thanks for your help.
Regards,
Carles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2006 10:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2006 10:14 PM
05-29-2006 10:14 PM
Re: if evaluation doesn't work fine
I was evaluating wrong variable, so script and if construction are fine.
Thanks for showing my little mistake that will allows me save a lot of work to some people.
Regards,
Carles