-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kvm plugins improvements #186
base: master
Are you sure you want to change the base?
Conversation
Closing and opening old pull request, to have it tested by travis-ci. |
res = {} | ||
macs_to_inf = find_macs_to_inf() | ||
interfaces = {} | ||
for e in Popen('cat /proc/net/dev | awk \'{ print $1 ":" $9 }\'', shell=True, stdout=PIPE).communicate()[0].split('\n'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line seems to contain a bug, which should be fixed before we can merge.
% cat /proc/net/dev | awk '{ print $1 ":" $9 }'
Inter-|:
face:multicast|bytes
eth0::0
eth1::5246
virbr0::0
lo::0
The format on my box is:
% cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
eth0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
eth1: 3833806033 3143411 0 0 0 0 0 5246 168429641 1939069 0 0 0 0 0 0
virbr0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
lo: 86071620 477326 0 0 0 0 0 0 86071620 477326 0 0 0 0 0 0
...which looks more human-readable than strictly parsable.
On a reasonably modern linux kernel, perhaps what you can find with "find /sys/class/net/*/statistics/" may be more useful.
@duritong: are you still interested in this pull request? What do you think about the issues above? |
On RedHat the binary that is used is called qemu-kvm not kvm.
So I reworked the whole stuff and I hope problems to be solved by now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on these plugins!
I added some suggestions.
Regarding the red-hat-specific(?) plugin: what is the difference between this one and the general kvm_net plugin?
Maybe you could merge these into a single plugin handling both cases? Working with code copies is (as you already noticed with the other plugins) a burden, that should be avoided, if possible.
else: | ||
kvm = Popen("which kvm", shell=True, stdout=PIPE) | ||
kvm.communicate() | ||
return not bool(kvm.returncode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose to phrase this clearer (instead of relying on the coincidence of the implicit interger/boolean conversion):
return kvm.returncode == 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't change the original behavior. Just added one that fits more for RHEL/CentOS.
In general this part is from my point of view problematic in 2 cases:
- which lookups are expensive
- we're not only looking at kvm.
I can change it in general, but as I said the intend of my PR was not to change the original behavior. But I can come up with general improvements, if people would like to see that.
def list_pids(): | ||
''' Find the pid of kvm processes | ||
@return a list of pids from running kvm | ||
''' | ||
pid = Popen("pidof qemu-system-x86_64", shell=True, stdout=PIPE) | ||
pid = Popen("pidof qemu-kvm qemu-system-x86_64 kvm", shell=True, stdout=PIPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this list of names lack "qemu-system-i386"?
Other architectures are probably not available due to kvm being bound to intel/amd - right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above I did not change the original behavior. So I just kept qemu-system-x86_64
as it was the current behavior. I can add though other architectures as well.
else: | ||
kvm = Popen("which kvm", shell=True, stdout=PIPE) | ||
kvm.communicate() | ||
return not bool(kvm.returncode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
def list_pids(): | ||
''' Find the pid of kvm processes | ||
@return a list of pids from running kvm | ||
''' | ||
pid = Popen("pidof qemu-system-x86_64", shell=True, stdout=PIPE) | ||
pid = Popen("pidof qemu-kvm qemu-system-x86_64 kvm", shell=True, stdout=PIPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
else: | ||
kvm = Popen("which kvm", shell=True, stdout=PIPE) | ||
kvm.communicate() | ||
return not bool(kvm.returncode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
def list_pids(): | ||
''' Find the pid of kvm processes | ||
@return a list of pids from running kvm | ||
''' | ||
pid = Popen("pidof qemu-system-x86_64", shell=True, stdout=PIPE) | ||
pid = Popen("pidof qemu-kvm qemu-system-x86_64 kvm", shell=True, stdout=PIPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
Regarding the RH specific plugin: I have only rhel based kvm boxes and there were some significant differences, I wasn't able to test on debian based kvm boxes. So either someone needs to test it or we should keep it as seperate plugins. I agree though, that a unified plugin would be better, but given I don't have access to debian based kvm boxes I can't really verify my changes. |
I would be happy, if you could change the bits necessary for your environment and also fix/improve more details along the way (in separate commits). Most of the plugins do not have a fixed maintainer and cannot be easily tested by the repository maintainers - thus it is usually highly welcome to combine fixes with general cleanups. Regarding Debian/Red Hat: I have access to Debian systems with kvm and I am fluent in python. Thus I would be happy to test and fix (if necessary) the plugins, as soon as you included the Red Hat specific parts. |
@duritong: what do you think? |
I'll try to work on it, december was a bit a busy month for me. |
@duritong: just a friendly (and patient) reminder ... |
@duritong: ping? |
Ping? |
Stale pull request message |
I added a few improvements to the kvm plugins: