summaryrefslogtreecommitdiffstats
path: root/node.d
diff options
context:
space:
mode:
Diffstat (limited to 'node.d')
-rw-r--r--node.d/Makefile.am28
-rw-r--r--node.d/Makefile.in583
-rw-r--r--node.d/README.md118
-rw-r--r--node.d/fronius.node.js399
-rw-r--r--node.d/named.node.js609
-rw-r--r--node.d/node_modules/asn1-ber.js6
-rw-r--r--node.d/node_modules/extend.js87
-rw-r--r--node.d/node_modules/lib/ber/errors.js9
-rw-r--r--node.d/node_modules/lib/ber/index.js17
-rw-r--r--node.d/node_modules/lib/ber/reader.js269
-rw-r--r--node.d/node_modules/lib/ber/types.js34
-rw-r--r--node.d/node_modules/lib/ber/writer.js317
-rw-r--r--node.d/node_modules/net-snmp.js1457
-rw-r--r--node.d/node_modules/netdata.js654
-rw-r--r--node.d/node_modules/pixl-xml.js606
-rw-r--r--node.d/sma_webbox.node.js237
-rw-r--r--node.d/snmp.node.js513
-rw-r--r--node.d/stiebeleltron.node.js196
18 files changed, 0 insertions, 6139 deletions
diff --git a/node.d/Makefile.am b/node.d/Makefile.am
deleted file mode 100644
index 7f67faa6a..000000000
--- a/node.d/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
-
-dist_node_DATA = \
- README.md \
- named.node.js \
- fronius.node.js \
- sma_webbox.node.js \
- snmp.node.js \
- stiebeleltron.node.js \
- $(NULL)
-
-nodemodulesdir=$(nodedir)/node_modules
-dist_nodemodules_DATA = \
- node_modules/netdata.js \
- node_modules/extend.js \
- node_modules/pixl-xml.js \
- node_modules/net-snmp.js \
- node_modules/asn1-ber.js \
- $(NULL)
-
-nodemoduleslibberdir=$(nodedir)/node_modules/lib/ber
-dist_nodemoduleslibber_DATA = \
- node_modules/lib/ber/index.js \
- node_modules/lib/ber/errors.js \
- node_modules/lib/ber/reader.js \
- node_modules/lib/ber/types.js \
- node_modules/lib/ber/writer.js \
- $(NULL)
diff --git a/node.d/Makefile.in b/node.d/Makefile.in
deleted file mode 100644
index dd572ee8b..000000000
--- a/node.d/Makefile.in
+++ /dev/null
@@ -1,583 +0,0 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
-
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
-am__make_running_with_option = \
- case $${target_option-} in \
- ?) ;; \
- *) echo "am__make_running_with_option: internal error: invalid" \
- "target option '$${target_option-}' specified" >&2; \
- exit 1;; \
- esac; \
- has_opt=no; \
- sane_makeflags=$$MAKEFLAGS; \
- if $(am__is_gnu_make); then \
- sane_makeflags=$$MFLAGS; \
- else \
- case $$MAKEFLAGS in \
- *\\[\ \ ]*) \
- bs=\\; \
- sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
- | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
- esac; \
- fi; \
- skip_next=no; \
- strip_trailopt () \
- { \
- flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
- }; \
- for flg in $$sane_makeflags; do \
- test $$skip_next = yes && { skip_next=no; continue; }; \
- case $$flg in \
- *=*|--*) continue;; \
- -*I) strip_trailopt 'I'; skip_next=yes;; \
- -*I?*) strip_trailopt 'I';; \
- -*O) strip_trailopt 'O'; skip_next=yes;; \
- -*O?*) strip_trailopt 'O';; \
- -*l) strip_trailopt 'l'; skip_next=yes;; \
- -*l?*) strip_trailopt 'l';; \
- -[dEDm]) skip_next=yes;; \
- -[JT]) skip_next=yes;; \
- esac; \
- case $$flg in \
- *$$target_option*) has_opt=yes; break;; \
- esac; \
- done; \
- test $$has_opt = yes
-am__make_dryrun = (target_option=n; $(am__make_running_with_option))
-am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-subdir = node.d
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
- $(dist_node_DATA) $(dist_nodemodules_DATA) \
- $(dist_nodemoduleslibber_DATA)
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___atomic.m4 \
- $(top_srcdir)/m4/ax_c__generic.m4 $(top_srcdir)/m4/ax_c_lto.m4 \
- $(top_srcdir)/m4/ax_c_mallinfo.m4 \
- $(top_srcdir)/m4/ax_c_mallopt.m4 \
- $(top_srcdir)/m4/ax_check_compile_flag.m4 \
- $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
- $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/jemalloc.m4 \
- $(top_srcdir)/m4/tcmalloc.m4 $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-AM_V_P = $(am__v_P_@AM_V@)
-am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
-am__v_P_0 = false
-am__v_P_1 = :
-AM_V_GEN = $(am__v_GEN_@AM_V@)
-am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
-am__v_GEN_0 = @echo " GEN " $@;
-am__v_GEN_1 =
-AM_V_at = $(am__v_at_@AM_V@)
-am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
-am__v_at_0 = @
-am__v_at_1 =
-SOURCES =
-DIST_SOURCES =
-am__can_run_installinfo = \
- case $$AM_UPDATE_INFO_DIR in \
- n|no|NO) false;; \
- *) (install-info --version) >/dev/null 2>&1;; \
- esac
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
- $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
- *) f=$$p;; \
- esac;
-am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
-am__install_max = 40
-am__nobase_strip_setup = \
- srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
-am__nobase_strip = \
- for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
-am__nobase_list = $(am__nobase_strip_setup); \
- for p in $$list; do echo "$$p $$p"; done | \
- sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
- $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
- if (++n[$$2] == $(am__install_max)) \
- { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
- END { for (dir in files) print dir, files[dir] }'
-am__base_list = \
- sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
- sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__uninstall_files_from_dir = { \
- test -z "$$files" \
- || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
- || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
- $(am__cd) "$$dir" && rm -f $$files; }; \
- }
-am__installdirs = "$(DESTDIR)$(nodedir)" "$(DESTDIR)$(nodemodulesdir)" \
- "$(DESTDIR)$(nodemoduleslibberdir)"
-DATA = $(dist_node_DATA) $(dist_nodemodules_DATA) \
- $(dist_nodemoduleslibber_DATA)
-am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-GREP = @GREP@
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-IPMIMONITORING_CFLAGS = @IPMIMONITORING_CFLAGS@
-IPMIMONITORING_LIBS = @IPMIMONITORING_LIBS@
-LDFLAGS = @LDFLAGS@
-LIBCAP_CFLAGS = @LIBCAP_CFLAGS@
-LIBCAP_LIBS = @LIBCAP_LIBS@
-LIBMNL_CFLAGS = @LIBMNL_CFLAGS@
-LIBMNL_LIBS = @LIBMNL_LIBS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-MATH_CFLAGS = @MATH_CFLAGS@
-MATH_LIBS = @MATH_LIBS@
-MKDIR_P = @MKDIR_P@
-NFACCT_CFLAGS = @NFACCT_CFLAGS@
-NFACCT_LIBS = @NFACCT_LIBS@
-OBJEXT = @OBJEXT@
-OPTIONAL_IPMIMONITORING_CFLAGS = @OPTIONAL_IPMIMONITORING_CFLAGS@
-OPTIONAL_IPMIMONITORING_LIBS = @OPTIONAL_IPMIMONITORING_LIBS@
-OPTIONAL_LIBCAP_CFLAGS = @OPTIONAL_LIBCAP_CFLAGS@
-OPTIONAL_LIBCAP_LIBS = @OPTIONAL_LIBCAP_LIBS@
-OPTIONAL_MATH_CLFAGS = @OPTIONAL_MATH_CLFAGS@
-OPTIONAL_MATH_LIBS = @OPTIONAL_MATH_LIBS@
-OPTIONAL_NFACCT_CLFAGS = @OPTIONAL_NFACCT_CLFAGS@
-OPTIONAL_NFACCT_LIBS = @OPTIONAL_NFACCT_LIBS@
-OPTIONAL_UUID_CLFAGS = @OPTIONAL_UUID_CLFAGS@
-OPTIONAL_UUID_LIBS = @OPTIONAL_UUID_LIBS@
-OPTIONAL_ZLIB_CLFAGS = @OPTIONAL_ZLIB_CLFAGS@
-OPTIONAL_ZLIB_LIBS = @OPTIONAL_ZLIB_LIBS@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_RPM_RELEASE = @PACKAGE_RPM_RELEASE@
-PACKAGE_RPM_VERSION = @PACKAGE_RPM_VERSION@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PKG_CONFIG = @PKG_CONFIG@
-PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
-PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
-PTHREAD_CC = @PTHREAD_CC@
-PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
-PTHREAD_LIBS = @PTHREAD_LIBS@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-SSE_CANDIDATE = @SSE_CANDIDATE@
-STRIP = @STRIP@
-UUID_CFLAGS = @UUID_CFLAGS@
-UUID_LIBS = @UUID_LIBS@
-VERSION = @VERSION@
-ZLIB_CFLAGS = @ZLIB_CFLAGS@
-ZLIB_LIBS = @ZLIB_LIBS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-ax_pthread_config = @ax_pthread_config@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-cachedir = @cachedir@
-chartsdir = @chartsdir@
-configdir = @configdir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-has_jemalloc = @has_jemalloc@
-has_tcmalloc = @has_tcmalloc@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-logdir = @logdir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-nodedir = @nodedir@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-pluginsdir = @pluginsdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-pythondir = @pythondir@
-registrydir = @registrydir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-varlibdir = @varlibdir@
-webdir = @webdir@
-MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
-dist_node_DATA = \
- README.md \
- named.node.js \
- fronius.node.js \
- sma_webbox.node.js \
- snmp.node.js \
- stiebeleltron.node.js \
- $(NULL)
-
-nodemodulesdir = $(nodedir)/node_modules
-dist_nodemodules_DATA = \
- node_modules/netdata.js \
- node_modules/extend.js \
- node_modules/pixl-xml.js \
- node_modules/net-snmp.js \
- node_modules/asn1-ber.js \
- $(NULL)
-
-nodemoduleslibberdir = $(nodedir)/node_modules/lib/ber
-dist_nodemoduleslibber_DATA = \
- node_modules/lib/ber/index.js \
- node_modules/lib/ber/errors.js \
- node_modules/lib/ber/reader.js \
- node_modules/lib/ber/types.js \
- node_modules/lib/ber/writer.js \
- $(NULL)
-
-all: all-am
-
-.SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu node.d/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --gnu node.d/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-install-dist_nodeDATA: $(dist_node_DATA)
- @$(NORMAL_INSTALL)
- @list='$(dist_node_DATA)'; test -n "$(nodedir)" || list=; \
- if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(nodedir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(nodedir)" || exit 1; \
- fi; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(nodedir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(nodedir)" || exit $$?; \
- done
-
-uninstall-dist_nodeDATA:
- @$(NORMAL_UNINSTALL)
- @list='$(dist_node_DATA)'; test -n "$(nodedir)" || list=; \
- files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- dir='$(DESTDIR)$(nodedir)'; $(am__uninstall_files_from_dir)
-install-dist_nodemodulesDATA: $(dist_nodemodules_DATA)
- @$(NORMAL_INSTALL)
- @list='$(dist_nodemodules_DATA)'; test -n "$(nodemodulesdir)" || list=; \
- if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(nodemodulesdir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(nodemodulesdir)" || exit 1; \
- fi; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(nodemodulesdir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(nodemodulesdir)" || exit $$?; \
- done
-
-uninstall-dist_nodemodulesDATA:
- @$(NORMAL_UNINSTALL)
- @list='$(dist_nodemodules_DATA)'; test -n "$(nodemodulesdir)" || list=; \
- files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- dir='$(DESTDIR)$(nodemodulesdir)'; $(am__uninstall_files_from_dir)
-install-dist_nodemoduleslibberDATA: $(dist_nodemoduleslibber_DATA)
- @$(NORMAL_INSTALL)
- @list='$(dist_nodemoduleslibber_DATA)'; test -n "$(nodemoduleslibberdir)" || list=; \
- if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(nodemoduleslibberdir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(nodemoduleslibberdir)" || exit 1; \
- fi; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(nodemoduleslibberdir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(nodemoduleslibberdir)" || exit $$?; \
- done
-
-uninstall-dist_nodemoduleslibberDATA:
- @$(NORMAL_UNINSTALL)
- @list='$(dist_nodemoduleslibber_DATA)'; test -n "$(nodemoduleslibberdir)" || list=; \
- files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- dir='$(DESTDIR)$(nodemoduleslibberdir)'; $(am__uninstall_files_from_dir)
-tags TAGS:
-
-ctags CTAGS:
-
-cscope cscopelist:
-
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
-check-am: all-am
-check: check-am
-all-am: Makefile $(DATA)
-installdirs:
- for dir in "$(DESTDIR)$(nodedir)" "$(DESTDIR)$(nodemodulesdir)" "$(DESTDIR)$(nodemoduleslibberdir)"; do \
- test -z "$$dir" || $(MKDIR_P) "$$dir"; \
- done
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- if test -z '$(STRIP)'; then \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- install; \
- else \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
- fi
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
- -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-clean: clean-am
-
-clean-am: clean-generic mostlyclean-am
-
-distclean: distclean-am
- -rm -f Makefile
-distclean-am: clean-am distclean-generic
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am: install-dist_nodeDATA install-dist_nodemodulesDATA \
- install-dist_nodemoduleslibberDATA
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-generic
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-dist_nodeDATA uninstall-dist_nodemodulesDATA \
- uninstall-dist_nodemoduleslibberDATA
-
-.MAKE: install-am install-strip
-
-.PHONY: all all-am check check-am clean clean-generic cscopelist-am \
- ctags-am distclean distclean-generic distdir dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-dist_nodeDATA \
- install-dist_nodemodulesDATA \
- install-dist_nodemoduleslibberDATA install-dvi install-dvi-am \
- install-exec install-exec-am install-html install-html-am \
- install-info install-info-am install-man install-pdf \
- install-pdf-am install-ps install-ps-am install-strip \
- installcheck installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
- pdf-am ps ps-am tags-am uninstall uninstall-am \
- uninstall-dist_nodeDATA uninstall-dist_nodemodulesDATA \
- uninstall-dist_nodemoduleslibberDATA
-
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/node.d/README.md b/node.d/README.md
deleted file mode 100644
index 6818d34de..000000000
--- a/node.d/README.md
+++ /dev/null
@@ -1,118 +0,0 @@
-# Disclaimer
-
-Module configurations are written in JSON and **node.js is required**.
-
-to be edited.
-
----
-
-The following node.d modules are supported:
-
-# fronius
-
-This module collects metrics from the configured solar power installation from Fronius Symo.
-See `netdata/conf.d/node.d/fronius.conf.md` for more details.
-
-**Requirements**
- * Configuration file `fronius.conf` in the node.d netdata config dir (default: `/etc/netdata/node.d/fronius.conf`)
- * Fronius Symo with network access (http)
-
-It produces per server:
-
-1. **Power**
- * Current power input from the grid (positive values), output to the grid (negative values), in W
- * Current power input from the solar panels, in W
- * Current power stored in the accumulator (if present), in W (in theory, untested)
-
-2. **Consumption**
- * Local consumption in W
-
-3. **Autonomy**
- * Relative autonomy in %. 100 % autonomy means that the solar panels are delivering more power than it is needed by local consumption.
- * Relative self consumption in %. The lower the better
-
-4. **Energy**
- * The energy produced during the current day, in kWh
- * The energy produced during the current year, in kWh
-
-5. **Inverter**
- * The current power output from the connected inverters, in W, one dimension per inverter. At least one is always present.
-
-
-### configuration
-
-Sample:
-
-```json
-{
- "enable_autodetect": false,
- "update_every": 5,
- "servers": [
- {
- "name": "Symo",
- "hostname": "symo.ip.or.dns",
- "update_every": 5,
- "api_path": "/solar_api/v1/GetPowerFlowRealtimeData.fcgi"
- }
- ]
-}
-```
-
-If no configuration is given, the module will be disabled. Each `update_every` is optional, the default is `5`.
-
----
-
-# stiebel eltron
-
-This module collects metrics from the configured heat pump and hot water installation from Stiebel Eltron ISG web.
-See `netdata/conf.d/node.d/stiebeleltron.conf.md` for more details.
-
-**Requirements**
- * Configuration file `stiebeleltron.conf` in the node.d netdata config dir (default: `/etc/netdata/node.d/stiebeleltron.conf`)
- * Stiebel Eltron ISG web with network access (http), without password login
-
-The charts are configurable, however, the provided default configuration collects the following:
-
-1. **General**
- * Outside temperature in C
- * Condenser temperature in C
- * Heating circuit pressure in bar
- * Flow rate in l/min
- * Output of water and heat pumps in %
-
-2. **Heating**
- * Heat circuit 1 temperature in C (set/actual)
- * Heat circuit 2 temperature in C (set/actual)
- * Flow temperature in C (set/actual)
- * Buffer temperature in C (set/actual)
- * Pre-flow temperature in C
-
-3. **Hot Water**
- * Hot water temperature in C (set/actual)
-
-4. **Room Temperature**
- * Heat circuit 1 room temperature in C (set/actual)
- * Heat circuit 2 room temperature in C (set/actual)
-
-5. **Eletric Reheating**
- * Dual Mode Reheating temperature in C (hot water/heating)
-
-6. **Process Data**
- * Remaining compressor rest time in s
-
-7. **Runtime**
- * Compressor runtime hours (hot water/heating)
- * Reheating runtime hours (reheating 1/reheating 2)
-
-8. **Energy**
- * Compressor today in kWh (hot water/heating)
- * Compressor Total in kWh (hot water/heating)
-
-
-### configuration
-
-The default configuration is provided in [netdata/conf.d/node.d/stiebeleltron.conf.md](https://github.com/firehol/netdata/blob/master/conf.d/node.d/stiebeleltron.conf.md). Just change the `update_every` (if necessary) and hostnames. **You may have to adapt the configuration to suit your needs and setup** (which might be different).
-
-If no configuration is given, the module will be disabled. Each `update_every` is optional, the default is `10`.
-
----
diff --git a/node.d/fronius.node.js b/node.d/fronius.node.js
deleted file mode 100644
index fc49e5d38..000000000
--- a/node.d/fronius.node.js
+++ /dev/null
@@ -1,399 +0,0 @@
-"use strict";
-
-// This program will connect to one or more Fronius Symo Inverters.
-// to get the Solar Power Generated (current, today).
-
-// example configuration in netdata/conf.d/node.d/fronius.conf.md
-
-var url = require("url");
-var http = require("http");
-var netdata = require("netdata");
-
-netdata.debug("loaded " + __filename + " plugin");
-
-var fronius = {
- name: "Fronius",
- enable_autodetect: false,
- update_every: 5,
- base_priority: 60000,
- charts: {},
-
- powerGridId: "p_grid",
- powerPvId: "p_pv",
- powerAccuId: "p_akku", // not my typo! Using the ID from the AP
- consumptionLoadId: "p_load",
- autonomyId: "rel_autonomy",
- consumptionSelfId: "rel_selfconsumption",
- solarConsumptionId: "solar_consumption",
- energyTodayId: "e_day",
- energyYearId: "e_year",
-
- createBasicDimension: function (id, name, divisor) {
- return {
- id: id, // the unique id of the dimension
- name: name, // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: divisor, // the divisor
- hidden: false // is hidden (boolean)
- };
- },
-
- // Gets the site power chart. Will be created if not existing.
- getSitePowerChart: function (service, suffix) {
- var id = this.getChartId(service, suffix);
- var chart = fronius.charts[id];
- if (fronius.isDefined(chart)) return chart;
-
- var dim = {};
- dim[fronius.powerGridId] = this.createBasicDimension(fronius.powerGridId, "grid", 1);
- dim[fronius.powerPvId] = this.createBasicDimension(fronius.powerPvId, "photovoltaics", 1);
- dim[fronius.powerAccuId] = this.createBasicDimension(fronius.powerAccuId, "accumulator", 1);
-
- chart = {
- id: id, // the unique id of the chart
- name: "", // the unique name of the chart
- title: service.name + " Current Site Power", // the title of the chart
- units: "W", // the units of the chart dimensions
- family: "power", // the family of the chart
- context: "fronius.power", // the context of the chart
- type: netdata.chartTypes.area, // the type of the chart
- priority: fronius.base_priority + 1, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: dim
- };
- chart = service.chart(id, chart);
- fronius.charts[id] = chart;
-
- return chart;
- },
-
- // Gets the site consumption chart. Will be created if not existing.
- getSiteConsumptionChart: function (service, suffix) {
- var id = this.getChartId(service, suffix);
- var chart = fronius.charts[id];
- if (fronius.isDefined(chart)) return chart;
- var dim = {};
- dim[fronius.consumptionLoadId] = this.createBasicDimension(fronius.consumptionLoadId, "load", 1);
-
- chart = {
- id: id, // the unique id of the chart
- name: "", // the unique name of the chart
- title: service.name + " Current Load", // the title of the chart
- units: "W", // the units of the chart dimensions
- family: "consumption", // the family of the chart
- context: "fronius.consumption", // the context of the chart
- type: netdata.chartTypes.area, // the type of the chart
- priority: fronius.base_priority + 2, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: dim
- };
- chart = service.chart(id, chart);
- fronius.charts[id] = chart;
-
- return chart;
- },
-
- // Gets the site consumption chart. Will be created if not existing.
- getSiteAutonomyChart: function (service, suffix) {
- var id = this.getChartId(service, suffix);
- var chart = fronius.charts[id];
- if (fronius.isDefined(chart)) return chart;
- var dim = {};
- dim[fronius.autonomyId] = this.createBasicDimension(fronius.autonomyId, "autonomy", 1);
- dim[fronius.consumptionSelfId] = this.createBasicDimension(fronius.consumptionSelfId, "self_consumption", 1);
- dim[fronius.solarConsumptionId] = this.createBasicDimension(fronius.solarConsumptionId, "solar_consumption", 1);
-
- chart = {
- id: id, // the unique id of the chart
- name: "", // the unique name of the chart
- title: service.name + " Current Autonomy", // the title of the chart
- units: "%", // the units of the chart dimensions
- family: "autonomy", // the family of the chart
- context: "fronius.autonomy", // the context of the chart
- type: netdata.chartTypes.area, // the type of the chart
- priority: fronius.base_priority + 3, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: dim
- };
- chart = service.chart(id, chart);
- fronius.charts[id] = chart;
-
- return chart;
- },
-
- // Gets the site energy chart for today. Will be created if not existing.
- getSiteEnergyTodayChart: function (service, suffix) {
- var chartId = this.getChartId(service, suffix);
- var chart = fronius.charts[chartId];
- if (fronius.isDefined(chart)) return chart;
- var dim = {};
- dim[fronius.energyTodayId] = this.createBasicDimension(fronius.energyTodayId, "today", 1000);
- chart = {
- id: chartId, // the unique id of the chart
- name: "", // the unique name of the chart
- title: service.name + " Energy production for today",// the title of the chart
- units: "kWh", // the units of the chart dimensions
- family: "energy", // the family of the chart
- context: "fronius.energy.today", // the context of the chart
- type: netdata.chartTypes.area, // the type of the chart
- priority: fronius.base_priority + 4, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: dim
- };
- chart = service.chart(chartId, chart);
- fronius.charts[chartId] = chart;
-
- return chart;
- },
-
- // Gets the site energy chart for today. Will be created if not existing.
- getSiteEnergyYearChart: function (service, suffix) {
- var chartId = this.getChartId(service, suffix);
- var chart = fronius.charts[chartId];
- if (fronius.isDefined(chart)) return chart;
- var dim = {};
- dim[fronius.energyYearId] = this.createBasicDimension(fronius.energyYearId, "year", 1000);
- chart = {
- id: chartId, // the unique id of the chart
- name: "", // the unique name of the chart
- title: service.name + " Energy production for this year",// the title of the chart
- units: "kWh", // the units of the chart dimensions
- family: "energy", // the family of the chart
- context: "fronius.energy.year", // the context of the chart
- type: netdata.chartTypes.area, // the type of the chart
- priority: fronius.base_priority + 5, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: dim
- };
- chart = service.chart(chartId, chart);
- fronius.charts[chartId] = chart;
-
- return chart;
- },
-
- // Gets the inverter power chart. Will be created if not existing.
- // Needs the array of inverters in order to create a chart with all inverters as dimensions
- getInverterPowerChart: function (service, suffix, inverters) {
- var chartId = this.getChartId(service, suffix);
- var chart = fronius.charts[chartId];
- if (fronius.isDefined(chart)) return chart;
-
- var dim = {};
- for (var key in inverters) {
- if (inverters.hasOwnProperty(key)) {
- var name = key;
- if (!isNaN(key)) name = "inverter_" + key;
- dim[key] = this.createBasicDimension("inverter_" + key, name, 1);
- }
- }
-
- chart = {
- id: chartId, // the unique id of the chart
- name: "", // the unique name of the chart
- title: service.name + " Current Inverter Output",// the title of the chart
- units: "W", // the units of the chart dimensions
- family: "inverters", // the family of the chart
- context: "fronius.inverter.output", // the context of the chart
- type: netdata.chartTypes.stacked, // the type of the chart
- priority: fronius.base_priority + 6, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: dim
- };
- chart = service.chart(chartId, chart);
- fronius.charts[chartId] = chart;
-
- return chart;
- },
-
- processResponse: function (service, content) {
- var json = fronius.convertToJson(content);
- if (json === null) return;
-
- // add the service
- service.commit();
-
- var chartDefinitions = fronius.parseCharts(service, json);
- var chartCount = chartDefinitions.length;
- while (chartCount--) {
- var chartObj = chartDefinitions[chartCount];
- service.begin(chartObj.chart);
- var dimCount = chartObj.dimensions.length;
- while (dimCount--) {
- var dim = chartObj.dimensions[dimCount];
- service.set(dim.name, dim.value);
- }
- service.end();
- }
- },
-
- parseCharts: function (service, json) {
- var site = json.Body.Data.Site;
- return [
- this.parsePowerChart(service, site),
- this.parseConsumptionChart(service, site),
- this.parseAutonomyChart(service, site),
- this.parseEnergyTodayChart(service, site),
- this.parseEnergyYearChart(service, site),
- this.parseInverterChart(service, json.Body.Data.Inverters)
- ];
- },
-
- parsePowerChart: function (service, site) {
- return this.getChart(this.getSitePowerChart(service, "power"),
- [
- this.getDimension(this.powerGridId, Math.round(site.P_Grid)),
- this.getDimension(this.powerPvId, Math.round(Math.max(site.P_PV, 0))),
- this.getDimension(this.powerAccuId, Math.round(site.P_Akku))
- ]
- );
- },
-
- parseConsumptionChart: function (service, site) {
- return this.getChart(this.getSiteConsumptionChart(service, "consumption"),
- [this.getDimension(this.consumptionLoadId, Math.round(Math.abs(site.P_Load)))]
- );
- },
-
- parseAutonomyChart: function (service, site) {
- var selfConsumption = site.rel_SelfConsumption;
- var solarConsumption = 0;
- var load = Math.abs(site.P_Load);
- var power = Math.max(site.P_PV, 0);
- if (power <= 0) solarConsumption = 0;
- else if (load >= power) solarConsumption = 100;
- else solarConsumption = 100 / power * load;
- return this.getChart(this.getSiteAutonomyChart(service, "autonomy"),
- [
- this.getDimension(this.autonomyId, Math.round(site.rel_Autonomy)),
- this.getDimension(this.consumptionSelfId, Math.round(selfConsumption === null ? 100 : selfConsumption)),
- this.getDimension(this.solarConsumptionId, Math.round(solarConsumption))
- ]
- );
- },
-
- parseEnergyTodayChart: function (service, site) {
- return this.getChart(this.getSiteEnergyTodayChart(service, "energy.today"),
- [this.getDimension(this.energyTodayId, Math.round(Math.max(site.E_Day, 0)))]
- );
- },
-
- parseEnergyYearChart: function (service, site) {
- return this.getChart(this.getSiteEnergyYearChart(service, "energy.year"),
- [this.getDimension(this.energyYearId, Math.round(Math.max(site.E_Year, 0)))]
- );
- },
-
- parseInverterChart: function (service, inverters) {
- var dimensions = [];
- for (var key in inverters) {
- if (inverters.hasOwnProperty(key)) {
- dimensions.push(this.getDimension(key, Math.round(inverters[key].P)));
- }
- }
- return this.getChart(this.getInverterPowerChart(service, "inverters.output", inverters), dimensions);
- },
-
- getDimension: function (name, value) {
- return {
- name: name,
- value: value
- };
- },
-
- getChart: function (chart, dimensions) {
- return {
- chart: chart,
- dimensions: dimensions
- };
- },
-
- getChartId: function (service, suffix) {
- return "fronius_" + service.name + "." + suffix;
- },
-
- convertToJson: function (httpBody) {
- if (httpBody === null) return null;
- var json = httpBody;
- // can't parse if it's already a json object,
- // the check enables easier testing if the httpBody is already valid JSON.
- if (typeof httpBody !== "object") {
- try {
- json = JSON.parse(httpBody);
- } catch (error) {
- netdata.error("fronius: Got a response, but it is not valid JSON. Ignoring. Error: " + error.message);
- return null;
- }
- }
- return this.isResponseValid(json) ? json : null;
- },
-
- // some basic validation
- isResponseValid: function (json) {
- if (this.isUndefined(json.Body)) return false;
- if (this.isUndefined(json.Body.Data)) return false;
- if (this.isUndefined(json.Body.Data.Site)) return false;
- return this.isDefined(json.Body.Data.Inverters);
- },
-
- // module.serviceExecute()
- // this function is called only from this module
- // its purpose is to prepare the request and call
- // netdata.serviceExecute()
- serviceExecute: function (name, uri, update_every) {
- netdata.debug(this.name + ": " + name + ": url: " + uri + ", update_every: " + update_every);
-
- var service = netdata.service({
- name: name,
- request: netdata.requestFromURL("http://" + uri),
- update_every: update_every,
- module: this
- });
- service.execute(this.processResponse);
- },
-
-
- configure: function (config) {
- if (fronius.isUndefined(config.servers)) return 0;
- var added = 0;
- var len = config.servers.length;
- while (len--) {
- var server = config.servers[len];
- if (fronius.isUndefined(server.update_every)) server.update_every = this.update_every;
- if (fronius.areUndefined([server.name, server.hostname, server.api_path])) continue;
-
- var url = server.hostname + server.api_path;
- this.serviceExecute(server.name, url, server.update_every);
- added++;
- }
- return added;
- },
-
- // module.update()
- // this is called repeatedly to collect data, by calling
- // netdata.serviceExecute()
- update: function (service, callback) {
- service.execute(function (serv, data) {
- service.module.processResponse(serv, data);
- callback();
- });
- },
-
- isUndefined: function (value) {
- return typeof value === "undefined";
- },
-
- areUndefined: function (valueArray) {
- var i = 0;
- for (i; i < valueArray.length; i++) {
- if (this.isUndefined(valueArray[i])) return true;
- }
- return false;
- },
-
- isDefined: function (value) {
- return typeof value !== "undefined";
- }
-};
-
-module.exports = fronius;
diff --git a/node.d/named.node.js b/node.d/named.node.js
deleted file mode 100644
index 02c890c60..000000000
--- a/node.d/named.node.js
+++ /dev/null
@@ -1,609 +0,0 @@
-'use strict';
-
-// collect statistics from bind (named) v9.10+
-//
-// bind statistics documentation at:
-// http://jpmens.net/2013/03/18/json-in-bind-9-s-statistics-server/
-// https://ftp.isc.org/isc/bind/9.10.3/doc/arm/Bv9ARM.ch06.html#statistics
-
-// example configuration in /etc/netdata/node.d/named.conf
-// the module supports auto-detection if bind is running at localhost
-
-/*
-{
- "enable_autodetect": true,
- "update_every": 5,
- "servers": [
- {
- "name": "bind1",
- "url": "http://127.0.0.1:8888/json/v1/server",
- "update_every": 1
- },
- {
- "name": "bind2",
- "url": "http://10.0.0.1:8888/xml/v3/server",
- "update_every": 2
- }
- ]
-}
-*/
-
-// the following is the bind named.conf configuration required
-
-/*
-statistics-channels {
- inet 127.0.0.1 port 8888 allow { 127.0.0.1; };
-};
-*/
-
-var url = require('url');
-var http = require('http');
-var XML = require('pixl-xml');
-var netdata = require('netdata');
-
-if(netdata.options.DEBUG === true) netdata.debug('loaded', __filename, 'plugin');
-
-var named = {
- name: __filename,
- enable_autodetect: true,
- update_every: 1,
- base_priority: 60000,
- charts: {},
-
- chartFromMembersCreate: function(service, obj, id, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor) {
- var chart = {
- id: id, // the unique id of the chart
- name: '', // the unique name of the chart
- title: service.name + ' ' + title_suffix, // the title of the chart
- units: units, // the units of the chart dimensions
- family: family, // the family of the chart
- context: context, // the context of the chart
- type: type, // the type of the chart
- priority: priority, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: {}
- };
-
- var found = 0;
- var dims = Object.keys(obj);
- var len = dims.length;
- for(var i = 0; i < len ;i++) {
- var x = dims[i];
-
- if(typeof(obj[x]) !== 'undefined' && obj[x] !== 0) {
- found++;
- chart.dimensions[x] = {
- id: x, // the unique id of the dimension
- name: x, // the name of the dimension
- algorithm: algorithm, // the id of the netdata algorithm
- multiplier: multiplier, // the multiplier
- divisor: divisor, // the divisor
- hidden: false // is hidden (boolean)
- }
- }
- }
-
- if(found === false)
- return null;
-
- chart = service.chart(id, chart);
- this.charts[id] = chart;
- return chart;
- },
-
- chartFromMembers: function(service, obj, id_suffix, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor) {
- var id = 'named_' + service.name + '.' + id_suffix;
- var chart = this.charts[id];
- var dims, len, x, i;
-
- if(typeof chart === 'undefined') {
- chart = this.chartFromMembersCreate(service, obj, id, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor);
- if(chart === null) return false;
- }
- else {
- // check if we need to re-generate the chart
- dims = Object.keys(obj);
- len = dims.length;
- for(i = 0; i < len ;i++) {
- x = dims[i];
- if(typeof(chart.dimensions[x]) === 'undefined') {
- chart = this.chartFromMembersCreate(service, obj, id, title_suffix, units, family, context, type, priority, algorithm, multiplier, divisor);
- if(chart === null) return false;
- break;
- }
- }
- }
-
- service.begin(chart);
-
- var found = 0;
- dims = Object.keys(obj);
- len = dims.length;
- for(i = 0; i < len ;i++) {
- x = dims[i];
- if(typeof(chart.dimensions[x]) !== 'undefined') {
- found++;
- service.set(x, obj[x]);
- }
- }
-
- service.end();
-
- return (found > 0);
- },
-
- // an index to map values to different charts
- lookups: {
- nsstats: {},
- resolver_stats: {},
- numfetch: {}
- },
-
- // transform the XML response of bind
- // to the JSON response of bind
- xml2js: function(service, data_xml) {
- var d = XML.parse(data_xml);
- if(d === null) return null;
-
- var a, aa, alen, alen2;
-
- var data = {};
- var len = d.server.counters.length;
- while(len--) {
- a = d.server.counters[len];
- if(typeof a.counter === 'undefined') continue;
- if(a.type === 'opcode') a.type = 'opcodes';
- else if(a.type === 'qtype') a.type = 'qtypes';
- else if(a.type === 'nsstat') a.type = 'nsstats';
- aa = data[a.type] = {};
- alen = 0;
- alen2 = a.counter.length;
- while(alen < alen2) {
- aa[a.counter[alen].name] = parseInt(a.counter[alen]._Data, 10);
- alen++;
- }
- }
-
- data.views = {};
- var vlen = d.views.view.length;
- while(vlen--) {
- var vname = d.views.view[vlen].name;
- data.views[vname] = { resolver: {} };
- len = d.views.view[vlen].counters.length;
- while(len--) {
- a = d.views.view[vlen].counters[len];
- if(typeof a.counter === 'undefined') continue;
- if(a.type === 'resstats') a.type = 'stats';
- else if(a.type === 'resqtype') a.type = 'qtypes';
- else if(a.type === 'adbstat') a.type = 'adb';
- aa = data.views[vname].resolver[a.type] = {};
- alen = 0;
- alen2 = a.counter.length;
- while(alen < alen2) {
- aa[a.counter[alen].name] = parseInt(a.counter[alen]._Data, 10);
- alen++;
- }
- }
- }
-
- return data;
- },
-
- processResponse: function(service, data) {
- if(data !== null) {
- var r, x, look, id, chart, keys, len;
-
- // parse XML or JSON
- // pepending on the URL given
- if(service.request.path.match(/^\/xml/) !== null)
- r = named.xml2js(service, data);
- else
- r = JSON.parse(data);
-
- if(typeof r === 'undefined' || r === null) {
- service.error("Cannot parse these data: " + data.toString());
- return;
- }
-
- if(service.added !== true)
- service.commit();
-
- if(typeof r.nsstats !== 'undefined') {
- // we split the nsstats object to several others
- var global_requests = {}, global_requests_enable = false;
- var global_failures = {}, global_failures_enable = false;
- var global_failures_detail = {}, global_failures_detail_enable = false;
- var global_updates = {}, global_updates_enable = false;
- var protocol_queries = {}, protocol_queries_enable = false;
- var global_queries = {}, global_queries_enable = false;
- var global_queries_success = {}, global_queries_success_enable = false;
- var default_enable = false;
- var RecursClients = 0;
-
- // RecursClients is an absolute value
- if(typeof r.nsstats['RecursClients'] !== 'undefined') {
- RecursClients = r.nsstats['RecursClients'];
- delete r.nsstats['RecursClients'];
- }
-
- keys = Object.keys(r.nsstats);
- len = keys.length;
- while(len--) {
- x = keys[len];
-
- // we maintain an index of the values found
- // mapping them to objects splitted
-
- look = named.lookups.nsstats[x];
- if(typeof look === 'undefined') {
- // a new value, not found in the index
- // index it:
- if(x === 'Requestv4') {
- named.lookups.nsstats[x] = {
- name: 'IPv4',
- type: 'global_requests'
- };
- }
- else if(x === 'Requestv6') {
- named.lookups.nsstats[x] = {
- name: 'IPv6',
- type: 'global_requests'
- };
- }
- else if(x === 'QryFailure') {
- named.lookups.nsstats[x] = {
- name: 'failures',
- type: 'global_failures'
- };
- }
- else if(x === 'QryUDP') {
- named.lookups.nsstats[x] = {
- name: 'UDP',
- type: 'protocol_queries'
- };
- }
- else if(x === 'QryTCP') {
- named.lookups.nsstats[x] = {
- name: 'TCP',
- type: 'protocol_queries'
- };
- }
- else if(x === 'QrySuccess') {
- named.lookups.nsstats[x] = {
- name: 'queries',
- type: 'global_queries_success'
- };
- }
- else if(x.match(/QryRej$/) !== null) {
- named.lookups.nsstats[x] = {
- name: x,
- type: 'global_failures_detail'
- };
- }
- else if(x.match(/^Qry/) !== null) {
- named.lookups.nsstats[x] = {
- name: x,
- type: 'global_queries'
- };
- }
- else if(x.match(/^Update/) !== null) {
- named.lookups.nsstats[x] = {
- name: x,
- type: 'global_updates'
- };
- }
- else {
- // values not mapped, will remain
- // in the default map
- named.lookups.nsstats[x] = {
- name: x,
- type: 'default'
- };
- }
-
- look = named.lookups.nsstats[x];
- // netdata.error('lookup nsstats value: ' + x + ' >>> ' + named.lookups.nsstats[x].type);
- }
-
- switch(look.type) {
- case 'global_requests': global_requests[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_requests_enable = true; break;
- case 'global_queries': global_queries[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_queries_enable = true; break;
- case 'global_queries_success': global_queries_success[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_queries_success_enable = true; break;
- case 'global_updates': global_updates[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_updates_enable = true; break;
- case 'protocol_queries': protocol_queries[look.name] = r.nsstats[x]; delete r.nsstats[x]; protocol_queries_enable = true; break;
- case 'global_failures': global_failures[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_failures_enable = true; break;
- case 'global_failures_detail': global_failures_detail[look.name] = r.nsstats[x]; delete r.nsstats[x]; global_failures_detail_enable = true; break;
- default: default_enable = true; break;
- }
- }
-
- if(global_requests_enable === true)
- service.module.chartFromMembers(service, global_requests, 'received_requests', 'Bind, Global Received Requests by IP version', 'requests/s', 'requests', 'named.requests', netdata.chartTypes.stacked, named.base_priority + 1, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(global_queries_success_enable === true)
- service.module.chartFromMembers(service, global_queries_success, 'global_queries_success', 'Bind, Global Successful Queries', 'queries/s', 'queries', 'named.queries_succcess', netdata.chartTypes.line, named.base_priority + 2, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(protocol_queries_enable === true)
- service.module.chartFromMembers(service, protocol_queries, 'protocols_queries', 'Bind, Global Queries by IP Protocol', 'queries/s', 'queries', 'named.protocol_queries', netdata.chartTypes.stacked, named.base_priority + 3, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(global_queries_enable === true)
- service.module.chartFromMembers(service, global_queries, 'global_queries', 'Bind, Global Queries Analysis', 'queries/s', 'queries', 'named.global_queries', netdata.chartTypes.stacked, named.base_priority + 4, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(global_updates_enable === true)
- service.module.chartFromMembers(service, global_updates, 'received_updates', 'Bind, Global Received Updates', 'updates/s', 'updates', 'named.global_updates', netdata.chartTypes.stacked, named.base_priority + 5, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(global_failures_enable === true)
- service.module.chartFromMembers(service, global_failures, 'query_failures', 'Bind, Global Query Failures', 'failures/s', 'failures', 'named.global_failures', netdata.chartTypes.line, named.base_priority + 6, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(global_failures_detail_enable === true)
- service.module.chartFromMembers(service, global_failures_detail, 'query_failures_detail', 'Bind, Global Query Failures Analysis', 'failures/s', 'failures', 'named.global_failures_detail', netdata.chartTypes.stacked, named.base_priority + 7, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(default_enable === true)
- service.module.chartFromMembers(service, r.nsstats, 'nsstats', 'Bind, Other Global Server Statistics', 'operations/s', 'other', 'named.nsstats', netdata.chartTypes.line, named.base_priority + 8, netdata.chartAlgorithms.incremental, 1, 1);
-
- // RecursClients chart
- id = 'named_' + service.name + '.recursive_clients';
- chart = named.charts[id];
-
- if(typeof chart === 'undefined') {
- chart = {
- id: id, // the unique id of the chart
- name: '', // the unique name of the chart
- title: service.name + ' Bind, Current Recursive Clients', // the title of the chart
- units: 'clients', // the units of the chart dimensions
- family: 'clients', // the family of the chart
- context: 'named.recursive_clients', // the context of the chart
- type: netdata.chartTypes.line, // the type of the chart
- priority: named.base_priority + 1, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: {
- 'clients': {
- id: 'clients', // the unique id of the dimension
- name: '', // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1, // the divisor
- hidden: false // is hidden (boolean)
- }
- }
- };
-
- chart = service.chart(id, chart);
- named.charts[id] = chart;
- }
-
- service.begin(chart);
- service.set('clients', RecursClients);
- service.end();
- }
-
- if(typeof r.opcodes !== 'undefined')
- service.module.chartFromMembers(service, r.opcodes, 'in_opcodes', 'Bind, Global Incoming Requests by OpCode', 'requests/s', 'requests', 'named.in_opcodes', netdata.chartTypes.stacked, named.base_priority + 9, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(typeof r.qtypes !== 'undefined')
- service.module.chartFromMembers(service, r.qtypes, 'in_qtypes', 'Bind, Global Incoming Requests by Query Type', 'requests/s', 'requests', 'named.in_qtypes', netdata.chartTypes.stacked, named.base_priority + 10, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(typeof r.sockstats !== 'undefined')
- service.module.chartFromMembers(service, r.sockstats, 'in_sockstats', 'Bind, Global Socket Statistics', 'operations/s', 'sockets', 'named.in_sockstats', netdata.chartTypes.line, named.base_priority + 11, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(typeof r.views !== 'undefined') {
- keys = Object.keys(r.views);
- len = keys.length;
- while(len--) {
- x = keys[len];
- var resolver = r.views[x].resolver;
-
- if(typeof resolver !== 'undefined') {
- if(typeof resolver.stats !== 'undefined') {
- var NumFetch = 0;
- var key = service.name + '.' + x;
- var rtt = {}, rtt_enable = false;
- default_enable = false;
-
- // NumFetch is an absolute value
- if(typeof resolver.stats['NumFetch'] !== 'undefined') {
- named.lookups.numfetch[key] = true;
- NumFetch = resolver.stats['NumFetch'];
- delete resolver.stats['NumFetch'];
- }
- if(typeof resolver.stats['BucketSize'] !== 'undefined') {
- delete resolver.stats['BucketSize'];
- }
-
- // split the QryRTT* from the main chart
- var ykeys = Object.keys(resolver.stats);
- var ylen = ykeys.length;
- while(ylen--) {
- var y = ykeys[ylen];
-
- // we maintain an index of the values found
- // mapping them to objects splitted
-
- look = named.lookups.resolver_stats[y];
- if(typeof look === 'undefined') {
- if(y.match(/^QryRTT/) !== null) {
- named.lookups.resolver_stats[y] = {
- name: y,
- type: 'rtt'
- };
- }
- else {
- named.lookups.resolver_stats[y] = {
- name: y,
- type: 'default'
- };
- }
-
- look = named.lookups.resolver_stats[y];
- // netdata.error('lookup resolver stats value: ' + y + ' >>> ' + look.type);
- }
-
- switch(look.type) {
- case 'rtt': rtt[look.name] = resolver.stats[y]; delete resolver.stats[y]; rtt_enable = true; break;
- default: default_enable = true; break;
- }
- }
-
- if(rtt_enable)
- service.module.chartFromMembers(service, rtt, 'view_resolver_rtt_' + x, 'Bind, ' + x + ' View, Resolver Round Trip Timings', 'queries/s', 'view_' + x, 'named.resolver_rtt', netdata.chartTypes.stacked, named.base_priority + 12, netdata.chartAlgorithms.incremental, 1, 1);
-
- if(default_enable)
- service.module.chartFromMembers(service, resolver.stats, 'view_resolver_stats_' + x, 'Bind, ' + x + ' View, Resolver Statistics', 'operations/s', 'view_' + x, 'named.resolver_stats', netdata.chartTypes.line, named.base_priority + 13, netdata.chartAlgorithms.incremental, 1, 1);
-
- // NumFetch chart
- if(typeof named.lookups.numfetch[key] !== 'undefined') {
- id = 'named_' + service.name + '.view_resolver_numfetch_' + x;
- chart = named.charts[id];
-
- if(typeof chart === 'undefined') {
- chart = {
- id: id, // the unique id of the chart
- name: '', // the unique name of the chart
- title: service.name + ' Bind, ' + x + ' View, Resolver Active Queries', // the title of the chart
- units: 'queries', // the units of the chart dimensions
- family: 'view_' + x, // the family of the chart
- context: 'named.resolver_active_queries', // the context of the chart
- type: netdata.chartTypes.line, // the type of the chart
- priority: named.base_priority + 1001, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: {
- 'queries': {
- id: 'queries', // the unique id of the dimension
- name: '', // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1, // the divisor
- hidden: false // is hidden (boolean)
- }
- }
- };
-
- chart = service.chart(id, chart);
- named.charts[id] = chart;
- }
-
- service.begin(chart);
- service.set('queries', NumFetch);
- service.end();
- }
- }
- }
-
- if(typeof resolver.qtypes !== 'undefined')
- service.module.chartFromMembers(service, resolver.qtypes, 'view_resolver_qtypes_' + x, 'Bind, ' + x + ' View, Requests by Query Type', 'requests/s', 'view_' + x, 'named.resolver_qtypes', netdata.chartTypes.stacked, named.base_priority + 14, netdata.chartAlgorithms.incremental, 1, 1);
-
- //if(typeof resolver.cache !== 'undefined')
- // service.module.chartFromMembers(service, resolver.cache, 'view_resolver_cache_' + x, 'Bind, ' + x + ' View, Cache Entries', 'entries', 'view_' + x, 'named.resolver_cache', netdata.chartTypes.stacked, named.base_priority + 15, netdata.chartAlgorithms.absolute, 1, 1);
-
- if(typeof resolver.cachestats['CacheHits'] !== 'undefined' && resolver.cachestats['CacheHits'] > 0) {
- id = 'named_' + service.name + '.view_resolver_cachehits_' + x;
- chart = named.charts[id];
-
- if(typeof chart === 'undefined') {
- chart = {
- id: id, // the unique id of the chart
- name: '', // the unique name of the chart
- title: service.name + ' Bind, ' + x + ' View, Resolver Cache Hits', // the title of the chart
- units: 'operations/s', // the units of the chart dimensions
- family: 'view_' + x, // the family of the chart
- context: 'named.resolver_cache_hits', // the context of the chart
- type: netdata.chartTypes.area, // the type of the chart
- priority: named.base_priority + 1100, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: {
- 'CacheHits': {
- id: 'CacheHits', // the unique id of the dimension
- name: 'hits', // the name of the dimension
- algorithm: netdata.chartAlgorithms.incremental,// the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1, // the divisor
- hidden: false // is hidden (boolean)
- },
- 'CacheMisses': {
- id: 'CacheMisses', // the unique id of the dimension
- name: 'misses', // the name of the dimension
- algorithm: netdata.chartAlgorithms.incremental,// the id of the netdata algorithm
- multiplier: -1, // the multiplier
- divisor: 1, // the divisor
- hidden: false // is hidden (boolean)
- }
- }
- };
-
- chart = service.chart(id, chart);
- named.charts[id] = chart;
- }
-
- service.begin(chart);
- service.set('CacheHits', resolver.cachestats['CacheHits']);
- service.set('CacheMisses', resolver.cachestats['CacheMisses']);
- service.end();
- }
-
- // this is wrong, it contains many types of info:
- // 1. CacheHits, CacheMisses - incremental (added above)
- // 2. QueryHits, QueryMisses - incremental
- // 3. DeleteLRU, DeleteTTL - incremental
- // 4. CacheNodes, CacheBuckets - absolute
- // 5. TreeMemTotal, TreeMemInUse - absolute
- // 6. HeapMemMax, HeapMemTotal, HeapMemInUse - absolute
- //if(typeof resolver.cachestats !== 'undefined')
- // service.module.chartFromMembers(service, resolver.cachestats, 'view_resolver_cachestats_' + x, 'Bind, ' + x + ' View, Cache Statistics', 'requests/s', 'view_' + x, 'named.resolver_cache_stats', netdata.chartTypes.line, named.base_priority + 1001, netdata.chartAlgorithms.incremental, 1, 1);
-
- //if(typeof resolver.adb !== 'undefined')
- // service.module.chartFromMembers(service, resolver.adb, 'view_resolver_adb_' + x, 'Bind, ' + x + ' View, ADB Statistics', 'entries', 'view_' + x, 'named.resolver_adb', netdata.chartTypes.line, named.base_priority + 1002, netdata.chartAlgorithms.absolute, 1, 1);
- }
- }
- }
- },
-
- // module.serviceExecute()
- // this function is called only from this module
- // its purpose is to prepare the request and call
- // netdata.serviceExecute()
- serviceExecute: function(name, a_url, update_every) {
- if(netdata.options.DEBUG === true) netdata.debug(this.name + ': ' + name + ': url: ' + a_url + ', update_every: ' + update_every);
- var service = netdata.service({
- name: name,
- request: netdata.requestFromURL(a_url),
- update_every: update_every,
- module: this
- });
-
- service.execute(this.processResponse);
- },
-
- configure: function(config) {
- var added = 0;
-
- if(this.enable_autodetect === true) {
- this.serviceExecute('local', 'http://localhost:8888/json/v1/server', this.update_every);
- added++;
- }
-
- if(typeof(config.servers) !== 'undefined') {
- var len = config.servers.length;
- while(len--) {
- if(typeof config.servers[len].update_every === 'undefined')
- config.servers[len].update_every = this.update_every;
-
- this.serviceExecute(config.servers[len].name, config.servers[len].url, config.servers[len].update_every);
- added++;
- }
- }
-
- return added;
- },
-
- // module.update()
- // this is called repeatidly to collect data, by calling
- // netdata.serviceExecute()
- update: function(service, callback) {
- service.execute(function(serv, data) {
- service.module.processResponse(serv, data);
- callback();
- });
- }
-};
-
-module.exports = named;
diff --git a/node.d/node_modules/asn1-ber.js b/node.d/node_modules/asn1-ber.js
deleted file mode 100644
index 57809f486..000000000
--- a/node.d/node_modules/asn1-ber.js
+++ /dev/null
@@ -1,6 +0,0 @@
-
-var Ber = require('./lib/ber/index')
-
-exports.Ber = Ber
-exports.BerReader = Ber.Reader
-exports.BerWriter = Ber.Writer
diff --git a/node.d/node_modules/extend.js b/node.d/node_modules/extend.js
deleted file mode 100644
index 0fdd8be22..000000000
--- a/node.d/node_modules/extend.js
+++ /dev/null
@@ -1,87 +0,0 @@
-// https://github.com/justmoon/node-extend
-
-'use strict';
-
-var hasOwn = Object.prototype.hasOwnProperty;
-var toStr = Object.prototype.toString;
-
-var isArray = function isArray(arr) {
- if (typeof Array.isArray === 'function') {
- return Array.isArray(arr);
- }
-
- return toStr.call(arr) === '[object Array]';
-};
-
-var isPlainObject = function isPlainObject(obj) {
- if (!obj || toStr.call(obj) !== '[object Object]') {
- return false;
- }
-
- var hasOwnConstructor = hasOwn.call(obj, 'constructor');
- var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
- // Not own constructor property must be Object
- if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
- return false;
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
- var key;
- for (key in obj) { /**/ }
-
- return typeof key === 'undefined' || hasOwn.call(obj, key);
-};
-
-module.exports = function extend() {
- var options, name, src, copy, copyIsArray, clone;
- var target = arguments[0];
- var i = 1;
- var length = arguments.length;
- var deep = false;
-
- // Handle a deep copy situation
- if (typeof target === 'boolean') {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- } else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) {
- target = {};
- }
-
- for (; i < length; ++i) {
- options = arguments[i];
- // Only deal with non-null/undefined values
- if (options != null) {
- // Extend the base object
- for (name in options) {
- src = target[name];
- copy = options[name];
-
- // Prevent never-ending loop
- if (target !== copy) {
- // Recurse if we're merging plain objects or arrays
- if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
- if (copyIsArray) {
- copyIsArray = false;
- clone = src && isArray(src) ? src : [];
- } else {
- clone = src && isPlainObject(src) ? src : {};
- }
-
- // Never move original objects, clone them
- target[name] = extend(deep, clone, copy);
-
- // Don't bring in undefined values
- } else if (typeof copy !== 'undefined') {
- target[name] = copy;
- }
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
diff --git a/node.d/node_modules/lib/ber/errors.js b/node.d/node_modules/lib/ber/errors.js
deleted file mode 100644
index 0106747e6..000000000
--- a/node.d/node_modules/lib/ber/errors.js
+++ /dev/null
@@ -1,9 +0,0 @@
-
-module.exports = {
- InvalidAsn1Error: function(msg) {
- var e = new Error()
- e.name = 'InvalidAsn1Error'
- e.message = msg || ''
- return e
- }
-}
diff --git a/node.d/node_modules/lib/ber/index.js b/node.d/node_modules/lib/ber/index.js
deleted file mode 100644
index 65985c1e1..000000000
--- a/node.d/node_modules/lib/ber/index.js
+++ /dev/null
@@ -1,17 +0,0 @@
-
-var errors = require('./errors')
-var types = require('./types')
-
-var Reader = require('./reader')
-var Writer = require('./writer')
-
-for (var t in types)
- if (types.hasOwnProperty(t))
- exports[t] = types[t]
-
-for (var e in errors)
- if (errors.hasOwnProperty(e))
- exports[e] = errors[e]
-
-exports.Reader = Reader
-exports.Writer = Writer
diff --git a/node.d/node_modules/lib/ber/reader.js b/node.d/node_modules/lib/ber/reader.js
deleted file mode 100644
index f93d829aa..000000000
--- a/node.d/node_modules/lib/ber/reader.js
+++ /dev/null
@@ -1,269 +0,0 @@
-
-var assert = require('assert');
-
-var ASN1 = require('./types');
-var errors = require('./errors');
-
-
-///--- Globals
-
-var InvalidAsn1Error = errors.InvalidAsn1Error;
-
-
-
-///--- API
-
-function Reader(data) {
- if (!data || !Buffer.isBuffer(data))
- throw new TypeError('data must be a node Buffer');
-
- this._buf = data;
- this._size = data.length;
-
- // These hold the "current" state
- this._len = 0;
- this._offset = 0;
-}
-
-Object.defineProperty(Reader.prototype, 'length', {
- enumerable: true,
- get: function () { return (this._len); }
-});
-
-Object.defineProperty(Reader.prototype, 'offset', {
- enumerable: true,
- get: function () { return (this._offset); }
-});
-
-Object.defineProperty(Reader.prototype, 'remain', {
- get: function () { return (this._size - this._offset); }
-});
-
-Object.defineProperty(Reader.prototype, 'buffer', {
- get: function () { return (this._buf.slice(this._offset)); }
-});
-
-
-/**
- * Reads a single byte and advances offset; you can pass in `true` to make this
- * a "peek" operation (i.e., get the byte, but don't advance the offset).
- *
- * @param {Boolean} peek true means don't move offset.
- * @return {Number} the next byte, null if not enough data.
- */
-Reader.prototype.readByte = function(peek) {
- if (this._size - this._offset < 1)
- return null;
-
- var b = this._buf[this._offset] & 0xff;
-
- if (!peek)
- this._offset += 1;
-
- return b;
-};
-
-
-Reader.prototype.peek = function() {
- return this.readByte(true);
-};
-
-
-/**
- * Reads a (potentially) variable length off the BER buffer. This call is
- * not really meant to be called directly, as callers have to manipulate
- * the internal buffer afterwards.
- *
- * As a result of this call, you can call `Reader.length`, until the
- * next thing called that does a readLength.
- *
- * @return {Number} the amount of offset to advance the buffer.
- * @throws {InvalidAsn1Error} on bad ASN.1
- */
-Reader.prototype.readLength = function(offset) {
- if (offset === undefined)
- offset = this._offset;
-
- if (offset >= this._size)
- return null;
-
- var lenB = this._buf[offset++] & 0xff;
- if (lenB === null)
- return null;
-
- if ((lenB & 0x80) == 0x80) {
- lenB &= 0x7f;
-
- if (lenB == 0)
- throw InvalidAsn1Error('Indefinite length not supported');
-
- if (lenB > 4)
- throw InvalidAsn1Error('encoding too long');
-
- if (this._size - offset < lenB)
- return null;
-
- this._len = 0;
- for (var i = 0; i < lenB; i++)
- this._len = (this._len << 8) + (this._buf[offset++] & 0xff);
-
- } else {
- // Wasn't a variable length
- this._len = lenB;
- }
-
- return offset;
-};
-
-
-/**
- * Parses the next sequence in this BER buffer.
- *
- * To get the length of the sequence, call `Reader.length`.
- *
- * @return {Number} the sequence's tag.
- */
-Reader.prototype.readSequence = function(tag) {
- var seq = this.peek();
- if (seq === null)
- return null;
- if (tag !== undefined && tag !== seq)
- throw InvalidAsn1Error('Expected 0x' + tag.toString(16) +
- ': got 0x' + seq.toString(16));
-
- var o = this.readLength(this._offset + 1); // stored in `length`
- if (o === null)
- return null;
-
- this._offset = o;
- return seq;
-};
-
-
-Reader.prototype.readInt = function(tag) {
- if (typeof(tag) !== 'number')
- tag = ASN1.Integer;
-
- return this._readTag(ASN1.Integer);
-};
-
-
-Reader.prototype.readBoolean = function(tag) {
- if (typeof(tag) !== 'number')
- tag = ASN1.Boolean;
-
- return (this._readTag(tag) === 0 ? false : true);
-};
-
-
-Reader.prototype.readEnumeration = function(tag) {
- if (typeof(tag) !== 'number')
- tag = ASN1.Enumeration;
-
- return this._readTag(ASN1.Enumeration);
-};
-
-
-Reader.prototype.readString = function(tag, retbuf) {
- if (!tag)
- tag = ASN1.OctetString;
-
- var b = this.peek();
- if (b === null)
- return null;
-
- if (b !== tag)
- throw InvalidAsn1Error('Expected 0x' + tag.toString(16) +
- ': got 0x' + b.toString(16));
-
- var o = this.readLength(this._offset + 1); // stored in `length`
-
- if (o === null)
- return null;
-
- if (this.length > this._size - o)
- return null;
-
- this._offset = o;
-
- if (this.length === 0)
- return retbuf ? new Buffer(0) : '';
-
- var str = this._buf.slice(this._offset, this._offset + this.length);
- this._offset += this.length;
-
- return retbuf ? str : str.toString('utf8');
-};
-
-Reader.prototype.readOID = function(tag) {
- if (!tag)
- tag = ASN1.OID;
-
- var b = this.readString(tag, true);
- if (b === null)
- return null;
-
- var values = [];
- var value = 0;
-
- for (var i = 0; i < b.length; i++) {
- var byte = b[i] & 0xff;
-
- value <<= 7;
- value += byte & 0x7f;
- if ((byte & 0x80) == 0) {
- values.push(value >>> 0);
- value = 0;
- }
- }
-
- value = values.shift();
- values.unshift(value % 40);
- values.unshift((value / 40) >> 0);
-
- return values.join('.');
-};
-
-
-Reader.prototype._readTag = function(tag) {
- assert.ok(tag !== undefined);
-
- var b = this.peek();
-
- if (b === null)
- return null;
-
- if (b !== tag)
- throw InvalidAsn1Error('Expected 0x' + tag.toString(16) +
- ': got 0x' + b.toString(16));
-
- var o = this.readLength(this._offset + 1); // stored in `length`
- if (o === null)
- return null;
-
- if (this.length > 4)
- throw InvalidAsn1Error('Integer too long: ' + this.length);
-
- if (this.length > this._size - o)
- return null;
- this._offset = o;
-
- var fb = this._buf[this._offset];
- var value = 0;
-
- for (var i = 0; i < this.length; i++) {
- value <<= 8;
- value |= (this._buf[this._offset++] & 0xff);
- }
-
- if ((fb & 0x80) == 0x80 && i !== 4)
- value -= (1 << (i * 8));
-
- return value >> 0;
-};
-
-
-
-///--- Exported API
-
-module.exports = Reader;
diff --git a/node.d/node_modules/lib/ber/types.js b/node.d/node_modules/lib/ber/types.js
deleted file mode 100644
index 345824bb1..000000000
--- a/node.d/node_modules/lib/ber/types.js
+++ /dev/null
@@ -1,34 +0,0 @@
-
-module.exports = {
- EOC: 0,
- Boolean: 1,
- Integer: 2,
- BitString: 3,
- OctetString: 4,
- Null: 5,
- OID: 6,
- ObjectDescriptor: 7,
- External: 8,
- Real: 9,
- Enumeration: 10,
- PDV: 11,
- Utf8String: 12,
- RelativeOID: 13,
- Sequence: 16,
- Set: 17,
- NumericString: 18,
- PrintableString: 19,
- T61String: 20,
- VideotexString: 21,
- IA5String: 22,
- UTCTime: 23,
- GeneralizedTime: 24,
- GraphicString: 25,
- VisibleString: 26,
- GeneralString: 28,
- UniversalString: 29,
- CharacterString: 30,
- BMPString: 31,
- Constructor: 32,
- Context: 128
-}
diff --git a/node.d/node_modules/lib/ber/writer.js b/node.d/node_modules/lib/ber/writer.js
deleted file mode 100644
index bf9805886..000000000
--- a/node.d/node_modules/lib/ber/writer.js
+++ /dev/null
@@ -1,317 +0,0 @@
-
-var assert = require('assert');
-var ASN1 = require('./types');
-var errors = require('./errors');
-
-
-///--- Globals
-
-var InvalidAsn1Error = errors.InvalidAsn1Error;
-
-var DEFAULT_OPTS = {
- size: 1024,
- growthFactor: 8
-};
-
-
-///--- Helpers
-
-function merge(from, to) {
- assert.ok(from);
- assert.equal(typeof(from), 'object');
- assert.ok(to);
- assert.equal(typeof(to), 'object');
-
- var keys = Object.getOwnPropertyNames(from);
- keys.forEach(function(key) {
- if (to[key])
- return;
-
- var value = Object.getOwnPropertyDescriptor(from, key);
- Object.defineProperty(to, key, value);
- });
-
- return to;
-}
-
-
-
-///--- API
-
-function Writer(options) {
- options = merge(DEFAULT_OPTS, options || {});
-
- this._buf = new Buffer(options.size || 1024);
- this._size = this._buf.length;
- this._offset = 0;
- this._options = options;
-
- // A list of offsets in the buffer where we need to insert
- // sequence tag/len pairs.
- this._seq = [];
-}
-
-Object.defineProperty(Writer.prototype, 'buffer', {
- get: function () {
- if (this._seq.length)
- throw new InvalidAsn1Error(this._seq.length + ' unended sequence(s)');
-
- return (this._buf.slice(0, this._offset));
- }
-});
-
-Writer.prototype.writeByte = function(b) {
- if (typeof(b) !== 'number')
- throw new TypeError('argument must be a Number');
-
- this._ensure(1);
- this._buf[this._offset++] = b;
-};
-
-
-Writer.prototype.writeInt = function(i, tag) {
- if (typeof(i) !== 'number')
- throw new TypeError('argument must be a Number');
- if (typeof(tag) !== 'number')
- tag = ASN1.Integer;
-
- var sz = 4;
-
- while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&
- (sz > 1)) {
- sz--;
- i <<= 8;
- }
-
- if (sz > 4)
- throw new InvalidAsn1Error('BER ints cannot be > 0xffffffff');
-
- this._ensure(2 + sz);
- this._buf[this._offset++] = tag;
- this._buf[this._offset++] = sz;
-
- while (sz-- > 0) {
- this._buf[this._offset++] = ((i & 0xff000000) >>> 24);
- i <<= 8;
- }
-
-};
-
-
-Writer.prototype.writeNull = function() {
- this.writeByte(ASN1.Null);
- this.writeByte(0x00);
-};
-
-
-Writer.prototype.writeEnumeration = function(i, tag) {
- if (typeof(i) !== 'number')
- throw new TypeError('argument must be a Number');
- if (typeof(tag) !== 'number')
- tag = ASN1.Enumeration;
-
- return this.writeInt(i, tag);
-};
-
-
-Writer.prototype.writeBoolean = function(b, tag) {
- if (typeof(b) !== 'boolean')
- throw new TypeError('argument must be a Boolean');
- if (typeof(tag) !== 'number')
- tag = ASN1.Boolean;
-
- this._ensure(3);
- this._buf[this._offset++] = tag;
- this._buf[this._offset++] = 0x01;
- this._buf[this._offset++] = b ? 0xff : 0x00;
-};
-
-
-Writer.prototype.writeString = function(s, tag) {
- if (typeof(s) !== 'string')
- throw new TypeError('argument must be a string (was: ' + typeof(s) + ')');
- if (typeof(tag) !== 'number')
- tag = ASN1.OctetString;
-
- var len = Buffer.byteLength(s);
- this.writeByte(tag);
- this.writeLength(len);
- if (len) {
- this._ensure(len);
- this._buf.write(s, this._offset);
- this._offset += len;
- }
-};
-
-
-Writer.prototype.writeBuffer = function(buf, tag) {
- if (!Buffer.isBuffer(buf))
- throw new TypeError('argument must be a buffer');
-
- // If no tag is specified we will assume `buf` already contains tag and length
- if (typeof(tag) === 'number') {
- this.writeByte(tag);
- this.writeLength(buf.length);
- }
-
- this._ensure(buf.length);
- buf.copy(this._buf, this._offset, 0, buf.length);
- this._offset += buf.length;
-};
-
-
-Writer.prototype.writeStringArray = function(strings, tag) {
- if (! (strings instanceof Array))
- throw new TypeError('argument must be an Array[String]');
-
- var self = this;
- strings.forEach(function(s) {
- self.writeString(s, tag);
- });
-};
-
-// This is really to solve DER cases, but whatever for now
-Writer.prototype.writeOID = function(s, tag) {
- if (typeof(s) !== 'string')
- throw new TypeError('argument must be a string');
- if (typeof(tag) !== 'number')
- tag = ASN1.OID;
-
- if (!/^([0-9]+\.){3,}[0-9]+$/.test(s))
- throw new Error('argument is not a valid OID string');
-
- function encodeOctet(bytes, octet) {
- if (octet < 128) {
- bytes.push(octet);
- } else if (octet < 16384) {
- bytes.push((octet >>> 7) | 0x80);
- bytes.push(octet & 0x7F);
- } else if (octet < 2097152) {
- bytes.push((octet >>> 14) | 0x80);
- bytes.push(((octet >>> 7) | 0x80) & 0xFF);
- bytes.push(octet & 0x7F);
- } else if (octet < 268435456) {
- bytes.push((octet >>> 21) | 0x80);
- bytes.push(((octet >>> 14) | 0x80) & 0xFF);
- bytes.push(((octet >>> 7) | 0x80) & 0xFF);
- bytes.push(octet & 0x7F);
- } else {
- bytes.push(((octet >>> 28) | 0x80) & 0xFF);
- bytes.push(((octet >>> 21) | 0x80) & 0xFF);
- bytes.push(((octet >>> 14) | 0x80) & 0xFF);
- bytes.push(((octet >>> 7) | 0x80) & 0xFF);
- bytes.push(octet & 0x7F);
- }
- }
-
- var tmp = s.split('.');
- var bytes = [];
- bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));
- tmp.slice(2).forEach(function(b) {
- encodeOctet(bytes, parseInt(b, 10));
- });
-
- var self = this;
- this._ensure(2 + bytes.length);
- this.writeByte(tag);
- this.writeLength(bytes.length);
- bytes.forEach(function(b) {
- self.writeByte(b);
- });
-};
-
-
-Writer.prototype.writeLength = function(len) {
- if (typeof(len) !== 'number')
- throw new TypeError('argument must be a Number');
-
- this._ensure(4);
-
- if (len <= 0x7f) {
- this._buf[this._offset++] = len;
- } else if (len <= 0xff) {
- this._buf[this._offset++] = 0x81;
- this._buf[this._offset++] = len;
- } else if (len <= 0xffff) {
- this._buf[this._offset++] = 0x82;
- this._buf[this._offset++] = len >> 8;
- this._buf[this._offset++] = len;
- } else if (len <= 0xffffff) {
- this._buf[this._offset++] = 0x83;
- this._buf[this._offset++] = len >> 16;
- this._buf[this._offset++] = len >> 8;
- this._buf[this._offset++] = len;
- } else {
- throw new InvalidAsn1Error('Length too long (> 4 bytes)');
- }
-};
-
-Writer.prototype.startSequence = function(tag) {
- if (typeof(tag) !== 'number')
- tag = ASN1.Sequence | ASN1.Constructor;
-
- this.writeByte(tag);
- this._seq.push(this._offset);
- this._ensure(3);
- this._offset += 3;
-};
-
-
-Writer.prototype.endSequence = function() {
- var seq = this._seq.pop();
- var start = seq + 3;
- var len = this._offset - start;
-
- if (len <= 0x7f) {
- this._shift(start, len, -2);
- this._buf[seq] = len;
- } else if (len <= 0xff) {
- this._shift(start, len, -1);
- this._buf[seq] = 0x81;
- this._buf[seq + 1] = len;
- } else if (len <= 0xffff) {
- this._buf[seq] = 0x82;
- this._buf[seq + 1] = len >> 8;
- this._buf[seq + 2] = len;
- } else if (len <= 0xffffff) {
- this._shift(start, len, 1);
- this._buf[seq] = 0x83;
- this._buf[seq + 1] = len >> 16;
- this._buf[seq + 2] = len >> 8;
- this._buf[seq + 3] = len;
- } else {
- throw new InvalidAsn1Error('Sequence too long');
- }
-};
-
-
-Writer.prototype._shift = function(start, len, shift) {
- assert.ok(start !== undefined);
- assert.ok(len !== undefined);
- assert.ok(shift);
-
- this._buf.copy(this._buf, start + shift, start, start + len);
- this._offset += shift;
-};
-
-Writer.prototype._ensure = function(len) {
- assert.ok(len);
-
- if (this._size - this._offset < len) {
- var sz = this._size * this._options.growthFactor;
- if (sz - this._offset < len)
- sz += len;
-
- var buf = new Buffer(sz);
-
- this._buf.copy(buf, 0, 0, this._offset);
- this._buf = buf;
- this._size = sz;
- }
-};
-
-
-
-///--- Exported API
-
-module.exports = Writer;
diff --git a/node.d/node_modules/net-snmp.js b/node.d/node_modules/net-snmp.js
deleted file mode 100644
index ac9a8d350..000000000
--- a/node.d/node_modules/net-snmp.js
+++ /dev/null
@@ -1,1457 +0,0 @@
-
-// Copyright 2013 Stephen Vickers <stephen.vickers.sv@gmail.com>
-
-var ber = require ("asn1-ber").Ber;
-var dgram = require ("dgram");
-var events = require ("events");
-var util = require ("util");
-
-/*****************************************************************************
- ** Constants
- **/
-
-function _expandConstantObject (object) {
- var keys = [];
- for (var key in object)
- keys.push (key);
- for (var i = 0; i < keys.length; i++)
- object[object[keys[i]]] = parseInt (keys[i]);
-}
-
-var ErrorStatus = {
- 0: "NoError",
- 1: "TooBig",
- 2: "NoSuchName",
- 3: "BadValue",
- 4: "ReadOnly",
- 5: "GeneralError",
- 6: "NoAccess",
- 7: "WrongType",
- 8: "WrongLength",
- 9: "WrongEncoding",
- 10: "WrongValue",
- 11: "NoCreation",
- 12: "InconsistentValue",
- 13: "ResourceUnavailable",
- 14: "CommitFailed",
- 15: "UndoFailed",
- 16: "AuthorizationError",
- 17: "NotWritable",
- 18: "InconsistentName"
-};
-
-_expandConstantObject (ErrorStatus);
-
-var ObjectType = {
- 1: "Boolean",
- 2: "Integer",
- 4: "OctetString",
- 5: "Null",
- 6: "OID",
- 64: "IpAddress",
- 65: "Counter",
- 66: "Gauge",
- 67: "TimeTicks",
- 68: "Opaque",
- 70: "Counter64",
- 128: "NoSuchObject",
- 129: "NoSuchInstance",
- 130: "EndOfMibView"
-};
-
-_expandConstantObject (ObjectType);
-
-ObjectType.Integer32 = ObjectType.Integer;
-ObjectType.Counter32 = ObjectType.Counter;
-ObjectType.Gauge32 = ObjectType.Gauge;
-ObjectType.Unsigned32 = ObjectType.Gauge32;
-
-var PduType = {
- 160: "GetRequest",
- 161: "GetNextRequest",
- 162: "GetResponse",
- 163: "SetRequest",
- 164: "Trap",
- 165: "GetBulkRequest",
- 166: "InformRequest",
- 167: "TrapV2",
- 168: "Report"
-};
-
-_expandConstantObject (PduType);
-
-var TrapType = {
- 0: "ColdStart",
- 1: "WarmStart",
- 2: "LinkDown",
- 3: "LinkUp",
- 4: "AuthenticationFailure",
- 5: "EgpNeighborLoss",
- 6: "EnterpriseSpecific"
-};
-
-_expandConstantObject (TrapType);
-
-var Version1 = 0;
-var Version2c = 1;
-
-/*****************************************************************************
- ** Exception class definitions
- **/
-
-function ResponseInvalidError (message) {
- this.name = "ResponseInvalidError";
- this.message = message;
- Error.captureStackTrace(this, ResponseInvalidError);
-}
-util.inherits (ResponseInvalidError, Error);
-
-function RequestInvalidError (message) {
- this.name = "RequestInvalidError";
- this.message = message;
- Error.captureStackTrace(this, RequestInvalidError);
-}
-util.inherits (RequestInvalidError, Error);
-
-function RequestFailedError (message, status) {
- this.name = "RequestFailedError";
- this.message = message;
- this.status = status;
- Error.captureStackTrace(this, RequestFailedError);
-}
-util.inherits (RequestFailedError, Error);
-
-function RequestTimedOutError (message) {
- this.name = "RequestTimedOutError";
- this.message = message;
- Error.captureStackTrace(this, RequestTimedOutError);
-}
-util.inherits (RequestTimedOutError, Error);
-
-/*****************************************************************************
- ** OID and varbind helper functions
- **/
-
-function isVarbindError (varbind) {
- return !!(varbind.type == ObjectType.NoSuchObject
- || varbind.type == ObjectType.NoSuchInstance
- || varbind.type == ObjectType.EndOfMibView);
-}
-
-function varbindError (varbind) {
- return (ObjectType[varbind.type] || "NotAnError") + ": " + varbind.oid;
-}
-
-function oidFollowsOid (oidString, nextString) {
- var oid = {str: oidString, len: oidString.length, idx: 0};
- var next = {str: nextString, len: nextString.length, idx: 0};
- var dotCharCode = ".".charCodeAt (0);
-
- function getNumber (item) {
- var n = 0;
- if (item.idx >= item.len)
- return null;
- while (item.idx < item.len) {
- var charCode = item.str.charCodeAt (item.idx++);
- if (charCode == dotCharCode)
- return n;
- n = (n ? (n * 10) : n) + (charCode - 48);
- }
- return n;
- }
-
- while (1) {
- var oidNumber = getNumber (oid);
- var nextNumber = getNumber (next);
-
- if (oidNumber !== null) {
- if (nextNumber !== null) {
- if (nextNumber > oidNumber) {
- return true;
- } else if (nextNumber < oidNumber) {
- return false;
- }
- } else {
- return true;
- }
- } else {
- return true;
- }
- }
-}
-
-function oidInSubtree (oidString, nextString) {
- var oid = oidString.split (".");
- var next = nextString.split (".");
-
- if (oid.length > next.length)
- return false;
-
- for (var i = 0; i < oid.length; i++) {
- if (next[i] != oid[i])
- return false;
- }
-
- return true;
-}
-
-/**
- ** Some SNMP agents produce integers on the wire such as 00 ff ff ff ff.
- ** The ASN.1 BER parser we use throws an error when parsing this, which we
- ** believe is correct. So, we decided not to bother the "asn1" developer(s)
- ** with this, instead opting to work around it here.
- **
- ** If an integer is 5 bytes in length we check if the first byte is 0, and if so
- ** simply drop it and parse it like it was a 4 byte integer, otherwise throw
- ** an error since the integer is too large.
- **/
-
-function readInt (buffer) {
- return readUint (buffer, true);
-}
-
-function readUint (buffer, isSigned) {
- buffer.readByte ();
- var length = buffer.readByte ();
- var value = 0;
- var signedBitSet = false;
-
- if (length > 5) {
- throw new RangeError ("Integer too long '" + length + "'");
- } else if (length == 5) {
- if (buffer.readByte () !== 0)
- throw new RangeError ("Integer too long '" + length + "'");
- length = 4;
- }
-
- for (var i = 0; i < length; i++) {
- value *= 256;
- value += buffer.readByte ();
-
- if (isSigned && i <= 0) {
- if ((value & 0x80) == 0x80)
- signedBitSet = true;
- }
- }
-
- if (signedBitSet)
- value -= (1 << (i * 8));
-
- return value;
-}
-
-function readUint64 (buffer) {
- var value = buffer.readString (ObjectType.Counter64, true);
-
- return value;
-}
-
-function readVarbinds (buffer, varbinds) {
- buffer.readSequence ();
-
- while (1) {
- buffer.readSequence ();
- var oid = buffer.readOID ();
- var type = buffer.peek ();
-
- if (type == null)
- break;
-
- var value;
-
- if (type == ObjectType.Boolean) {
- value = buffer.readBoolean ();
- } else if (type == ObjectType.Integer) {
- value = readInt (buffer);
- } else if (type == ObjectType.OctetString) {
- value = buffer.readString (null, true);
- } else if (type == ObjectType.Null) {
- buffer.readByte ();
- buffer.readByte ();
- value = null;
- } else if (type == ObjectType.OID) {
- value = buffer.readOID ();
- } else if (type == ObjectType.IpAddress) {
- var bytes = buffer.readString (ObjectType.IpAddress, true);
- if (bytes.length != 4)
- throw new ResponseInvalidError ("Length '" + bytes.length
- + "' of IP address '" + bytes.toString ("hex")
- + "' is not 4");
- value = bytes[0] + "." + bytes[1] + "." + bytes[2] + "." + bytes[3];
- } else if (type == ObjectType.Counter) {
- value = readUint (buffer);
- } else if (type == ObjectType.Gauge) {
- value = readUint (buffer);
- } else if (type == ObjectType.TimeTicks) {
- value = readUint (buffer);
- } else if (type == ObjectType.Opaque) {
- value = buffer.readString (ObjectType.Opaque, true);
- } else if (type == ObjectType.Counter64) {
- value = readUint64 (buffer);
- } else if (type == ObjectType.NoSuchObject) {
- buffer.readByte ();
- buffer.readByte ();
- value = null;
- } else if (type == ObjectType.NoSuchInstance) {
- buffer.readByte ();
- buffer.readByte ();
- value = null;
- } else if (type == ObjectType.EndOfMibView) {
- buffer.readByte ();
- buffer.readByte ();
- value = null;
- } else {
- throw new ResponseInvalidError ("Unknown type '" + type
- + "' in response");
- }
-
- varbinds.push ({
- oid: oid,
- type: type,
- value: value
- });
- }
-}
-
-function writeUint (buffer, type, value) {
- var b = new Buffer (4);
- b.writeUInt32BE (value, 0);
- buffer.writeBuffer (b, type);
-}
-
-function writeUint64 (buffer, value) {
- buffer.writeBuffer (value, ObjectType.Counter64);
-}
-
-function writeVarbinds (buffer, varbinds) {
- buffer.startSequence ();
- for (var i = 0; i < varbinds.length; i++) {
- buffer.startSequence ();
- buffer.writeOID (varbinds[i].oid);
-
- if (varbinds[i].type && varbinds[i].hasOwnProperty("value")) {
- var type = varbinds[i].type;
- var value = varbinds[i].value;
-
- if (type == ObjectType.Boolean) {
- buffer.writeBoolean (value ? true : false);
- } else if (type == ObjectType.Integer) { // also Integer32
- buffer.writeInt (value);
- } else if (type == ObjectType.OctetString) {
- if (typeof value == "string")
- buffer.writeString (value);
- else
- buffer.writeBuffer (value, ObjectType.OctetString);
- } else if (type == ObjectType.Null) {
- buffer.writeNull ();
- } else if (type == ObjectType.OID) {
- buffer.writeOID (value);
- } else if (type == ObjectType.IpAddress) {
- var bytes = value.split (".");
- if (bytes.length != 4)
- throw new RequestInvalidError ("Invalid IP address '"
- + value + "'");
- buffer.writeBuffer (new Buffer (bytes), 64);
- } else if (type == ObjectType.Counter) { // also Counter32
- writeUint (buffer, ObjectType.Counter, value);
- } else if (type == ObjectType.Gauge) { // also Gauge32 & Unsigned32
- writeUint (buffer, ObjectType.Gauge, value);
- } else if (type == ObjectType.TimeTicks) {
- writeUint (buffer, ObjectType.TimeTicks, value);
- } else if (type == ObjectType.Opaque) {
- buffer.writeBuffer (value, ObjectType.Opaque);
- } else if (type == ObjectType.Counter64) {
- writeUint64 (buffer, value);
- } else {
- throw new RequestInvalidError ("Unknown type '" + type
- + "' in request");
- }
- } else {
- buffer.writeNull ();
- }
-
- buffer.endSequence ();
- }
- buffer.endSequence ();
-}
-
-/*****************************************************************************
- ** PDU class definitions
- **/
-
-var SimplePdu = function (id, varbinds, options) {
- this.id = id;
- this.varbinds = varbinds;
- this.options = options || {};
-};
-
-SimplePdu.prototype.toBuffer = function (buffer) {
- buffer.startSequence (this.type);
-
- buffer.writeInt (this.id);
- buffer.writeInt ((this.type == PduType.GetBulkRequest)
- ? (this.options.nonRepeaters || 0)
- : 0);
- buffer.writeInt ((this.type == PduType.GetBulkRequest)
- ? (this.options.maxRepetitions || 0)
- : 0);
-
- writeVarbinds (buffer, this.varbinds);
-
- buffer.endSequence ();
-};
-
-var GetBulkRequestPdu = function () {
- this.type = PduType.GetBulkRequest;
- GetBulkRequestPdu.super_.apply (this, arguments);
-};
-
-util.inherits (GetBulkRequestPdu, SimplePdu);
-
-var GetNextRequestPdu = function () {
- this.type = PduType.GetNextRequest;
- GetNextRequestPdu.super_.apply (this, arguments);
-};
-
-util.inherits (GetNextRequestPdu, SimplePdu);
-
-var GetResponsePdu = function (buffer) {
- this.type = PduType.GetResponse;
-
- buffer.readSequence (this.type);
-
- this.id = buffer.readInt ();
-
- this.errorStatus = buffer.readInt ();
- this.errorIndex = buffer.readInt ();
-
- this.varbinds = [];
-
- readVarbinds (buffer, this.varbinds);
-};
-
-var GetRequestPdu = function () {
- this.type = PduType.GetRequest;
- GetRequestPdu.super_.apply (this, arguments);
-};
-
-util.inherits (GetRequestPdu, SimplePdu);
-
-var InformRequestPdu = function () {
- this.type = PduType.InformRequest;
- InformRequestPdu.super_.apply (this, arguments);
-};
-
-util.inherits (InformRequestPdu, SimplePdu);
-
-var SetRequestPdu = function () {
- this.type = PduType.SetRequest;
- SetRequestPdu.super_.apply (this, arguments);
-};
-
-util.inherits (SetRequestPdu, SimplePdu);
-
-var TrapPdu = function (typeOrOid, varbinds, options) {
- this.type = PduType.Trap;
-
- this.agentAddr = options.agentAddr || "127.0.0.1";
- this.upTime = options.upTime;
-
- if (typeof typeOrOid == "string") {
- this.generic = TrapType.EnterpriseSpecific;
- this.specific = parseInt (typeOrOid.match (/\.(\d+)$/)[1]);
- this.enterprise = typeOrOid.replace (/\.(\d+)$/, "");
- } else {
- this.generic = typeOrOid;
- this.specific = 0;
- this.enterprise = "1.3.6.1.4.1";
- }
-
- this.varbinds = varbinds;
-};
-
-TrapPdu.prototype.toBuffer = function (buffer) {
- buffer.startSequence (this.type);
-
- buffer.writeOID (this.enterprise);
- buffer.writeBuffer (new Buffer (this.agentAddr.split (".")),
- ObjectType.IpAddress);
- buffer.writeInt (this.generic);
- buffer.writeInt (this.specific);
- writeUint (buffer, ObjectType.TimeTicks,
- this.upTime || Math.floor (process.uptime () * 100));
-
- writeVarbinds (buffer, this.varbinds);
-
- buffer.endSequence ();
-};
-
-var TrapV2Pdu = function () {
- this.type = PduType.TrapV2;
- TrapV2Pdu.super_.apply (this, arguments);
-};
-
-util.inherits (TrapV2Pdu, SimplePdu);
-
-/*****************************************************************************
- ** Message class definitions
- **/
-
-var RequestMessage = function (version, community, pdu) {
- this.version = version;
- this.community = community;
- this.pdu = pdu;
-};
-
-RequestMessage.prototype.toBuffer = function () {
- if (this.buffer)
- return this.buffer;
-
- var writer = new ber.Writer ();
-
- writer.startSequence ();
-
- writer.writeInt (this.version);
- writer.writeString (this.community);
-
- this.pdu.toBuffer (writer);
-
- writer.endSequence ();
-
- this.buffer = writer.buffer;
-
- return this.buffer;
-};
-
-var ResponseMessage = function (buffer) {
- var reader = new ber.Reader (buffer);
-
- reader.readSequence ();
-
- this.version = reader.readInt ();
- this.community = reader.readString ();
-
- var type = reader.peek ();
-
- if (type == PduType.GetResponse) {
- this.pdu = new GetResponsePdu (reader);
- } else {
- throw new ResponseInvalidError ("Unknown PDU type '" + type
- + "' in response");
- }
-};
-
-/*****************************************************************************
- ** Session class definition
- **/
-
-var Session = function (target, community, options) {
- this.target = target || "127.0.0.1";
- this.community = community || "public";
-
- this.version = (options && options.version)
- ? options.version
- : Version1;
-
- this.transport = (options && options.transport)
- ? options.transport
- : "udp4";
- this.port = (options && options.port )
- ? options.port
- : 161;
- this.trapPort = (options && options.trapPort )
- ? options.trapPort
- : 162;
-
- this.retries = (options && (options.retries || options.retries == 0))
- ? options.retries
- : 1;
- this.timeout = (options && options.timeout)
- ? options.timeout
- : 5000;
-
- this.sourceAddress = (options && options.sourceAddress )
- ? options.sourceAddress
- : undefined;
- this.sourcePort = (options && options.sourcePort )
- ? parseInt(options.sourcePort)
- : undefined;
-
- this.reqs = {};
- this.reqCount = 0;
-
- this.dgram = dgram.createSocket (this.transport);
- this.dgram.unref();
-
- var me = this;
- this.dgram.on ("message", me.onMsg.bind (me));
- this.dgram.on ("close", me.onClose.bind (me));
- this.dgram.on ("error", me.onError.bind (me));
-
- if (this.sourceAddress || this.sourcePort)
- this.dgram.bind (this.sourcePort, this.sourceAddress);
-};
-
-util.inherits (Session, events.EventEmitter);
-
-Session.prototype.close = function () {
- this.dgram.close ();
- return this;
-};
-
-Session.prototype.cancelRequests = function (error) {
- var id;
- for (id in this.reqs) {
- var req = this.reqs[id];
- this.unregisterRequest (req.id);
- req.responseCb (error);
- }
-};
-
-function _generateId () {
- return Math.floor (Math.random () + Math.random () * 10000000)
-}
-
-Session.prototype.get = function (oids, responseCb) {
- function feedCb (req, message) {
- var pdu = message.pdu;
- var varbinds = [];
-
- if (req.message.pdu.varbinds.length != pdu.varbinds.length) {
- req.responseCb (new ResponseInvalidError ("Requested OIDs do not "
- + "match response OIDs"));
- } else {
- for (var i = 0; i < req.message.pdu.varbinds.length; i++) {
- if (req.message.pdu.varbinds[i].oid != pdu.varbinds[i].oid) {
- req.responseCb (new ResponseInvalidError ("OID '"
- + req.message.pdu.varbinds[i].oid
- + "' in request at positiion '" + i + "' does not "
- + "match OID '" + pdu.varbinds[i].oid + "' in response "
- + "at position '" + i + "'"));
- return;
- } else {
- varbinds.push (pdu.varbinds[i]);
- }
- }
-
- req.responseCb (null, varbinds);
- }
- }
-
- var pduVarbinds = [];
-
- for (var i = 0; i < oids.length; i++) {
- var varbind = {
- oid: oids[i]
- };
- pduVarbinds.push (varbind);
- }
-
- this.simpleGet (GetRequestPdu, feedCb, pduVarbinds, responseCb);
-
- return this;
-};
-
-Session.prototype.getBulk = function () {
- var oids, nonRepeaters, maxRepetitions, responseCb;
-
- if (arguments.length >= 4) {
- oids = arguments[0];
- nonRepeaters = arguments[1];
- maxRepetitions = arguments[2];
- responseCb = arguments[3];
- } else if (arguments.length >= 3) {
- oids = arguments[0];
- nonRepeaters = arguments[1];
- maxRepetitions = 10;
- responseCb = arguments[2];
- } else {
- oids = arguments[0];
- nonRepeaters = 0;
- maxRepetitions = 10;
- responseCb = arguments[1];
- }
-
- function feedCb (req, message) {
- var pdu = message.pdu;
- var varbinds = [];
- var i = 0;
-
- // first walk through and grab non-repeaters
- if (pdu.varbinds.length < nonRepeaters) {
- req.responseCb (new ResponseInvalidError ("Varbind count in "
- + "response '" + pdu.varbinds.length + "' is less than "
- + "non-repeaters '" + nonRepeaters + "' in request"));
- } else {
- for ( ; i < nonRepeaters; i++) {
- if (isVarbindError (pdu.varbinds[i])) {
- varbinds.push (pdu.varbinds[i]);
- } else if (! oidFollowsOid (req.message.pdu.varbinds[i].oid,
- pdu.varbinds[i].oid)) {
- req.responseCb (new ResponseInvalidError ("OID '"
- + req.message.pdu.varbinds[i].oid + "' in request at "
- + "positiion '" + i + "' does not precede "
- + "OID '" + pdu.varbinds[i].oid + "' in response "
- + "at position '" + i + "'"));
- return;
- } else {
- varbinds.push (pdu.varbinds[i]);
- }
- }
- }
-
- var repeaters = req.message.pdu.varbinds.length - nonRepeaters;
-
- // secondly walk through and grab repeaters
- if (pdu.varbinds.length % (repeaters)) {
- req.responseCb (new ResponseInvalidError ("Varbind count in "
- + "response '" + pdu.varbinds.length + "' is not a "
- + "multiple of repeaters '" + repeaters
- + "' plus non-repeaters '" + nonRepeaters + "' in request"));
- } else {
- while (i < pdu.varbinds.length) {
- for (var j = 0; j < repeaters; j++, i++) {
- var reqIndex = nonRepeaters + j;
- var respIndex = i;
-
- if (isVarbindError (pdu.varbinds[respIndex])) {
- if (! varbinds[reqIndex])
- varbinds[reqIndex] = [];
- varbinds[reqIndex].push (pdu.varbinds[respIndex]);
- } else if (! oidFollowsOid (
- req.message.pdu.varbinds[reqIndex].oid,
- pdu.varbinds[respIndex].oid)) {
- req.responseCb (new ResponseInvalidError ("OID '"
- + req.message.pdu.varbinds[reqIndex].oid
- + "' in request at positiion '" + (reqIndex)
- + "' does not precede OID '"
- + pdu.varbinds[respIndex].oid
- + "' in response at position '" + (respIndex) + "'"));
- return;
- } else {
- if (! varbinds[reqIndex])
- varbinds[reqIndex] = [];
- varbinds[reqIndex].push (pdu.varbinds[respIndex]);
- }
- }
- }
- }
-
- req.responseCb (null, varbinds);
- }
-
- var pduVarbinds = [];
-
- for (var i = 0; i < oids.length; i++) {
- var varbind = {
- oid: oids[i]
- };
- pduVarbinds.push (varbind);
- }
-
- var options = {
- nonRepeaters: nonRepeaters,
- maxRepetitions: maxRepetitions
- };
-
- this.simpleGet (GetBulkRequestPdu, feedCb, pduVarbinds, responseCb,
- options);
-
- return this;
-};
-
-Session.prototype.getNext = function (oids, responseCb) {
- function feedCb (req, message) {
- var pdu = message.pdu;
- var varbinds = [];
-
- if (req.message.pdu.varbinds.length != pdu.varbinds.length) {
- req.responseCb (new ResponseInvalidError ("Requested OIDs do not "
- + "match response OIDs"));
- } else {
- for (var i = 0; i < req.message.pdu.varbinds.length; i++) {
- if (isVarbindError (pdu.varbinds[i])) {
- varbinds.push (pdu.varbinds[i]);
- } else if (! oidFollowsOid (req.message.pdu.varbinds[i].oid,
- pdu.varbinds[i].oid)) {
- req.responseCb (new ResponseInvalidError ("OID '"
- + req.message.pdu.varbinds[i].oid + "' in request at "
- + "positiion '" + i + "' does not precede "
- + "OID '" + pdu.varbinds[i].oid + "' in response "
- + "at position '" + i + "'"));
- return;
- } else {
- varbinds.push (pdu.varbinds[i]);
- }
- }
-
- req.responseCb (null, varbinds);
- }
- }
-
- var pduVarbinds = [];
-
- for (var i = 0; i < oids.length; i++) {
- var varbind = {
- oid: oids[i]
- };
- pduVarbinds.push (varbind);
- }
-
- this.simpleGet (GetNextRequestPdu, feedCb, pduVarbinds, responseCb);
-
- return this;
-};
-
-Session.prototype.inform = function () {
- var typeOrOid = arguments[0];
- var varbinds, options = {}, responseCb;
-
- /**
- ** Support the following signatures:
- **
- ** typeOrOid, varbinds, options, callback
- ** typeOrOid, varbinds, callback
- ** typeOrOid, options, callback
- ** typeOrOid, callback
- **/
- if (arguments.length >= 4) {
- varbinds = arguments[1];
- options = arguments[2];
- responseCb = arguments[3];
- } else if (arguments.length >= 3) {
- if (arguments[1].constructor != Array) {
- varbinds = [];
- options = arguments[1];
- responseCb = arguments[2];
- } else {
- varbinds = arguments[1];
- responseCb = arguments[2];
- }
- } else {
- varbinds = [];
- responseCb = arguments[1];
- }
-
- function feedCb (req, message) {
- var pdu = message.pdu;
- var varbinds = [];
-
- if (req.message.pdu.varbinds.length != pdu.varbinds.length) {
- req.responseCb (new ResponseInvalidError ("Inform OIDs do not "
- + "match response OIDs"));
- } else {
- for (var i = 0; i < req.message.pdu.varbinds.length; i++) {
- if (req.message.pdu.varbinds[i].oid != pdu.varbinds[i].oid) {
- req.responseCb (new ResponseInvalidError ("OID '"
- + req.message.pdu.varbinds[i].oid
- + "' in inform at positiion '" + i + "' does not "
- + "match OID '" + pdu.varbinds[i].oid + "' in response "
- + "at position '" + i + "'"));
- return;
- } else {
- varbinds.push (pdu.varbinds[i]);
- }
- }
-
- req.responseCb (null, varbinds);
- }
- }
-
- if (typeof typeOrOid != "string")
- typeOrOid = "1.3.6.1.6.3.1.1.5." + (typeOrOid + 1);
-
- var pduVarbinds = [
- {
- oid: "1.3.6.1.2.1.1.3.0",
- type: ObjectType.TimeTicks,
- value: options.upTime || Math.floor (process.uptime () * 100)
- },
- {
- oid: "1.3.6.1.6.3.1.1.4.1.0",
- type: ObjectType.OID,
- value: typeOrOid
- }
- ];
-
- for (var i = 0; i < varbinds.length; i++) {
- var varbind = {
- oid: varbinds[i].oid,
- type: varbinds[i].type,
- value: varbinds[i].value
- };
- pduVarbinds.push (varbind);
- }
-
- options.port = this.trapPort;
-
- this.simpleGet (InformRequestPdu, feedCb, pduVarbinds, responseCb, options);
-
- return this;
-};
-
-Session.prototype.onClose = function () {
- this.cancelRequests (new Error ("Socket forcibly closed"));
- this.emit ("close");
-};
-
-Session.prototype.onError = function (error) {
- this.emit (error);
-};
-
-Session.prototype.onMsg = function (buffer, remote) {
- try {
- var message = new ResponseMessage (buffer);
-
- var req = this.unregisterRequest (message.pdu.id);
- if (! req)
- return;
-
- try {
- if (message.version != req.message.version) {
- req.responseCb (new ResponseInvalidError ("Version in request '"
- + req.message.version + "' does not match version in "
- + "response '" + message.version));
- } else if (message.community != req.message.community) {
- req.responseCb (new ResponseInvalidError ("Community '"
- + req.message.community + "' in request does not match "
- + "community '" + message.community + "' in response"));
- } else if (message.pdu.type == PduType.GetResponse) {
- req.onResponse (req, message);
- } else {
- req.responseCb (new ResponseInvalidError ("Unknown PDU type '"
- + message.pdu.type + "' in response"));
- }
- } catch (error) {
- req.responseCb (error);
- }
- } catch (error) {
- this.emit("error", error);
- }
-};
-
-Session.prototype.onSimpleGetResponse = function (req, message) {
- var pdu = message.pdu;
-
- if (pdu.errorStatus > 0) {
- var statusString = ErrorStatus[pdu.errorStatus]
- || ErrorStatus.GeneralError;
- var statusCode = ErrorStatus[statusString]
- || ErrorStatus[ErrorStatus.GeneralError];
-
- if (pdu.errorIndex <= 0 || pdu.errorIndex > pdu.varbinds.length) {
- req.responseCb (new RequestFailedError (statusString, statusCode));
- } else {
- var oid = pdu.varbinds[pdu.errorIndex - 1].oid;
- var error = new RequestFailedError (statusString + ": " + oid,
- statusCode);
- req.responseCb (error);
- }
- } else {
- req.feedCb (req, message);
- }
-};
-
-Session.prototype.registerRequest = function (req) {
- if (! this.reqs[req.id]) {
- this.reqs[req.id] = req;
- if (this.reqCount <= 0)
- this.dgram.ref();
- this.reqCount++;
- }
- var me = this;
- req.timer = setTimeout (function () {
- if (req.retries-- > 0) {
- me.send (req);
- } else {
- me.unregisterRequest (req.id);
- req.responseCb (new RequestTimedOutError (
- "Request timed out"));
- }
- }, req.timeout);
-};
-
-Session.prototype.send = function (req, noWait) {
- try {
- var me = this;
-
- var buffer = req.message.toBuffer ();
-
- this.dgram.send (buffer, 0, buffer.length, req.port, this.target,
- function (error, bytes) {
- if (error) {
- req.responseCb (error);
- } else {
- if (noWait) {
- req.responseCb (null);
- } else {
- me.registerRequest (req);
- }
- }
- });
- } catch (error) {
- req.responseCb (error);
- }
-
- return this;
-};
-
-Session.prototype.set = function (varbinds, responseCb) {
- function feedCb (req, message) {
- var pdu = message.pdu;
- var varbinds = [];
-
- if (req.message.pdu.varbinds.length != pdu.varbinds.length) {
- req.responseCb (new ResponseInvalidError ("Requested OIDs do not "
- + "match response OIDs"));
- } else {
- for (var i = 0; i < req.message.pdu.varbinds.length; i++) {
- if (req.message.pdu.varbinds[i].oid != pdu.varbinds[i].oid) {
- req.responseCb (new ResponseInvalidError ("OID '"
- + req.message.pdu.varbinds[i].oid
- + "' in request at positiion '" + i + "' does not "
- + "match OID '" + pdu.varbinds[i].oid + "' in response "
- + "at position '" + i + "'"));
- return;
- } else {
- varbinds.push (pdu.varbinds[i]);
- }
- }
-
- req.responseCb (null, varbinds);
- }
- }
-
- var pduVarbinds = [];
-
- for (var i = 0; i < varbinds.length; i++) {
- var varbind = {
- oid: varbinds[i].oid,
- type: varbinds[i].type,
- value: varbinds[i].value
- };
- pduVarbinds.push (varbind);
- }
-
- this.simpleGet (SetRequestPdu, feedCb, pduVarbinds, responseCb);
-
- return this;
-};
-
-Session.prototype.simpleGet = function (pduClass, feedCb, varbinds,
- responseCb, options) {
- var req = {};
-
- try {
- var id = _generateId ();
- var pdu = new pduClass (id, varbinds, options);
- var message = new RequestMessage (this.version, this.community, pdu);
-
- req = {
- id: id,
- message: message,
- responseCb: responseCb,
- retries: this.retries,
- timeout: this.timeout,
- onResponse: this.onSimpleGetResponse,
- feedCb: feedCb,
- port: (options && options.port) ? options.port : this.port
- };
-
- this.send (req);
- } catch (error) {
- if (req.responseCb)
- req.responseCb (error);
- }
-};
-
-function subtreeCb (req, varbinds) {
- var done = 0;
-
- for (var i = varbinds.length; i > 0; i--) {
- if (! oidInSubtree (req.baseOid, varbinds[i - 1].oid)) {
- done = 1;
- varbinds.pop ();
- }
- }
-
- if (varbinds.length > 0)
- req.feedCb (varbinds);
-
- if (done)
- return true;
-}
-
-Session.prototype.subtree = function () {
- var me = this;
- var oid = arguments[0];
- var maxRepetitions, feedCb, doneCb;
-
- if (arguments.length < 4) {
- maxRepetitions = 20;
- feedCb = arguments[1];
- doneCb = arguments[2];
- } else {
- maxRepetitions = arguments[1];
- feedCb = arguments[2];
- doneCb = arguments[3];
- }
-
- var req = {
- feedCb: feedCb,
- doneCb: doneCb,
- maxRepetitions: maxRepetitions,
- baseOid: oid
- };
-
- this.walk (oid, maxRepetitions, subtreeCb.bind (me, req), doneCb);
-
- return this;
-};
-
-function tableColumnsResponseCb (req, error) {
- if (error) {
- req.responseCb (error);
- } else if (req.error) {
- req.responseCb (req.error);
- } else {
- if (req.columns.length > 0) {
- var column = req.columns.pop ();
- var me = this;
- this.subtree (req.rowOid + column, req.maxRepetitions,
- tableColumnsFeedCb.bind (me, req),
- tableColumnsResponseCb.bind (me, req));
- } else {
- req.responseCb (null, req.table);
- }
- }
-}
-
-function tableColumnsFeedCb (req, varbinds) {
- for (var i = 0; i < varbinds.length; i++) {
- if (isVarbindError (varbinds[i])) {
- req.error = new RequestFailedError (varbindError (varbind[i]));
- return true;
- }
-
- var oid = varbinds[i].oid.replace (req.rowOid, "");
- if (oid && oid != varbinds[i].oid) {
- var match = oid.match (/^(\d+)\.(.+)$/);
- if (match && match[1] > 0) {
- if (! req.table[match[2]])
- req.table[match[2]] = {};
- req.table[match[2]][match[1]] = varbinds[i].value;
- }
- }
- }
-}
-
-Session.prototype.tableColumns = function () {
- var me = this;
-
- var oid = arguments[0];
- var columns = arguments[1];
- var maxRepetitions, responseCb;
-
- if (arguments.length < 4) {
- responseCb = arguments[2];
- maxRepetitions = 20;
- } else {
- maxRepetitions = arguments[2];
- responseCb = arguments[3];
- }
-
- var req = {
- responseCb: responseCb,
- maxRepetitions: maxRepetitions,
- baseOid: oid,
- rowOid: oid + ".1.",
- columns: columns.slice(0),
- table: {}
- };
-
- if (req.columns.length > 0) {
- var column = req.columns.pop ();
- this.subtree (req.rowOid + column, maxRepetitions,
- tableColumnsFeedCb.bind (me, req),
- tableColumnsResponseCb.bind (me, req));
- }
-
- return this;
-};
-
-function tableResponseCb (req, error) {
- if (error)
- req.responseCb (error);
- else if (req.error)
- req.responseCb (req.error);
- else
- req.responseCb (null, req.table);
-}
-
-function tableFeedCb (req, varbinds) {
- for (var i = 0; i < varbinds.length; i++) {
- if (isVarbindError (varbinds[i])) {
- req.error = new RequestFailedError (varbindError (varbind[i]));
- return true;
- }
-
- var oid = varbinds[i].oid.replace (req.rowOid, "");
- if (oid && oid != varbinds[i].oid) {
- var match = oid.match (/^(\d+)\.(.+)$/);
- if (match && match[1] > 0) {
- if (! req.table[match[2]])
- req.table[match[2]] = {};
- req.table[match[2]][match[1]] = varbinds[i].value;
- }
- }
- }
-}
-
-Session.prototype.table = function () {
- var me = this;
-
- var oid = arguments[0];
- var maxRepetitions, responseCb;
-
- if (arguments.length < 3) {
- responseCb = arguments[1];
- maxRepetitions = 20;
- } else {
- maxRepetitions = arguments[1];
- responseCb = arguments[2];
- }
-
- var req = {
- responseCb: responseCb,
- maxRepetitions: maxRepetitions,
- baseOid: oid,
- rowOid: oid + ".1.",
- table: {}
- };
-
- this.subtree (oid, maxRepetitions, tableFeedCb.bind (me, req),
- tableResponseCb.bind (me, req));
-
- return this;
-};
-
-Session.prototype.trap = function () {
- var req = {};
-
- try {
- var typeOrOid = arguments[0];
- var varbinds, options = {}, responseCb;
-
- /**
- ** Support the following signatures:
- **
- ** typeOrOid, varbinds, options, callback
- ** typeOrOid, varbinds, agentAddr, callback
- ** typeOrOid, varbinds, callback
- ** typeOrOid, agentAddr, callback
- ** typeOrOid, options, callback
- ** typeOrOid, callback
- **/
- if (arguments.length >= 4) {
- varbinds = arguments[1];
- if (typeof arguments[2] == "string") {
- options.agentAddr = arguments[2];
- } else if (arguments[2].constructor != Array) {
- options = arguments[2];
- }
- responseCb = arguments[3];
- } else if (arguments.length >= 3) {
- if (typeof arguments[1] == "string") {
- varbinds = [];
- options.agentAddr = arguments[1];
- } else if (arguments[1].constructor != Array) {
- varbinds = [];
- options = arguments[1];
- } else {
- varbinds = arguments[1];
- agentAddr = null;
- }
- responseCb = arguments[2];
- } else {
- varbinds = [];
- responseCb = arguments[1];
- }
-
- var pdu, pduVarbinds = [];
-
- for (var i = 0; i < varbinds.length; i++) {
- var varbind = {
- oid: varbinds[i].oid,
- type: varbinds[i].type,
- value: varbinds[i].value
- };
- pduVarbinds.push (varbind);
- }
-
- var id = _generateId ();
-
- if (this.version == Version2c) {
- if (typeof typeOrOid != "string")
- typeOrOid = "1.3.6.1.6.3.1.1.5." + (typeOrOid + 1);
-
- pduVarbinds.unshift (
- {
- oid: "1.3.6.1.2.1.1.3.0",
- type: ObjectType.TimeTicks,
- value: options.upTime || Math.floor (process.uptime () * 100)
- },
- {
- oid: "1.3.6.1.6.3.1.1.4.1.0",
- type: ObjectType.OID,
- value: typeOrOid
- }
- );
-
- pdu = new TrapV2Pdu (id, pduVarbinds, options);
- } else {
- pdu = new TrapPdu (typeOrOid, pduVarbinds, options);
- }
-
- var message = new RequestMessage (this.version, this.community, pdu);
-
- req = {
- id: id,
- message: message,
- responseCb: responseCb,
- port: this.trapPort
- };
-
- this.send (req, true);
- } catch (error) {
- if (req.responseCb)
- req.responseCb (error);
- }
-
- return this;
-};
-
-Session.prototype.unregisterRequest = function (id) {
- var req = this.reqs[id];
- if (req) {
- delete this.reqs[id];
- clearTimeout (req.timer);
- delete req.timer;
- this.reqCount--;
- if (this.reqCount <= 0)
- this.dgram.unref();
- return req;
- } else {
- return null;
- }
-};
-
-function walkCb (req, error, varbinds) {
- var done = 0;
- var oid;
-
- if (error) {
- if (error instanceof RequestFailedError) {
- if (error.status != ErrorStatus.NoSuchName) {
- req.doneCb (error);
- return;
- } else {
- // signal the version 1 walk code below that it should stop
- done = 1;
- }
- } else {
- req.doneCb (error);
- return;
- }
- }
-
- if (this.version == Version2c) {
- for (var i = varbinds[0].length; i > 0; i--) {
- if (varbinds[0][i - 1].type == ObjectType.EndOfMibView) {
- varbinds[0].pop ();
- done = 1;
- }
- }
- if (req.feedCb (varbinds[0]))
- done = 1;
- if (! done)
- oid = varbinds[0][varbinds[0].length - 1].oid;
- } else {
- if (! done) {
- if (req.feedCb (varbinds)) {
- done = 1;
- } else {
- oid = varbinds[0].oid;
- }
- }
- }
-
- if (done)
- req.doneCb (null);
- else
- this.walk (oid, req.maxRepetitions, req.feedCb, req.doneCb,
- req.baseOid);
-}
-
-Session.prototype.walk = function () {
- var me = this;
- var oid = arguments[0];
- var maxRepetitions, feedCb, doneCb, baseOid;
-
- if (arguments.length < 4) {
- maxRepetitions = 20;
- feedCb = arguments[1];
- doneCb = arguments[2];
- } else {
- maxRepetitions = arguments[1];
- feedCb = arguments[2];
- doneCb = arguments[3];
- }
-
- var req = {
- maxRepetitions: maxRepetitions,
- feedCb: feedCb,
- doneCb: doneCb
- };
-
- if (this.version == Version2c)
- this.getBulk ([oid], 0, maxRepetitions,
- walkCb.bind (me, req));
- else
- this.getNext ([oid], walkCb.bind (me, req));
-
- return this;
-};
-
-/*****************************************************************************
- ** Exports
- **/
-
-exports.Session = Session;
-
-exports.createSession = function (target, community, options) {
- return new Session (target, community, options);
-};
-
-exports.isVarbindError = isVarbindError;
-exports.varbindError = varbindError;
-
-exports.Version1 = Version1;
-exports.Version2c = Version2c;
-
-exports.ErrorStatus = ErrorStatus;
-exports.TrapType = TrapType;
-exports.ObjectType = ObjectType;
-
-exports.ResponseInvalidError = ResponseInvalidError;
-exports.RequestInvalidError = RequestInvalidError;
-exports.RequestFailedError = RequestFailedError;
-exports.RequestTimedOutError = RequestTimedOutError;
-
-/**
- ** We've added this for testing.
- **/
-exports.ObjectParser = {
- readInt: readInt,
- readUint: readUint
-};
diff --git a/node.d/node_modules/netdata.js b/node.d/node_modules/netdata.js
deleted file mode 100644
index 4ab8308c1..000000000
--- a/node.d/node_modules/netdata.js
+++ /dev/null
@@ -1,654 +0,0 @@
-'use strict';
-
-// netdata
-// real-time performance and health monitoring, done right!
-// (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
-// GPL v3+
-
-var url = require('url');
-var http = require('http');
-var util = require('util');
-
-/*
-var netdata = require('netdata');
-
-var example_chart = {
- id: 'id', // the unique id of the chart
- name: 'name', // the name of the chart
- title: 'title', // the title of the chart
- units: 'units', // the units of the chart dimensions
- family: 'family', // the family of the chart
- context: 'context', // the context of the chart
- type: netdata.chartTypes.line, // the type of the chart
- priority: 0, // the priority relative to others in the same family
- update_every: 1, // the expected update frequency of the chart
- dimensions: {
- 'dim1': {
- id: 'dim1', // the unique id of the dimension
- name: 'name', // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute, // the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1, // the divisor
- hidden: false, // is hidden (boolean)
- },
- 'dim2': {
- id: 'dim2', // the unique id of the dimension
- name: 'name', // the name of the dimension
- algorithm: 'absolute', // the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1, // the divisor
- hidden: false, // is hidden (boolean)
- }
- // add as many dimensions as needed
- }
-};
-*/
-
-var netdata = {
- options: {
- filename: __filename,
- DEBUG: false,
- update_every: 1
- },
-
- chartAlgorithms: {
- incremental: 'incremental',
- absolute: 'absolute',
- percentage_of_absolute_row: 'percentage-of-absolute-row',
- percentage_of_incremental_row: 'percentage-of-incremental-row'
- },
-
- chartTypes: {
- line: 'line',
- area: 'area',
- stacked: 'stacked'
- },
-
- services: new Array(),
- modules_configuring: 0,
- charts: {},
-
- processors: {
- http: {
- name: 'http',
-
- process: function(service, callback) {
- var __DEBUG = netdata.options.DEBUG;
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': making ' + this.name + ' request: ' + netdata.stringify(service.request));
-
- var req = http.request(service.request, function(response) {
- if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': got server response...');
-
- var end = false;
- var data = '';
- response.setEncoding('utf8');
-
- if(response.statusCode !== 200) {
- if(end === false) {
- service.error('Got HTTP code ' + response.statusCode + ', failed to get data.');
- end = true;
- return callback(null);
- }
- }
-
- response.on('data', function(chunk) {
- if(end === false) data += chunk;
- });
-
- response.on('error', function() {
- if(end === false) {
- service.error(': Read error, failed to get data.');
- end = true;
- return callback(null);
- }
- });
-
- response.on('end', function() {
- if(end === false) {
- if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': read completed.');
- end = true;
- return callback(data);
- }
- });
- });
-
- req.on('error', function(e) {
- if(__DEBUG === true) netdata.debug('Failed to make request: ' + netdata.stringify(service.request) + ', message: ' + e.message);
- service.error('Failed to make request, message: ' + e.message);
- return callback(null);
- });
-
- // write data to request body
- if(typeof service.postData !== 'undefined' && service.request.method === 'POST') {
- if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': posting data: ' + service.postData);
- req.write(service.postData);
- }
-
- req.end();
- }
- }
- },
-
- stringify: function(obj) {
- return util.inspect(obj, {depth: 10});
- },
-
- zeropad2: function(s) {
- return ("00" + s).slice(-2);
- },
-
- logdate: function(d) {
- if(typeof d === 'undefined') d = new Date();
- return d.getFullYear().toString() + '-' + this.zeropad2(d.getMonth() + 1) + '-' + this.zeropad2(d.getDate())
- + ' ' + this.zeropad2(d.getHours()) + ':' + this.zeropad2(d.getMinutes()) + ':' + this.zeropad2(d.getSeconds());
- },
-
- // show debug info, if debug is enabled
- debug: function(msg) {
- if(this.options.DEBUG === true) {
- console.error(this.logdate() + ': ' + netdata.options.filename + ': DEBUG: ' + ((typeof(msg) === 'object')?netdata.stringify(msg):msg).toString());
- }
- },
-
- // log an error
- error: function(msg) {
- console.error(this.logdate() + ': ' + netdata.options.filename + ': ERROR: ' + ((typeof(msg) === 'object')?netdata.stringify(msg):msg).toString());
- },
-
- // send data to netdata
- send: function(msg) {
- console.log(msg.toString());
- },
-
- service: function(service) {
- if(typeof service === 'undefined')
- service = {};
-
- var now = Date.now();
-
- service._current_chart = null; // the current chart we work on
- service._queue = ''; // data to be sent to netdata
-
- service.error_reported = false; // error log flood control
-
- service.added = false; // added to netdata.services
- service.enabled = true;
- service.updates = 0;
- service.running = false;
- service.started = 0;
- service.ended = 0;
-
- if(typeof service.module === 'undefined') {
- service.module = { name: 'not-defined-module' };
- service.error('Attempted to create service without a module.');
- service.enabled = false;
- }
-
- if(typeof service.name === 'undefined') {
- service.name = 'unnamed@' + service.module.name + '/' + now;
- }
-
- if(typeof service.processor === 'undefined')
- service.processor = netdata.processors.http;
-
- if(typeof service.update_every === 'undefined')
- service.update_every = service.module.update_every;
-
- if(typeof service.update_every === 'undefined')
- service.update_every = netdata.options.update_every;
-
- if(service.update_every < netdata.options.update_every)
- service.update_every = netdata.options.update_every;
-
- // align the runs
- service.next_run = now - (now % (service.update_every * 1000)) + (service.update_every * 1000);
-
- service.commit = function() {
- if(this.added !== true) {
- this.added = true;
-
- var now = Date.now();
- this.next_run = now - (now % (service.update_every * 1000)) + (service.update_every * 1000);
-
- netdata.services.push(this);
- if(netdata.options.DEBUG === true) netdata.debug(this.module.name + ': ' + this.name + ': service committed.');
- }
- };
-
- service.execute = function(responseProcessor) {
- var __DEBUG = netdata.options.DEBUG;
-
- if(service.enabled === false)
- return responseProcessor(null);
-
- this.module.active++;
- this.running = true;
- this.started = Date.now();
- this.updates++;
-
- if(__DEBUG === true)
- netdata.debug(this.module.name + ': ' + this.name + ': making ' + this.processor.name + ' request: ' + netdata.stringify(this));
-
- this.processor.process(this, function(response) {
- service.ended = Date.now();
- service.duration = service.ended - service.started;
-
- if(typeof response === 'undefined')
- response = null;
-
- if(response !== null)
- service.errorClear();
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': processing ' + service.processor.name + ' response (received in ' + (service.ended - service.started).toString() + ' ms)');
-
- try {
- responseProcessor(service, response);
- }
- catch(e) {
- netdata.error(e);
- service.error("responseProcessor failed process response data.");
- }
-
- service.running = false;
- service.module.active--;
- if(service.module.active < 0) {
- service.module.active = 0;
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': active module counter below zero.');
- }
-
- if(service.module.active === 0) {
- // check if we run under configure
- if(service.module.configure_callback !== null) {
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': configuration finish callback called from processResponse().');
-
- var configure_callback = service.module.configure_callback;
- service.module.configure_callback = null;
- configure_callback();
- }
- }
- });
- };
-
- service.update = function() {
- if(netdata.options.DEBUG === true)
- netdata.debug(this.module.name + ': ' + this.name + ': starting data collection...');
-
- this.module.update(this, function() {
- if(netdata.options.DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': data collection ended in ' + service.duration.toString() + ' ms.');
- });
- };
-
- service.error = function(message) {
- if(this.error_reported === false) {
- netdata.error(this.module.name + ': ' + this.name + ': ' + message);
- this.error_reported = true;
- }
- else if(netdata.options.DEBUG === true)
- netdata.debug(this.module.name + ': ' + this.name + ': ' + message);
- };
-
- service.errorClear = function() {
- this.error_reported = false;
- };
-
- service.queue = function(txt) {
- this._queue += txt + '\n';
- };
-
- service._send_chart_to_netdata = function(chart) {
- // internal function to send a chart to netdata
- this.queue('CHART "' + chart.id + '" "' + chart.name + '" "' + chart.title + '" "' + chart.units + '" "' + chart.family + '" "' + chart.context + '" "' + chart.type + '" ' + chart.priority.toString() + ' ' + chart.update_every.toString());
-
- if(typeof(chart.dimensions) !== 'undefined') {
- var dims = Object.keys(chart.dimensions);
- var len = dims.length;
- while(len--) {
- var d = chart.dimensions[dims[len]];
-
- this.queue('DIMENSION "' + d.id + '" "' + d.name + '" "' + d.algorithm + '" ' + d.multiplier.toString() + ' ' + d.divisor.toString() + ' ' + ((d.hidden === true) ? 'hidden' : '').toString());
- d._created = true;
- d._updated = false;
- }
- }
-
- chart._created = true;
- chart._updated = false;
- };
-
- // begin data collection for a chart
- service.begin = function(chart) {
- if(this._current_chart !== null && this._current_chart !== chart) {
- this.error('Called begin() for chart ' + chart.id + ' while chart ' + this._current_chart.id + ' is still open. Closing it.');
- this.end();
- }
-
- if(typeof(chart.id) === 'undefined' || netdata.charts[chart.id] !== chart) {
- this.error('Called begin() for chart ' + chart.id + ' that is not mine. Where did you find it? Ignoring it.');
- return false;
- }
-
- if(netdata.options.DEBUG === true) netdata.debug('setting current chart to ' + chart.id);
- this._current_chart = chart;
- this._current_chart._began = true;
-
- if(this._current_chart._dimensions_count !== 0) {
- if(this._current_chart._created === false || this._current_chart._updated === true)
- this._send_chart_to_netdata(this._current_chart);
-
- var now = this.ended;
- this.queue('BEGIN ' + this._current_chart.id + ' ' + ((this._current_chart._last_updated > 0)?((now - this._current_chart._last_updated) * 1000):'').toString());
- }
- // else this.error('Called begin() for chart ' + chart.id + ' which is empty.');
-
- this._current_chart._last_updated = now;
- this._current_chart._began = true;
- this._current_chart._counter++;
-
- return true;
- };
-
- // set a collected value for a chart
- // we do most things on the first value we attempt to set
- service.set = function(dimension, value) {
- if(this._current_chart === null) {
- this.error('Called set(' + dimension + ', ' + value + ') without an open chart.');
- return false;
- }
-
- if(typeof(this._current_chart.dimensions[dimension]) === 'undefined') {
- this.error('Called set(' + dimension + ', ' + value + ') but dimension "' + dimension + '" does not exist in chart "' + this._current_chart.id + '".');
- return false;
- }
-
- if(typeof value === 'undefined' || value === null)
- return false;
-
- if(this._current_chart._dimensions_count !== 0)
- this.queue('SET ' + dimension + ' = ' + value.toString());
-
- return true;
- };
-
- // end data collection for the current chart - after calling begin()
- service.end = function() {
- if(this._current_chart !== null && this._current_chart._began === false) {
- this.error('Called end() without an open chart.');
- return false;
- }
-
- if(this._current_chart._dimensions_count !== 0) {
- this.queue('END');
- netdata.send(this._queue);
- }
-
- this._queue = '';
- this._current_chart._began = false;
- if(netdata.options.DEBUG === true) netdata.debug('sent chart ' + this._current_chart.id);
- this._current_chart = null;
- return true;
- };
-
- // discard the collected values for the current chart - after calling begin()
- service.flush = function() {
- if(this._current_chart === null || this._current_chart._began === false) {
- this.error('Called flush() without an open chart.');
- return false;
- }
-
- this._queue = '';
- this._current_chart._began = false;
- this._current_chart = null;
- return true;
- };
-
- // create a netdata chart
- service.chart = function(id, chart) {
- var __DEBUG = netdata.options.DEBUG;
-
- if(typeof(netdata.charts[id]) === 'undefined') {
- netdata.charts[id] = {
- _created: false,
- _updated: true,
- _began: false,
- _counter: 0,
- _last_updated: 0,
- _dimensions_count: 0,
- id: id,
- name: id,
- title: 'untitled chart',
- units: 'a unit',
- family: '',
- context: '',
- type: netdata.chartTypes.line,
- priority: 50000,
- update_every: netdata.options.update_every,
- dimensions: {}
- };
- }
-
- var c = netdata.charts[id];
-
- if(typeof(chart.name) !== 'undefined' && chart.name !== c.name) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its name');
- c.name = chart.name;
- c._updated = true;
- }
-
- if(typeof(chart.title) !== 'undefined' && chart.title !== c.title) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its title');
- c.title = chart.title;
- c._updated = true;
- }
-
- if(typeof(chart.units) !== 'undefined' && chart.units !== c.units) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its units');
- c.units = chart.units;
- c._updated = true;
- }
-
- if(typeof(chart.family) !== 'undefined' && chart.family !== c.family) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its family');
- c.family = chart.family;
- c._updated = true;
- }
-
- if(typeof(chart.context) !== 'undefined' && chart.context !== c.context) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its context');
- c.context = chart.context;
- c._updated = true;
- }
-
- if(typeof(chart.type) !== 'undefined' && chart.type !== c.type) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its type');
- c.type = chart.type;
- c._updated = true;
- }
-
- if(typeof(chart.priority) !== 'undefined' && chart.priority !== c.priority) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its priority');
- c.priority = chart.priority;
- c._updated = true;
- }
-
- if(typeof(chart.update_every) !== 'undefined' && chart.update_every !== c.update_every) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ' updated its update_every from ' + c.update_every + ' to ' + chart.update_every);
- c.update_every = chart.update_every;
- c._updated = true;
- }
-
- if(typeof(chart.dimensions) !== 'undefined') {
- var dims = Object.keys(chart.dimensions);
- var len = dims.length;
- while(len--) {
- var x = dims[len];
-
- if(typeof(c.dimensions[x]) === 'undefined') {
- c._dimensions_count++;
-
- c.dimensions[x] = {
- _created: false,
- _updated: false,
- id: x, // the unique id of the dimension
- name: x, // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute, // the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1, // the divisor
- hidden: false // is hidden (boolean)
- };
-
- if(__DEBUG === true) netdata.debug('chart ' + id + ' created dimension ' + x);
- c._updated = true;
- }
-
- var dim = chart.dimensions[x];
- var d = c.dimensions[x];
-
- if(typeof(dim.name) !== 'undefined' && d.name !== dim.name) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its name');
- d.name = dim.name;
- d._updated = true;
- }
-
- if(typeof(dim.algorithm) !== 'undefined' && d.algorithm !== dim.algorithm) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its algorithm from ' + d.algorithm + ' to ' + dim.algorithm);
- d.algorithm = dim.algorithm;
- d._updated = true;
- }
-
- if(typeof(dim.multiplier) !== 'undefined' && d.multiplier !== dim.multiplier) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its multiplier');
- d.multiplier = dim.multiplier;
- d._updated = true;
- }
-
- if(typeof(dim.divisor) !== 'undefined' && d.divisor !== dim.divisor) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its divisor');
- d.divisor = dim.divisor;
- d._updated = true;
- }
-
- if(typeof(dim.hidden) !== 'undefined' && d.hidden !== dim.hidden) {
- if(__DEBUG === true) netdata.debug('chart ' + id + ', dimension ' + x + ' updated its hidden status');
- d.hidden = dim.hidden;
- d._updated = true;
- }
-
- if(d._updated) c._updated = true;
- }
- }
-
- //if(netdata.options.DEBUG === true) netdata.debug(netdata.charts);
- return netdata.charts[id];
- };
-
- return service;
- },
-
- runAllServices: function() {
- if(netdata.options.DEBUG === true) netdata.debug('runAllServices()');
-
- var now = Date.now();
- var len = netdata.services.length;
- while(len--) {
- var service = netdata.services[len];
-
- if(service.enabled === false || service.running === true) continue;
- if(now <= service.next_run) continue;
-
- service.update();
-
- now = Date.now();
- service.next_run = now - (now % (service.update_every * 1000)) + (service.update_every * 1000);
- }
-
- // 1/10th of update_every in pause
- setTimeout(netdata.runAllServices, netdata.options.update_every * 100);
- },
-
- start: function() {
- if(netdata.options.DEBUG === true) this.debug('started, services: ' + netdata.stringify(this.services));
-
- if(this.services.length === 0) {
- this.disableNodePlugin();
-
- // eslint suggested way to exit
- var exit = process.exit;
- exit(1);
- }
- else this.runAllServices();
- },
-
- // disable the whole node.js plugin
- disableNodePlugin: function() {
- this.send('DISABLE');
-
- // eslint suggested way to exit
- var exit = process.exit;
- exit(1);
- },
-
- requestFromParams: function(protocol, hostname, port, path, method) {
- return {
- protocol: protocol,
- hostname: hostname,
- port: port,
- path: path,
- //family: 4,
- method: method,
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Connection': 'keep-alive'
- },
- agent: new http.Agent({
- keepAlive: true,
- keepAliveMsecs: netdata.options.update_every * 1000,
- maxSockets: 2, // it must be 2 to work
- maxFreeSockets: 1
- })
- };
- },
-
- requestFromURL: function(a_url) {
- var u = url.parse(a_url);
- return netdata.requestFromParams(u.protocol, u.hostname, u.port, u.path, 'GET');
- },
-
- configure: function(module, config, callback) {
- if(netdata.options.DEBUG === true) this.debug(module.name + ': configuring (update_every: ' + this.options.update_every + ')...');
-
- module.active = 0;
- module.update_every = this.options.update_every;
-
- if(typeof config.update_every !== 'undefined')
- module.update_every = config.update_every;
-
- module.enable_autodetect = (config.enable_autodetect)?true:false;
-
- if(typeof(callback) === 'function')
- module.configure_callback = callback;
- else
- module.configure_callback = null;
-
- var added = module.configure(config);
-
- if(netdata.options.DEBUG === true) this.debug(module.name + ': configured, reporting ' + added + ' eligible services.');
-
- if(module.configure_callback !== null && added === 0) {
- if(netdata.options.DEBUG === true) this.debug(module.name + ': configuration finish callback called from configure().');
- var configure_callback = module.configure_callback;
- module.configure_callback = null;
- configure_callback();
- }
-
- return added;
- }
-};
-
-if(netdata.options.DEBUG === true) netdata.debug('loaded netdata from:', __filename);
-module.exports = netdata;
diff --git a/node.d/node_modules/pixl-xml.js b/node.d/node_modules/pixl-xml.js
deleted file mode 100644
index 481acbaeb..000000000
--- a/node.d/node_modules/pixl-xml.js
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- JavaScript XML Library
- Plus a bunch of object utility functions
-
- Usage:
- var XML = require('pixl-xml');
- var myxmlstring = '<?xml version="1.0"?><Document>' +
- '<Simple>Hello</Simple>' +
- '<Node Key="Value">Content</Node>' +
- '</Document>';
-
- var tree = XML.parse( myxmlstring, { preserveAttributes: true });
- console.log( tree );
-
- tree.Simple = "Hello2";
- tree.Node._Attribs.Key = "Value2";
- tree.Node._Data = "Content2";
- tree.New = "I added this";
-
- console.log( XML.stringify( tree, 'Document' ) );
-
- Copyright (c) 2004 - 2015 Joseph Huckaby
- Released under the MIT License
- This version is for Node.JS, converted in 2012.
-*/
-
-var fs = require('fs');
-
-var indent_string = "\t";
-var xml_header = '<?xml version="1.0"?>';
-var sort_args = null;
-var re_valid_tag_name = /^\w[\w\-\:]*$/;
-
-var XML = exports.XML = function XML(args) {
- // class constructor for XML parser class
- // pass in args hash or text to parse
- if (!args) args = '';
- if (isa_hash(args)) {
- for (var key in args) this[key] = args[key];
- }
- else this.text = args || '';
-
- // stringify buffers
- if (this.text instanceof Buffer) {
- this.text = this.text.toString();
- }
-
- if (!this.text.match(/^\s*</)) {
- // try as file path
- var file = this.text;
- this.text = fs.readFileSync(file, { encoding: 'utf8' });
- if (!this.text) throw new Error("File not found: " + file);
- }
-
- this.tree = {};
- this.errors = [];
- this.piNodeList = [];
- this.dtdNodeList = [];
- this.documentNodeName = '';
-
- if (this.lowerCase) {
- this.attribsKey = this.attribsKey.toLowerCase();
- this.dataKey = this.dataKey.toLowerCase();
- }
-
- this.patTag.lastIndex = 0;
- if (this.text) this.parse();
-}
-
-XML.prototype.preserveAttributes = false;
-XML.prototype.lowerCase = false;
-
-XML.prototype.patTag = /([^<]*?)<([^>]+)>/g;
-XML.prototype.patSpecialTag = /^\s*([\!\?])/;
-XML.prototype.patPITag = /^\s*\?/;
-XML.prototype.patCommentTag = /^\s*\!--/;
-XML.prototype.patDTDTag = /^\s*\!DOCTYPE/;
-XML.prototype.patCDATATag = /^\s*\!\s*\[\s*CDATA/;
-XML.prototype.patStandardTag = /^\s*(\/?)([\w\-\:\.]+)\s*(.*)$/;
-XML.prototype.patSelfClosing = /\/\s*$/;
-XML.prototype.patAttrib = new RegExp("([\\w\\-\\:\\.]+)\\s*=\\s*([\\\"\\'])([^\\2]*?)\\2", "g");
-XML.prototype.patPINode = /^\s*\?\s*([\w\-\:]+)\s*(.*)$/;
-XML.prototype.patEndComment = /--$/;
-XML.prototype.patNextClose = /([^>]*?)>/g;
-XML.prototype.patExternalDTDNode = new RegExp("^\\s*\\!DOCTYPE\\s+([\\w\\-\\:]+)\\s+(SYSTEM|PUBLIC)\\s+\\\"([^\\\"]+)\\\"");
-XML.prototype.patInlineDTDNode = /^\s*\!DOCTYPE\s+([\w\-\:]+)\s+\[/;
-XML.prototype.patEndDTD = /\]$/;
-XML.prototype.patDTDNode = /^\s*\!DOCTYPE\s+([\w\-\:]+)\s+\[(.*)\]/;
-XML.prototype.patEndCDATA = /\]\]$/;
-XML.prototype.patCDATANode = /^\s*\!\s*\[\s*CDATA\s*\[([^]*)\]\]/;
-
-XML.prototype.attribsKey = '_Attribs';
-XML.prototype.dataKey = '_Data';
-
-XML.prototype.parse = function(branch, name) {
- // parse text into XML tree, recurse for nested nodes
- if (!branch) branch = this.tree;
- if (!name) name = null;
- var foundClosing = false;
- var matches = null;
-
- // match each tag, plus preceding text
- while ( matches = this.patTag.exec(this.text) ) {
- var before = matches[1];
- var tag = matches[2];
-
- // text leading up to tag = content of parent node
- if (before.match(/\S/)) {
- if (typeof(branch[this.dataKey]) != 'undefined') branch[this.dataKey] += ' '; else branch[this.dataKey] = '';
- branch[this.dataKey] += trim(decode_entities(before));
- }
-
- // parse based on tag type
- if (tag.match(this.patSpecialTag)) {
- // special tag
- if (tag.match(this.patPITag)) tag = this.parsePINode(tag);
- else if (tag.match(this.patCommentTag)) tag = this.parseCommentNode(tag);
- else if (tag.match(this.patDTDTag)) tag = this.parseDTDNode(tag);
- else if (tag.match(this.patCDATATag)) {
- tag = this.parseCDATANode(tag);
- if (typeof(branch[this.dataKey]) != 'undefined') branch[this.dataKey] += ' '; else branch[this.dataKey] = '';
- branch[this.dataKey] += trim(decode_entities(tag));
- } // cdata
- else {
- this.throwParseError( "Malformed special tag", tag );
- break;
- } // error
-
- if (tag == null) break;
- continue;
- } // special tag
- else {
- // Tag is standard, so parse name and attributes (if any)
- var matches = tag.match(this.patStandardTag);
- if (!matches) {
- this.throwParseError( "Malformed tag", tag );
- break;
- }
-
- var closing = matches[1];
- var nodeName = this.lowerCase ? matches[2].toLowerCase() : matches[2];
- var attribsRaw = matches[3];
-
- // If this is a closing tag, make sure it matches its opening tag
- if (closing) {
- if (nodeName == (name || '')) {
- foundClosing = 1;
- break;
- }
- else {
- this.throwParseError( "Mismatched closing tag (expected </" + name + ">)", tag );
- break;
- }
- } // closing tag
- else {
- // Not a closing tag, so parse attributes into hash. If tag
- // is self-closing, no recursive parsing is needed.
- var selfClosing = !!attribsRaw.match(this.patSelfClosing);
- var leaf = {};
- var attribs = leaf;
-
- // preserve attributes means they go into a sub-hash named "_Attribs"
- // the XML composer honors this for restoring the tree back into XML
- if (this.preserveAttributes) {
- leaf[this.attribsKey] = {};
- attribs = leaf[this.attribsKey];
- }
-
- // parse attributes
- this.patAttrib.lastIndex = 0;
- while ( matches = this.patAttrib.exec(attribsRaw) ) {
- var key = this.lowerCase ? matches[1].toLowerCase() : matches[1];
- attribs[ key ] = decode_entities( matches[3] );
- } // foreach attrib
-
- // if no attribs found, but we created the _Attribs subhash, clean it up now
- if (this.preserveAttributes && !num_keys(attribs)) {
- delete leaf[this.attribsKey];
- }
-
- // Recurse for nested nodes
- if (!selfClosing) {
- this.parse( leaf, nodeName );
- if (this.error()) break;
- }
-
- // Compress into simple node if text only
- var num_leaf_keys = num_keys(leaf);
- if ((typeof(leaf[this.dataKey]) != 'undefined') && (num_leaf_keys == 1)) {
- leaf = leaf[this.dataKey];
- }
- else if (!num_leaf_keys) {
- leaf = '';
- }
-
- // Add leaf to parent branch
- if (typeof(branch[nodeName]) != 'undefined') {
- if (isa_array(branch[nodeName])) {
- branch[nodeName].push( leaf );
- }
- else {
- var temp = branch[nodeName];
- branch[nodeName] = [ temp, leaf ];
- }
- }
- else {
- branch[nodeName] = leaf;
- }
-
- if (this.error() || (branch == this.tree)) break;
- } // not closing
- } // standard tag
- } // main reg exp
-
- // Make sure we found the closing tag
- if (name && !foundClosing) {
- this.throwParseError( "Missing closing tag (expected </" + name + ">)", name );
- }
-
- // If we are the master node, finish parsing and setup our doc node
- if (branch == this.tree) {
- if (typeof(this.tree[this.dataKey]) != 'undefined') delete this.tree[this.dataKey];
-
- if (num_keys(this.tree) > 1) {
- this.throwParseError( 'Only one top-level node is allowed in document', first_key(this.tree) );
- return;
- }
-
- this.documentNodeName = first_key(this.tree);
- if (this.documentNodeName) {
- this.tree = this.tree[this.documentNodeName];
- }
- }
-};
-
-XML.prototype.throwParseError = function(key, tag) {
- // log error and locate current line number in source XML document
- var parsedSource = this.text.substring(0, this.patTag.lastIndex);
- var eolMatch = parsedSource.match(/\n/g);
- var lineNum = (eolMatch ? eolMatch.length : 0) + 1;
- lineNum -= tag.match(/\n/) ? tag.match(/\n/g).length : 0;
-
- this.errors.push({
- type: 'Parse',
- key: key,
- text: '<' + tag + '>',
- line: lineNum
- });
-
- // Throw actual error (must wrap parse in try/catch)
- throw new Error( this.getLastError() );
-};
-
-XML.prototype.error = function() {
- // return number of errors
- return this.errors.length;
-};
-
-XML.prototype.getError = function(error) {
- // get formatted error
- var text = '';
- if (!error) return '';
-
- text = (error.type || 'General') + ' Error';
- if (error.code) text += ' ' + error.code;
- text += ': ' + error.key;
-
- if (error.line) text += ' on line ' + error.line;
- if (error.text) text += ': ' + error.text;
-
- return text;
-};
-
-XML.prototype.getLastError = function() {
- // Get most recently thrown error in plain text format
- if (!this.error()) return '';
- return this.getError( this.errors[this.errors.length - 1] );
-};
-
-XML.prototype.parsePINode = function(tag) {
- // Parse Processor Instruction Node, e.g. <?xml version="1.0"?>
- if (!tag.match(this.patPINode)) {
- this.throwParseError( "Malformed processor instruction", tag );
- return null;
- }
-
- this.piNodeList.push( tag );
- return tag;
-};
-
-XML.prototype.parseCommentNode = function(tag) {
- // Parse Comment Node, e.g. <!-- hello -->
- var matches = null;
- this.patNextClose.lastIndex = this.patTag.lastIndex;
-
- while (!tag.match(this.patEndComment)) {
- if (matches = this.patNextClose.exec(this.text)) {
- tag += '>' + matches[1];
- }
- else {
- this.throwParseError( "Unclosed comment tag", tag );
- return null;
- }
- }
-
- this.patTag.lastIndex = this.patNextClose.lastIndex;
- return tag;
-};
-
-XML.prototype.parseDTDNode = function(tag) {
- // Parse Document Type Descriptor Node, e.g. <!DOCTYPE ... >
- var matches = null;
-
- if (tag.match(this.patExternalDTDNode)) {
- // tag is external, and thus self-closing
- this.dtdNodeList.push( tag );
- }
- else if (tag.match(this.patInlineDTDNode)) {
- // Tag is inline, so check for nested nodes.
- this.patNextClose.lastIndex = this.patTag.lastIndex;
-
- while (!tag.match(this.patEndDTD)) {
- if (matches = this.patNextClose.exec(this.text)) {
- tag += '>' + matches[1];
- }
- else {
- this.throwParseError( "Unclosed DTD tag", tag );
- return null;
- }
- }
-
- this.patTag.lastIndex = this.patNextClose.lastIndex;
-
- // Make sure complete tag is well-formed, and push onto DTD stack.
- if (tag.match(this.patDTDNode)) {
- this.dtdNodeList.push( tag );
- }
- else {
- this.throwParseError( "Malformed DTD tag", tag );
- return null;
- }
- }
- else {
- this.throwParseError( "Malformed DTD tag", tag );
- return null;
- }
-
- return tag;
-};
-
-XML.prototype.parseCDATANode = function(tag) {
- // Parse CDATA Node, e.g. <![CDATA[Brooks & Shields]]>
- var matches = null;
- this.patNextClose.lastIndex = this.patTag.lastIndex;
-
- while (!tag.match(this.patEndCDATA)) {
- if (matches = this.patNextClose.exec(this.text)) {
- tag += '>' + matches[1];
- }
- else {
- this.throwParseError( "Unclosed CDATA tag", tag );
- return null;
- }
- }
-
- this.patTag.lastIndex = this.patNextClose.lastIndex;
-
- if (matches = tag.match(this.patCDATANode)) {
- return matches[1];
- }
- else {
- this.throwParseError( "Malformed CDATA tag", tag );
- return null;
- }
-};
-
-XML.prototype.getTree = function() {
- // get reference to parsed XML tree
- return this.tree;
-};
-
-XML.prototype.compose = function() {
- // compose tree back into XML
- var raw = compose_xml( this.tree, this.documentNodeName );
- var body = raw.substring( raw.indexOf("\n") + 1, raw.length );
- var xml = '';
-
- if (this.piNodeList.length) {
- for (var idx = 0, len = this.piNodeList.length; idx < len; idx++) {
- xml += '<' + this.piNodeList[idx] + '>' + "\n";
- }
- }
- else {
- xml += xml_header + "\n";
- }
-
- if (this.dtdNodeList.length) {
- for (var idx = 0, len = this.dtdNodeList.length; idx < len; idx++) {
- xml += '<' + this.dtdNodeList[idx] + '>' + "\n";
- }
- }
-
- xml += body;
- return xml;
-};
-
-//
-// Static Utility Functions:
-//
-
-var parse_xml = exports.parse = function parse_xml(text, opts) {
- // turn text into XML tree quickly
- if (!opts) opts = {};
- opts.text = text;
- var parser = new XML(opts);
- return parser.error() ? parser.getLastError() : parser.getTree();
-};
-
-var trim = exports.trim = function trim(text) {
- // strip whitespace from beginning and end of string
- if (text == null) return '';
-
- if (text && text.replace) {
- text = text.replace(/^\s+/, "");
- text = text.replace(/\s+$/, "");
- }
-
- return text;
-};
-
-var encode_entities = exports.encodeEntities = function encode_entities(text) {
- // Simple entitize exports.for = function for composing XML
- if (text == null) return '';
-
- if (text && text.replace) {
- text = text.replace(/\&/g, "&amp;"); // MUST BE FIRST
- text = text.replace(/</g, "&lt;");
- text = text.replace(/>/g, "&gt;");
- }
-
- return text;
-};
-
-var encode_attrib_entities = exports.encodeAttribEntities = function encode_attrib_entities(text) {
- // Simple entitize exports.for = function for composing XML attributes
- if (text == null) return '';
-
- if (text && text.replace) {
- text = text.replace(/\&/g, "&amp;"); // MUST BE FIRST
- text = text.replace(/</g, "&lt;");
- text = text.replace(/>/g, "&gt;");
- text = text.replace(/\"/g, "&quot;");
- text = text.replace(/\'/g, "&apos;");
- }
-
- return text;
-};
-
-var decode_entities = exports.decodeEntities = function decode_entities(text) {
- // Decode XML entities into raw ASCII
- if (text == null) return '';
-
- if (text && text.replace && text.match(/\&/)) {
- text = text.replace(/\&lt\;/g, "<");
- text = text.replace(/\&gt\;/g, ">");
- text = text.replace(/\&quot\;/g, '"');
- text = text.replace(/\&apos\;/g, "'");
- text = text.replace(/\&amp\;/g, "&"); // MUST BE LAST
- }
-
- return text;
-};
-
-var compose_xml = exports.stringify = function compose_xml(node, name, indent) {
- // Compose node into XML including attributes
- // Recurse for child nodes
- var xml = "";
-
- // If this is the root node, set the indent to 0
- // and setup the XML header (PI node)
- if (!indent) {
- indent = 0;
- xml = xml_header + "\n";
-
- if (!name) {
- // no name provided, assume content is wrapped in it
- name = first_key(node);
- node = node[name];
- }
- }
-
- // Setup the indent text
- var indent_text = "";
- for (var k = 0; k < indent; k++) indent_text += indent_string;
-
- if ((typeof(node) == 'object') && (node != null)) {
- // node is object -- now see if it is an array or hash
- if (!node.length) { // what about zero-length array?
- // node is hash
- xml += indent_text + "<" + name;
-
- var num_keys = 0;
- var has_attribs = 0;
- for (var key in node) num_keys++; // there must be a better way...
-
- if (node["_Attribs"]) {
- has_attribs = 1;
- var sorted_keys = hash_keys_to_array(node["_Attribs"]).sort();
- for (var idx = 0, len = sorted_keys.length; idx < len; idx++) {
- var key = sorted_keys[idx];
- xml += " " + key + "=\"" + encode_attrib_entities(node["_Attribs"][key]) + "\"";
- }
- } // has attribs
-
- if (num_keys > has_attribs) {
- // has child elements
- xml += ">";
-
- if (node["_Data"]) {
- // simple text child node
- xml += encode_entities(node["_Data"]) + "</" + name + ">\n";
- } // just text
- else {
- xml += "\n";
-
- var sorted_keys = hash_keys_to_array(node).sort();
- for (var idx = 0, len = sorted_keys.length; idx < len; idx++) {
- var key = sorted_keys[idx];
- if ((key != "_Attribs") && key.match(re_valid_tag_name)) {
- // recurse for node, with incremented indent value
- xml += compose_xml( node[key], key, indent + 1 );
- } // not _Attribs key
- } // foreach key
-
- xml += indent_text + "</" + name + ">\n";
- } // real children
- }
- else {
- // no child elements, so self-close
- xml += "/>\n";
- }
- } // standard node
- else {
- // node is array
- for (var idx = 0; idx < node.length; idx++) {
- // recurse for node in array with same indent
- xml += compose_xml( node[idx], name, indent );
- }
- } // array of nodes
- } // complex node
- else {
- // node is simple string
- xml += indent_text + "<" + name + ">" + encode_entities(node) + "</" + name + ">\n";
- } // simple text node
-
- return xml;
-};
-
-var always_array = exports.alwaysArray = function always_array(obj, key) {
- // if object is not array, return array containing object
- // if key is passed, work like XMLalwaysarray() instead
- if (key) {
- if ((typeof(obj[key]) != 'object') || (typeof(obj[key].length) == 'undefined')) {
- var temp = obj[key];
- delete obj[key];
- obj[key] = new Array();
- obj[key][0] = temp;
- }
- return null;
- }
- else {
- if ((typeof(obj) != 'object') || (typeof(obj.length) == 'undefined')) { return [ obj ]; }
- else return obj;
- }
-};
-
-var hash_keys_to_array = exports.hashKeysToArray = function hash_keys_to_array(hash) {
- // convert hash keys to array (discard values)
- var array = [];
- for (var key in hash) array.push(key);
- return array;
-};
-
-var isa_hash = exports.isaHash = function isa_hash(arg) {
- // determine if arg is a hash
- return( !!arg && (typeof(arg) == 'object') && (typeof(arg.length) == 'undefined') );
-};
-
-var isa_array = exports.isaArray = function isa_array(arg) {
- // determine if arg is an array or is array-like
- if (typeof(arg) == 'array') return true;
- return( !!arg && (typeof(arg) == 'object') && (typeof(arg.length) != 'undefined') );
-};
-
-var first_key = exports.firstKey = function first_key(hash) {
- // return first key from hash (unordered)
- for (var key in hash) return key;
- return null; // no keys in hash
-};
-
-var num_keys = exports.numKeys = function num_keys(hash) {
- // count the number of keys in a hash
- var count = 0;
- for (var a in hash) count++;
- return count;
-};
diff --git a/node.d/sma_webbox.node.js b/node.d/sma_webbox.node.js
deleted file mode 100644
index 3d99943d4..000000000
--- a/node.d/sma_webbox.node.js
+++ /dev/null
@@ -1,237 +0,0 @@
-'use strict';
-
-// This program will connect to one or more SMA Sunny Webboxes
-// to get the Solar Power Generated (current, today, total).
-
-// example configuration in /etc/netdata/node.d/sma_webbox.conf
-/*
-{
- "enable_autodetect": false,
- "update_every": 5,
- "servers": [
- {
- "name": "plant1",
- "hostname": "10.0.1.1",
- "update_every": 10
- },
- {
- "name": "plant2",
- "hostname": "10.0.2.1",
- "update_every": 15
- }
- ]
-}
-*/
-
-var url = require('url');
-var http = require('http');
-var netdata = require('netdata');
-
-if(netdata.options.DEBUG === true) netdata.debug('loaded ' + __filename + ' plugin');
-
-var webbox = {
- name: __filename,
- enable_autodetect: true,
- update_every: 1,
- base_priority: 60000,
- charts: {},
-
- processResponse: function(service, data) {
- if(data !== null) {
- var r = JSON.parse(data);
-
- var d = {
- 'GriPwr': {
- unit: null,
- value: null
- },
- 'GriEgyTdy': {
- unit: null,
- value: null
- },
- 'GriEgyTot': {
- unit: null,
- value: null
- }
- };
-
- // parse the webbox response
- // and put it in our d object
- var found = 0;
- var len = r.result.overview.length;
- while(len--) {
- var e = r.result.overview[len];
- if(typeof(d[e.meta]) !== 'undefined') {
- found++;
- d[e.meta].value = e.value;
- d[e.meta].unit = e.unit;
- }
- }
-
- // add the service
- if(found > 0 && service.added !== true)
- service.commit();
-
- // Grid Current Power Chart
- if(d['GriPwr'].value !== null) {
- var id = 'smawebbox_' + service.name + '.current';
- var chart = webbox.charts[id];
-
- if(typeof chart === 'undefined') {
- chart = {
- id: id, // the unique id of the chart
- name: '', // the unique name of the chart
- title: service.name + ' Current Grid Power', // the title of the chart
- units: d['GriPwr'].unit, // the units of the chart dimensions
- family: 'now', // the family of the chart
- context: 'smawebbox.grid_power', // the context of the chart
- type: netdata.chartTypes.area, // the type of the chart
- priority: webbox.base_priority + 1, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: {
- 'GriPwr': {
- id: 'GriPwr', // the unique id of the dimension
- name: 'power', // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1, // the divisor
- hidden: false // is hidden (boolean)
- }
- }
- };
-
- chart = service.chart(id, chart);
- webbox.charts[id] = chart;
- }
-
- service.begin(chart);
- service.set('GriPwr', Math.round(d['GriPwr'].value));
- service.end();
- }
-
- if(d['GriEgyTdy'].value !== null) {
- var id = 'smawebbox_' + service.name + '.today';
- var chart = webbox.charts[id];
-
- if(typeof chart === 'undefined') {
- chart = {
- id: id, // the unique id of the chart
- name: '', // the unique name of the chart
- title: service.name + ' Today Grid Power', // the title of the chart
- units: d['GriEgyTdy'].unit, // the units of the chart dimensions
- family: 'today', // the family of the chart
- context: 'smawebbox.grid_power_today', // the context of the chart
- type: netdata.chartTypes.area, // the type of the chart
- priority: webbox.base_priority + 2, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: {
- 'GriEgyTdy': {
- id: 'GriEgyTdy', // the unique id of the dimension
- name: 'power', // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1000, // the divisor
- hidden: false // is hidden (boolean)
- }
- }
- };
-
- chart = service.chart(id, chart);
- webbox.charts[id] = chart;
- }
-
- service.begin(chart);
- service.set('GriEgyTdy', Math.round(d['GriEgyTdy'].value * 1000));
- service.end();
- }
-
- if(d['GriEgyTot'].value !== null) {
- var id = 'smawebbox_' + service.name + '.total';
- var chart = webbox.charts[id];
-
- if(typeof chart === 'undefined') {
- chart = {
- id: id, // the unique id of the chart
- name: '', // the unique name of the chart
- title: service.name + ' Total Grid Power', // the title of the chart
- units: d['GriEgyTot'].unit, // the units of the chart dimensions
- family: 'total', // the family of the chart
- context: 'smawebbox.grid_power_total', // the context of the chart
- type: netdata.chartTypes.area, // the type of the chart
- priority: webbox.base_priority + 3, // the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: {
- 'GriEgyTot': {
- id: 'GriEgyTot', // the unique id of the dimension
- name: 'power', // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
- multiplier: 1, // the multiplier
- divisor: 1000, // the divisor
- hidden: false // is hidden (boolean)
- }
- }
- };
-
- chart = service.chart(id, chart);
- webbox.charts[id] = chart;
- }
-
- service.begin(chart);
- service.set('GriEgyTot', Math.round(d['GriEgyTot'].value * 1000));
- service.end();
- }
- }
- },
-
- // module.serviceExecute()
- // this function is called only from this module
- // its purpose is to prepare the request and call
- // netdata.serviceExecute()
- serviceExecute: function(name, hostname, update_every) {
- if(netdata.options.DEBUG === true) netdata.debug(this.name + ': ' + name + ': hostname: ' + hostname + ', update_every: ' + update_every);
-
- var service = netdata.service({
- name: name,
- request: netdata.requestFromURL('http://' + hostname + '/rpc'),
- update_every: update_every,
- module: this
- });
- service.postData = 'RPC={"proc":"GetPlantOverview","format":"JSON","version":"1.0","id":"1"}';
- service.request.method = 'POST';
- service.request.headers['Content-Length'] = service.postData.length;
-
- service.execute(this.processResponse);
- },
-
- configure: function(config) {
- var added = 0;
-
- if(typeof(config.servers) !== 'undefined') {
- var len = config.servers.length;
- while(len--) {
- if(typeof config.servers[len].update_every === 'undefined')
- config.servers[len].update_every = this.update_every;
-
- if(config.servers[len].update_every < 5)
- config.servers[len].update_every = 5;
-
- this.serviceExecute(config.servers[len].name, config.servers[len].hostname, config.servers[len].update_every);
- added++;
- }
- }
-
- return added;
- },
-
- // module.update()
- // this is called repeatidly to collect data, by calling
- // netdata.serviceExecute()
- update: function(service, callback) {
- service.execute(function(serv, data) {
- service.module.processResponse(serv, data);
- callback();
- });
- },
-};
-
-module.exports = webbox;
diff --git a/node.d/snmp.node.js b/node.d/snmp.node.js
deleted file mode 100644
index 3e7027958..000000000
--- a/node.d/snmp.node.js
+++ /dev/null
@@ -1,513 +0,0 @@
-'use strict';
-// netdata snmp module
-// This program will connect to one or more SNMP Agents
-//
-
-// example configuration in /etc/netdata/node.d/snmp.conf
-/*
-{
- "enable_autodetect": false,
- "update_every": 5,
- "max_request_size": 50,
- "servers": [
- {
- "hostname": "10.11.12.8",
- "community": "public",
- "update_every": 10,
- "max_request_size": 50,
- "options": { "timeout": 10000 },
- "charts": {
- "snmp_switch.bandwidth_port1": {
- "title": "Switch Bandwidth for port 1",
- "units": "kilobits/s",
- "type": "area",
- "priority": 1,
- "dimensions": {
- "in": {
- "oid": ".1.3.6.1.2.1.2.2.1.10.1",
- "algorithm": "incremental",
- "multiplier": 8,
- "divisor": 1024,
- "offset": 0
- },
- "out": {
- "oid": ".1.3.6.1.2.1.2.2.1.16.1",
- "algorithm": "incremental",
- "multiplier": -8,
- "divisor": 1024,
- "offset": 0
- }
- }
- },
- "snmp_switch.bandwidth_port2": {
- "title": "Switch Bandwidth for port 2",
- "units": "kilobits/s",
- "type": "area",
- "priority": 1,
- "dimensions": {
- "in": {
- "oid": ".1.3.6.1.2.1.2.2.1.10.2",
- "algorithm": "incremental",
- "multiplier": 8,
- "divisor": 1024,
- "offset": 0
- },
- "out": {
- "oid": ".1.3.6.1.2.1.2.2.1.16.2",
- "algorithm": "incremental",
- "multiplier": -8,
- "divisor": 1024,
- "offset": 0
- }
- }
- }
- }
- }
- ]
-}
-*/
-
-// You can also give ranges of charts like the following.
-// This will append 1-24 to id, title, oid (on each dimension)
-// so that 24 charts will be created.
-/*
-{
- "enable_autodetect": false,
- "update_every": 10,
- "max_request_size": 50,
- "servers": [
- {
- "hostname": "10.11.12.8",
- "community": "public",
- "update_every": 10,
- "max_request_size": 50,
- "options": { "timeout": 20000 },
- "charts": {
- "snmp_switch.bandwidth_port": {
- "title": "Switch Bandwidth for port ",
- "units": "kilobits/s",
- "type": "area",
- "priority": 1,
- "multiply_range": [ 1, 24 ],
- "dimensions": {
- "in": {
- "oid": ".1.3.6.1.2.1.2.2.1.10.",
- "algorithm": "incremental",
- "multiplier": 8,
- "divisor": 1024,
- "offset": 0
- },
- "out": {
- "oid": ".1.3.6.1.2.1.2.2.1.16.",
- "algorithm": "incremental",
- "multiplier": -8,
- "divisor": 1024,
- "offset": 0
- }
- }
- }
- }
- }
- ]
-}
-*/
-
-var net_snmp = require('net-snmp');
-var extend = require('extend');
-var netdata = require('netdata');
-
-if(netdata.options.DEBUG === true) netdata.debug('loaded', __filename, ' plugin');
-
-netdata.processors.snmp = {
- name: 'snmp',
-
- fixoid: function(oid) {
- if(typeof oid !== 'string')
- return oid;
-
- if(oid.charAt(0) === '.')
- return oid.substring(1, oid.length);
-
- return oid;
- },
-
- prepare: function(service) {
- var __DEBUG = netdata.options.DEBUG;
-
- if(typeof service.snmp_oids === 'undefined' || service.snmp_oids === null || service.snmp_oids.length === 0) {
- // this is the first time we see this service
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': preparing ' + this.name + ' OIDs');
-
- // build an index of all OIDs
- service.snmp_oids_index = {};
- var chart_keys = Object.keys(service.request.charts);
- var chart_keys_len = chart_keys.length;
- while(chart_keys_len--) {
- var c = chart_keys[chart_keys_len];
- var chart = service.request.charts[c];
-
- // for each chart
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': indexing ' + this.name + ' chart: ' + c);
-
- if(typeof chart.titleoid !== 'undefined') {
- service.snmp_oids_index[this.fixoid(chart.titleoid)] = {
- type: 'title',
- link: chart
- };
- }
-
- var dim_keys = Object.keys(chart.dimensions);
- var dim_keys_len = dim_keys.length;
- while(dim_keys_len--) {
- var d = dim_keys[dim_keys_len];
- var dim = chart.dimensions[d];
-
- // for each dimension in the chart
-
- var oid = this.fixoid(dim.oid);
- var oidname = this.fixoid(dim.oidname);
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': indexing ' + this.name + ' chart: ' + c + ', dimension: ' + d + ', OID: ' + oid + ", OID name: " + oidname);
-
- // link it to the point we need to set the value to
- service.snmp_oids_index[oid] = {
- type: 'value',
- link: dim
- };
-
- if(typeof oidname !== 'undefined')
- service.snmp_oids_index[oidname] = {
- type: 'name',
- link: dim
- };
-
- // and set the value to null
- dim.value = null;
- }
- }
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': indexed ' + this.name + ' OIDs: ' + netdata.stringify(service.snmp_oids_index));
-
- // now create the array of OIDs needed by net-snmp
- service.snmp_oids = Object.keys(service.snmp_oids_index);
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': final list of ' + this.name + ' OIDs: ' + netdata.stringify(service.snmp_oids));
-
- service.snmp_oids_cleaned = 0;
- }
- else if(service.snmp_oids_cleaned === 0) {
- service.snmp_oids_cleaned = 1;
-
- // the second time, keep only values
-
- service.snmp_oids = new Array();
- var oid_keys = Object.keys(service.snmp_oids_index);
- var oid_keys_len = oid_keys.length;
- while(oid_keys_len--) {
- if (service.snmp_oids_index[oid_keys[oid_keys_len]].type === 'value')
- service.snmp_oids.push(oid_keys[oid_keys_len]);
- }
- }
- },
-
- getdata: function(service, index, ok, failed, callback) {
- var __DEBUG = netdata.options.DEBUG;
- var that = this;
-
- if(index >= service.snmp_oids.length) {
- callback((ok > 0)?{ ok: ok, failed: failed }:null);
- return;
- }
-
- var slice;
- if(service.snmp_oids.length <= service.request.max_request_size) {
- slice = service.snmp_oids;
- index = service.snmp_oids.length;
- }
- else if(service.snmp_oids.length - index <= service.request.max_request_size) {
- slice = service.snmp_oids.slice(index, service.snmp_oids.length);
- index = service.snmp_oids.length;
- }
- else {
- slice = service.snmp_oids.slice(index, index + service.request.max_request_size);
- index += service.request.max_request_size;
- }
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': making ' + slice.length + ' entries request, max is: ' + service.request.max_request_size);
-
- service.snmp_session.get(slice, function(error, varbinds) {
- if(error) {
- service.error('Received error = ' + netdata.stringify(error) + ' varbinds = ' + netdata.stringify(varbinds));
-
- // make all values null
- var len = slice.length;
- while(len--)
- service.snmp_oids_index[slice[len]].value = null;
- }
- else {
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': got valid ' + service.module.name + ' response: ' + netdata.stringify(varbinds));
-
- var varbinds_len = varbinds.length;
- for(var i = 0; i < varbinds_len ; i++) {
- var value = null;
-
- if(net_snmp.isVarbindError(varbinds[i])) {
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': failed ' + service.module.name + ' get for OIDs ' + varbinds[i].oid);
-
- service.error('OID ' + varbinds[i].oid + ' gave error: ' + snmp.varbindError(varbinds[i]));
- value = null;
- failed++;
- }
- else {
- // test fom Counter64
- // varbinds[i].type = net_snmp.ObjectType.Counter64;
- // varbinds[i].value = new Buffer([0x34, 0x49, 0x2e, 0xdc, 0xd1]);
-
- switch(varbinds[i].type) {
- case net_snmp.ObjectType.OctetString:
- if(service.snmp_oids_index[varbinds[i].oid].type !== 'title')
- // parse floating point values, exposed as strings
- value = parseFloat(varbinds[i].value) * 1000;
- if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + ", ObjectType " + net_snmp.ObjectType[varbinds[i].type] + " (" + netdata.stringify(varbinds[i].type) + "), typeof(" + typeof(varbinds[i].value) + "), in JSON: " + netdata.stringify(varbinds[i].value) + ", value = " + value.toString() + " (parsed as float in string)");
- else
- // just use the string
- value = varbinds[i].value;
- if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + ", ObjectType " + net_snmp.ObjectType[varbinds[i].type] + " (" + netdata.stringify(varbinds[i].type) + "), typeof(" + typeof(varbinds[i].value) + "), in JSON: " + netdata.stringify(varbinds[i].value) + ", value = " + value.toString() + " (parsed as string)");
- break;
-
- case net_snmp.ObjectType.Counter64:
- // copy the buffer
- value = '0x' + varbinds[i].value.toString('hex');
- if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + ", ObjectType " + net_snmp.ObjectType[varbinds[i].type] + " (" + netdata.stringify(varbinds[i].type) + "), typeof(" + typeof(varbinds[i].value) + "), in JSON: " + netdata.stringify(varbinds[i].value) + ", value = " + value.toString() + " (parsed as buffer)");
- break;
-
- case net_snmp.ObjectType.Integer:
- case net_snmp.ObjectType.Counter:
- case net_snmp.ObjectType.Gauge:
- default:
- value = varbinds[i].value;
- if(__DEBUG === true) netdata.debug(service.module.name + ': ' + service.name + ': found ' + service.module.name + ' value of OIDs ' + varbinds[i].oid + ", ObjectType " + net_snmp.ObjectType[varbinds[i].type] + " (" + netdata.stringify(varbinds[i].type) + "), typeof(" + typeof(varbinds[i].value) + "), in JSON: " + netdata.stringify(varbinds[i].value) + ", value = " + value.toString() + " (parsed as number)");
- break;
- }
-
- ok++;
- }
-
- if(value !== null) {
- switch(service.snmp_oids_index[varbinds[i].oid].type) {
- case 'title': service.snmp_oids_index[varbinds[i].oid].link.title += ' ' + value; break;
- case 'name' : service.snmp_oids_index[varbinds[i].oid].link.name = value; break;
- case 'value': service.snmp_oids_index[varbinds[i].oid].link.value = value; break;
- }
- }
- }
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': finished ' + service.module.name + ' with ' + ok + ' successful and ' + failed + ' failed values');
- }
- that.getdata(service, index, ok, failed, callback);
- });
- },
-
- process: function(service, callback) {
- var __DEBUG = netdata.options.DEBUG;
-
- this.prepare(service);
-
- if(service.snmp_oids.length === 0) {
- // no OIDs found for this service
-
- if(__DEBUG === true)
- service.error('no OIDs to process.');
-
- callback(null);
- return;
- }
-
- if(typeof service.snmp_session === 'undefined' || service.snmp_session === null) {
- // no SNMP session has been created for this service
- // the SNMP session is just the initialization of NET-SNMP
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': opening ' + this.name + ' session on ' + service.request.hostname + ' community ' + service.request.community + ' options ' + netdata.stringify(service.request.options));
-
- // create the SNMP session
- service.snmp_session = net_snmp.createSession (service.request.hostname, service.request.community, service.request.options);
-
- if(__DEBUG === true)
- netdata.debug(service.module.name + ': ' + service.name + ': got ' + this.name + ' session: ' + netdata.stringify(service.snmp_session));
-
- // if we later need traps, this is how to do it:
- //service.snmp_session.trap(net_snmp.TrapType.LinkDown, function(error) {
- // if(error) console.error('trap error: ' + netdata.stringify(error));
- //});
- }
-
- // do it, get the SNMP values for the sessions we need
- this.getdata(service, 0, 0, 0, callback);
- }
-};
-
-var snmp = {
- name: __filename,
- enable_autodetect: true,
- update_every: 1,
- base_priority: 50000,
-
- charts: {},
-
- processResponse: function(service, data) {
- if(data !== null) {
- if(service.added !== true)
- service.commit();
-
- var chart_keys = Object.keys(service.request.charts);
- var chart_keys_len = chart_keys.length;
- for(var i = 0; i < chart_keys_len; i++) {
- var c = chart_keys[i];
-
- var chart = snmp.charts[c];
- if(typeof chart === 'undefined') {
- chart = service.chart(c, service.request.charts[c]);
- snmp.charts[c] = chart;
- }
-
- service.begin(chart);
-
- var dimensions = service.request.charts[c].dimensions;
- var dim_keys = Object.keys(dimensions);
- var dim_keys_len = dim_keys.length;
- for(var j = 0; j < dim_keys_len ; j++) {
- var d = dim_keys[j];
-
- if (dimensions[d].value !== null) {
- if(typeof dimensions[d].offset === 'number')
- service.set(d, dimensions[d].value + dimensions[d].offset);
- else
- service.set(d, dimensions[d].value);
- }
- }
-
- service.end();
- }
- }
- },
-
- // module.serviceExecute()
- // this function is called only from this module
- // its purpose is to prepare the request and call
- // netdata.serviceExecute()
- serviceExecute: function(conf) {
- var __DEBUG = netdata.options.DEBUG;
-
- if(__DEBUG === true)
- netdata.debug(this.name + ': snmp hostname: ' + conf.hostname + ', update_every: ' + conf.update_every);
-
- var service = netdata.service({
- name: conf.hostname,
- request: conf,
- update_every: conf.update_every,
- module: this,
- processor: netdata.processors.snmp
- });
-
- // multiply the charts, if required
- var chart_keys = Object.keys(service.request.charts);
- var chart_keys_len = chart_keys.length;
- for( var i = 0; i < chart_keys_len ; i++ ) {
- var c = chart_keys[i];
- var service_request_chart = service.request.charts[c];
-
- if(__DEBUG === true)
- netdata.debug(this.name + ': snmp hostname: ' + conf.hostname + ', examining chart: ' + c);
-
- if(typeof service_request_chart.update_every === 'undefined')
- service_request_chart.update_every = service.update_every;
-
- if(typeof service_request_chart.multiply_range !== 'undefined') {
- var from = service_request_chart.multiply_range[0];
- var to = service_request_chart.multiply_range[1];
- var prio = service_request_chart.priority || 1;
-
- if(prio < snmp.base_priority) prio += snmp.base_priority;
-
- while(from <= to) {
- var id = c + from.toString();
- var chart = extend(true, {}, service_request_chart);
- chart.title += from.toString();
-
- if(typeof chart.titleoid !== 'undefined')
- chart.titleoid += from.toString();
-
- chart.priority = prio++;
-
- var dim_keys = Object.keys(chart.dimensions);
- var dim_keys_len = dim_keys.length;
- for(var j = 0; j < dim_keys_len ; j++) {
- var d = dim_keys[j];
-
- chart.dimensions[d].oid += from.toString();
-
- if(typeof chart.dimensions[d].oidname !== 'undefined')
- chart.dimensions[d].oidname += from.toString();
- }
- service.request.charts[id] = chart;
- from++;
- }
-
- delete service.request.charts[c];
- }
- else {
- if(service.request.charts[c].priority < snmp.base_priority)
- service.request.charts[c].priority += snmp.base_priority;
- }
- }
-
- service.execute(this.processResponse);
- },
-
- configure: function(config) {
- var added = 0;
-
- if(typeof config.max_request_size === 'undefined')
- config.max_request_size = 50;
-
- if(typeof(config.servers) !== 'undefined') {
- var len = config.servers.length;
- while(len--) {
- if(typeof config.servers[len].update_every === 'undefined')
- config.servers[len].update_every = this.update_every;
-
- if(typeof config.servers[len].max_request_size === 'undefined')
- config.servers[len].max_request_size = config.max_request_size;
-
- this.serviceExecute(config.servers[len]);
- added++;
- }
- }
-
- return added;
- },
-
- // module.update()
- // this is called repeatidly to collect data, by calling
- // service.execute()
- update: function(service, callback) {
- service.execute(function(serv, data) {
- service.module.processResponse(serv, data);
- callback();
- });
- }
-};
-
-module.exports = snmp;
diff --git a/node.d/stiebeleltron.node.js b/node.d/stiebeleltron.node.js
deleted file mode 100644
index 77317f2fb..000000000
--- a/node.d/stiebeleltron.node.js
+++ /dev/null
@@ -1,196 +0,0 @@
-'use strict';
-
-// This program will connect to one Stiebel Eltron ISG for heatpump heating
-// to get the heat pump metrics.
-
-// example configuration in netdata/conf.d/node.d/stiebeleltron.conf.md
-
-var url = require("url");
-var http = require("http");
-var netdata = require("netdata");
-
-netdata.debug("loaded " + __filename + " plugin");
-
-var stiebeleltron = {
- name: "Stiebel Eltron",
- enable_autodetect: false,
- update_every: 10,
- base_priority: 60000,
- charts: {},
- pages: {},
-
- createBasicDimension: function (id, name, multiplier, divisor) {
- return {
- id: id, // the unique id of the dimension
- name: name, // the name of the dimension
- algorithm: netdata.chartAlgorithms.absolute,// the id of the netdata algorithm
- multiplier: multiplier, // the multiplier
- divisor: divisor, // the divisor
- hidden: false // is hidden (boolean)
- };
- },
-
- processResponse: function (service, html) {
- if (html === null) return;
-
- // add the service
- service.commit();
-
- var page = stiebeleltron.pages[service.name];
- var categories = page.categories;
- var categoriesCount = categories.length;
- while (categoriesCount--) {
- var context = {
- html: html,
- service: service,
- category: categories[categoriesCount],
- page: page,
- chartDefinition: null,
- dimension: null
- };
- stiebeleltron.processCategory(context);
-
- }
- },
-
- processCategory: function (context) {
- var charts = context.category.charts;
- var chartCount = charts.length;
- while (chartCount--) {
- context.chartDefinition = charts[chartCount];
- stiebeleltron.processChart(context);
- }
- },
-
- processChart: function (context) {
- var dimensions = context.chartDefinition.dimensions;
- var dimensionCount = dimensions.length;
- context.service.begin(stiebeleltron.getChartFromContext(context));
-
- while (dimensionCount--) {
- context.dimension = dimensions[dimensionCount];
- stiebeleltron.processDimension(context);
- }
- context.service.end();
- },
-
- processDimension: function (context) {
- var dimension = context.dimension;
- var match = new RegExp(dimension.regex).exec(context.html);
- if (match === null) return;
- var value = match[1].replace(",", ".");
- // most values have a single digit by default, which requires the values to be multiplied. can be overridden.
- if (stiebeleltron.isDefined(dimension.digits)) {
- value *= Math.pow(10, dimension.digits);
- } else {
- value *= 10;
- }
- context.service.set(stiebeleltron.getDimensionId(context), value);
- },
-
- getChartFromContext: function (context) {
- var chartId = this.getChartId(context);
- var chart = stiebeleltron.charts[chartId];
- if (stiebeleltron.isDefined(chart)) return chart;
-
- var chartDefinition = context.chartDefinition;
- var service = context.service;
- var dimensions = {};
-
- var dimCount = chartDefinition.dimensions.length;
- while (dimCount--) {
- var dim = chartDefinition.dimensions[dimCount];
- var multiplier = 1;
- var divisor = 10;
- if (stiebeleltron.isDefined(dim.digits)) divisor = Math.pow(10, Math.max(0, dim.digits));
- if (stiebeleltron.isDefined(dim.multiplier)) multiplier = dim.multiplier;
- if (stiebeleltron.isDefined(dim.divisor)) divisor = dim.divisor;
- context.dimension = dim;
- var dimId = this.getDimensionId(context);
- dimensions[dimId] = this.createBasicDimension(dimId, dim.name, multiplier, divisor);
- }
-
- chart = {
- id: chartId,
- name: '',
- title: chartDefinition.title,
- units: chartDefinition.unit,
- family: context.category.name,
- context: 'stiebeleltron.' + context.category.id + '.' + chartDefinition.id,
- type: chartDefinition.type,
- priority: stiebeleltron.base_priority + chartDefinition.prio,// the priority relative to others in the same family
- update_every: service.update_every, // the expected update frequency of the chart
- dimensions: dimensions
- };
- chart = service.chart(chartId, chart);
- stiebeleltron.charts[chartId] = chart;
-
- return chart;
- },
-
- // module.serviceExecute()
- // this function is called only from this module
- // its purpose is to prepare the request and call
- // netdata.serviceExecute()
- serviceExecute: function (name, uri, update_every) {
- netdata.debug(this.name + ': ' + name + ': url: ' + uri + ', update_every: ' + update_every);
-
- var service = netdata.service({
- name: name,
- request: netdata.requestFromURL(uri),
- update_every: update_every,
- module: this
- });
- service.execute(this.processResponse);
- },
-
-
- configure: function (config) {
- if (stiebeleltron.isUndefined(config.pages)) return 0;
- var added = 0;
- var pageCount = config.pages.length;
- while (pageCount--) {
- var page = config.pages[pageCount];
- // some validation
- if (stiebeleltron.isUndefined(page.categories) || page.categories.length < 1) {
- netdata.error("Your Stiebel Eltron config is invalid. Disabling plugin.");
- return 0;
- }
- if (stiebeleltron.isUndefined(page.update_every)) page.update_every = this.update_every;
- this.pages[page.name] = page;
- this.serviceExecute(page.name, page.url, page.update_every);
- added++;
- }
- return added;
- },
-
- // module.update()
- // this is called repeatedly to collect data, by calling
- // netdata.serviceExecute()
- update: function (service, callback) {
- service.execute(function (serv, data) {
- service.module.processResponse(serv, data);
- callback();
- });
- },
-
- getChartId: function (context) {
- return "stiebeleltron_" + context.page.id +
- "." + context.category.id +
- "." + context.chartDefinition.id;
- },
-
- getDimensionId: function (context) {
- return context.dimension.id;
- },
-
- isUndefined: function (value) {
- return typeof value === 'undefined';
- },
-
- isDefined: function (value) {
- return typeof value !== 'undefined';
- }
-};
-
-module.exports = stiebeleltron;