为了监控小型家庭服务器,我在 docker 上运行 prometheus 和 node_exporter (以及 grafana 和其他一些东西)(类似于https://github.com/stefanprodan/dockprom)。我在桥接的 docker 网络上运行 prometheus。对于node_exporter,我有两个影响node_network_transmit_bytes_total指标的选项。
node_network_transmit_bytes_total指标仅包含 docker 的虚拟内部 NIC,而不包含被监控机器的物理 NIC。/proc这是从主机到/host/proc容器的依赖绑定安装(具体来说,我的物理接口是,在主机上
eno0可见):/proc/net/dev$ docker exec -it nodeexporter2 cat /host/proc/net/dev | awk '{print $1}'
Inter-|
face
eth0:
lo:
Run Code Online (Sandbox Code Playgroud)
localhost意思是普罗米修斯本身docker exec -it prometheus wget -O - http://actual-hostname:9100/metrics有效(并使用我主机的 LAN IP,192.168.xx),但配置actual-hostname:9100为 prometheus 目标会出现错误 ( Get …以下代码在Debian 7上的g ++ 4.7.2-5上编译并正常工作.
#include <iostream>
#include <string.h>
using namespace std;
class mystring {
char * buf;
static char * dupbuf(const char * buf) {
char * result = new char[strlen(buf) + 1];
strcpy(result, buf);
return result;
}
public:
mystring(const char * o)
: buf(dupbuf(o)) {}
~mystring() { delete[] buf; }
mystring(const mystring &) = delete;
mystring & operator=(const mystring&) = delete;
void write(ostream & o) const {
if (!buf) { exit(1); } // remove me
o << buf;
} …Run Code Online (Sandbox Code Playgroud)