Re: [systemd-devel] [PATCH] v3 Read NIC partitions on Dell Servers
On 10.11.2015 21:57, jhar...@gmail.com wrote: > +char path[256]; Is that on the safe side? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] libudev: subdirectories in sysfs (what does "available" mean?)
- Original Message - > From: "Greg KH"> To: "Anne Mulhern" > Cc: "David Herrmann" , "systemd" > > Sent: Tuesday, November 24, 2015 3:15:21 PM > Subject: Re: [systemd-devel] libudev: subdirectories in sysfs (what does > "available" mean?) > > On Tue, Nov 24, 2015 at 12:37:46PM -0500, Anne Mulhern wrote: > > > > - Original Message - > > > From: "Greg KH" > > > To: "Anne Mulhern" > > > Cc: "David Herrmann" , "systemd" > > > > > > Sent: Tuesday, November 24, 2015 11:42:21 AM > > > Subject: Re: [systemd-devel] libudev: subdirectories in sysfs (what does > > > "available" mean?) > > > > > > On Tue, Nov 24, 2015 at 10:37:08AM -0500, Anne Mulhern wrote: > > > > > > > > > > > > > > > > > > > > - Original Message - > > > > > From: "David Herrmann" > > > > > To: "Anne Mulhern" > > > > > Cc: "systemd" > > > > > Sent: Tuesday, November 24, 2015 10:15:05 AM > > > > > Subject: Re: [systemd-devel] libudev: subdirectories in sysfs (what > > > > > does > > > > > "available" mean?) > > > > > > > > > > Hi > > > > > > > > > > On Tue, Nov 24, 2015 at 3:54 PM, Anne Mulhern > > > > > wrote: > > > > > >> From: "David Herrmann" > > > > > >> On Tue, Nov 17, 2015 at 11:57 PM, Anne Mulhern > > > > > >> > > > > > >> wrote: > > > > > >> >> From: "David Herrmann" > > > > > >> >> On Mon, Nov 16, 2015 at 5:35 PM, Anne Mulhern > > > > > >> >> > > > > > >> >> wrote: > > > > > >> >> > libudev has some cooperating procedures that return the keys > > > > > >> >> > for > > > > > >> >> > a > > > > > >> >> > bunch > > > > > >> >> > of > > > > > >> >> > sysfs attributes for a given device. > > > > > >> >> > > > > > > >> >> > These attributes all correspond to files that are stored in > > > > > >> >> > the > > > > > >> >> > sysfs > > > > > >> >> > device directory. > > > > > >> >> > > > > > > >> >> > In the same directory there are sometimes subdirectories, > > > > > >> >> > that > > > > > >> >> > themselves > > > > > >> >> > contain files > > > > > >> >> > with information about their corresponding attribute. The dm > > > > > >> >> > directory > > > > > >> >> > is > > > > > >> >> > one obvious > > > > > >> >> > example. > > > > > >> >> > > > > > > >> >> > Are their any plans for libudev to add an ability to get the > > > > > >> >> > values > > > > > >> >> > from > > > > > >> >> > these subdirectories > > > > > >> >> > as some kind of attributes? > > > > > >> >> > > > > > > >> >> > If no, why? > > > > > >> >> > > > > > >> >> sd_device_get_sysattr_value(device, "foo/bar/baz", ); > > > > > >> >> > > > > > >> >> This should work fine (or its udev_device_* equivalent). > > > > > >> >> > > > > > >> >> Btw., I recommend just using readdir(), open(), read(), and > > > > > >> >> write(). > > > > > >> >> sysfs is a filesystem, no reason to wrap all those commands. > > > > > >> > > > > > > >> > Thanks, I'm asking this more as the pyudev maintainer than as > > > > > >> > someone > > > > > >> > who actually wants these values. > > > > > >> > > > > > > >> > The funny thing is, I recently found out that the list obtained > > > > > >> > by > > > > > >> > udev_device_get_sysattr_list_entry () and friends contains so > > > > > >> > called "available" keys, but when those get passed to > > > > > >> > udev_device_get_sysattr_value () the result might be NULL. > > > > > >> > That makes sense in the sense that they might represent files > > > > > >> > that are unreadable. > > > > > >> > > > > > > >> > Now I find out that I can make up keys not in the results of > > > > > >> > udev_device_get_sysattr_list_entry () and pass those to > > > > > >> > udev_device_get_sysattr_value() and get a non-null result. > > > > > >> > > > > > > >> > So, what does "available" mean? Do these sysattr_list_entry() > > > > > >> > methods give any useful information? > > > > > >> > > > > > >> "available" probably means attributes which are direct descendants > > > > > >> of > > > > > >> the device. That is, sysattr_list_entry() only lists such direct > > > > > >> descendants, while sysattr_value() allows you to query anything > > > > > >> (you > > > > > >> probably can even pass "foo/../../bar/baz"). > > > > > >> > > > > > >> Thanks > > > > > >> David > > > > > >> > > > > > > > > > > > > I think it's yet more complicated than that. For example, > > > > > > 'dm' (for device mapper) is not in the list of available > > > > > > attributes, but 'dm/name' is certainly an attribute that > > > > > > can be read by sysattr_value(). > > > > > > > > > > 'dm' is not an attribute, so it will never be listed as available > > > > > attribute.
[systemd-devel] systemd-cgtop vs docker-stats
Hi, I am implementing a zabbix monitoring service for docker (some implementations that I found are not working the way I need). I am using a bash script for collecting container CPU % direct from cgroup cpuacct. The bash script (at the end of this message) is very simple (I copied the idea from docker-stats - https://github.com/docker/docker/blob/master/api/client/stats.go#L81) However, it seems that docker-stats is not so accurate as systemd-cgtop so my question are: a) How systemd-cgtop calculate a system.slice (in my case, an docker container) CPU % ? Can someone point me the cgroups/systemd/linux files used? I am looking at https://github.com/systemd/systemd/blob/master/src/cgtop/cgtop.c#L126 but I am not a C expert. b) Is it possible to get CPU% using a bash script reading systemd-cgtop ? I have tried something like: systemd-cgtop -b -n2 , but it is not collecting CPU% info. Thank you, Tiago MY BASH SCRIPT: *get_container_cpu_percentage()* { CID=$1 NUM_PROC=$(cat /proc/cpuinfo | grep processor | wc -l) SYSTEM_PRE=$(get_system_cpu_usage) CONTAINER_PRE=$(get_container_cpu_usage $CID) sleep 2 SYSTEM=$(get_system_cpu_usage) CONTAINER=$(get_container_cpu_usage $CID) CONTAINER_DELTA=$((CONTAINER-CONTAINER_PRE)) SYSTEM_DELTA=$((SYSTEM-SYSTEM_PRE)) if [ "$CONTAINER_DELTA" -gt "0" ] && [ "$SYSTEM_DELTA" -gt "0" ]; then #awk "BEGIN {printf \"%.2f\",${CONTAINER_DELTA}/${SYSTEM_DELTA}*100*${NUM_PROC}}" awk "BEGIN {printf \"%.2f\",${CONTAINER_DELTA}/${SYSTEM_DELTA}*100}" else echo "0" fi } *get_system_cpu_usage()* { cat /proc/stat | grep "cpu " | awk -v CLK_TCK=$(getconf CLK_TCK) '{sum=0; mult=10; for (i=2;i<=9;i++) {sum+=$i}; sum*=(mult/CLK_TCK); print sum}' } *get_container_cpu_usage()* { CID=$1 FILE="/sys/fs/cgroup/cpu,cpuacct/system.slice/docker-${CID}*.scope/cpuacct.usage" get_container_info $FILE } ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [help][227] Enabling a user service breaks a little my system!
Hello! I'm suffering a issue with systemd's user services that I fixed only with a workaround, but today I want to fix this issue completely. I have created a user service which starts GNU Emacs, and another user service which starts GNU Screen[1], and enabled both. After rebooting my machine and login into my account, I get a pop up asking me to unlock my keyring, when it should be unlocked automatically after I login. Also, opening a shell and entering `systemctl --user` outputs the error: --8<---cut here---start->8--- $ LC_ALL=C systemctl --user Failed to connect to bus: No such file or directory --8<---cut here---end--->8--- However, this is not the case if I enter the command on GNU Screen (which was started by systemd as a user service). I have absolutely no idea why that happens. Finally, there are some environment variables I need for my configuration work properly. For instance, I issue: --8<---cut here---start->8--- $ systemctl --user import-environment SSH_AUTH_SOCK --8<---cut here---end--->8--- `SSH_AUTH_SOCK` is set and exported when my window manager executes the `.xprofile` file. The variable don't seems to be imported: --8<---cut here---start->8--- $ systemctl --user show-environment DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DISPLAY=:0 HOME=/home/jorge LANG=es_CR.utf8 LC_ADDRESS=es_CR.utf8 LC_COLLATE=es_CR.utf8 LC_CTYPE=es_CR.utf8 LC_IDENTIFICATION=es_CR.utf8 LC_MEASUREMENT=es_CR.utf8 LC_MESSAGES=es_CR.utf8 LC_MONETARY=es_CR.utf8 LC_NAME=es_CR.utf8 LC_NUMERIC=es_CR.utf8 LC_PAPER=es_CR.utf8 LC_TELEPHONE=es_CR.utf8 LC_TIME=es_CR.utf8 LOGNAME=jorge MAIL=/var/spool/mail/jorge PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin SHELL=/usr/bin/zsh USER=jorge XDG_RUNTIME_DIR=/run/user/1000 --8<---cut here---end--->8--- Note: I don't use GDM but LightDM. [1]: This makes no sense, I know, I should put such service in `/etc/systemd/system/` and enable it as screen@myusername. I'll make this transition as soon as I solve my problem with systemd and environment variables. -- Pax et bonum. Jorge Araya Navarro https://es.gravatar.com/shackra ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] wrong return value when fork() fail in exec_spawn() ?
Hi, all, It seems that the exec_spawn() will return 0 if fork() fails, because that return log_unit_error_errno(params->unit_id, errno, "Failed to fork: %m"); will return -r eventually. And here r = exec_context_load_environment() , which has exited successfully. This may lead big trouble to the caller of exec_spawn(). For example, mount_spawn(), which also calls exec_spawn(), will not goto fail but run continuelly in this case. Then the following unit_watch_pid() will fail at assert(pid >= 1);. I also commit a patch to fix this problem, please help to review. Thanks a lot! Li Cheng 0001-core-execute-fix-fork-fail-handling-in-exec_spawn.patch Description: Binary data ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel