tracking high water usage of mount point

Oracle Linux 5.6 x86-64

This may or may not end up being a strictly 'scripting' issue, but I'll start here.

I'm looking for a way of establishing the 'max' or 'high water' useage of a given mount point over a period of a week. My first thought was for a cron job, as:

*/5 * * * * df -h | grep /backup | >> /home/me/dfhist.lis

which works fine as far as it goes, but it would be nice to be able to append the current date/time to each. While ultimately what I need is to establish the high and low usage points during a week, but would be nice to also see the pattern.

If a completely different approach will work, I'm all ears, but I'm not the SA and don't have root access.

Rest assured, it is scripting.

No problem: the commands you have in cron now go into a script, along with a call to "/usr/bin/date". You might probably want to put the output of both commands into variables and mince them through some text filter (awk, sed, ... pick your choice) to achieve the output format you want. Test the script on the command line until you are satisfied with its output. It should output exactly one line.

Then put into cron a call to your script instead of the call to "df" with a redirection as you already had it.

You don't have to be. Every user has his own crontab (not sure where it is located in Oracle Linux - in AIX it is located in "/var/spool/cron/crontabs/<user>" and probably it is in some similar location). Put it there and you are all fine. It is theoretically possible to block a users access to the cron facility ("/etc/cron.deny"), but this is rarely done.

If you need help writing such a script, report back - i didn't want to spoil the fun of writing it yourself.

I hope this helps.

bakunin

Oh, I know my immediate question is. I was leaving open the possibility that there was some built-in capability/utility that was already tracking this information - something of which I was/am totally unaware. Somehting like "gee, you don't need to script that at all, just execute the 'chkframbo' command.

That I can do. I was hoping to be able to just concatenate/stream the returned value of the call to date (`date +format`) into my redirection. I'd played around with piping to awk before redirecting the final output, but got nowhere.

Oh, I'm quite familiar with cron. My comment about not being an SA and not having root goes back to my being open to getting the information I need with some unknown (to me) os utility ... implying that if such utility exists but requires root access, I wouldn't be able to use it.

I think I can handle the script. Was hoping to get something I could do in a single (with piping and redirection) command.

Thanks for the response.

You can do that:

/usr/bin/printf "[%s] %s\n" "$(/usr/bin/date +"<format>")" "$(/usr/bin/df -h /backup | /usr/bin/tail -1)"

See "man date" for suitable format options. Once the output suits you put it into cron with a redirection to your logfile.

I hope this helps.

bakunin

1 Like

That got it. I was just working from the wrong end -- trying to get the df output first. Thanks for the assist. :b: