Sponsored Content
Full Discussion: Storage usage over time
Top Forums Shell Programming and Scripting Storage usage over time Post 303003323 by venus699 on Wednesday 13th of September 2017 09:26:05 AM
Old 09-13-2017
actualy just tryed some awk comands. and did some research around it, but canīt find anything that compare 2 files. lest say:
  • Record the first file df -kP > file1.csv
  • compare file1 to max.csv and save the respective values that are greater than the previous we had on max.csv

I'm open to ideas, I'm trying to use awk maybe python but I have low skills.
I'm using opensuse.

---------- Post updated 09-13-17 at 08:26 AM ---------- Previous update was 09-12-17 at 09:52 AM ----------

This is what I have archive atm, still not done yet having some troubles with duplicate fields for some reason. if any one up to test it would be cool.

Code:
fileactual="results/fileactual.csv"
fileMaxMin="results/maxminconsumption.csv"
filemax="results/filemax.csv"
filemin="results/filemin.csv"

filecomparemax="results/comparemax.csv"
filecomparemax2="results/compare2max.csv"

filecomparemin="results/comparemin.csv"
filecomparemin2="results/compar2min.csv"


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

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

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



#--------past the 2 files so later we can compare
paste -d" " $fileactual $filemax > $filecomparemax
paste -d" " $fileactual $filemin > $filecomparemin

#--------remove first line from DF command.
awk '{if (NR!=1) {print}}' $filecomparemax > $filecomparemax2

awk '{if (NR!=1) {print}}' $filecomparemin > $filecomparemin2
#-------selecing the biger 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}' $filecomparemax2 > $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}' $filecomparemin2 > $filemin

echo 'THIS IS THE MAX VALUES

------------------------------' > $fileMaxMin
awk 'NR==1' $fileactual >> $fileMaxMin

cat $filemax >> $fileMaxMin

echo '-----------------------------

THIS IS THE LOWER VALUES

------------------------------' >> $fileMaxMin
awk 'NR==1' $fileactual  >> $fileMaxMin

cat $filemin >> $fileMaxMin

rm $filecomparemax
rm $filecomparemax2
rm $filecomparemin
rm $filecomparemin2
rm $fileactual


probably not the best approach looking for new ideas.

Last edited by rbatte1; 09-15-2017 at 12:35 PM.. Reason: Added ICODE tags and corrected spelling
 

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
csv(3tcl)							  CSV processing							 csv(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
csv - Procedures to handle CSV data. SYNOPSIS
package require Tcl 8.3 package require csv ?0.7.3? ::csv::iscomplete data ::csv::join values {sepChar ,} {delChar "} ::csv::joinlist values {sepChar ,} {delChar "} ::csv::joinmatrix matrix {sepChar ,} {delChar "} ::csv::read2matrix ?-alternate? chan m {sepChar ,} {expand none} ::csv::read2queue ?-alternate? chan q {sepChar ,} ::csv::report cmd matrix ?chan? ::csv::split ?-alternate? line {sepChar ,} {delChar "} ::csv::split2matrix ?-alternate? m line {sepChar ,} {expand none} ::csv::split2queue ?-alternate? q line {sepChar ,} ::csv::writematrix m chan {sepChar ,} {delChar "} ::csv::writequeue q chan {sepChar ,} {delChar "} _________________________________________________________________ DESCRIPTION
The csv package provides commands to manipulate information in CSV FORMAT (CSV = Comma Separated Values). COMMANDS
The following commands are available: ::csv::iscomplete data A predicate checking if the argument data is a complete csv record. The result is a boolean flag indicating the completeness of the data. The result is true if the data is complete. ::csv::join values {sepChar ,} {delChar "} Takes a list of values and returns a string in CSV format containing these values. The separator character can be defined by the caller, but this is optional. The default is ",". The quoting character can be defined by the caller, but this is optional. The default is '"'. ::csv::joinlist values {sepChar ,} {delChar "} Takes a list of lists of values and returns a string in CSV format containing these values. The separator character can be defined by the caller, but this is optional. The default is ",". The quoting character can be defined by the caller, but this is optional. The default is '"'. Each element of the outer list is considered a record, these are separated by newlines in the result. The ele- ments of each record are formatted as usual (via ::csv::join). ::csv::joinmatrix matrix {sepChar ,} {delChar "} Takes a matrix object following the API specified for the struct::matrix package and returns a string in CSV format containing these values. The separator character can be defined by the caller, but this is optional. The default is ",". The quoting character can be defined by the caller, but this is optional. The default is '"'. Each row of the matrix is considered a record, these are separated by newlines in the result. The elements of each record are formatted as usual (via ::csv::join). ::csv::read2matrix ?-alternate? chan m {sepChar ,} {expand none} A wrapper around ::csv::split2matrix (see below) reading CSV-formatted lines from the specified channel (until EOF) and adding them to the given matrix. For an explanation of the expand argument see ::csv::split2matrix. ::csv::read2queue ?-alternate? chan q {sepChar ,} A wrapper around ::csv::split2queue (see below) reading CSV-formatted lines from the specified channel (until EOF) and adding them to the given queue. ::csv::report cmd matrix ?chan? A report command which can be used by the matrix methods format 2string and format 2chan. For the latter this command delegates the work to ::csv::writematrix. cmd is expected to be either printmatrix or printmatrix2channel. The channel argument, chan, has to be present for the latter and must not be present for the first. ::csv::split ?-alternate? line {sepChar ,} {delChar "} converts a line in CSV format into a list of the values contained in the line. The character used to separate the values from each other can be defined by the caller, via sepChar, but this is optional. The default is ",". The quoting character can be defined by the caller, but this is optional. The default is '"'. If the option -alternate is specified a slightly different syntax is used to parse the input. This syntax is explained below, in the section FORMAT. ::csv::split2matrix ?-alternate? m line {sepChar ,} {expand none} The same as ::csv::split, but appends the resulting list as a new row to the matrix m, using the method add row. The expansion mode specified via expand determines how the command handles a matrix with less columns than contained in line. The allowed modes are: none This is the default mode. In this mode it is the responsibility of the caller to ensure that the matrix has enough columns to contain the full line. If there are not enough columns the list of values is silently truncated at the end to fit. empty In this mode the command expands an empty matrix to hold all columns of the specified line, but goes no further. The overall effect is that the first of a series of lines determines the number of columns in the matrix and all following lines are truncated to that size, as if mode none was set. auto In this mode the command expands the matrix as needed to hold all columns contained in line. The overall effect is that after adding a series of lines the matrix will have enough columns to hold all columns of the longest line encountered so far. ::csv::split2queue ?-alternate? q line {sepChar ,} The same as ::csv::split, but appending the resulting list as a single item to the queue q, using the method put. ::csv::writematrix m chan {sepChar ,} {delChar "} A wrapper around ::csv::join taking all rows in the matrix m and writing them CSV formatted into the channel chan. ::csv::writequeue q chan {sepChar ,} {delChar "} A wrapper around ::csv::join taking all items in the queue q (assumes that they are lists) and writing them CSV formatted into the channel chan. FORMAT
The format of regular CSV files is specified as [1] Each record of a csv file (comma-separated values, as exported e.g. by Excel) is a set of ASCII values separated by ",". For other languages it may be ";" however, although this is not important for this case as the functions provided here allow any separator character. [2] If and only if a value contains itself the separator ",", then it (the value) has to be put between "". If the value does not con- tain the separator character then quoting is optional. [3] If a value contains the character ", that character is represented by "". [4] The output string "" represents the value ". In other words, it is assumed that it was created through rule 3, and only this rule, i.e. that the value was not quoted. An alternate format definition mainly used by MS products specifies that the output string "" is a representation of the empty string. In other words, it is assumed that the output was generated out of the empty string by quoting it (i.e. rule 2), and not through rule 3. This is the only difference between the regular and the alternate format. The alternate format is activated through specification of the option -alternate to the various split commands. EXAMPLE
Using the regular format the record 123,"123,521.2","Mary says ""Hello, I am Mary""","" is parsed into the items a) 123 b) 123,521.2 c) Mary says "Hello, I am Mary" d) " Using the alternate format the result is a) 123 b) 123,521.2 c) Mary says "Hello, I am Mary" d) (the empty string) instead. As can be seen only item (d) is different, now the empty string instead of a ". BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category csv of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
matrix, queue KEYWORDS
csv, matrix, package, queue, tcllib CATEGORY
Text processing COPYRIGHT
Copyright (c) 2002-2011 Andreas Kupries <andreas_kupries@users.sourceforge.net> csv 0.7.3 csv(3tcl)
All times are GMT -4. The time now is 02:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy