Sponsored Content
Full Discussion: Storage usage over time
Top Forums Shell Programming and Scripting Storage usage over time Post 303003756 by venus699 on Wednesday 20th of September 2017 05:48:11 AM
Old 09-20-2017
i did another one, to collect data over time, the space of folder in filepath.
fell free to use it Smilie

also if any one know how to improve the code to be more efficient just share, im here to learn Smilie
Code:
filepath="/home/"
foldername="*"
data="data1.csv"
actualdata2="data2.csv"
actualdata3="data3.csv"
actualheader="data4.csv"
#---------------new file if $data dont exist yet
if [ ! -e $data ]; then
	echo " " >> $data
	for file in $filepath$foldername
		do
		du -sh $file | awk  '{print $2}' >>  $data
	done

fi
#---------------input from wc -l so later we can check if we need to update our file
countfilepath=`ls $filepath | wc -l`
countfileline=`awk '{if (NR!=1) {print}}' data1.csv | wc -l`

#------------- file existe do this.
if [ -e $data ]; then
#--------------- if number of files is not equal to number of lines in file
    if [ $countfilepath -eq $countfileline ]; then
		echo $(date +%m'-'%d) >> $actualdata2
		for file in $filepath$foldername
       		do
	        du -sh $file | awk  '{print $1}' >>  $actualdata2
		done
	    paste -d" " $data $actualdata2 > $actualdata3
	    mv $actualdata3 $data
            rm $actualdata2 

    else
	    mv $data $(date +%Y%m%d)'_'$(date +%H%M%S)'_'$data	
	    echo " " >> $data
	    	
		for file in $filepath$foldername
                    do
                    du -sh $file | awk  '{print $2}' >>  $data
	        done
	    echo $(date +%m'-'%d) >> $actualdata2	
		for file in $filepath$foldername
                    do 
                    du -sh $file | awk  '{print $1}' >>  $actualdata2
                done
            paste -d" " $data $actualdata2 > $actualdata3
            mv $actualdata3 $data
	    rm $actualdata2  
    fi
fi

 

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
uudemon(4)						     Kernel Interfaces Manual							uudemon(4)

NAME
uudemon.admin, uudemon.cleanu, uudemon.hour, uudemon.poll - Administrative shell scripts for polling remote systems, cleaning up spool directories, reporting status to the system administrator, and routine invocations of the uuxqt and uusched daemons SYNOPSIS
These shell scripts reside in the following directory: /usr/lib/uucp DESCRIPTION
All the scripts can be run from the command line or can be run automatically by the cron daemon. To automatically run the scripts, remove the comment character (#) from the beginning of the relevant line in the /var/spool/cron/crontabs/uucp file. This script reports status to the system administrator. It issues the uustat command to find out the status of uucp jobs. It mails the results to the uucp login ID. The script may be modified to send mail to any login ID such as the uucp administrative login ID (uucpa) or root. This script cleans up the /var/spool/uucp and /var/spool/uucppublic directories by running the uucleanup command. The uucleanup com- mand is run with the following parameters: -C7, -D7, X2, -o2, -W1. This script runs the uusched and uuxqt daemons in the background. This script polls the systems listed in the /usr/lib/uucp/Poll file. The uudemon.poll script should be scheduled before the uudemon.hour script. This allows uudemon.poll to create any command files before cron runs the uudemon.hour script. FILES
Contains the uudemon.admin, uudemon.cleanu, uudemon.hour and uudemon.poll files. Contains the uucp file. RELATED INFORMATION
Commands: cron(8), uucleanup(8), uusched(8), uuxqt(1) Files: /usr/lib/uucp delim off uudemon(4)
All times are GMT -4. The time now is 12:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy