Folks
I have extracted some raw data from our servers and wish to do some simple arithmetic to it. The end result that I wish to get is
1. The amount of data that is presently used.
2. The amount allocated to them
3. The % of data that is used of allocated space.
I can extract the first two fields fairly easily, but I am not able to get the calculation right with "bc". I am able to use bc "interactively" i.e. from the command line, but when I introduce variables to it, it refuses to process the data. Can you please assist? Thanks.
#-------------------------------------------------
# Declare variables
#-------------------------------------------------
PASSWD='*****'
RAW='/home/clarence/docs/scripts/tmp/qreport_server1.txt'
LIMIT='/home/clarence/docs/scripts/tmp/limit.txt'
USAGE='/home/clarence/docs/scripts/tmp/usage.txt'
#-------------------------------------------------
# Get the information from the filers
#-------------------------------------------------
rsh server1 -l root:$PASSWD "quota report -t" > /home/clarence/docs/scripts/tmp/qreport_server1.txt
#-------------------------------------------------
# Grep out needed information
#-------------------------------------------------
grep -i group_one $RAW | awk '{print $6}' > $LIMIT
grep -i group_one $RAW | awk '{print $5}' > $USAGE
# echo "scale=4;6/3" | bc --> this works.
# echo "scale=4;$USAGE/$LIMIT" | bc --> DOES NOT work. Why?
# PERCENT=`bc $USAGE/$LIMIT \*100` --> this does not work
#-------------------------------------------------
# Generate the report
#-------------------------------------------------
echo "Quota Report for FM_group"
echo "Current data usage is: " `cat "$LIMIT"`
echo "Quota limit is set to: " `cat "$USAGE"`
echo
echo "Percentage of Data to Quota Limit is: " `cat "$PERCENT"`
I have extracted some raw data from our servers and wish to do some simple arithmetic to it. The end result that I wish to get is
1. The amount of data that is presently used.
2. The amount allocated to them
3. The % of data that is used of allocated space.
I can extract the first two fields fairly easily, but I am not able to get the calculation right with "bc". I am able to use bc "interactively" i.e. from the command line, but when I introduce variables to it, it refuses to process the data. Can you please assist? Thanks.
#-------------------------------------------------
# Declare variables
#-------------------------------------------------
PASSWD='*****'
RAW='/home/clarence/docs/scripts/tmp/qreport_server1.txt'
LIMIT='/home/clarence/docs/scripts/tmp/limit.txt'
USAGE='/home/clarence/docs/scripts/tmp/usage.txt'
#-------------------------------------------------
# Get the information from the filers
#-------------------------------------------------
rsh server1 -l root:$PASSWD "quota report -t" > /home/clarence/docs/scripts/tmp/qreport_server1.txt
#-------------------------------------------------
# Grep out needed information
#-------------------------------------------------
grep -i group_one $RAW | awk '{print $6}' > $LIMIT
grep -i group_one $RAW | awk '{print $5}' > $USAGE
# echo "scale=4;6/3" | bc --> this works.
# echo "scale=4;$USAGE/$LIMIT" | bc --> DOES NOT work. Why?
# PERCENT=`bc $USAGE/$LIMIT \*100` --> this does not work
#-------------------------------------------------
# Generate the report
#-------------------------------------------------
echo "Quota Report for FM_group"
echo "Current data usage is: " `cat "$LIMIT"`
echo "Quota limit is set to: " `cat "$USAGE"`
echo
echo "Percentage of Data to Quota Limit is: " `cat "$PERCENT"`