Welcome to CFEngine readbeard_m,
You can use =cf-key -s= to display information about connections
made recently
(as defined by
[[
https://docs.cfengine.com/docs/3.10/reference-components.html#lastseenexpireafter][lastseenexpireafter]]).
#+BEGIN_EXAMPLE
# cf-key -s
Direction IP Name
Last connection Key
Incoming 172.30.0.136
myhost.example.com Tue Sep 12 01:51:53 2017
SHA=a297a110a4d7417924d872e2b1f64f92210cd805fea7368059b6c12a77661f19
Outgoing 172.30.0.136
myhost.example.com Tue Sep 12 01:50:51 2017
SHA=a297a110a4d7417924d872e2b1f64f92210cd805fea7368059b6c12a77661f19
Total Entries 2
#+END_EXAMPLE
You can use a simple one-liner to extract the hostname or ip from
matching keys:
#+BEGIN_SRC bash
cf-key -s | awk
'/SHA=a297a110a4d7417924d872e2b1f64f92210cd805fea7368059b6c12a77661f19/
{print $3;exit}'
#+END_SRC
#+BEGIN_EXAMPLE
myhost.example.com
#+END_EXAMPLE
In Enterprise you can query the API.
#+BEGIN_EXAMPLE
curl --user username:password
https://hub/api/host/a297a110a4d7417924d872e2b1f64f92210cd805fea7368059b6c12a77661f19
#+END_EXAMPLE
#+BEGIN_EXAMPLE
{
"data": [
{
"firstseen": "1483983635",
"hostname": "
ip-172-30-0-136.cfengine.com",
"id":
"SHA=a297a110a4d7417924d872e2b1f64f92210cd805fea7368059b6c12a77661f19",
"ip": "172.30.0.136",
"lastreport": "1505174453"
}
],
"meta": {
"count": 1,
"page": 1,
"timestamp": 1505174504,
"total": 1
}
}
#+END_EXAMPLE
I hope this helps!