ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So this file is generated with a perl script. I would suggest you to sum up those things in that perl script. In perl you can print the required result easily there is a built-in sort function. (so print what you want means reverse sort list and print the ordered result)
Hi Daniel,
I removed the sed statement out of the script that removed the string from the output but I still got the same results. Looking at jm_out does it still not have tabs? I also attached the resultant file jm_temp. Thanks for all your help.
Brian
Last edited by master-of-puppets; 09-28-2014 at 07:27 PM.
Sadly it hangs and doesn't write anything to jm_temp. But hey thank you so much for your time. I think I'll just write a script that does everything including what the Perl script is now doing so I don't have to deal with this crazy output file. Thanks Daniel.
Last edited by master-of-puppets; 09-28-2014 at 10:49 PM.
Sadly it hangs and doesn't write anything to jm_temp.
This is puzzling because I tested with the large real-world InFile which you provided. Ran fine, with subsecond elapsed time, wrote 940 lines to the OutFile.
"Hangs and doesn't write anything" could be the program saying "Okay, I'm running, and waiting for input." Suggestion: check the way you specified the InFile. Keying error?
As a side not on possible keying errors, please note the space between -F and the quote "" as if it is not there you will get the issue you have mentioned.
This is puzzling because I tested with the large real-world InFile which you provided. Ran fine, with subsecond elapsed time, wrote 940 lines to the OutFile.
"Hangs and doesn't write anything" could be the program saying "Okay, I'm running, and waiting for input." Suggestion: check the way you specified the InFile. Keying error?
Daniel B. Martin
Hi Daniel,
The input file that we were working from was from this person who no longer works for the company and I didn't like the format of his output. It wasn't very useful. I created a new script that runs on each of the four build servers. It looks in local files only so as not to create any unnecessary network traffic. When each of the four servers finish generating their reports the files are then concatenated together and added to a weekly report along with some other data that was generated by my other script. The report is a csv file so that our admin can take it and generate pivot tables and graphs out of it.
Here's the new script that I came up with:
Code:
#!/bin/bash
OUTPUT_DIR=/share/es-ops/Build_Farm_Reports/WorkSpace_Reports
BASE=/export/ws
TODAY=`date +"%m-%d-%y"`
HOSTNAME=`hostname`
case "$HOSTNAME" in
sideshow) WORKSPACES=(bob mel sideshow-ws2) ;;
simpsons) WORKSPACES=(bart homer lisa marge releases rt-private simpsons-ws0 simpsons-ws1 simpsons-ws2 vsimpsons-ws) ;;
moes) WORKSPACES=(barney carl lenny moes-ws2) ;;
flanders) WORKSPACES=(flanders-ws0 flanders-ws1 flanders-ws2 maude ned rod todd to-delete) ;;
esac
if ! [ -f $OUTPUT_DIR/$HOSTNAME_top_5_workspace.csv ]; then
echo "Top 5 consumers of space per workspace on server `hostname` $TODAY" > $OUTPUT_DIR/"$HOSTNAME"_top_5_per_workspace.csv
echo ",,," >> $OUTPUT_DIR/"$HOSTNAME"_top_5_per_workspace.csv
echo ",,," >> $OUTPUT_DIR/"$HOSTNAME"_top_5_per_workspace.csv
for v in "${WORKSPACES[@]}"
do
echo "Top 5 consumers on workspace $v" >> $OUTPUT_DIR/"$HOSTNAME"_top_5_per_workspace.csv
echo ",,," >> $OUTPUT_DIR/"$HOSTNAME"_top_5_per_workspace.csv
find $BASE/$v -printf "%u %s\n" | awk '{user[$1]+=$2}; END{ for( i in user) print i " " user[i]}' | sed -e '/^[0-9]/d' | sed -e 's/root//g' | sed -e '/^ [0-9]/d' | awk '{print $1, $2/1024/1024/1024, "GB"}' | sort -n -r -k2 | head -5 >> $OUTPUT_DIR/"$HOSTNAME"_top_5_per_workspace.csv
echo ",,," >> $OUTPUT_DIR/"$HOSTNAME"_top_5_per_workspace.csv
done
fi
Sample output from host sideshow:
Code:
Top 5 consumers of space per workspace on server sideshow 09-29-14
,,,
,,,
Top 5 consumers on workspace bob
,,,
radickj 97.0708 GB
nichols2 90.4442 GB
sherryr 75.3845 GB
rabii 67.4304 GB
lefevre 39.0694 GB
,,,
Top 5 consumers on workspace mel
,,,
akrishna 125.225 GB
somyalip 124.585 GB
mvijayas 105.741 GB
release 102.279 GB
vuhang 83.4457 GB
,,,
Top 5 consumers on workspace sideshow-ws2
,,,
marlette 124.913 GB
iyershan 35.785 GB
starkd 19.3732 GB
jcook 3.8147e-06 GB
baylisn 3.8147e-06 GB
,,,
I want to thank you Daniel and everyone here. On a rivaling site they banned me for no good reason. They tried to contend that I was trying to trick the people on there into writing my scripts for me. None of the people on here have ever been condescending or judgmental like on that site. Thanks again.
Brian
Last edited by master-of-puppets; 09-30-2014 at 01:08 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.