Hi all,
I am interning in a unix department and am very new to programming. I am supposed to write a script that counts the amount of filesystems a server has allocated, and the amount free. This is what I was given to start with:
I am very new and not much of this makes sense. I was told that i would need to have to add a couple more variables which would show the total filesystems free, and allocated. Any help is appreciated. Thanks.
Im very tempted to reply by giving clues and where to look since you are very new to UNIX
(how much is very new? - Why did you not post something in dummies then?)
1) Learning the hard way! (but then Im sure you will have learned alot by the time you finished...)
- a - Start by reading the script and look at all words that seem to be unix commands, the look what tha manuals say : man <command> e.g. man df
- b- Uncomment (remove the #) the line set -x and place it after the first line (To undestand this part, its man sh or ksh...)
- c - Run the script, and see what it does...
- d - Modify the script to see what happens (e.g. remove grep -v Free|... and again something else etc...)
- e - If you did not make a copy before, you are now doomed... (ask your collegues for the script again...) Now you shou have an alomst clear understanding of what is going on, if not post here in dummies what you executed, the result and what you dont understand...
.
.
- f - Try to figure out how you will have to modify your script to achieve the requested task and do it.
- G - Come back here with your freshly written script explaining what you wanted to do, the result you got, and explain your issue.
We will gladly comment your work, your progress in understanding, and hopefully assist you through the debugging of now your own script
So courage!
..
Waiting to see your first question...
---------- Post updated at 18:18 ---------- Previous update was at 18:17 ----------
Should I bother for
2) ?
---------- Post updated at 18:40 ---------- Previous update was at 18:18 ----------
2) You could start by comparing the output of df -m versus your script then figure out what is missing...(in both cases in regard of the appointed given task...)
Last edited by vbe; 07-09-2009 at 01:32 PM..
Reason: errata
Very new meaning that I have jumped into this with no background experience and am trying getting my feet wet. I'm pretty much learning as I go and seeing if this is a field i would like to pursue.
ok, i have rearranged the script a little bit. I have left in the comment for set -x because it seems that the information is a little more organized for me that way. This is what I have right now:
Now my first question, is how would I be able to separate this info into easier to read columns. Also how can i add the titles as the first line?
A variable that i believe i have to use is something for the entire server. I would need to have the script calculate the totals from "InUse" and "FREE" and have that echo back at the end. I hope this makes sense and thank you for your time.
My understanding of the appointed task (but then I may be wrong - I speak french ordinarily... and so forgive my spelling and curious syntax...) was :
Count how many filesystems are on the host and how much free space is left ( per filesystem or globally?)
It could be display as the script does and add an extra line where you cumulate the columns to give a total...
set -x tells the shell to work in debug mode, and so each line will be shown with the command executed and if successfull.
Your code line:
tells you what its reading, so you can use it to do your title e.g
but needs formatting...
just add that echo before the df line...
---------- Post updated at 19:46 ---------- Previous update was at 19:42 ----------
I believe i need to count all the space that is left on the host (which i think is globally?) and have that echo back. along with that, i would need to have a return of all the space that is allocated to the filesystems on the host.
I added in the line that you gave me for the title. Is there anyway that i could have the information that is returned below them form into columns below the title?
my return is
I would like for it to look like this:
and then somewhere have the total free and total InUse.
calculation:
there is a command: bc
but here are some clues for you to work on:
1:Search the forum, there are plenty of examples!
2: you can do this with the shell:
let DIFF=$WANTED-$GOT
sum=`expr $1 + $2`
---------- Post updated at 20:08 ---------- Previous update was at 20:01 ----------
Leave aside the formatting for now and conentrate on your calculation work!
You will need as many new variable as totals you want to display so if only the total of "InUse" and "FREE", that would be 2: TOTINUSE and TOTFREE
Need to leave... Hope someone else will follow you soon
All the best
---------- Post updated 07-10-09 at 17:05 ---------- Previous update was 07-09-09 at 20:08 ----------
Everything is done inside the script, i am just trying to figure out how to use printf for it. Im looking all over the place but nothing is dumbed down enough for me haha.
Hello,
I am running ubuntu 14.04 in a server with 32GB ram.
Due to receiving "high load" errors during ssh connection, I took a look at what's happening from command line. I detected that 20GB of total memory was allocated to a program.
Below you can see some initial part of installation... (4 Replies)
Hi ,
I Would like to know the space allocated by adding up all the allocated space to group of filesystems ..
example ,
df -h|grep /db | awk '{ print $4 }' ---> giving me all the used space on the filesystem but need to know the total used space by adding up all the values (3 Replies)
I want to find the size of the total memory allocated on the heap for the following statement:
int* a = new int;How can I use the sizeof operator for this?
I used:
printf("\t===> %d\n",sizeof(*a));
Is this statement correct?
I have asked the question because when I checked the memory of... (13 Replies)
Actually for a process to run it needs text, stack , heap and data segments. All these find a place in the physical memory.
Out of these 4 only heap does exist after the termination of the process that created it. I want to know the exact reason why this happens. Also why the other process need to... (20 Replies)
I have a pointer to a structure containing an integer pointer:
struct members {
int id;
int *neigh;
};
The number of members N and its neighbors M change as the code runs, so I allocate the memory dynamically:
members *grid = malloc(sizeof(members)*N);
for(i=0;i<N;i++)... (2 Replies)
Hey guys,
I am somewhat new to Solaris - and very new when it comes to mounts.
My problem is that when I installed Solaris, I allocated way too little diskspace to my / mount (it first became obvious now, however, because of new needs).
bash-3.00# df -h
Filesystem size ... (25 Replies)
i am working with solaris 9 and my disk usages are
# df -k
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c0t0d0s0 2148263 1902721 202577 91% /
/proc 0 0 0 0% /proc
mnttab 0 0 0 ... (3 Replies)
Hi,
I have a server that is getting the following alarm a couple times a day:
Mar 25 10:56:54 hostname xntpd: too many recvbufs allocated (30)
Mar 25 10:56:54 hostname xntpd: too many recvbufs allocated (30)
I know this is some sort of NTP related issue but I need to gauge the severity of... (0 Replies)
Hi,
How to find out what is the maximum memory allocated to TOMCAT server in SunOS 5.8?
The Tomcat server crashes down during peak times....
Regards (1 Reply)