blob: e4f871ebc95e8e597788bc18c6eaffc3385902d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include "ingestor.hpp"
#include <format>
#include <pq-connection.h>
#include <sys/utsname.h>
namespace {
[[nodiscard]]
std::string
getHostname(bool fqdn)
{
utsname uts {};
if (uname(&uts)) {
throw std::runtime_error(std::format("Failed to get hostname (uts: {}:{})", errno, strerror(errno)));
}
if (fqdn) {
return std::format("{}.{}", uts.nodename, uts.domainname);
}
return uts.nodename;
}
}
int
main(int, char **)
{
auto dbconn = std::make_shared<PQ::Connection>("dbname=webstat user=webstat");
WebStat::Ingestor {getHostname(false), dbconn}.ingestLog(stdin);
}
|