We get the path to our executable via a readlink() on
"/proc/self/exe", which appends a " (deleted)" during
package reloads.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This way we can use
println!("something: {}", AsHex(bytes));
without having to turn them into an allocated string first.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
and drop the now unused extract_lists function
this also fixes a bug, where we did not add the datastore to the list at
all when there was no rrd data
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
there is now a 'extract_cached_data' which just returns
the data of the specified field, and an api function that converts
a list of fields to the correct serde value
this way we do not have to create a serde value in rrd/cache.rs
(makes for a better interface)
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
this is an interface to simply get the Vec<Option<f64>> out of rrd
without going through serde values
we return a list of timestamps and a HashMap with the lists we could find
(otherwise it is not in the map)
if no lists could be extracted, the time list is also empty
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This way read_password() will not write the prompt into
stdout if stdout was redirected into a file, but instead
opens `/dev/tty`.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
when checking a path, we only pushed the components to the checked value
that would contain a parameter and not fixed ones
e.g. from the path components (with params datastore="foo")
["datastore", "{datastore}"]
only ["foo"] was given to the lookup_privs function
instead of ["datastore", "foo"]
this fixes an issue where e.g. a prune on /datastore/foo would fail
for a user that has the role DatastorePowerUser on /datastore (with
propagate) or /datastore/foo
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
add tests for check_api_permission and many Permission combinations
this test fails for now and will be fixed with the next commit
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Fix time delta calculation, and use old percentage when
querying more often than once a second.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
The ProcFsStat type uses values which need to be scaled by
it, so it makes sense to have this be public.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
See the following kernel code snippet from
kernel/sched/cputime.c's account_guest_time():
/* Add guest time to cpustat. */
if (task_nice(p) > 0) {
cpustat[CPUTIME_NICE] += cputime;
cpustat[CPUTIME_GUEST_NICE] += cputime;
} else {
cpustat[CPUTIME_USER] += cputime;
cpustat[CPUTIME_GUEST] += cputime;
}
So the old sum was wrong as some time frames were counted
double in the `total` value.
The data will likely still deviate from PVE, but we should
check by how much, as this version does seem more accurate.
We can still fix it to just use the same math as pve if it
seems off.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
we also have to fallback to the id_schema of the section_config when
we parse it, not only on write
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
converts a parsed section config to an Vector of typed items
this way we can simply get a list of users from the user config
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
if set in the SectionConfigPlugin, we set the given
field to the section_id for each entry
this way we can have e.g. the userid in the Struct and ObjectSchema,
without having to write it twice to the config but we are still getting
it when parsing the config
when a plugin does not specify an id_property, then the id_schema of
the SectionConfig will be used as fallback
also adds a test for this with multiple plugins
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>