Sponsored Content
Full Discussion: Need help the sum from loop
Top Forums Shell Programming and Scripting Need help the sum from loop Post 302998125 by ranjancom2000 on Thursday 25th of May 2017 02:40:19 PM
Old 05-25-2017
Lightbulb Need help the sum from loop

Hi all,

I have one host i need to run in loop to check the capacity from different frame and get the output to one file and sum it and convert to TB

this is Code

Code:
#!/bin/ksh
DATE=`date '+%d%m%y'`
for f in `cat /home/esx-capacity/esx-host.txt`
do
for g in `cat /home/esx-capacity/frame`
do
 symaccess -sid $g  list devinfo -ig $f |grep -i total |awk '{print $3} > /home/esx-capacity/num
done
done

echo $g - num >>  Report

esx-host.txt -test1server
frame -123,234,345

I need to get the capacity from each frame and sum all and provide the output as below
test1server - 1000 TB
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

While loop - The sum seems to be local

Hi, I am trying to extracting the sum of all varibles listed in a file. The code is as follows ##### FILE1 ######## Value1:2 Value2:2 Value3:6 Value4:5 ##### shell script ###### #!/bin/sh total=0 (2 Replies)
Discussion started by: eagercyber
2 Replies

2. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

3. Shell Programming and Scripting

Print sum and relative value of the sum

Hi i data looks like this: student 1 Subject1 45 55 Subject2 44 55 Subject3 33 44 // student 2 Subject1 45 55 Subject2 44 55 Subject3 33 44 i would like to sum $2, $3 (marks) and divide each entry in $2 and $3 with their respective sums and print for each student as $4 and... (2 Replies)
Discussion started by: saint2006
2 Replies

4. Shell Programming and Scripting

loop + sum + print using awk

Hi, I am unable sum of each column in the loop usng awk command. Awk is not allowing the parameters in the command. i am facing the below error. awk: 0602-562 Field $() is not correct. Source file abc.txt 100,200,300,400,500,600,700,800,900 101,201,301,401,501,601,701,801,901 ... (1 Reply)
Discussion started by: number10
1 Replies

5. Shell Programming and Scripting

Loop through file to sum conditionally

Hi, I have a file with header, detail and trailer records. HDR|111 DTL|abc|100|xyz DTL|abc|50|xyz TRL|150 I need to add the values in 3rd field from DTL records. Using awk, I am doing it as follows: awk -F'|' '$1=="DTL"{a += $3} END {print a}' <source_file> However, I want to... (3 Replies)
Discussion started by: delta21
3 Replies

6. Shell Programming and Scripting

For Loop & SUM

pcmpath query device |awk 'BEGIN{print "DEVICE NAME\tSERIAL"} /DEVICE NAME/ {printf "%s\t", $5; getline; print substr($2, length($2)-3)}' This script returns output like below to pull out "DEVICE NAME SERIAL". ...... hdisk28 110B hdisk29 1112 hdisk30 1115 hdisk31 1116 hdisk32 1128... (2 Replies)
Discussion started by: Daniel Gate
2 Replies

7. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies

8. Shell Programming and Scripting

Sum up numbers in a for loop

Hi i have to calculate some numbers, column by column. Herfore i used a for-loop.. for i in {4..26};do awk -F"," '{x'$i'+=$'$i'}END{print '$i'"\t" x'$i'}' file.tmp;done ----- printout ----- 4 660905240 5 71205272 6 8.26169e+07 7 8.85961e+07 8 8.60936e+07 9 7.42238e+07 10 5.6051e+07... (7 Replies)
Discussion started by: IMPe
7 Replies

9. Post Here to Contact Site Administrators and Moderators

awk to sum in Loop

i want code in awk with loop to get the sum * is delimiter in file TOTAL_AMOUNT=SUM(CLP04) suppose there are 12 CLP04 segment in my file i want to add upto 5 CLP04 then print next line after BPR segment after calculate the total amount CLP04 means ex ... (5 Replies)
Discussion started by: MOHANP12
5 Replies
VIRT-WHO(8)						      System Manager's Manual						       VIRT-WHO(8)

NAME
virt-who - Agent for reporting virtual guest IDs to Subscription Asset Manager. SYNOPSIS
virt-who [-d] [-i INTERVAL] [-b] [-o] [--sam|--satellite] [--libvirt|--vdsm|--esx|--rhevm|--hyperv] OPTIONS
-h, --help show this help message and exit -d, --debug Enable debugging output -b, --background Run in the background and monitor virtual guests -o, --one-shot Send the list of guest IDs and exit immediately -i INTERVAL, --interval=INTERVAL Acquire and send list of virtual guest each N seconds Virtualization backend Choose virtualization backend that should be used to gather host/guest associations --libvirt Use libvirt to list virtual guests [default] --vdsm Use vdsm to list virtual guests --esx Register ESX machines using vCenter --rhevm Register guests using RHEV-M --hyperv Register guests using Hyper-V Subscription manager Choose where the host/guest associations should be reported --sam Report host/guest associations to the Subscription Asset Manager [default] --satellite Report host/guest associations to the Satellite vCenter/ESX options Use this options with --esx --esx-owner=OWNER Organization who has purchased subscriptions of the products --esx-env=ENV Environment where the vCenter server belongs to --esx-server=SERVER URL of the vCenter server to connect to --esx-username=USERNAME Username for connecting to vCenter --esx-password=PASSWORD Password for connecting to vCenter RHEV-M options Use this options with --rhevm --rhevm-owner=OWNER Organization who has purchased subscriptions of the products --rhevm-env=ENV Environment where the RHEV-M belongs to --rhevm-server=SERVER URL of the RHEV-M server to connect to --rhevm-username=USERNAME Username for connecting to RHEV-M --rhevm-password=PASSWORD Password for connecting to RHEV-M Hyper-V options Use this options with --hyperv --hyperv-owner=OWNER Organization who has purchased subscriptions of the products --hyperv-env=ENV Environment where the Hyper-V belongs to --hyperv-server=SERVER URL of the Hyper-V server to connect to --hyperv-username=USERNAME Username for connecting to Hyper-V --hyperv-password=PASSWORD Password for connecting to Hyper-V Satellite options: Use this options with --satellite --satellite-server=SAT_SERVER Satellite server URL --satellite-username=SAT_USERNAME Username for connecting to Satellite server --satellite-password=SAT_PASSWORD Password for connecting to Satellite server ENVIRONMENT
virt-who also reads environmental variables. They have the same name as command line arguments but upper-cased, with underscore instead of dash and prefixed with VIRTWHO_ (e.g. VIRTWHO_ONE_SHOT). Empty variables are considered as disabled, non-empty as enabled USAGE
MODE virt-who has three modes how it can run: 1. one-shot mode # virt-who -o In this mode virt-who just sends list of guest UUIDs to the server and exits. 2. interval mode # virt-who This is default mode. virt-who will check and send list of guest UUIDs once per hour. This interval can be changed using "-i INTER- VAL" option where INTERVAL is number of seconds how often it should check and send the list. 3. background mode # virt-who -b This mode is similar to interval mode but it monitors events from libvirt and update list of guest UUIDs as soon as possible. It also does the interval check (interval can be altered by "-i INTERVAL" option). NOTE: virt-who don't print anything to terminal in this mode NOTE: monitoring for events requires libvirt backend, but this mode can be used with all backends. VIRTUALIZATION BACKEND virt-who can use couple of virtualization backends. 1. libvirt # virt-who # virt-who --libvirt Use libvirt as virtualization backend. This is default. NOTE: virt-who can monitor for events only in this mode. 2. vdsm # virt-who --vdsm Use vdsm as virtualization backend. 3. ESX # virt-who --esx --esx-owner=ESX_OWNER --esx-env=ESX_ENV --esx-server=ESX_SERVER --esx-username=ESX_USERNAME --esx-pass- word=ESX_PASSWORD Use ESX (vCenter) as virtualization backend and specify option required to connect to ESX server. 4. RHEV-M # virt-who --rhevm --rhevm-owner=RHEVM_OWNER --rhevm-env=RHEVM_ENV --rhevm-server=RHEVM_SERVER --rhevm-username=RHEVM_USERNAME --rhevm-password=RHEVM_PASSWORD Use RHEV-M as virtualization backend and specify option required to connect to RHEV-M server. 5. Hyper-V # virt-who --hyperv --hyperv-owner=HYPERV_OWNER --hyperv-env=HYPERV_ENV --hyperv-server=HYPERV_SERVER --hyperv-user- name=HYPERV_USERNAME --hyperv-password=HYPERV_PASSWORD Use Hyper-V as virtualization backend and specify option required to connect to Hyper-V server. SUBSCRIPTION MANAGER virt-who can report host/guest associations either to Subscription Asset Manager (SAM) or to Satellite. 1. Subscription Asset Manager # virt-who # virt-who --sam System must be registered using subscription-manager prior to using virt-who. Configuration for connecting to SAM is shared between subscription-manager and virt-who. This is default. 2. Satellite # virt-who --satellite --satellite-server=SAT_SERVER --satellite-username=SAT_USERNAME --satellite-password=SAT_PASSWORD This option can't be used for monitoring local guests, use rhn-virtualization-host instead. LOGGING
virt-who always writes error output to file /var/log/rhsm/rhsm.log. In all modes, excluding background ("-b"), it writes same output also to the standard error output. virt-who can be started with option "-d" in all modes and with all backends. This option will enable verbose output with more information. AUTHOR
Radek Novacek <rnovacek at redhat dot com> virt-who August 2013 VIRT-WHO(8)
All times are GMT -4. The time now is 06:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy