I have set up an ssh connection from my mac to XenServer. I'm able to get the metrics for CPU and memory using xentop command as shown below
Further, I wanted to get the CPU utilization using a bash script so that I So that I can get the average values for this, as shown below.
.
As you can see in the above figure, The problem I'm facing is that the first value is coming out to be zero, followed by other values. For all the times the first value always comes as 0. Can someone please explain what I'm doing wrong.
PS: The -bi3 means that the command will be executed thrice.
Please let me know if you have any questions.
Thanks in advance.
Related
I am trying to drive a BLDC motor using FOC algorithm. As shown in the figure, I have implemented an RPM controller on top of current control loop of FOC, where the output of RPM PI controller is directly fed to the Iqset of FOC block and Idset is kept at 0.
figure
Problem: I want Iqset to vary form 0 to 60A but this value is low, even at the stalling load Iqset reaches to only 4 to 5A. I have tried different values of Kp and Ki for tuning the RPM controller but unable to achieve the desired result.
I don't know where i am wrong, any help would highly be appreciated.
Further experimental Info: I have tried setting the Iqset at 0.25A just to eliminate the RPM controller, in that case motor runs at full speed with no problem. That brings my attention to the RPM controller but i don't know where i am wrong.
Thanks.
I am a student at university and I am stuck with some code for my assignment, and would appreciate the help from the community with this. I am very new to bash, and I would say that I do not know how to write bash at all, I struggle with it. I much prefer python or C# lol. Anyways, I am required to create a cluster monitor. I have got to create a simple menu with 2 options that allows the user to choose between the options "Cluster Status" and "Process Analytics". I have created the menu, it's very basic, and the code for that is below:
#!/bin/bash
clear
echo="Choose one of the following options: "
echo="1) Cluster Status"
echo="2) Process Analytics"
echo="3) Exit"
read ans:
if ["$ans"=='1']
then
echo="Loading..."
bash Cluster_Status.sh
elif ["$ans"=='2']
then
echo="Loading..."
bash Process_Analytics.sh
elif ["$ans"=='3']
then
echo="Loading..."
In this menu, I also need to make it so that when it has completed execution, it pauses and returns to the main menu.
I have got 5 nodes for the cluster, with sample data in them, which can be provided if anyone wants to help with this.
The part that I am most stuck with is the creating of the cluster status and the process analytics part of this.
The cluster status is a script that provides a screen and file printout of the current stats of the entire cluster, with all of its parameters set in a nodeconfig.read.me file, which I have got. The stats need to be presented either in a sum or as an average. For example, the total amount of CPUs would be a sum, and the total CPU load would be an average. I need to do this in a table, which I cannot figure out how to do, as I am limited by the amount of different functions I can use.
The process analytics section asks me to process the current processes that are running on each node, if there are any, and I need to present the following stats onscreen and also have it saved to a file:
• Most popular process (in terms of instances running)
• Most CPU demanding process (in terms of CPU usage)
• Most MEM demanding process (in terms of Memory usage)
• Most Disk demanding process (in terms of Disk usage)
• Most Net demanding process (in terms of Network usage)
• 5 top users of CPU/MEM/DISK & Net (separate tables)
I have got to do this in PuTTy, so I am limited to the built in functions of PuTTy, cat, grep, ls, pipe, echo, tr, tee, cut, touch, head, tail. These are the only things that I can use when writing this, and because of the limitation, I am stuck when trying to find how to write this. I have researched how to do this for the last week, and I still do not know how to complete this. I do not ask for this assignment to be completed by anyone. I just want to ask for help on how to use these commands to be able to create this script. Thank you for your help from now, and I am sorry if this is posted in the wrong area. I am still fairly new with using stackoverflow.
i'm working on a script that will monitor traffic on specific hosts from nagios. I have studied some scripts already made and have gathered almost all the info i need to do it but i have encountered a problem in identifying the OID's necessary for the traffic. I wanted to use IF-MIB::ifOutOctets.1 and IF-MIB::ifInOctets.1 to get the incoming and outgoing traffic but when i tested with the following line:
snmpwalk -v 1 -c public myComputer OID
i got the same result for both the OID's and that doesn't seem right. I'm wandering if there are other variables i could try instead of those i'm using now.
It would be useful even if you can point me to where i could find some info on the IF-MIB, because i can get all the values with snmpwalk but i don't know how to interpret them
Ok, i found the answer, after some searching. The values are equal because i was not asking the right interface(i was asking the loopback). There is this command snmpwalk -v 1 -c public hostname 1.3.6.1.2.1.31.1.1.1 that lists a lot of OID's and from there you can see 'IF-MIB::ifName' which stand for the interfaces. And if you execute IF-MIB::ifInOctets.x where x corresponds to the interface you are interested in you can find a number in bytes. I am not sure what it means, or how it's generated but i tested executing twice the command:
date ; snmpwalk -v 1 -c public myComputer ifOutOctets.x
at an interval of aprox 1 min, and then i subtracted the two values and devided them by the number of seconds that passed between the executions. I compared the value with the one obtained from iptraf and they kinda match, so i think you can used this way to find the traffic a station with snmp.
I want to find a way that I can call a command or method, and get an int with the cpu usage the moment I called it. Not like top, where it keeps refreshing.
I am writing an app in MacRuby, so I can either use a cl command, or some ruby api.
any thoughts?
thanks
edit: can I somehow call top and get one frame of it in ruby? and from there I can get the percentage I need. Although I guess this way is not ideal..
kinda SOLVED: top -l 1 on mac, top -n 1 on linux. It runs top for just one frame.
The w command gives a output which contains load average in the first line.
So try w | head -1
It's not an int, and not strictly "CPU usage", but it might be a start.
Have you checked whether there's a command-line option for top to just give an instantaneous once-only output, and have you looked at ps?
How can I get the display number that used while running Xvfb?
For example somebody run
./Xvfb :14
I need somehow to get the used display number 14.
Thanks in advance
on a unix system, run
ps -ef|grep Xvfb
and it should list it there with the process
There are two ways I can think of:
Look for the lock files, which will typically take the form \tmp.X*-lock, where * is the display number;
Look at the log files, typically \var\adm\xfvb.log, but might be anywhere. There should be a line which says which display xfvb started listening to.