aboutsummaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
Diffstat (limited to 'binding')
-rw-r--r--binding/task-manager-binding.c55
1 files changed, 54 insertions, 1 deletions
diff --git a/binding/task-manager-binding.c b/binding/task-manager-binding.c
index 16bbf9f..c9946c2 100644
--- a/binding/task-manager-binding.c
+++ b/binding/task-manager-binding.c
@@ -129,6 +129,52 @@ void kill_process(struct afb_req request)
/* we don't signal success, there's no use for it */
}
+void get_extra_info(struct afb_req request)
+{
+ struct json_object *ret_json, *json_obj;
+ json_object *req = afb_req_json(request);
+ int tid = json_object_get_int(req);
+
+ ret_json = json_object_new_object();
+ json_obj = json_object_new_object();
+
+ char path[32];
+ char str_val[256];
+ char param[80];
+
+ sprintf(path, "/proc/%d/sched", tid);
+ FILE *fsched = fopen(path, "r");
+
+ if (fsched == NULL) {
+ afb_req_fail(request, "Failed", "Error processing arguments.");
+ }
+ else {
+ json_object_object_add(json_obj, "tid", json_object_new_int(tid));
+
+ fscanf(fsched, "%255s", str_val);
+ json_object_object_add(json_obj, "cmd", json_object_new_string(str_val));
+
+ fscanf(fsched, "%*s"); // the '-' line
+ while (!feof(fsched)) {
+ fscanf(fsched, "%79s%*s%255s", param, str_val);
+ if (strstr(param, "exec_start"))
+ json_object_object_add(json_obj, "exec_start", json_object_new_string(str_val));
+ else if (strstr(param, "vruntime"))
+ json_object_object_add(json_obj, "vruntime", json_object_new_string(str_val));
+ else if (strstr(param, "sum_exec_runtime"))
+ json_object_object_add(json_obj, "sum_exec_runtime", json_object_new_string(str_val));
+ else if (strstr(param, "prio"))
+ json_object_object_add(json_obj, "prio", json_object_new_string(str_val));
+ }
+ }
+ fclose(fsched);
+
+ json_object_object_add(ret_json, "msgType", json_object_new_string("extraInfo"));
+ json_object_object_add(ret_json, "info", json_obj);
+
+ afb_req_success(request, ret_json, NULL);
+}
+
int fill_pstat(proc_t *proc_info, struct pstat *pstat_values)
{
@@ -196,7 +242,14 @@ static const struct afb_verb_v2 _afb_verbs_v2_taskmanager[] = {
.auth = NULL,
.info = "Kill the process specified by tid",
.session = AFB_SESSION_NONE_V2
- }
+ },
+ {
+ .verb = "get_extra_info",
+ .callback = get_extra_info,
+ .auth = NULL,
+ .info = "Get exta info about current process",
+ .session = AFB_SESSION_NONE_V2
+ },
};