I got this alert for one of my servers that disk space is -1. Confused, I decided to type the command directly on the server to see why it's returning such as weird value, and now I'm even more confused, because it's returning -869. This is the command:
df -kh returns this:
The command is suppose to do 100-89 and return the disk space left. It's been working for years, except tonight it randomly stopped. Huh?
Why would it have done this? What's the proper command to get what I want? I don't get why it decided to stop working just now though. Replacing $4 with $5 seems to work... but why? It worked fine before. I can see why it should be 5 because the % is the 5th element... but I'm still confused why it worked before and now it stopped.
OS is CentOS 6.5.
Code:
df -kh / | tail -1 | awk '{ print 100-$4 }'
df -kh returns this:
Code:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 8.5G 7.1G 971M 89% /
tmpfs 119M 0 119M 0% /dev/shm
/dev/sda1 485M 33M 427M 8% /boot
The command is suppose to do 100-89 and return the disk space left. It's been working for years, except tonight it randomly stopped. Huh?
Why would it have done this? What's the proper command to get what I want? I don't get why it decided to stop working just now though. Replacing $4 with $5 seems to work... but why? It worked fine before. I can see why it should be 5 because the % is the 5th element... but I'm still confused why it worked before and now it stopped.
OS is CentOS 6.5.
Last edited:
