summaryrefslogtreecommitdiff
path: root/src/systemd/job.rs
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2017-05-23 09:03:02 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2017-05-23 09:03:02 -0400
commitb22fc3f433f91e1c893122794415f0f61f08e95c (patch)
tree17bf79a22cbffd44fe16f566fb8d5b07fcfb147c /src/systemd/job.rs
parent42d1dcc48bfee8b0c33371861d3f4af72c13a1c3 (diff)
systemd: Very bad parsing of systemd jobs
Diffstat (limited to 'src/systemd/job.rs')
-rw-r--r--src/systemd/job.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/systemd/job.rs b/src/systemd/job.rs
new file mode 100644
index 0000000..68fb18d
--- /dev/null
+++ b/src/systemd/job.rs
@@ -0,0 +1,24 @@
+use std::collections::HashMap;
+use std::process::Command;
+
+use std::io;
+
+#[derive(Debug)]
+pub struct Unit {
+ name: String,
+ type_: String
+}
+
+pub fn get_jobs() -> io::Result<Vec<Unit>> {
+ let mut units = Vec::new();
+ let status = try!(Command::new("systemctl")
+ .args(&["show", "*"]).output());
+
+ for line in String::from_utf8_lossy(&status.stdout).split('\n') {
+ let words = line.split('=').collect::<Vec<&str>>();
+ if words.len() == 2 && words[0] == "Id" {
+ units.push(Unit { name: words[1].to_owned(), type_: "Unknown".to_owned() });
+ }
+ }
+ return Ok(units);
+}