summaryrefslogtreecommitdiffstats
path: root/sbin/devd
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2016-04-03 20:29:21 +0000
committerimp <imp@FreeBSD.org>2016-04-03 20:29:21 +0000
commit02ef7784f5b2272db77fa87b83dd1d3f4f4583a3 (patch)
treee1e253b9c6db21c42955d15e67c45718f77b5f0b /sbin/devd
parenta5f0ce1fd75ae19f01d9e1ade052999191cae22e (diff)
downloadFreeBSD-src-02ef7784f5b2272db77fa87b83dd1d3f4f4583a3.zip
FreeBSD-src-02ef7784f5b2272db77fa87b83dd1d3f4f4583a3.tar.gz
Add a timestamp variable to the environment. This is when the event
was read from the kernel by devd.
Diffstat (limited to 'sbin/devd')
-rw-r--r--sbin/devd/devd.cc12
-rw-r--r--sbin/devd/devd.conf.52
2 files changed, 13 insertions, 1 deletions
diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc
index 367783f..b2aea19 100644
--- a/sbin/devd/devd.cc
+++ b/sbin/devd/devd.cc
@@ -788,6 +788,8 @@ process_event(char *buffer)
{
char type;
char *sp;
+ struct timeval tv;
+ char *timestr;
sp = buffer + 1;
devdlog(LOG_INFO, "Processing event '%s'\n", buffer);
@@ -797,7 +799,15 @@ process_event(char *buffer)
cfg.set_variable("*", buffer - 1);
// $_ is the entire line without the initial character
cfg.set_variable("_", buffer);
- // No match doesn't have a device, and the format is a little
+
+ // Save the time this happened (as approximated by when we got
+ // around to processing it).
+ gettimeofday(&tv, NULL);
+ asprintf(&timestr, "%jd.%06ld", (uintmax_t)tv.tv_sec, tv.tv_usec);
+ cfg.set_variable("timestamp", timestr);
+ free(timestr);
+
+ // Match doesn't have a device, and the format is a little
// different, so handle it separately.
switch (type) {
case notify:
diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5
index 21779ed..83c4c76 100644
--- a/sbin/devd/devd.conf.5
+++ b/sbin/devd/devd.conf.5
@@ -245,6 +245,8 @@ Variables for other classes of events are dependent on those events.
The entire message from the current event
.It Li _
The entire message from the current event, after the initial type character
+.It Li timestamp
+The time this event was processed, in seconds since 1970 dot fraction
.It Li bus
Device name of parent bus.
.It Li cdev
OpenPOWER on IntegriCloud