I wrote a script that builds disk groups using vxvm, and it works really good. I added a feature that would tell you the max size you could build your your lvol to. I do this by getting the size of the disks I am using in KB, I subtract 5104 from it, and then I multiply it by the number of disks I am using to build my disk group. I set this to a variable called $NUMBER for use throughout the script. The function is finished, it outputs the answer to a file called value.txt. For some reason it works great until $NUMBER = 5 or more.
Below is the section of the script that is giving me issues:
Code:
function adder_func
{
TYPE=$1
if [ -s sizes.$TYPE ]; then
let sum=0
for i in `cat sizes.$TYPE`
do
((i=$i - 5104))
((new_sum=$i + $sum))
sum=$new_sum
done
((last_sum=$new_sum*$NUMBER))
echo ${last_sum}
else
break
fi
}
## Call the adder_func function and output to value.txt to get the max size for your lvol.
adder_func size > value.txt
When the function is with an option called 'size' it reads from a file called sizes.size (sizes.$TYPE). As you see, the size option is the same as the $TYPE variable.
Output from sizes.size (which is the size of the disks in KB):
524288000
Here is the output from value.txt when the $NUMBER variable = 5:
-1149269920
When I do the math, of course it shouldn't be a large negative number:
root@server:/root_home> bc -l
524288000-5104
524282896
524282896*5
2621414480
So it should be 2621414480 or 2499.97GB, or about 2.5TB.
Am I surpassing the numerical limits of the function?
function adder_func
{
TYPE=$1
if [ -s sizes.$TYPE ]; then
let sum=0
for i in `cat sizes.$TYPE`
do
((i=$i-5104))
((new_sum=$i + $sum))
sum=$new_sum
done
((meg_sum=$new_sum/1024))
((gig_sum=$meg_sum/1024))
((last_sum=$gig_sum*$NUMBER))
echo ${last_sum}G
else
break
fi
}
## Call the adder_func function and output to value.txt to get the max size for your lvol.
adder_func size > value.txt
Now everything will be GigaByte readable, instead of in KBytes.
And now the output of value.txt:
2495G
And the effect:
Are you ready to create a lvol in fakedg?
Enter 'y' for Yes or 'n' for No :y
Enter the name of your lvol.
Lvol name :fakelvol
Enter the size of your lvol.
The maximum size is: 2495G
Hi Experts,
I am in need for some help. My competence level on unix is not at all helping me to resolve this. Please help.
My Input for a system command is as under:
Counters are getting pegged each hour. I need to have a difference printed rather than pegged counter values.
Counter... (2 Replies)
Hello, I have a technical problem: I work on AIX 7.1 with Java 1.7 (32 and 64 bit) and I make an application that intercepts certain functions related to time. In this application there is a Java JNI agent with whom I can intercept the Java "getLastModifiedTime" no problem but I am unable to... (5 Replies)
I am trying to allow the user to be notified that the id has already taken from the file "record" and that the user has to contain a numerical figure as well. however when i run it, it will only stay at the please enter a number section and does not change. do u know where is the problem?
... (2 Replies)
Hi,
I am new to shell script. I want to count to Delimiter count for my source file. For that I have written script. When I tried to execute the script I could not able to view the results. It throws errors. I don't know what the problem is. My aim is I want to store the delimiter count in one... (4 Replies)
Hi,
I need some help.
Shell script counter. i need to add condition to check if counter is more than 10 and longer than 3 hours? it runs every 5 mins. it only check count and send email right now.
it runs in cron as below
gregcount.ksh gregdb 10 > /tmp/gregcount.out 2> /tmp/gregcount.err
... (1 Reply)
Hi,
I have a client-server socket program. It has been working fine for over a year, but recently it started to show strange behavior.:confused:
After the server program runs for a while, it will show in the top command saying it is using lots of CPU, MEM. I assume it means the server code is... (1 Reply)
I have generated a script that will email a list of people if a certain PID is not running, using "mailx". I have the script running every 5 minutes as a cron job.
I want the script to stop sending an email, if the email has been sent 5 times (meaning PID is dead). I want this so that my... (3 Replies)
I have the following
for(( i=1; 1<=2; i++))
do
e1=123 n1=123
e2=456 n2=456
coord= $e1,$n1
echo "coordinate=$coord"
done
exit
this echos
coordinate=123,123
I need it to loop so:
loop1
coord=$e1,$n1
loop2 (3 Replies)