systemd status

pull/1131/head
Jeff Becker 4 years ago
parent 6d3493ed72
commit 66181d8a8f
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -47,7 +47,12 @@ namespace llarp
remote.port(0);
// try inserting remote address by ip into decaying hash set
// if it cannot insert it has hit a limit
return not m_PathLimits.Insert(remote);
if(m_PathLimits.Insert(remote))
{
m_HopsRejected++;
return false;
}
return true;
#endif
}
@ -291,6 +296,8 @@ namespace llarp
{
MapPut< SyncTransitMap_t::Lock_t >(m_TransitPaths, hop->info.txID, hop);
MapPut< SyncTransitMap_t::Lock_t >(m_TransitPaths, hop->info.rxID, hop);
m_TransitHopCount++;
m_HopsAccepted++;
}
void
@ -309,6 +316,7 @@ namespace llarp
{
m_Router->outboundMessageHandler().QueueRemoveEmptyPath(itr->first);
itr = map.erase(itr);
m_TransitHopCount--;
}
else
++itr;

@ -163,12 +163,36 @@ namespace llarp
const byte_t*
OurRouterID() const;
/// current number of transit paths we have
uint64_t
CurrentTransitPaths() const
{
return m_TransitHopCount;
}
/// number of paths we rejected total
uint64_t
TransitPathsRejected() const
{
return m_HopsRejected;
}
/// number of paths we accepted total
uint64_t
TransitPathsAccepted() const
{
return m_HopsRejected;
}
private:
AbstractRouter* m_Router;
SyncTransitMap_t m_TransitPaths;
SyncOwnedPathsMap_t m_OurPaths;
bool m_AllowTransit;
util::DecayingHashSet< llarp::Addr > m_PathLimits;
uint64_t m_TransitHopCount = 0;
uint64_t m_HopsAccepted = 0;
uint64_t m_HopsRejected = 0;
};
} // namespace path
} // namespace llarp

@ -78,6 +78,12 @@ namespace llarp
return ePathRoleAny;
}
BuildStats
CurrentBuildStats() const
{
return m_BuildStats;
}
bool
Stop() override;

@ -32,6 +32,10 @@
#include <unistd.h>
#endif
#if defined(WITH_SYSTEMD)
#include <systemd/sd-daemon.h>
#endif
static constexpr std::chrono::milliseconds ROUTER_TICK_INTERVAL = 1s;
namespace llarp
@ -674,7 +678,28 @@ namespace llarp
const auto now = Now();
#if defined(WITH_SYSTEMD)
::sd_notify(0, "WATCHDOG=1");
{
std::stringstream ss;
ss << "WATCHDOG=1\nSTATUS=" << llarp::VERSION_FULL;
if(IsServiceNode())
{
ss << " snode | known/svc/clients: " << nodedb()->num_loaded() << "/"
<< NumberOfConnectedRouters() << "/" << NumberOfConnectedClients()
<< " | " << pathContext().CurrentTransitPaths() << " active paths";
}
else
{
ss << " client | known/connected: " << nodedb()->num_loaded() << "/"
<< NumberOfConnectedRouters() << " | path success: ";
hiddenServiceContext().ForEachService(
[&ss](const auto &name, const auto &ep) {
ss << " [" << name << " " << std::setprecision(4)
<< (100.0 * ep->CurrentBuildStats().SuccessRatio) << "%]";
});
}
const auto status = ss.str();
::sd_notify(0, status.c_str());
}
#endif
routerProfiling().Tick();
@ -1128,6 +1153,9 @@ namespace llarp
_stopping.store(true);
LogContext::Instance().RevertRuntimeLevel();
LogInfo("stopping router");
#if defined(WITH_SYSTEMD)
sd_notify(0, "STOPPING=1\nSTATUS=Shutting down");
#endif
hiddenServiceContext().StopAll();
_exitContext.Stop();
if(rpcServer)

Loading…
Cancel
Save