Sponsored Content
Full Discussion: Storage usage over time
Top Forums Shell Programming and Scripting Storage usage over time Post 303003536 by venus699 on Friday 15th of September 2017 11:17:16 AM
Old 09-15-2017
i made it work, does the job i needed.
fell free to use it, dont forget when opening the file maxminconsumption.csv to import it into excel,i use -> , to discting each columm.

Cheers Smilie


Code:
#|/bin/bash
# ----------------------------------------------- #
#          storageconsumption.sh                  #
#     Storage max / min values                  #
#                   Version 1.0                        #
#                   by:                                    #
# ----------------------------------------------- #

fileactual="fileactual.csv"
fileMaxMin="maxminconsumption.csv"
filemax="filemax.csv"
filemin="filemin.csv"
filecomparemax="comparemax.csv"
filecomparemin="comparemin.csv"



#--------print all the df data to the actualfile
df -hP | awk '{print $0}' > $fileactual


#-------Check if file exists, if it donst will save fresh data from DF command
if [ ! -f $filemax ]; then
  df -hP | awk '{print $0}' > $filemax
fi

if [ ! -f $filemin ]; then
  df -hP | awk '{print $0}' > $filemin
fi


#--------past the 2 files in a new one so in the next command "awk" we can compare the columms
paste -d" " $fileactual $filemax > $filecomparemax
paste -d" " $fileactual $filemin > $filecomparemin


#-------selecing the biger value on column 3 = used space and print the total row. colummns 1 to 6 is from the actual file, 7 to 12 is from the filemax / filemin
awk '$3 > $9 {print $1","$2","$3","$4","$5","$6}; $3 < $9 {print $7","$8","$9","$10","$11","$12} ; $3==$9 {print $7","$8","$9","$10","$11","$12}' $filecomparemax > $filemax
#-------selecing the lower value on column 3 = used space and print the row
awk '$3 < $9 {print $1","$2","$3","$4","$5","$6}; $3 > $9 {print $7","$8","$9","$10","$11","$12} ; $3==$9 {print $7","$8","$9","$10","$11","$12}' $filecomparemin > $filemin

#-------print the header of our final file.
echo 'THIS IS THE MAX VALUES

-----------------,-----------------,-----------------,-----------------,-----------------,----------------- ' > $fileMaxMin

#-------print our MAX values
cat $filemax >> $fileMaxMin

echo '-----------------,-----------------,-----------------,-----------------,-----------------,----------------- 

THIS IS THE LOWER VALUES

-----------------,-----------------,-----------------,-----------------,-----------------,----------------- ' >> $fileMaxMin

#-------print our MIN values
cat $filemin >> $fileMaxMin

#------- delete desnecessary files.
rm $filecomparemax
rm $filecomparemin
rm $fileactual

This User Gave Thanks to venus699 For This Post:
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

time command usage in sh script

how do i get the following type of information when we have a time command in sh script. 0.01user 0.00system 1:32.98elapsed 0%CPU (0avgtext+0avgdata 5360maxresident)k 0inputs+0outputs (342major+0minor)pagefaults 0swaps I always see the following for the time command real 0m0.000s user ... (7 Replies)
Discussion started by: kris_search
7 Replies

2. AIX

AIX 4.3 storage usage report

hi, i'm new to this company and i'm using old AIX 4.3 with DAS and SSA storage. What is the best way to query a report for disk capacity, usage, free, etc. I know in AIX 5 there's a command for "du -g /" or "du -m /" to report the total usage but I'm not using AIX5. In AIX 4.3 I can use "df... (5 Replies)
Discussion started by: venerayan
5 Replies

3. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

4. Programming

usb real time video storage

Hi, Am working on an embedded device with a camera and I would want to send the video data it streams to a usb device connected to it. Am using the c language and of course Linux (Fedora). Any help and suggestions are most welcomed. Thanks in advance.:) (1 Reply)
Discussion started by: THSstd
1 Replies

5. Shell Programming and Scripting

Users and their storage usage

Hey, I'm trying to make a script that can list users and their storage usage in a file. Im trying to get it to where the format is: User xxkbs User2 xkb and so on. So far I figured out how to get the users, but I cannot figure out how to get the storage usage per user. This is what... (2 Replies)
Discussion started by: HakerDemon
2 Replies

6. UNIX for Advanced & Expert Users

Find memory usage along with time

Hi Guys, I have a script. It calls an executable inside (programmed in C). I will have to find the execution time of that script and amount of memory consumed by that process as well. #!/bin/sh echo "Script starting" echo "executable staring" executable parm1 parm2 parm3 echo... (4 Replies)
Discussion started by: PikK45
4 Replies

7. UNIX for Dummies Questions & Answers

Memory usage per user,percent usage,sytem time in ksh

Let's say i have 20 users logged on Server. How can I know how much memory percent used each of them is using with system time in each user? (2 Replies)
Discussion started by: roy1912
2 Replies

8. Linux

Ps command on cpu usage and time

Hi All, Am very new to Linux and unix ...need below help . need to list of process consuming more than 40% cpu and which are older than 10 days of a particular user .... Thanks V (4 Replies)
Discussion started by: venky456
4 Replies
All times are GMT -4. The time now is 04:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy