Commit Diff


commit - f1abd5434f0239fd4c8fb2bc97d01a69da79e528
commit + 234f6a5ae752165729a40ff12448387f12d57ae8
blob - 86a23cf98588dad1cef5194f9335c4c2cfab2ec1
blob + 7ce02769dc850a2f922a30887b7724c6ce55b5c3
--- src/metrics.rs
+++ src/metrics.rs
@@ -39,16 +39,16 @@ static DESCRIPTORS: &[u8] = concat!(
     "# HELP s6_service_status Status of the service.\n",
     "# TYPE s6_service_pid gauge\n",
     "# HELP s6_service_pid Process id of the service.\n",
-    "# TYPE s6_service_exitcode stateset\n",
-    "# HELP s6_service_exitcode Exit code of the service.\n",
-    "# TYPE s6_service_signum stateset\n",
-    "# HELP s6_service_signum Signal number of the service.\n",
-    "# TYPE s6_service_updownsince_seconds gauge\n",
-    "# HELP s6_service_updownsince_seconds Since the service was up or down.\n",
-    "# UNIT s6_service_updownsince_seconds seconds\n",
-    "# TYPE s6_service_readysince_seconds gauge\n",
-    "# HELP s6_service_readysince_seconds Since the service was ready.\n",
-    "# UNIT s6_service_readysince_seconds seconds\n",
+    "# TYPE s6_service_exit_code stateset\n",
+    "# HELP s6_service_exit_code Exit code of the service.\n",
+    "# TYPE s6_service_signal_number stateset\n",
+    "# HELP s6_service_signal_number Signal number of the service.\n",
+    "# TYPE s6_service_up_down_since_seconds gauge\n",
+    "# HELP s6_service_up_down_since_seconds Since the service was up or down.\n",
+    "# UNIT s6_service_up_down_since_seconds seconds\n",
+    "# TYPE s6_service_ready_since_seconds gauge\n",
+    "# HELP s6_service_ready_since_seconds Since the service was ready.\n",
+    "# UNIT s6_service_ready_since_seconds seconds\n",
 )
 .as_bytes();
 
@@ -92,35 +92,37 @@ impl<'w, W: Write, I: Iterator<Item = ServiceDir>> Wri
             concat!(
                 "s6_service_status{{service=\"{}\",s6_service_status=\"supervised\"}} 1\n",
                 "s6_service_status{{service=\"{0}\",s6_service_status=\"up\"}} {}\n",
-                "s6_service_status{{service=\"{0}\",s6_service_status=\"wantedup\"}} {}\n",
+                "s6_service_status{{service=\"{0}\",s6_service_status=\"wanted_up\"}} {}\n",
+                "s6_service_status{{service=\"{0}\",s6_service_status=\"normally_up\"}} {}\n",
                 "s6_service_status{{service=\"{0}\",s6_service_status=\"ready\"}} {}\n",
                 "s6_service_status{{service=\"{0}\",s6_service_status=\"paused\"}} {}\n",
-                "s6_service_status{{service=\"{0}\",s6_service_status=\"normallyup\"}} {}\n",
                 "s6_service_pid{{service=\"{0}\"}} {}\n",
-                "s6_service_updownsince_seconds{{service=\"{0}\"}} {}\n",
-                "s6_service_readysince_seconds{{service=\"{0}\"}} {}\n",
+                "s6_service_up_down_since_seconds{{service=\"{0}\"}} {}\n",
+                "s6_service_ready_since_seconds{{service=\"{0}\"}} {}\n",
             ),
             service,
             if status.up { 1 } else { 0 },
-            if status.wantedup { 1 } else { 0 },
+            if status.wanted_up { 1 } else { 0 },
+            if status.normally_up { 1 } else { 0 },
             if status.ready { 1 } else { 0 },
             if status.paused { 1 } else { 0 },
-            if status.normallyup { 1 } else { 0 },
             status.pid,
-            status.updownsince.as_secs(),
-            status.readysince.as_secs(),
+            status.up_down_since.as_secs(),
+            status.ready_since.as_secs(),
         )?;
-        if let Some(exitcode) = status.exitcode {
+        if let Some(exit_code) = status.exit_code {
             writeln!(
                 self.writer,
-                concat!("s6_service_exitcode{{service=\"{}\",s6_service_exitcode=\"{}\"}} 1"),
-                service, exitcode
+                concat!("s6_service_exit_code{{service=\"{}\",s6_service_exit_code=\"{}\"}} 1"),
+                service, exit_code
             )?
         }
-        if let Some(signum) = status.signum {
+        if let Some(signum) = status.signal_number {
             writeln!(
                 self.writer,
-                concat!("s6_service_signum{{service=\"{}\",s6_service_signum=\"{}\"}} 1"),
+                concat!(
+                    "s6_service_signal_number{{service=\"{}\",s6_service_signal_number=\"{}\"}} 1"
+                ),
                 service, signum
             )?
         }
blob - a7dc88f478952bbe005f95a24e45c686a60dcf09
blob + a273441350861a0f2df0a2e164ed9813cbb408fb
--- src/s6.rs
+++ src/s6.rs
@@ -33,10 +33,10 @@ struct SvStatus {
     stamp: Duration,
     ready_stamp: Duration,
     pid: u64,
-    wstat: ExitStatus,
+    wait_status: ExitStatus,
     paused: bool,
     finishing: bool,
-    wantup: bool,
+    want_up: bool,
     ready: bool,
 }
 
@@ -46,12 +46,12 @@ impl From<[u8; 35]> for SvStatus {
             stamp: Tain::from_be_bytes(pack[0..12].try_into().expect("12 bytes")).into(),
             ready_stamp: Tain::from_be_bytes(pack[12..24].try_into().expect("12 bytes")).into(),
             pid: u64::from_be_bytes(pack[24..32].try_into().expect("8 bytes")),
-            wstat: ExitStatus::from_raw(u16::from_be_bytes(
+            wait_status: ExitStatus::from_raw(u16::from_be_bytes(
                 pack[32..34].try_into().expect("2 bytes"),
             ) as i32),
             paused: pack[34] & 1 == 1,
             finishing: pack[34] & 2 == 2,
-            wantup: pack[34] & 4 == 4,
+            want_up: pack[34] & 4 == 4,
             ready: pack[34] & 8 == 8,
         }
     }
@@ -69,16 +69,16 @@ impl TryFrom<File> for SvStatus {
 
 pub struct SupervisedStatus {
     pub up: bool,
-    pub wantedup: bool,
+    pub wanted_up: bool,
+    pub normally_up: bool,
     pub ready: bool,
     pub paused: bool,
     pub pid: u64,
-    pub normallyup: bool,
-    pub exitcode: Option<i32>,
-    pub signum: Option<i32>,
-    pub updownsince: Duration,
-    pub readysince: Duration,
+    pub exit_code: Option<i32>,
     // signal
+    pub signal_number: Option<i32>,
+    pub up_down_since: Duration,
+    pub ready_since: Duration,
 }
 
 pub enum Status {
@@ -119,26 +119,26 @@ impl ServiceDir {
             assert!(path.pop());
             assert!(path.pop());
             path.push("down");
-            let normallyup = !path.try_exists()?;
+            let normally_up = !path.try_exists()?;
             Ok(Status::Supervised(SupervisedStatus {
                 up: status.pid != 0 && !status.finishing,
-                wantedup: status.wantup,
+                wanted_up: status.want_up,
+                normally_up,
                 ready: status.pid != 0 && status.ready,
                 paused: status.paused,
                 pid: status.pid,
-                exitcode: if status.pid != 0 && !status.finishing {
+                exit_code: if status.pid != 0 && !status.finishing {
                     None
                 } else {
-                    status.wstat.code()
+                    status.wait_status.code()
                 },
-                signum: if status.pid != 0 && !status.finishing {
+                signal_number: if status.pid != 0 && !status.finishing {
                     None
                 } else {
-                    status.wstat.signal()
+                    status.wait_status.signal()
                 },
-                normallyup,
-                updownsince: status.stamp,
-                readysince: status.ready_stamp,
+                up_down_since: status.stamp,
+                ready_since: status.ready_stamp,
             }))
         } else {
             Ok(Status::Unsupervised)