|| "${phpfpm_response[26]}" != "idle" \
|| "${phpfpm_response[29]}" != "active" \
|| "${phpfpm_response[32]}" != "total" \
- || "${phpfpm_response[43]}" != "slow" \
]]
then
echo >&2 "phpfpm: invalid response from phpfpm status server: ${phpfpm_response[*]}"
phpfpm_total_processes="${phpfpm_response[34]}"
phpfpm_max_active_processes="${phpfpm_response[38]}"
phpfpm_max_children_reached="${phpfpm_response[42]}"
- phpfpm_slow_requests="${phpfpm_response[45]}"
+ if [ "${phpfpm_response[43]}" == "slow" ]
+ then
+ phpfpm_slow_requests="${phpfpm_response[45]}"
+ else
+ phpfpm_slow_requests="-1"
+ fi
if [[ -z "${phpfpm_pool}" \
|| -z "${phpfpm_start_time}" \
|| -z "${phpfpm_total_processes}" \
|| -z "${phpfpm_max_active_processes}" \
|| -z "${phpfpm_max_children_reached}" \
- || -z "${phpfpm_slow_requests}" \
]]
then
echo >&2 "phpfpm: empty values got from phpfpm status server: ${phpfpm_response[*]}"
CHART phpfpm_$m.performance '' "PHP-FPM Performance" "status" phpfpm phpfpm.performance line $((phpfpm_priority + 3)) $phpfpm_update_every
DIMENSION reached 'max children reached' absolute 1 1
-DIMENSION slow 'slow requests' absolute 1 1
EOF
+ if [ $((phpfpm_slow_requests)) -ne -1 ]
+ then
+ echo "DIMENSION slow 'slow requests' absolute 1 1"
+ fi
done
return 0
END
BEGIN phpfpm_$m.performance $1
SET reached = $((phpfpm_max_children_reached))
-SET slow = $((phpfpm_slow_requests))
-END
EOF
+ if [ $((phpfpm_slow_requests)) -ne -1 ]
+ then
+ echo "SET slow = $((phpfpm_slow_requests))"
+ fi
+ echo "END"
done
return 0
}
+
+phpfpm_check
+phpfpm_create
+phpfpm_update
tomcat_curl_opts=""
# set tomcat username/password here
-tomcatUser=""
-tomcatPassword=""
+tomcat_user=""
+tomcat_password=""
# _update_every is a special variable - it holds the number of seconds
# between the calls of the _update() function
echo >&2 "tomcat url is unset or set to the empty string"
return 1
fi
- if [ -z "${tomcatUser}" ]; then
- echo >&2 "tomcat user is unset or set to the empty string"
- return 1
+ if [ -z "${tomcat_user}" ]; then
+ # check backwards compatibility
+ if [ -z "${tomcatUser}" ]; then
+ echo >&2 "tomcat user is unset or set to the empty string"
+ return 1
+ else
+ tomcat_user="${tomcatUser}"
+ fi
fi
- if [ -z "${tomcatPassword}" ]; then
- echo >&2 "tomcat password is unset or set to the empty string"
- return 1
+ if [ -z "${tomcat_password}" ]; then
+ # check backwards compatibility
+ if [ -z "${tomcatPassword}" ]; then
+ echo >&2 "tomcat password is unset or set to the empty string"
+ return 1
+ else
+ tomcat_password="${tomcatPassword}"
+ fi
fi
# check if we can get to tomcat's status page
tomcat_get() {
# collect tomcat values
tomcat_port="$(IFS=/ read -ra a <<< "$tomcat_url"; hostport=${a[2]}; echo "${hostport#*:}")"
- mapfile -t lines < <(curl -u "$tomcatUser":"$tomcatPassword" -Ss ${tomcat_curl_opts} "$tomcat_url" |\
+ mapfile -t lines < <(curl -u "$tomcat_user":"$tomcat_password" -Ss ${tomcat_curl_opts} "$tomcat_url" |\
xmlstarlet sel \
-t -m "/status/jvm/memory" -v @free \
-n -m "/status/connector[@name='\"http-bio-$tomcat_port\"']/threadInfo" -v @currentThreadCount \
AC_DEFINE_UNQUOTED([NETDATA_USER], ["${with_user}"], [use this user to drop privileged])
AC_SUBST([varlibdir], ["\$(localstatedir)/lib/netdata"])
+AC_SUBST([registrydir], ["\$(localstatedir)/lib/netdata/registry"])
AC_SUBST([cachedir], ["\$(localstatedir)/cache/netdata"])
AC_SUBST([chartsdir], ["\$(libexecdir)/netdata/charts.d"])
AC_SUBST([nodedir], ["\$(libexecdir)/netdata/node.d"])
* edit `contrib/debian/rules` and adjust the `dh` rule near the
top to remove systemd (see comments in that file).
-* edit `contrib/debian/control`: remove `dh-systemd` from the
- Build-Depends list, and add `pkg-config` to it.
+* rename `contrib/debian/control.wheezy` to `contrib/debian/control`.
+
+* uncomment `EXTRA_OPTS="-P /var/run/netdata.pid"` in
+ `contrib/debian/netdata.default`
+
+* edit `contrib/debian/netdata.init` and change `PIDFILE` to
+ `/var/run/netdata.pid`
+
+* uncomment `postrotate` in `system/netdata.logrotate.in` and change
+ `try-restart` to `restart`
Then proceed as the main instructions above.
source is to remove the current package from your system, then
install the new package. Upgrading on wheezy is known to not
work cleanly; Jessie may behave as expected.
-
--- /dev/null
+Source: netdata
+Build-Depends: debhelper (>= 9),
+ dh-autoreconf,
+ pkg-config,
+ dpkg-dev (>= 1.13.19),
+ zlib1g-dev,
+ uuid-dev
+Section: net
+Priority: optional
+Maintainer: Costa Tsaousis <costa@tsaousis.gr>
+Standards-Version: 3.9.6
+Homepage: https://github.com/firehol/netdata/wiki
+
+Package: netdata
+Architecture: any
+Depends: adduser,
+ libcap2-bin (>= 1:2.0),
+ lsb-base (>= 3.1-23.2),
+ ${misc:Depends},
+ ${shlibs:Depends}
+Description: real-time charts for system monitoring
+ Netdata is a daemon that collects data in realtime (per second)
+ and presents a web site to view and analyze them. The presentation
+ is also real-time and full of interactive charts that precisely
+ render all collected values.
# Extra arguments to pass to netdata
#
#EXTRA_OPTS=""
-
+#uncomment following line if you are building a wheezy-package
+#EXTRA_OPTS="-P /var/run/netdata.pid"
# Disclaimer
+**Python plugin support is experimental and implementation may change in the future**
+
Currently every plugin must be written in python3.
All third party libraries should be installed system-wide or in `python_modules` directory.
Also plugins support changing their data collection frequency by setting `update_every` variable in their configuration file.
config = {
'local': {
'user' : 'root',
- 'password' : 'a',
+ 'password' : '',
'socket' : '/var/run/mysqld/mysqld.sock',
'update_every' : 3,
'retries' : 4,
print(header + lines + "END")
return True
-
-#FIXME debug only:
-if __name__ == "__main__":
- my = Service(config['local'],'loc')
- my.check()
- my.create()
- my.update(1)
sbin_PROGRAMS = netdata
dist_cache_DATA = .keep
+dist_varlib_DATA = .keep
+dist_registry_DATA = .keep
dist_log_DATA = .keep
plugins_PROGRAMS = apps.plugin
// fprintf(stderr, "MEMORY_POINTER: Checking pointer at %p, real %p for %s/%u@%s.\n", marked_ptr, (void *)(marked_ptr - MALLOC_PREFIX), function, line, file);
- if(real_ptr[0] != MALLOC_MARK) fatal("MEMORY: prefix MARK is not valid for %s/%u@%s.", function, line, file);
+ if(real_ptr[0] != MALLOC_MARK) fatal("MEMORY: prefix MARK is not valid for %s/%d@%s.", function, line, file);
size_t size = real_ptr[1];
uint32_t *end_ptr = (uint32_t *)(marked_ptr + size);
- if(end_ptr[0] != MALLOC_MARK) fatal("MEMORY: suffix MARK of allocation with size %zu is not valid for %s/%u@%s.", size, function, line, file);
+ if(end_ptr[0] != MALLOC_MARK) fatal("MEMORY: suffix MARK of allocation with size %zu is not valid for %s/%d@%s.", size, function, line, file);
if(size_without_overheads_ptr) *size_without_overheads_ptr = size;
void *malloc_debug(const char *file, int line, const char *function, size_t size) {
void *ptr = malloc(size + MALLOC_OVERHEAD);
- if(!ptr) fatal("MEMORY: Cannot allocate %zu bytes for %s/%u@%s.", size, function, line, file);
+ if(!ptr) fatal("MEMORY: Cannot allocate %zu bytes for %s/%d@%s.", size, function, line, file);
allocations.allocated += size;
allocations.allocations++;
- debug(D_MEMORY, "MEMORY: Allocated %zu bytes for %s/%u@%s."
+ debug(D_MEMORY, "MEMORY: Allocated %zu bytes for %s/%d@%s."
" Status: allocated %zu in %zu allocs."
, size
, function, line, file
allocations.allocated -= size;
allocations.allocations--;
- debug(D_MEMORY, "MEMORY: freed %zu bytes for %s/%u@%s."
+ debug(D_MEMORY, "MEMORY: freed %zu bytes for %s/%d@%s."
" Status: allocated %zu in %zu allocs."
, size
, function, line, file
void *real_ptr = check_allocation(file, line, function, ptr, &old_size);
void *new_ptr = realloc(real_ptr, size + MALLOC_OVERHEAD);
- if(!new_ptr) fatal("MEMORY: Cannot allocate %zu bytes for %s/%u@%s.", size, function, line, file);
+ if(!new_ptr) fatal("MEMORY: Cannot allocate %zu bytes for %s/%d@%s.", size, function, line, file);
allocations.allocated += size;
allocations.allocated -= old_size;
- debug(D_MEMORY, "MEMORY: Re-allocated from %zu to %zu bytes for %s/%u@%s."
+ debug(D_MEMORY, "MEMORY: Re-allocated from %zu to %zu bytes for %s/%d@%s."
" Status: allocated %zu in %zu allocs."
, old_size, size
, function, line, file
#endif /* NETDATA_INTERNAL_CHECKS */
+// ----------------------------------------------------------------------------
+
+void netdata_cleanup_and_exit(int ret) {
+ exit(ret);
+}
+
+
// ----------------------------------------------------------------------------
// system functions
// to retrieve settings of the system
return NULL;
}
- snprintfz(w->compare, MAX_COMPARE_NAME, "%d", uid);
+ snprintfz(w->compare, MAX_COMPARE_NAME, "%u", uid);
w->comparehash = simple_hash(w->compare);
w->comparelen = strlen(w->compare);
- snprintfz(w->id, MAX_NAME, "%d", uid);
+ snprintfz(w->id, MAX_NAME, "%u", uid);
w->idhash = simple_hash(w->id);
struct passwd *pw = getpwuid(uid);
if(!pw)
- snprintfz(w->name, MAX_NAME, "%d", uid);
+ snprintfz(w->name, MAX_NAME, "%u", uid);
else
snprintfz(w->name, MAX_NAME, "%s", pw->pw_name);
users_root_target = w;
if(unlikely(debug))
- fprintf(stderr, "apps.plugin: added uid %d ('%s') target\n", w->uid, w->name);
+ fprintf(stderr, "apps.plugin: added uid %u ('%s') target\n", w->uid, w->name);
return w;
}
return NULL;
}
- snprintfz(w->compare, MAX_COMPARE_NAME, "%d", gid);
+ snprintfz(w->compare, MAX_COMPARE_NAME, "%u", gid);
w->comparehash = simple_hash(w->compare);
w->comparelen = strlen(w->compare);
- snprintfz(w->id, MAX_NAME, "%d", gid);
+ snprintfz(w->id, MAX_NAME, "%u", gid);
w->idhash = simple_hash(w->id);
struct group *gr = getgrgid(gid);
if(!gr)
- snprintfz(w->name, MAX_NAME, "%d", gid);
+ snprintfz(w->name, MAX_NAME, "%u", gid);
else
snprintfz(w->name, MAX_NAME, "%s", gr->gr_name);
groups_root_target = w;
if(unlikely(debug))
- fprintf(stderr, "apps.plugin: added gid %d ('%s') target\n", w->gid, w->name);
+ fprintf(stderr, "apps.plugin: added gid %u ('%s') target\n", w->gid, w->name);
return w;
}
all_pids[pid] = calloc(sizeof(struct pid_stat), 1);
if(!all_pids[pid]) {
- error("Cannot allocate %lu bytes of memory", (unsigned long)sizeof(struct pid_stat));
+ error("Cannot allocate %zu bytes of memory", (size_t)sizeof(struct pid_stat));
return NULL;
}
all_pids[pid]->fds = calloc(sizeof(int), 100);
if(!all_pids[pid]->fds)
- error("Cannot allocate %ld bytes of memory", (unsigned long)(sizeof(int) * 100));
+ error("Cannot allocate %zu bytes of memory", (size_t)(sizeof(int) * 100));
else all_pids[pid]->fds_size = 100;
if(root_of_pids) root_of_pids->prev = all_pids[pid];
w = p->user_target;
else {
if(unlikely(debug && p->user_target))
- fprintf(stderr, "apps.plugin: \t\tpid %d (%s) switched user from %d (%s) to %d.\n", p->pid, p->comm, p->user_target->uid, p->user_target->name, p->uid);
+ fprintf(stderr, "apps.plugin: \t\tpid %d (%s) switched user from %u (%s) to %u.\n", p->pid, p->comm, p->user_target->uid, p->user_target->name, p->uid);
w = p->user_target = get_users_target(p->uid);
}
w = p->group_target;
else {
if(unlikely(debug && p->group_target))
- fprintf(stderr, "apps.plugin: \t\tpid %d (%s) switched group from %d (%s) to %d.\n", p->pid, p->comm, p->group_target->gid, p->group_target->name, p->gid);
+ fprintf(stderr, "apps.plugin: \t\tpid %d (%s) switched group from %u (%s) to %u.\n", p->pid, p->comm, p->group_target->gid, p->group_target->name, p->gid);
w = p->group_target = get_groups_target(p->gid);
}
if(lseek(fd, size, SEEK_SET) == (off_t)size) {
if(write(fd, "", 1) == 1) {
if(ftruncate(fd, size))
- error("Cannot truncate file '%s' to size %ld. Will use the larger file.", filename, size);
+ error("Cannot truncate file '%s' to size %zu. Will use the larger file.", filename, size);
#ifdef MADV_MERGEABLE
if(flags & MAP_SHARED || !enable_ksm || !ksm) {
}
#endif
}
- else error("Cannot write to file '%s' at position %ld.", filename, size);
+ else error("Cannot write to file '%s' at position %zu.", filename, size);
}
- else error("Cannot seek file '%s' to size %ld.", filename, size);
+ else error("Cannot seek file '%s' to size %zu.", filename, size);
close(fd);
}
extern char *strncpyz(char *dst, const char *src, size_t n);
extern int vsnprintfz(char *dst, size_t n, const char *fmt, va_list args);
-extern int snprintfz(char *dst, size_t n, const char *fmt, ...);
+extern int snprintfz(char *dst, size_t n, const char *fmt, ...) __attribute__ (( format (printf, 3, 4)));
extern void *mymmap(const char *filename, size_t size, int flags, int ksm);
extern int savememory(const char *filename, void *mem, size_t size);
}
if(setresgid(gid, gid, gid) != 0) {
- error("Cannot switch to user's %s group (gid: %d).", username, gid);
+ error("Cannot switch to user's %s group (gid: %u).", username, gid);
return -1;
}
if(setresuid(uid, uid, uid) != 0) {
- error("Cannot switch to user %s (uid: %d).", username, uid);
+ error("Cannot switch to user %s (uid: %u).", username, uid);
return -1;
}
if(setgid(gid) != 0) {
- error("Cannot switch to user's %s group (gid: %d).", username, gid);
+ error("Cannot switch to user's %s group (gid: %u).", username, gid);
return -1;
}
if(setegid(gid) != 0) {
- error("Cannot effectively switch to user's %s group (gid: %d).", username, gid);
+ error("Cannot effectively switch to user's %s group (gid: %u).", username, gid);
return -1;
}
if(setuid(uid) != 0) {
- error("Cannot switch to user %s (uid: %d).", username, uid);
+ error("Cannot switch to user %s (uid: %u).", username, uid);
return -1;
}
if(seteuid(uid) != 0) {
- error("Cannot effectively switch to user %s (uid: %d).", username, uid);
+ error("Cannot effectively switch to user %s (uid: %u).", username, uid);
return -1;
}
va_end( args );
}
- exit(1);
+ netdata_cleanup_and_exit(1);
}
void log_access( const char *fmt, ... )
#include <stdarg.h>
#include <time.h>
+#include "main.h"
+
#ifndef NETDATA_LOG_H
#define NETDATA_LOG_H 1
setenv("NETDATA_HOST_PREFIX", config_get("global", "host access prefix" , "") , 1);
setenv("HOME" , config_get("global", "home directory" , CACHE_DIR) , 1);
- // avoid extended to stat(/etc/localtime)
+ // disable buffering for python plugins
+ setenv("PYTHONUNBUFFERED", "1", 1);
+
+ // avoid flood calls to stat(/etc/localtime)
// http://stackoverflow.com/questions/4554271/how-to-avoid-excessive-stat-etc-localtime-calls-in-strftime-on-linux
setenv("TZ", ":/etc/localtime", 0);
extern void kill_childs(void);
extern int killpid(pid_t pid, int signal);
-extern void netdata_cleanup_and_exit(int ret);
+extern void netdata_cleanup_and_exit(int ret) __attribute__ ((noreturn));
#endif /* NETDATA_MAIN_H */
}
words = procfile_linewords(ff, l);
if(words < 12) {
- error("Cannot read /proc/net/netstat IpExt line. Expected 12 params, read %d.", words);
+ error("Cannot read /proc/net/netstat IpExt line. Expected 12 params, read %u.", words);
continue;
}
if(do_rc == 1 && strcmp(type, "rc") == 0) {
if(words < 4) {
- error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 4);
+ error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 4);
continue;
}
}
else if(do_fh == 1 && strcmp(type, "fh") == 0) {
if(words < 6) {
- error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 6);
+ error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 6);
continue;
}
}
else if(do_io == 1 && strcmp(type, "io") == 0) {
if(words < 3) {
- error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 3);
+ error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 3);
continue;
}
}
else if(do_th == 1 && strcmp(type, "th") == 0) {
if(words < 13) {
- error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 13);
+ error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 13);
continue;
}
}
else if(do_ra == 1 && strcmp(type, "ra") == 0) {
if(words < 13) {
- error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 13);
+ error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 13);
continue;
}
}
else if(do_net == 1 && strcmp(type, "net") == 0) {
if(words < 5) {
- error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 5);
+ error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 5);
continue;
}
}
else if(do_rpc == 1 && strcmp(type, "rpc") == 0) {
if(words < 6) {
- error("%s line of /proc/net/rpc/nfsd has %d words, expected %d", type, words, 6);
+ error("%s line of /proc/net/rpc/nfsd has %u words, expected %d", type, words, 6);
continue;
}
words = procfile_linewords(ff, l);
if(words < 20) {
- error("Cannot read /proc/net/snmp Ip line. Expected 20 params, read %d.", words);
+ error("Cannot read /proc/net/snmp Ip line. Expected 20 params, read %u.", words);
continue;
}
words = procfile_linewords(ff, l);
if(words < 15) {
- error("Cannot read /proc/net/snmp Tcp line. Expected 15 params, read %d.", words);
+ error("Cannot read /proc/net/snmp Tcp line. Expected 15 params, read %u.", words);
continue;
}
words = procfile_linewords(ff, l);
if(words < 7) {
- error("Cannot read /proc/net/snmp Udp line. Expected 7 params, read %d.", words);
+ error("Cannot read /proc/net/snmp Udp line. Expected 7 params, read %u.", words);
continue;
}
for(l = 0; l < lines ;l++) {
words = procfile_linewords(ff, l);
if(words < 2) {
- if(words) error("Cannot read /proc/net/snmp6 line %d. Expected 2 params, read %d.", l, words);
+ if(words) error("Cannot read /proc/net/snmp6 line %u. Expected 2 params, read %u.", l, words);
continue;
}
for(l = 1; l < lines ;l++) {
words = procfile_linewords(ff, l);
if(words < 17) {
- if(words) error("Cannot read /proc/net/stat/nf_conntrack line. Expected 17 params, read %d.", words);
+ if(words) error("Cannot read /proc/net/stat/nf_conntrack line. Expected 17 params, read %u.", words);
continue;
}
if(strncmp(procfile_lineword(ff, l, 0), "cpu", 3) == 0) {
words = procfile_linewords(ff, l);
if(words < 9) {
- error("Cannot read /proc/stat cpu line. Expected 9 params, read %d.", words);
+ error("Cannot read /proc/stat cpu line. Expected 9 params, read %u.", words);
continue;
}
for(l = 0; l < lines ;l++) {
words = procfile_linewords(ff, l);
if(words < 2) {
- if(words) error("Cannot read /proc/vmstat line %d. Expected 2 params, read %d.", l, words);
+ if(words) error("Cannot read /proc/vmstat line %u. Expected 2 params, read %u.", l, words);
continue;
}
ff->size += PROCFILE_INCREMENT_BUFFER;
}
- debug(D_PROCFILE, "Reading file '%s', from position %ld with length %ld", ff->filename, s, ff->size - s);
+ debug(D_PROCFILE, "Reading file '%s', from position %ld with length %lu", ff->filename, s, ff->size - s);
r = read(ff->fd, &ff->data[s], ff->size - s);
if(unlikely(r == -1)) {
if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) error(PF_PREFIX ": Cannot read from file '%s'", ff->filename);
uint32_t words, w;
char *s;
- debug(D_PROCFILE, "File '%s' with %d lines and %d words", ff->filename, ff->lines->len, ff->words->len);
+ debug(D_PROCFILE, "File '%s' with %u lines and %u words", ff->filename, ff->lines->len, ff->words->len);
for(l = 0; likely(l < lines) ;l++) {
words = procfile_linewords(ff, l);
- debug(D_PROCFILE, " line %d starts at word %d and has %d words", l, ff->lines->lines[l].first, ff->lines->lines[l].words);
+ debug(D_PROCFILE, " line %u starts at word %u and has %u words", l, ff->lines->lines[l].first, ff->lines->lines[l].words);
for(w = 0; likely(w < words) ;w++) {
s = procfile_lineword(ff, l, w);
- debug(D_PROCFILE, " [%d.%d] '%s'", l, w, s);
+ debug(D_PROCFILE, " [%u.%u] '%s'", l, w, s);
}
}
}
// check if we will re-write the entire data set
if(unlikely(usecdiff(&st->last_collected_time, &st->last_updated) > st->update_every * st->entries * 1000000ULL)) {
- info("%s: too old data (last updated at %zu.%zu, last collected at %zu.%zu). Reseting it. Will not store the next entry.", st->name, st->last_updated.tv_sec, st->last_updated.tv_usec, st->last_collected_time.tv_sec, st->last_collected_time.tv_usec);
+ info("%s: too old data (last updated at %ld.%ld, last collected at %ld.%ld). Reseting it. Will not store the next entry.", st->name, st->last_updated.tv_sec, st->last_updated.tv_usec, st->last_collected_time.tv_sec, st->last_collected_time.tv_usec);
rrdset_reset(st);
st->usec_since_last_update = st->update_every * 1000000ULL;
"\t\t\t\"data_url\": \"/api/v1/data?chart=%s\",\n"
"\t\t\t\"chart_type\": \"%s\",\n"
"\t\t\t\"duration\": %ld,\n"
- "\t\t\t\"first_entry\": %lu,\n"
- "\t\t\t\"last_entry\": %lu,\n"
+ "\t\t\t\"first_entry\": %ld,\n"
+ "\t\t\t\"last_entry\": %ld,\n"
"\t\t\t\"update_every\": %d,\n"
"\t\t\t\"dimensions\": {\n"
, st->id
"\t\t\t\"units\": \"%s\",\n"
"\t\t\t\"url\": \"/data/%s/%s\",\n"
"\t\t\t\"chart_type\": \"%s\",\n"
- "\t\t\t\"counter\": %ld,\n"
+ "\t\t\t\"counter\": %lu,\n"
"\t\t\t\"entries\": %ld,\n"
- "\t\t\t\"first_entry_t\": %lu,\n"
- "\t\t\t\"last_entry\": %ld,\n"
- "\t\t\t\"last_entry_t\": %lu,\n"
- "\t\t\t\"last_entry_secs_ago\": %lu,\n"
+ "\t\t\t\"first_entry_t\": %ld,\n"
+ "\t\t\t\"last_entry\": %lu,\n"
+ "\t\t\t\"last_entry_t\": %ld,\n"
+ "\t\t\t\"last_entry_secs_ago\": %ld,\n"
"\t\t\t\"update_every\": %d,\n"
"\t\t\t\"isdetail\": %d,\n"
"\t\t\t\"usec_since_last_update\": %llu,\n"
"\t\t\t\t\t\"algorithm\": \"%s\",\n"
"\t\t\t\t\t\"multiplier\": %ld,\n"
"\t\t\t\t\t\"divisor\": %ld,\n"
- "\t\t\t\t\t\"last_entry_t\": %lu,\n"
+ "\t\t\t\t\t\"last_entry_t\": %ld,\n"
"\t\t\t\t\t\"collected_value\": " COLLECTED_NUMBER_FORMAT ",\n"
"\t\t\t\t\t\"calculated_value\": " CALCULATED_NUMBER_FORMAT ",\n"
"\t\t\t\t\t\"last_collected_value\": " COLLECTED_NUMBER_FORMAT ",\n"
if(unlikely(slot < 0)) slot = st->entries - 1;
if(unlikely(slot == stop_at_slot)) stop_now = counter;
- if(unlikely(debug)) debug(D_RRD_STATS, "ROW %s slot: %ld, entries_counter: %ld, group_count: %ld, added: %ld, now: %lu, %s %s"
+ if(unlikely(debug)) debug(D_RRD_STATS, "ROW %s slot: %ld, entries_counter: %ld, group_count: %ld, added: %ld, now: %ld, %s %s"
, st->id
, slot
, counter
// checks for debugging
if(st->debug) {
- debug(D_RRD_STATS, "%s first_entry_t = %lu, last_entry_t = %lu, duration = %lu, after = %lu, before = %lu, duration = %lu, entries_to_show = %lu, group = %lu"
+ debug(D_RRD_STATS, "%s first_entry_t = %ld, last_entry_t = %ld, duration = %ld, after = %ld, before = %ld, duration = %ld, entries_to_show = %ld, group = %ld"
, st->id
, rrdset_first_entry_t(st)
, rrdset_last_entry_t(st)
);
if(before < after)
- debug(D_RRD_STATS, "WARNING: %s The newest value in the database (%lu) is earlier than the oldest (%lu)", st->name, before, after);
+ debug(D_RRD_STATS, "WARNING: %s The newest value in the database (%ld) is earlier than the oldest (%ld)", st->name, before, after);
if((before - after) > st->entries * st->update_every)
- debug(D_RRD_STATS, "WARNING: %s The time difference between the oldest and the newest entries (%lu) is higher than the capacity of the database (%lu)", st->name, before - after, st->entries * st->update_every);
+ debug(D_RRD_STATS, "WARNING: %s The time difference between the oldest and the newest entries (%ld) is higher than the capacity of the database (%ld)", st->name, before - after, st->entries * st->update_every);
}
int print_this = 0;
- if(st->debug) debug(D_RRD_STATS, "%s t = %ld, count = %ld, group_count = %ld, printed = %ld, now = %lu, %s %s"
+ if(st->debug) debug(D_RRD_STATS, "%s t = %ld, count = %ld, group_count = %ld, printed = %ld, now = %ld, %s %s"
, st->id
, t
, count + 1
} // max_loop
- debug(D_RRD_STATS, "RRD_STATS_JSON: %s total %ld bytes", st->name, wb->len);
+ debug(D_RRD_STATS, "RRD_STATS_JSON: %s total %lu bytes", st->name, wb->len);
pthread_rwlock_unlock(&st->rwlock);
return last_timestamp;
#define COLLECTED_NUMBER_FORMAT "%0.7Lf"
*/
-typedef int32_t storage_number;
-typedef uint32_t ustorage_number;
-#define STORAGE_NUMBER_FORMAT "%d"
+typedef uint32_t storage_number;
+#define STORAGE_NUMBER_FORMAT "%u"
#define SN_NOT_EXISTS (0x0 << 24)
#define SN_EXISTS (0x1 << 24)
mi = mountinfo_find_by_filesystem_mount_source(root, "cgroup", "cpuacct");
if(!mi) mi = mountinfo_find_by_filesystem_super_option(root, "cgroup", "cpuacct");
- if(!mi) s = "/sys/fs/cgroup/cpuacct";
+ if(!mi) {
+ error("Cannot find cgroup cpuacct mountinfo. Assuming default: /sys/fs/cgroup/cpuacct");
+ s = "/sys/fs/cgroup/cpuacct";
+ }
else s = mi->mount_point;
snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, s);
cgroup_cpuacct_base = config_get("plugin:cgroups", "path to /sys/fs/cgroup/cpuacct", filename);
mi = mountinfo_find_by_filesystem_mount_source(root, "cgroup", "blkio");
if(!mi) mi = mountinfo_find_by_filesystem_super_option(root, "cgroup", "blkio");
- if(!mi) s = "/sys/fs/cgroup/blkio";
+ if(!mi) {
+ error("Cannot find cgroup blkio mountinfo. Assuming default: /sys/fs/cgroup/blkio");
+ s = "/sys/fs/cgroup/blkio";
+ }
else s = mi->mount_point;
snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, s);
cgroup_blkio_base = config_get("plugin:cgroups", "path to /sys/fs/cgroup/blkio", filename);
mi = mountinfo_find_by_filesystem_mount_source(root, "cgroup", "memory");
if(!mi) mi = mountinfo_find_by_filesystem_super_option(root, "cgroup", "memory");
- if(!mi) s = "/sys/fs/cgroup/memory";
+ if(!mi) {
+ error("Cannot find cgroup memory mountinfo. Assuming default: /sys/fs/cgroup/memory");
+ s = "/sys/fs/cgroup/memory";
+ }
else s = mi->mount_point;
snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, s);
cgroup_memory_base = config_get("plugin:cgroups", "path to /sys/fs/cgroup/memory", filename);
if(!ff) return;
if(procfile_lines(ff) < 1) {
- error("File '%s' should have 1+ lines but has %d.", ca->filename, procfile_lines(ff));
+ error("File '%s' should have 1+ lines but has %u.", ca->filename, procfile_lines(ff));
return;
}
st = rrdset_create(type, "cpu_per_core", NULL, "cpu", "cgroup.cpu_per_core", title, "%", 40100, update_every, RRDSET_TYPE_STACKED);
for(i = 0; i < cg->cpuacct_usage.cpus ;i++) {
- snprintfz(id, CHART_TITLE_MAX, "cpu%d", i);
+ snprintfz(id, CHART_TITLE_MAX, "cpu%u", i);
rrddim_add(st, id, NULL, 100, 1000000, RRDDIM_INCREMENTAL);
}
}
else rrdset_next(st);
for(i = 0; i < cg->cpuacct_usage.cpus ;i++) {
- snprintfz(id, CHART_TITLE_MAX, "cpu%d", i);
+ snprintfz(id, CHART_TITLE_MAX, "cpu%u", i);
rrddim_set(st, id, cg->cpuacct_usage.cpu_percpu[i]);
}
rrdset_done(st);
unsigned long oincrement = increment;
increment = increment * st->update_every * 1000000 / delay;
- fprintf(stderr, "\n\nORIGINAL INCREMENT: %lu, INCREMENT %lu, DELAY %lu, SHIFT %lu\n", oincrement * 10, increment * 10, delay, shift);
+ fprintf(stderr, "\n\nORIGINAL INCREMENT: %lu, INCREMENT %ld, DELAY %ld, SHIFT %ld\n", oincrement * 10, increment * 10, delay, shift);
int ret = 0;
storage_number sn;
static inline void _buffer_overflow_check(BUFFER *b, const char *file, const char *function, const unsigned long line)
{
if(b->len > b->size) {
- error("BUFFER: length %ld is above size %ld, at line %lu, at function %s() of file '%s'.", b->len, b->size, line, function, file);
+ error("BUFFER: length %zu is above size %zu, at line %lu, at function %s() of file '%s'.", b->len, b->size, line, function, file);
b->len = b->size;
}
buffer_overflow_check(wb);
if(*txt) {
- debug(D_WEB_BUFFER, "strcat(): increasing web_buffer at position %ld, size = %ld\n", wb->len, wb->size);
+ debug(D_WEB_BUFFER, "strcat(): increasing web_buffer at position %zu, size = %zu\n", wb->len, wb->size);
len = strlen(txt);
buffer_increase(wb, len);
buffer_strcat(wb, txt);
// if it does.
buffer_overflow_check(wb);
- debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %ld, size = %ld\n", wb->len, wb->size);
+ debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %zu, size = %zu\n", wb->len, wb->size);
buffer_need_bytes(wb, len + WEB_DATA_LENGTH_INCREASE_STEP);
va_start(args, fmt);
// check if the file is owned by expected user
if(stat.st_uid != web_files_uid()) {
- error("%llu: File '%s' is owned by user %d (expected user %d). Access Denied.", w->id, webfilename, stat.st_uid, web_files_uid());
+ error("%llu: File '%s' is owned by user %u (expected user %u). Access Denied.", w->id, webfilename, stat.st_uid, web_files_uid());
buffer_sprintf(w->response.data, "Access to file '%s' is not permitted.", webfilename);
return 403;
}
// check if the file is owned by expected group
if(stat.st_gid != web_files_gid()) {
- error("%llu: File '%s' is owned by group %d (expected group %d). Access Denied.", w->id, webfilename, stat.st_gid, web_files_gid());
+ error("%llu: File '%s' is owned by group %u (expected group %u). Access Denied.", w->id, webfilename, stat.st_gid, web_files_gid());
buffer_sprintf(w->response.data, "Access to file '%s' is not permitted.", webfilename);
return 403;
}
units = st->units;
}
- debug(D_WEB_CLIENT, "%llu: API command 'badge.svg' for chart '%s', dimensions '%s', after '%lld', before '%lld', points '%d', group '%u', options '0x%08x'"
+ debug(D_WEB_CLIENT, "%llu: API command 'badge.svg' for chart '%s', dimensions '%s', after '%lld', before '%lld', points '%d', group '%d', options '0x%08x'"
, w->id
, chart
, (dimensions)?buffer_tostring(dimensions):""
long long after = (after_str && *after_str) ?atol(after_str):0;
int points = (points_str && *points_str)?atoi(points_str):0;
- debug(D_WEB_CLIENT, "%llu: API command 'data' for chart '%s', dimensions '%s', after '%lld', before '%lld', points '%d', group '%u', format '%u', options '0x%08x'"
+ debug(D_WEB_CLIENT, "%llu: API command 'data' for chart '%s', dimensions '%s', after '%lld', before '%lld', points '%d', group '%d', format '%u', options '0x%08x'"
, w->id
, chart
, (dimensions)?buffer_tostring(dimensions):""
);
buffer_sprintf(w->response.data,
- "%s({version:'%s',reqId:'%s',status:'ok',sig:'%lu',table:",
+ "%s({version:'%s',reqId:'%s',status:'ok',sig:'%ld',table:",
responseHandler, google_version, google_reqId, st->last_updated.tv_sec);
}
else if(format == DATASOURCE_JSONP) {
if(datasource_type == DATASOURCE_DATATABLE_JSONP) {
buffer_sprintf(w->response.data,
- "%s({version:'%s',reqId:'%s',status:'ok',sig:'%lu',table:",
+ "%s({version:'%s',reqId:'%s',status:'ok',sig:'%ld',table:",
google_responseHandler, google_version, google_reqId, st->last_updated.tv_sec);
}
- debug(D_WEB_CLIENT_ACCESS, "%llu: Sending RRD data '%s' (id %s, %d lines, %d group, %d group_method, %lu after, %lu before).",
+ debug(D_WEB_CLIENT_ACCESS, "%llu: Sending RRD data '%s' (id %s, %d lines, %d group, %d group_method, %ld after, %ld before).",
w->id, st->name, st->id, lines, group_count, group_method, after, before);
time_t timestamp_in_data = rrd_stats_json(datasource_type, st, w->response.data, lines, group_count, group_method, (unsigned long)after, (unsigned long)before, nonzero);
if(w->response.data->len > TOO_BIG_REQUEST) {
strcpy(w->last_url, "too big request");
- debug(D_WEB_CLIENT_ACCESS, "%llu: Received request is too big (%zd bytes).", w->id, w->response.data->len);
+ debug(D_WEB_CLIENT_ACCESS, "%llu: Received request is too big (%zu bytes).", w->id, w->response.data->len);
code = 400;
buffer_flush(w->response.data);
- buffer_sprintf(w->response.data, "Received request is too big (%zd bytes).\r\n", w->response.data->len);
+ buffer_sprintf(w->response.data, "Received request is too big (%zu bytes).\r\n", w->response.data->len);
}
else {
// wait for more data
// if we know the content length, put it
if(!w->response.zoutput && (w->response.data->len || w->response.rlen))
buffer_sprintf(w->response.header_output,
- "Content-Length: %ld\r\n"
+ "Content-Length: %zu\r\n"
, w->response.data->len? w->response.data->len: w->response.rlen
);
else if(!w->response.zoutput)
// when using compression,
// w->response.sent is the amount of bytes passed through compression
- debug(D_DEFLATE, "%llu: web_client_send_deflate(): w->response.data->len = %zu, w->response.sent = %zu, w->response.zhave = %zu, w->response.zsent = %zu, w->response.zstream.avail_in = %d, w->response.zstream.avail_out = %d, w->response.zstream.total_in = %lu, w->response.zstream.total_out = %lu.",
+ debug(D_DEFLATE, "%llu: web_client_send_deflate(): w->response.data->len = %zu, w->response.sent = %zu, w->response.zhave = %zu, w->response.zsent = %zu, w->response.zstream.avail_in = %u, w->response.zstream.avail_out = %u, w->response.zstream.total_in = %lu, w->response.zstream.total_out = %lu.",
w->id, w->response.data->len, w->response.sent, w->response.zhave, w->response.zsent, w->response.zstream.avail_in, w->response.zstream.avail_out, w->response.zstream.total_in, w->response.zstream.total_out);
if(w->response.data->len - w->response.sent == 0 && w->response.zstream.avail_in == 0 && w->response.zhave == w->response.zsent && w->response.zstream.avail_out != 0) {
}
if(unlikely(!w->keepalive)) {
- debug(D_WEB_CLIENT, "%llu: Closing (keep-alive is not enabled). %ld bytes sent.", w->id, w->response.sent);
+ debug(D_WEB_CLIENT, "%llu: Closing (keep-alive is not enabled). %zu bytes sent.", w->id, w->response.sent);
WEB_CLIENT_IS_DEAD(w);
return t;
}
w->stats_sent_bytes += len;
w->response.zsent += len;
len += t;
- debug(D_WEB_CLIENT, "%llu: Sent %zu bytes.", w->id, len);
+ debug(D_WEB_CLIENT, "%llu: Sent %zd bytes.", w->id, len);
}
else if(len == 0) {
debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client (zhave = %zu, zsent = %zu, need to send = %zu).",
}
if(unlikely(!w->keepalive)) {
- debug(D_WEB_CLIENT, "%llu: Closing (keep-alive is not enabled). %ld bytes sent.", w->id, w->response.sent);
+ debug(D_WEB_CLIENT, "%llu: Closing (keep-alive is not enabled). %zu bytes sent.", w->id, w->response.sent);
WEB_CLIENT_IS_DEAD(w);
return 0;
}
if(likely(bytes > 0)) {
w->stats_sent_bytes += bytes;
w->response.sent += bytes;
- debug(D_WEB_CLIENT, "%llu: Sent %zu bytes.", w->id, bytes);
+ debug(D_WEB_CLIENT, "%llu: Sent %zd bytes.", w->id, bytes);
}
else if(likely(bytes == 0)) {
debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client.", w->id);
w->response.data->len += bytes;
w->response.data->buffer[w->response.data->len] = '\0';
- debug(D_WEB_CLIENT, "%llu: Received %zu bytes.", w->id, bytes);
+ debug(D_WEB_CLIENT, "%llu: Received %zd bytes.", w->id, bytes);
debug(D_WEB_DATA, "%llu: Received data: '%s'.", w->id, &w->response.data->buffer[old]);
if(w->mode == WEB_CLIENT_MODE_FILECOPY) {
data = null;
}
- if(data === null && redirect !== null && max_redirects > 0) {
- NETDATA.registry.server = redirect;
- NETDATA.registry.access(max_redirects - 1, callback);
+ if(data === null) {
+ if(redirect !== null && max_redirects > 0) {
+ NETDATA.registry.server = redirect;
+ NETDATA.registry.access(max_redirects - 1, callback);
+ }
+ else {
+ if(typeof callback === 'function')
+ callback(null);
+ }
}
else {
if(typeof data.person_guid === 'string')
callback(null);
});
},
-
+
switch: function(new_person_guid, callback) {
// impersonate
$.ajax({
info: undefined
},
+ 'phpfpm': {
+ title: 'PHP-FPM',
+ info: undefined,
+ },
+
'named': {
title: 'named',
info: undefined
- },
+ }
};
var submenuData = {
break;
case 'mysql':
+ case 'phpfpm':
case 'named':
case 'cgroup':
chart.menu = chart.type;