Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
df19d8f
include unix plugin
lauraschlimmer Aug 7, 2016
8301837
rename UnixPlugin -> UnixStatsPlugin
lauraschlimmer Aug 7, 2016
1367251
UnixStatsPlugin::getMountInfo stub
lauraschlimmer Aug 7, 2016
b34262e
get mount info for apple
lauraschlimmer Aug 7, 2016
f080a29
mount info for linux
lauraschlimmer Aug 7, 2016
fcd4d86
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 7, 2016
2a15f7e
Merge branch 'master' of https://github.com/eventql/evcollect into fe…
lauraschlimmer Aug 7, 2016
7eba3fc
fix linux build
lauraschlimmer Aug 7, 2016
9129793
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 7, 2016
e8f1027
fix linux build
lauraschlimmer Aug 7, 2016
8e591a8
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 7, 2016
636f25c
fix linux build
lauraschlimmer Aug 7, 2016
3432f1a
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 7, 2016
07e667b
fix linux build
lauraschlimmer Aug 7, 2016
a8c8647
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 7, 2016
976d587
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 7, 2016
6632889
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 7, 2016
596ed55
fix linux build
lauraschlimmer Aug 7, 2016
ba992e2
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 7, 2016
4ed93e2
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 7, 2016
059bed7
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 7, 2016
1e86836
Merge branch 'master' of https://github.com/eventql/evcollect into fe…
lauraschlimmer Aug 7, 2016
d02c445
fix linker flags for gcc
lauraschlimmer Aug 7, 2016
9314012
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 7, 2016
4cc018e
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 7, 2016
b986602
wip
lauraschlimmer Aug 7, 2016
97094b9
merged master
lauraschlimmer Aug 7, 2016
98f88aa
UnixStatsPlugin: ifree disk space
lauraschlimmer Aug 7, 2016
cbf67ac
hardcoded config with unix_stats
lauraschlimmer Aug 7, 2016
c07352a
UnixStatsPlugin: report df -h stats
lauraschlimmer Aug 7, 2016
d7e6de8
removed MountInfo.fs_type
lauraschlimmer Aug 7, 2016
d6e4144
mount info for linux
lauraschlimmer Aug 7, 2016
2896226
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 7, 2016
ee8fadf
merged master
lauraschlimmer Aug 7, 2016
71139d6
linux mnt_info
lauraschlimmer Aug 7, 2016
78980f0
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 7, 2016
b97f328
merged master
lauraschlimmer Aug 7, 2016
4b1046e
src/evcollect/pluginns/unix_stats -> plugins/unix_stats
lauraschlimmer Aug 7, 2016
5764f91
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 7, 2016
63d37b5
unix stats makefile
lauraschlimmer Aug 7, 2016
6c58c45
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 8, 2016
31d44d8
build unix stats plugin lib
lauraschlimmer Aug 8, 2016
838bacf
config: load unix stats plugin
lauraschlimmer Aug 8, 2016
f983763
unix stats: getEvent
lauraschlimmer Aug 8, 2016
4c3a6f5
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 8, 2016
8f7c573
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 8, 2016
1aac371
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 8, 2016
03141bd
unix stats: fixed json
lauraschlimmer Aug 8, 2016
e653093
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 8, 2016
5e920cf
check for os
lauraschlimmer Aug 8, 2016
45f25db
use MOUNTED
lauraschlimmer Aug 8, 2016
16a4bb3
read /proc/loadavg
lauraschlimmer Aug 8, 2016
0e06c2b
loadavg for osx
lauraschlimmer Aug 8, 2016
ed0156b
print error if sysctlbyname fails
lauraschlimmer Aug 9, 2016
c519fc7
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 9, 2016
ecc31ce
wip
lauraschlimmer Aug 9, 2016
506989f
unix stats EVCOLLECT_PLUGIN_INIT
lauraschlimmer Aug 9, 2016
3085fad
linux getloadavg
lauraschlimmer Aug 9, 2016
35fc511
unix stats: sysinfo
lauraschlimmer Aug 9, 2016
5366edd
unix stats uptime plugin
lauraschlimmer Aug 9, 2016
dd33bfa
init unix stats
lauraschlimmer Aug 9, 2016
044f576
uptime plugin: better time handling
lauraschlimmer Aug 9, 2016
85a3f2b
linux uptime stats
lauraschlimmer Aug 9, 2016
d7e1b18
splitted unix stats in different events and created a combined event
lauraschlimmer Aug 10, 2016
c86a41d
unix.stats doc
lauraschlimmer Aug 10, 2016
4f68091
rename unix_stats -> unix.stats
lauraschlimmer Aug 10, 2016
58cec0c
doc
lauraschlimmer Aug 10, 2016
b671b64
unix.processes: get process list for osx
lauraschlimmer Aug 10, 2016
cadc7c0
open proc/{pid} directories
lauraschlimmer Aug 10, 2016
e7a666a
fix
lauraschlimmer Aug 10, 2016
01e8e10
fix
lauraschlimmer Aug 10, 2016
f98703b
wip
lauraschlimmer Aug 10, 2016
ea667ee
Merge branch 'unix_stats' into feature/unix_plugin
lauraschlimmer Aug 10, 2016
f9ff655
Merge branch 'master' into feature/unix_plugin
lauraschlimmer Aug 10, 2016
0f0f5c6
read /proc/{pid}/stat files
lauraschlimmer Aug 10, 2016
fd1766e
proc/{pid}/stat regex
lauraschlimmer Aug 10, 2016
c6c46ee
parse /proc/{pid}/stat file
lauraschlimmer Aug 11, 2016
a834938
parse /proc/{pid}/stat files and write values to json
lauraschlimmer Aug 11, 2016
0cb6105
fixed process event json string
lauraschlimmer Aug 11, 2016
bec4e5b
docu
lauraschlimmer Aug 11, 2016
6e50512
format
lauraschlimmer Aug 11, 2016
3ff5891
...
lauraschlimmer Aug 11, 2016
9532c4a
moved disk info code to DiskInfo
lauraschlimmer Aug 11, 2016
1f1ec6c
DiskInfo json
lauraschlimmer Aug 12, 2016
d388814
make evcollect plugin api c compatible
lauraschlimmer Aug 12, 2016
0a75eb3
unix stats plugin build
lauraschlimmer Aug 12, 2016
6301af0
fix unix stats plugin build
lauraschlimmer Aug 12, 2016
d0dae99
unix plugin: kernel version for osx
lauraschlimmer Aug 12, 2016
ec8aa65
moved process stats code to own files
lauraschlimmer Aug 12, 2016
bd0e0a7
unix stats plugin: kernel version for linux
lauraschlimmer Aug 12, 2016
30e9ea0
unix stats plugin: linux kernel arguments
lauraschlimmer Aug 12, 2016
6b5a389
don't use logging in time
lauraschlimmer Aug 12, 2016
6d208a3
comments
lauraschlimmer Aug 12, 2016
f6cef96
unix stats plugin: getProcessInfo
lauraschlimmer Aug 12, 2016
d4b931e
make sure all open directories are closed
lauraschlimmer Aug 12, 2016
39de2a4
Merge branch 'master' of http://github.com/eventql/evcollect into fea…
lauraschlimmer Aug 15, 2016
6609005
kernel info json
lauraschlimmer Aug 15, 2016
502be9f
cleanup
lauraschlimmer Aug 15, 2016
1a06e68
{kernel, process, disk} stats json
lauraschlimmer Aug 15, 2016
8a6b3aa
disk stats: close mount info file
lauraschlimmer Aug 15, 2016
a0115eb
process stats: linux fixes
lauraschlimmer Aug 15, 2016
bc2de95
Merge branch 'feature/unix_plugin' of https://github.com/eventql/evco…
lauraschlimmer Aug 15, 2016
949b0b3
cleanup
lauraschlimmer Aug 15, 2016
c5a1373
cleanup
lauraschlimmer Aug 15, 2016
f00b3c5
docu
lauraschlimmer Aug 19, 2016
850f582
docu
lauraschlimmer Aug 19, 2016
6899de9
unix stats event json
lauraschlimmer Aug 19, 2016
b6d6c99
includes
lauraschlimmer Aug 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ SUBDIRS = \
. \
src/evcollect \
plugins/eventql \
plugins/hostname
plugins/hostname \
plugins/unix_stats

EXTRA_DIST = \
doc \
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ AM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])
ACX_PTHREAD
AM_CONDITIONAL([HAVE_PTHREAD], [test "x$acx_pthread_ok" = "xyes"])

AC_CONFIG_FILES([Makefile src/evcollect/Makefile plugins/hostname/Makefile plugins/eventql/Makefile])
AC_CONFIG_FILES([Makefile src/evcollect/Makefile plugins/hostname/Makefile plugins/eventql/Makefile plugins/unix_stats/Makefile])
AC_OUTPUT
32 changes: 32 additions & 0 deletions plugins/unix_stats/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
MAINTAINERCLEANFILES = Makefile.in

AM_CXXFLAGS = -std=c++0x -Wall -Wextra -Wdelete-non-virtual-dtor -g -fvisibility=hidden -I$(top_srcdir)/src
AM_CFLAGS = -std=c11 -Wall -pedantic -g
AM_LDFLAGS = -fvisibility=hidden -module -avoid-version -shared -export-dynamic -static-libstdc++ -static-libgcc -rpath $(libdir)

noinst_LTLIBRARIES = plugin_unix_stats.la

plugin_unix_stats_la_SOURCES = \
util/stringutil.cc \
util/stringutil.h \
util/stringutil_impl.h \
util/time.cc \
util/time.h \
util/time_impl.h \
disk_stats.h \
disk_stats.cc \
kernel_stats.h \
kernel_stats.cc \
process_stats.h \
process_stats.cc \
unix_stats_plugin.cc

PLUGINDIR=$(DESTDIR)$(libdir)/evcollect/plugins

install-data-hook: $(noinst_LTLIBRARIES)
@for soname in `echo | $(EGREP) "^dlname=" $^ | $(SED) -e "s|^dlname='\(.*\)'|\1|"`; do \
mkdir -p ${PLUGINDIR}; \
echo Installing $$soname to ${PLUGINDIR}; \
cp $(abs_builddir)/.libs/$$soname ${PLUGINDIR}; \
done

135 changes: 135 additions & 0 deletions plugins/unix_stats/disk_stats.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**
* Copyright (c) 2016 DeepCortex GmbH <legal@eventql.io>
* Authors:
* - Paul Asmuth <paul@eventql.io>
* - Laura Schlimmer <laura@eventql.io>
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License ("the license") as
* published by the Free Software Foundation, either version 3 of the License,
* or any later version.
*
* In accordance with Section 7(e) of the license, the licensing of the Program
* under the license does not imply a trademark license. Therefore any rights,
* title and interest in our trademarks remain entirely with us.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the license for more details.
*
* You can be released from the requirements of the license by purchasing a
* commercial license. Buying such a license is mandatory as soon as you develop
* commercial activities involving this program without disclosing the source
* code of your own applications
*/

#include <sys/statvfs.h>
#include <unistd.h>
#include <stdio.h>
#include "util/stringutil.h"
#include "disk_stats.h"

#if __linux__
#include <mntent.h>
#endif

#if __APPLE__
#include <sys/mount.h>
#endif

namespace evcollect {
namespace plugin_unix_stats {

std::vector<MountInfo> getMountInfo() {
std::vector<MountInfo> mount_info;

#if __linux__

auto file = setmntent(MOUNTED, "r");
while (auto mntent = getmntent(file)) {
MountInfo mn_info = {
.device = mntent->mnt_fsname,
.mount_point = mntent->mnt_dir
};

mount_info.emplace_back(mn_info);
}
fclose(file);

#elif __APPLE__
struct statfs* mntbuf;
auto mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
for (auto i = 0; i < mntsize; ++i) {
MountInfo mn_info = {
.device = mntbuf[i].f_mntfromname,
.mount_point = mntbuf[i].f_mntonname
};

mount_info.emplace_back(mn_info);
}

#endif

return mount_info;
}


bool getDiskInfo(std::vector<DiskInfo> disk_info) {
auto mount_info = getMountInfo();

for (size_t i = 0; i < mount_info.size(); ++i) {
struct statvfs buf;
if (statvfs(mount_info[i].mount_point.c_str(), &buf) == -1) {
continue;
}

DiskInfo di;
di.total = buf.f_blocks * buf.f_frsize;
di.available = buf.f_bavail * buf.f_frsize;
di.used = di.total - di.available;
di.capacity = di.total > 0 ? (di.used / di.total) * 100 : 100;
di.ifree = buf.f_favail;
di.iused = buf.f_files - di.ifree;

disk_info.emplace_back(di);
}

return true;
}

std::string toJSON(std::vector<DiskInfo> disk_info) {
std::string json;
json.append(R"({disk: )");

for (size_t i = 0; i < disk_info.size(); ++i) {
if (i > 0) {
json.append(",");
}

json.append(StringUtil::format(R"([
"filesystem": $0,
"mount_point": $1,
"total": $2,
"available": $3,
"used": $4,
"capacity": $5,
"ifree": $6,
"iused": $7
])",
disk_info[i].filesystem,
disk_info[i].mount_point,
disk_info[i].total,
disk_info[i].available,
disk_info[i].used,
disk_info[i].capacity,
disk_info[i].ifree,
disk_info[i].used
));
}

json.append("}");
return json;
}

} //namespace plugin_unix_stats
} //namespace evcollect
53 changes: 53 additions & 0 deletions plugins/unix_stats/disk_stats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (c) 2016 DeepCortex GmbH <legal@eventql.io>
* Authors:
* - Paul Asmuth <paul@eventql.io>
* - Laura Schlimmer <laura@eventql.io>
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License ("the license") as
* published by the Free Software Foundation, either version 3 of the License,
* or any later version.
*
* In accordance with Section 7(e) of the license, the licensing of the Program
* under the license does not imply a trademark license. Therefore any rights,
* title and interest in our trademarks remain entirely with us.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the license for more details.
*
* You can be released from the requirements of the license by purchasing a
* commercial license. Buying such a license is mandatory as soon as you develop
* commercial activities involving this program without disclosing the source
* code of your own applications
*/

#include <vector>

namespace evcollect {
namespace plugin_unix_stats {

struct MountInfo {
std::string device;
std::string mount_point;
};

struct DiskInfo {
std::string filesystem;
std::string mount_point;
uint64_t total;
uint64_t used;
uint64_t available;
uint8_t capacity;
uint64_t iused;
uint64_t ifree;
};


bool getDiskInfo(std::vector<DiskInfo> disk_info);

std::string toJSON(std::vector<DiskInfo> disk_info);

} //namespace plugin_unix_stats
} //namespace evcollect
Loading