├── remote ├── .gitignore ├── package.lua ├── utils.lua ├── index.lua ├── test-ping.lua └── http-auth.lua ├── cmake ├── package │ ├── debian │ │ ├── compat │ │ ├── postrm.in │ │ ├── service.upstart.in │ │ ├── prerm.in │ │ ├── postinst.in │ │ └── service.init.in │ ├── rpm │ │ ├── rackspace-monitoring-agent.cfg │ │ ├── rackspace-monitoring-agent-prelink.conf.in │ │ ├── rpm_macros_gpg │ │ ├── preun.in │ │ ├── rpm-sign.exp │ │ └── postinst.in │ ├── windows │ │ ├── testca.cer │ │ ├── testca.pvk │ │ ├── testss.cer │ │ ├── testss.pfx │ │ └── testss.pvk │ ├── logrotate │ │ └── script.in │ ├── systemd │ │ └── service.in │ ├── freebsd │ │ └── rackspace-monitoring-agent.init │ └── sysv-redhat │ │ └── script.in ├── repo │ └── reprepro.in ├── WinUpload.cmake ├── RepRepro.cmake ├── CreateRepo.cmake ├── WinSign.cmake └── Sign.cmake ├── contrib ├── docker │ ├── Makefile │ ├── README.md │ ├── build.sh │ └── Dockerfile ├── printversion │ └── main.lua ├── printbinarydir │ └── main.lua └── confd-examples │ ├── my_http.yaml │ ├── znc_process_monitoring_plugin.yaml │ └── my_fs.yaml ├── static └── tests │ ├── checks │ ├── .gitattributes │ ├── redis_valid_password.txt │ ├── redis_invalid_password.txt │ ├── redis_operation_not_permitted.txt │ ├── zookeeper_response_broken.txt │ ├── mssql_database.txt │ ├── zookeeper_response.txt │ ├── mssql_sql_statistics.txt │ ├── mssql_memory_manager.txt │ ├── mssql_buffer_manager.txt │ ├── redis_2.4_response.txt │ └── mssql_plan_cache.txt │ ├── custom_plugins │ ├── not_executable.sh │ ├── timeout.py │ ├── non_zero_with_status.sh │ ├── windows1.bat │ ├── timeout.sh │ ├── windows2.ps1 │ ├── cloudkick_agent_custom_plugin_2.sh │ ├── cloudkick_agent_custom_plugin_1.sh │ ├── lots_of_data.sh │ ├── plugin_custom_arguments.sh │ ├── repeated_status_line.sh │ ├── plugin_units.sh │ ├── plugin_dimensions.sh │ ├── plugin_1.sh │ ├── invalid_metric_lines_1.sh │ ├── invalid_metric_lines_2.sh │ ├── partial_output_with_sleep.sh │ ├── invalid_metric_lines_3.sh │ └── invalid_metric_lines_4.sh │ ├── upgrade │ ├── .gitattributes │ ├── 0001.sh │ └── test.msi │ ├── hostinfo │ ├── cve_out.txt │ ├── hostname_in.txt │ ├── wordpress_Version_out.txt │ ├── login_in.txt │ ├── login_out.txt │ ├── apache2_RamPerPreforkChild_out.txt │ ├── passwd_in.txt │ ├── php_Modules_out.txt │ ├── wordpress_Version_in.txt │ ├── cron_in.txt │ ├── hostname_out.txt │ ├── postfix_Process_in.txt │ ├── connections_arp_out.txt │ ├── autoupdates_apt_in.txt │ ├── nginx_ConfValidOrError_out.txt │ ├── cve_in.txt │ ├── fail2ban_logfilepath_out.txt │ ├── php_Modules_in.txt │ ├── fail2ban_jailslist_out.txt │ ├── wordpress_Plugins_out.txt │ ├── autoupdates_yum_out.txt │ ├── ip6tables_in.txt │ ├── deleted_libs_out.txt │ ├── lsyncd_out.txt │ ├── postfix_Process_out.txt │ ├── autoupdates_apt_out.txt │ ├── apache2_RamPerPreforkChild_in.txt │ ├── packages_linux_in.txt │ ├── fail2ban_logfilepath_in.txt │ ├── ip4routes_in.txt │ ├── ip6routes_in.txt │ ├── fstab_in.txt │ ├── nginx_ConfArgs_out.txt │ ├── cron_out.txt │ ├── deleted_libs_in.txt │ ├── nginx_ConfFile_out.txt │ ├── fail2ban_jailslist_in.txt │ ├── nginx_ConfArgs_in.txt │ ├── sysctl_in.txt │ ├── fstab_out.txt │ ├── ip6routes_out.txt │ ├── nginx_ConfFile_in.txt │ ├── nginx_Vhost_out.txt │ ├── packages_linux_out.txt │ ├── connections_arp_in.txt │ ├── passwd_out.txt │ ├── sysctl_out.txt │ ├── ip4routes_out.txt │ ├── nginx_Vhost_in.txt │ ├── apache2_VhostConfig_out.txt │ ├── ip6tables_out.txt │ ├── nginx_ConfValidOrError_in.txt │ ├── autoupdates_yum_in.txt │ ├── apache2_apacheOut_out.txt │ ├── kernel_modules_in.txt │ ├── remote_services_out.txt │ ├── php_VersionAndError_out.txt │ ├── wordpress_Plugins_in.txt │ ├── lsyncd_in.txt │ ├── nginx_VersionAndConfigureOptions_in.txt │ ├── pam_in.txt │ ├── last_logins_in.txt │ ├── nginx_VersionAndConfigureOptions_out.txt │ ├── remote_services_in.txt │ ├── kernel_modules_out.txt │ ├── connections_netstat_out.txt │ ├── fail2ban_bannedstats_out.txt │ ├── pam_out.txt │ ├── php_ApacheError_in.txt │ ├── php_VersionAndError_in.txt │ ├── connections_netstat_in.txt │ ├── magento_out.txt │ ├── php_ApacheError_out.txt │ ├── postfix_Config_in.txt │ ├── ip4routes.txt │ ├── postfix_Config_out.txt │ ├── last_logins_out.txt │ ├── fail2ban_bannedstats_in.txt │ ├── apache2_VhostOutput_out.txt │ ├── iptables_in.txt │ ├── fail2ban_activitylog_out.txt │ ├── iptables_out.txt │ ├── magento_in.txt │ ├── apache2_VhostOutput_in.txt │ ├── cve.txt │ ├── apache2_apacheOut_in.txt │ ├── apache2_VhostConfig_in.txt │ └── fail2ban_activitylog_in.txt │ ├── protocol │ ├── static_files │ │ └── upgrades │ │ │ └── bundle │ │ │ └── 1.0.2.19 │ ├── check_metrics.post.response.json │ ├── binary_upgrade.available.response.json │ ├── bundle_upgrade.available.response.json │ ├── check_schedule.changed.request.json │ ├── check_schedule.changed.response.json │ ├── binary_upgrade.available.request.json │ ├── binary_upgrade.get_version.request.json │ ├── bundle_upgrade.available.request.json │ ├── bundle_upgrade.get_version.request.json │ ├── check_schedule.get.request.json │ ├── heartbeat.post.response.json │ ├── handshake.hello.response.json │ ├── bundle_upgrade.get_version.response.json │ ├── binary_upgrade.get_version.response.json │ ├── invalid-version │ │ └── handshake.hello.response.json │ ├── heartbeat.post.request.json │ ├── rate-limiting │ │ └── rate-limit-error.json │ ├── handshake.hello.request.json │ ├── invalid-process-version │ │ └── handshake.hello.response.json │ ├── invalid-bundle-version │ │ └── handshake.hello.response.json │ └── check_schedule.get.response.json │ ├── system_info.network_interfaces.request.json │ ├── monitoring-agent-localhost.cfg │ └── data │ └── sample.state ├── tests ├── fixtures │ ├── custom_plugins │ │ ├── not_executable.sh │ │ ├── timeout.sh │ │ ├── timeout.py │ │ ├── non_zero_with_status.sh │ │ ├── cloudkick_agent_custom_plugin_2.sh │ │ ├── cloudkick_agent_custom_plugin_1.sh │ │ ├── plugin_custom_arguments.sh │ │ ├── repeated_status_line.sh │ │ ├── plugin_units.sh │ │ ├── plugin_dimensions.sh │ │ ├── plugin_1.sh │ │ ├── invalid_metric_lines_1.sh │ │ ├── invalid_metric_lines_2.sh │ │ ├── partial_output_with_sleep.sh │ │ ├── invalid_metric_lines_3.sh │ │ └── invalid_metric_lines_4.sh │ ├── checks │ │ ├── .gitattributes │ │ ├── redis_valid_password.txt │ │ ├── redis_invalid_password.txt │ │ ├── redis_operation_not_permitted.txt │ │ ├── zookeeper_response_broken.txt │ │ ├── zookeeper_response.txt │ │ └── redis_2.4_response.txt │ ├── protocol │ │ ├── static_files │ │ │ └── upgrades │ │ │ │ └── bundle │ │ │ │ ├── 1.0.2.19 │ │ │ │ └── 1.0.2.19.sig │ │ ├── check_metrics.post.response.json │ │ ├── binary_upgrade.available.response.json │ │ ├── bundle_upgrade.available.response.json │ │ ├── check_schedule.changed.request.json │ │ ├── check_schedule.changed.response.json │ │ ├── binary_upgrade.available.request.json │ │ ├── bundle_upgrade.available.request.json │ │ ├── binary_upgrade.get_version.request.json │ │ ├── bundle_upgrade.get_version.request.json │ │ ├── check_schedule.get.request.json │ │ ├── handshake.hello.response.json │ │ ├── heartbeat.post.response.json │ │ ├── bundle_upgrade.get_version.response.json │ │ ├── binary_upgrade.get_version.response.json │ │ ├── invalid-version │ │ │ └── handshake.hello.response.json │ │ ├── heartbeat.post.request.json │ │ ├── rate-limiting │ │ │ └── rate-limit-error.json │ │ ├── invalid-process-version │ │ │ └── handshake.hello.response.json │ │ ├── handshake.hello.request.json │ │ ├── invalid-bundle-version │ │ │ └── handshake.hello.response.json │ │ ├── check_schedule.get.response.json │ │ └── init.lua │ ├── monitoring-agent-localhost.cfg │ ├── hostinfo │ │ ├── autoupdates_yum_enabled.txt │ │ ├── ip4routes.txt │ │ ├── cron.txt │ │ ├── cve.txt │ │ └── deleted_libs.txt │ ├── procmounts.txt │ └── init.lua ├── test-hostname.lua ├── test-check-load-average.lua ├── test-protocol.lua ├── run.lua ├── code_cert.test.lua └── setup.tcl ├── agent.ico ├── docker-compose.yml ├── hostinfo ├── debug │ ├── NIL.json │ ├── WHO.json │ ├── HOSTNAME.json │ ├── AUTOUPDATES.json │ ├── CRON.json │ ├── LSYNCD.json │ ├── FSTAB.json │ ├── DATE.json │ ├── MAGENTO.json │ ├── CONNECTIONS.json │ ├── SYSTEM.json │ ├── FILESYSTEM_STATE.json │ ├── DISK.json │ ├── IP6TABLES.json │ ├── MEMORY.json │ ├── CPU.json │ ├── WORDPRESS.json │ ├── PHP.json │ ├── POSTFIX.json │ ├── LOGIN.json │ ├── IP4ROUTES.json │ ├── DELETED_LIBS.json │ ├── NGINX_CONFIG.json │ ├── APACHE2.json │ ├── REMOTE_SERVICES.json │ ├── IPTABLES.json │ └── NETWORK.json ├── nil.lua ├── date.lua ├── who.lua ├── system.lua ├── filesystem_state.lua ├── disk.lua ├── memory.lua ├── cpu.lua ├── all.lua ├── hostname.lua ├── network.lua ├── sshd.lua ├── filesystem.lua ├── sysctl.lua ├── lshw.lua ├── login.lua ├── services.lua ├── ip6routes.lua ├── fstab.lua ├── ip4routes.lua └── procs.lua ├── .gitignore ├── .luacheckrc ├── appveyor.yml ├── Dockerfile ├── .travis.yml ├── package.lua ├── schedule └── init.lua ├── staging.lua ├── check ├── null.lua ├── windows │ ├── init.lua │ ├── entry_handlers.lua │ └── os.lua ├── load_average.lua ├── memory.lua └── filesystem_state.lua ├── hostname.lua ├── Makefile ├── endpoint.lua ├── client ├── virgo_client.lua └── virgo_connection_stream.lua ├── features.lua └── ro.lua /remote/.gitignore: -------------------------------------------------------------------------------- 1 | deps 2 | -------------------------------------------------------------------------------- /cmake/package/debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /cmake/package/rpm/rackspace-monitoring-agent.cfg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /contrib/docker/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | ./build.sh 3 | -------------------------------------------------------------------------------- /static/tests/checks/.gitattributes: -------------------------------------------------------------------------------- 1 | * -text 2 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/not_executable.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/tests/upgrade/.gitattributes: -------------------------------------------------------------------------------- 1 | * -text 2 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/not_executable.sh: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /static/tests/checks/redis_valid_password.txt: -------------------------------------------------------------------------------- 1 | +OK 2 | -------------------------------------------------------------------------------- /tests/fixtures/checks/.gitattributes: -------------------------------------------------------------------------------- 1 | * -text 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/cve_out.txt: -------------------------------------------------------------------------------- 1 | ["CVE-2010-0405"] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/hostname_in.txt: -------------------------------------------------------------------------------- 1 | generic-hostname 2 | -------------------------------------------------------------------------------- /tests/fixtures/checks/redis_valid_password.txt: -------------------------------------------------------------------------------- 1 | +OK 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/wordpress_Version_out.txt: -------------------------------------------------------------------------------- 1 | ["4.3"] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/login_in.txt: -------------------------------------------------------------------------------- 1 | SYSLOG_SU_ENAB yes 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/login_out.txt: -------------------------------------------------------------------------------- 1 | [{"SYSLOG_SU_ENAB":"yes"}] 2 | -------------------------------------------------------------------------------- /contrib/printversion/main.lua: -------------------------------------------------------------------------------- 1 | print(require('../../package').version) 2 | -------------------------------------------------------------------------------- /static/tests/checks/redis_invalid_password.txt: -------------------------------------------------------------------------------- 1 | -ERR invalid password 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/apache2_RamPerPreforkChild_out.txt: -------------------------------------------------------------------------------- 1 | [2.17578125] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/passwd_in.txt: -------------------------------------------------------------------------------- 1 | root P 07/27/2015 0 99999 7 -1 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/php_Modules_out.txt: -------------------------------------------------------------------------------- 1 | ["zlib","Zend OPcache"] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/wordpress_Version_in.txt: -------------------------------------------------------------------------------- 1 | $wp_version = '4.3'; 2 | -------------------------------------------------------------------------------- /static/tests/protocol/static_files/upgrades/bundle/1.0.2.19: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /static/tests/upgrade/0001.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo '0.2.0-24' 4 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/static_files/upgrades/bundle/1.0.2.19: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/cron_in.txt: -------------------------------------------------------------------------------- 1 | * * * * * /usr/bin/znc >/dev/null 2>&1 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/hostname_out.txt: -------------------------------------------------------------------------------- 1 | [{"hostname": "generic-hostname"}] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/postfix_Process_in.txt: -------------------------------------------------------------------------------- 1 | 3593 /usr/lib/postfix/master 2 | -------------------------------------------------------------------------------- /tests/fixtures/checks/redis_invalid_password.txt: -------------------------------------------------------------------------------- 1 | -ERR invalid password 2 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/timeout.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sleep 500 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/connections_arp_out.txt: -------------------------------------------------------------------------------- 1 | ["162.209.76.3","162.209.76.2"] 2 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/static_files/upgrades/bundle/1.0.2.19.sig: -------------------------------------------------------------------------------- 1 | I'm a sig 2 | -------------------------------------------------------------------------------- /cmake/package/debian/postrm.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | update-rc.d -f @APP_NAME@ remove 4 | -------------------------------------------------------------------------------- /cmake/package/rpm/rackspace-monitoring-agent-prelink.conf.in: -------------------------------------------------------------------------------- 1 | -b /usr/bin/@APP_NAME@ 2 | -------------------------------------------------------------------------------- /static/tests/checks/redis_operation_not_permitted.txt: -------------------------------------------------------------------------------- 1 | -ERR operation not permitted 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/autoupdates_apt_in.txt: -------------------------------------------------------------------------------- 1 | APT::Periodic::Unattended-Upgrade "1"; 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_ConfValidOrError_out.txt: -------------------------------------------------------------------------------- 1 | [{"status":0},{"status":0}] 2 | -------------------------------------------------------------------------------- /tests/fixtures/checks/redis_operation_not_permitted.txt: -------------------------------------------------------------------------------- 1 | -ERR operation not permitted 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/cve_in.txt: -------------------------------------------------------------------------------- 1 | prefixed random data CVE-2010-0405 suffixed random data 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/fail2ban_logfilepath_out.txt: -------------------------------------------------------------------------------- 1 | ["/var/log/fail2ban.log","SYSLOG"] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/php_Modules_in.txt: -------------------------------------------------------------------------------- 1 | zlib 2 | 3 | [Zend Modules] 4 | Zend OPcache 5 | -------------------------------------------------------------------------------- /static/tests/hostinfo/fail2ban_jailslist_out.txt: -------------------------------------------------------------------------------- 1 | [["sshd"],["sshd","foo","bar","baz","derp"]] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/wordpress_Plugins_out.txt: -------------------------------------------------------------------------------- 1 | [{"name":"Akismet"},{"version":"3.1.3"}] 2 | -------------------------------------------------------------------------------- /agent.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/virgo-agent-toolkit/rackspace-monitoring-agent/HEAD/agent.ico -------------------------------------------------------------------------------- /contrib/docker/README.md: -------------------------------------------------------------------------------- 1 | This directory creates a system tarball for use in systemd-nspawn systems. 2 | -------------------------------------------------------------------------------- /contrib/printbinarydir/main.lua: -------------------------------------------------------------------------------- 1 | local jit = require('jit') 2 | print(jit.os .. '-' .. jit.arch) 3 | -------------------------------------------------------------------------------- /static/tests/hostinfo/autoupdates_yum_out.txt: -------------------------------------------------------------------------------- 1 | [{"status":"enabled","update_method":"yum_cron"}] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/ip6tables_in.txt: -------------------------------------------------------------------------------- 1 | -P INPUT ACCEPT 2 | -P FORWARD ACCEPT 3 | -P OUTPUT ACCEPT 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/deleted_libs_out.txt: -------------------------------------------------------------------------------- 1 | [{"deleted_lib_name":"/dev/zero","used_by_process":"sshd"}] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/lsyncd_out.txt: -------------------------------------------------------------------------------- 1 | ["/etc/lsyncd/lsyncd.conf.lua","/etc/lsyncd/lsyncd.conf.lua"] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/postfix_Process_out.txt: -------------------------------------------------------------------------------- 1 | [{"process":"/usr/lib/postfix/master","PID":"3593"}] 2 | -------------------------------------------------------------------------------- /cmake/package/rpm/rpm_macros_gpg: -------------------------------------------------------------------------------- 1 | %_signature gpg 2 | %_gpg_name Rackspace Cloud Monitoring Agent Package Repo 3 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/timeout.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import time 4 | 5 | time.sleep(500) 6 | -------------------------------------------------------------------------------- /static/tests/hostinfo/autoupdates_apt_out.txt: -------------------------------------------------------------------------------- 1 | [{"status":"enabled","update_method":"unattended_upgrades"}] 2 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/timeout.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import time 4 | 5 | time.sleep(500) 6 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | build: 2 | build: . 3 | environment: 4 | TRAVIS: "true" 5 | volumes: 6 | - .:/src 7 | -------------------------------------------------------------------------------- /static/tests/hostinfo/apache2_RamPerPreforkChild_in.txt: -------------------------------------------------------------------------------- 1 | mapped: 121504K writeable/private: 2228K shared: 4K 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/packages_linux_in.txt: -------------------------------------------------------------------------------- 1 | apt-transport-https 1.0.9.7ubuntu4 2 | systemd-libs 208-20.el7_1.5 3 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/non_zero_with_status.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status ponies > unicorns" 4 | exit 100 5 | -------------------------------------------------------------------------------- /static/tests/hostinfo/fail2ban_logfilepath_in.txt: -------------------------------------------------------------------------------- 1 | Current logging target is: 2 | `- /var/log/fail2ban.log 3 | `- SYSLOG 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/ip4routes_in.txt: -------------------------------------------------------------------------------- 1 | 0.0.0.0 162.209.76.1 0.0.0.0 UG 0 0 0 eth0 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/ip6routes_in.txt: -------------------------------------------------------------------------------- 1 | 2001:4800:7812:514::/64 :: U 256 0 0 eth0 2 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/non_zero_with_status.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status ponies > unicorns" 4 | exit 100 5 | -------------------------------------------------------------------------------- /static/tests/hostinfo/fstab_in.txt: -------------------------------------------------------------------------------- 1 | /dev/xvda1 / ext4 errors=remount-ro,noatime,barrier=0 0 1 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_ConfArgs_out.txt: -------------------------------------------------------------------------------- 1 | [{"prefix":"/usr/share/nginx"}, 2 | {"conf_path":"/etc/nginx/nginx.conf"}] 3 | -------------------------------------------------------------------------------- /static/tests/hostinfo/cron_out.txt: -------------------------------------------------------------------------------- 1 | [{"dom":"*","m":"*","command":"/usr/bin/znc >/dev/null 2>&1","h":"*","dow":"*","mon":"*"}] 2 | -------------------------------------------------------------------------------- /hostinfo/debug/NIL.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"NIL", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[], 5 | "timestamp":1441066692000 6 | } -------------------------------------------------------------------------------- /hostinfo/debug/WHO.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"WHO", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[], 5 | "timestamp":1441066692000 6 | } -------------------------------------------------------------------------------- /static/tests/upgrade/test.msi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/virgo-agent-toolkit/rackspace-monitoring-agent/HEAD/static/tests/upgrade/test.msi -------------------------------------------------------------------------------- /cmake/package/windows/testca.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/virgo-agent-toolkit/rackspace-monitoring-agent/HEAD/cmake/package/windows/testca.cer -------------------------------------------------------------------------------- /cmake/package/windows/testca.pvk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/virgo-agent-toolkit/rackspace-monitoring-agent/HEAD/cmake/package/windows/testca.pvk -------------------------------------------------------------------------------- /cmake/package/windows/testss.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/virgo-agent-toolkit/rackspace-monitoring-agent/HEAD/cmake/package/windows/testss.cer -------------------------------------------------------------------------------- /cmake/package/windows/testss.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/virgo-agent-toolkit/rackspace-monitoring-agent/HEAD/cmake/package/windows/testss.pfx -------------------------------------------------------------------------------- /cmake/package/windows/testss.pvk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/virgo-agent-toolkit/rackspace-monitoring-agent/HEAD/cmake/package/windows/testss.pvk -------------------------------------------------------------------------------- /static/tests/hostinfo/deleted_libs_in.txt: -------------------------------------------------------------------------------- 1 | sshd 14810 sshd DEL REG 0,5 5541790 /dev/zero 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_ConfFile_out.txt: -------------------------------------------------------------------------------- 1 | ["/etc/nginx/mime.types", 2 | "/etc/nginx/conf.d/*.conf", 3 | "/etc/nginx/sites-enabled/*"] 4 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/windows1.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo status ok Test plugin is OK 3 | echo metric metric1 int 1 4 | echo metric metric2 int 100 5 | -------------------------------------------------------------------------------- /static/tests/hostinfo/fail2ban_jailslist_in.txt: -------------------------------------------------------------------------------- 1 | Status 2 | |- Number of jail: 1 3 | `- Jail list: sshd 4 | `- Jail list: sshd foo, bar, baz, derp 5 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/timeout.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sleep 5 4 | #reducing the timeout since it stalls the progress of other tests for 500 seconds 5 | -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_ConfArgs_in.txt: -------------------------------------------------------------------------------- 1 | --prefix=/usr/share/nginx 2 | --conf-path=/etc/nginx/nginx.conf 3 | --http-log-path=/var/log/nginx/access.log 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/sysctl_in.txt: -------------------------------------------------------------------------------- 1 | vm.dirty_writeback_centisecs = 500 2 | vm.lowmem_reserve_ratio = 256 256 32 3 | vm.lowmem_reserve_ratio = 256 256 32 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/fstab_out.txt: -------------------------------------------------------------------------------- 1 | [{"mount_point":"/","options":"errors=remount-ro,noatime,barrier=0","file_system":"/dev/xvda1","pass":"0","type":"ext4"}] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/ip6routes_out.txt: -------------------------------------------------------------------------------- 1 | [{"use":"0","iface":"eth0","flag":"U","destination":"2001:4800:7812:514::/64","next_hop":"::","ref":"0","met":"256"}] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_ConfFile_in.txt: -------------------------------------------------------------------------------- 1 | include /etc/nginx/mime.types; 2 | include /etc/nginx/conf.d/*.conf; 3 | include /etc/nginx/sites-enabled/*; 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_Vhost_out.txt: -------------------------------------------------------------------------------- 1 | [{"listen":"80"}, 2 | {"listen":"[::]:80"}, 3 | {"domain":"example.com"}, 4 | {"docroot":"/var/www/example.com"}] 5 | -------------------------------------------------------------------------------- /static/tests/hostinfo/packages_linux_out.txt: -------------------------------------------------------------------------------- 1 | [{"name":"apt-transport-https","version":"1.0.9.7ubuntu4"},{"name":"systemd-libs","version":"208-20.el7_1.5"}] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/connections_arp_in.txt: -------------------------------------------------------------------------------- 1 | ? (162.209.76.3) at 70:ca:9b:8d:8a:bf [ether] on eth0 2 | ? (162.209.76.2) at 70:ca:9b:8d:dd:bf [ether] on eth0 3 | -------------------------------------------------------------------------------- /static/tests/hostinfo/passwd_out.txt: -------------------------------------------------------------------------------- 1 | [{"warning_period":"99999","last_changed":"07/27/2015","status":"P","inactivity_period":"7","name":"root","minimum_age":"0"}] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/sysctl_out.txt: -------------------------------------------------------------------------------- 1 | [{"vm.dirty_writeback_centisecs":"500"},{"vm.lowmem_reserve_ratio":"256\t256\t32"},{"vm.lowmem_reserve_ratio":"256 256 32"}] 2 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/windows2.ps1: -------------------------------------------------------------------------------- 1 | Write-Output "status ok Test plugin is OK" 2 | Write-Output "metric metric1 int 1" 3 | Write-Output "metric metric2 int 100" 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/ip4routes_out.txt: -------------------------------------------------------------------------------- 1 | [{"mss":"0","genmask":"0.0.0.0","irtt":"0","flags":"UG","destination":"0.0.0.0","gateway":"162.209.76.1","iface":"eth0","window":"0"}] -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_Vhost_in.txt: -------------------------------------------------------------------------------- 1 | listen 80; 2 | listen [::]:80; 3 | 4 | server_name example.com; 5 | 6 | root /var/www/example.com; 7 | index index.html; 8 | -------------------------------------------------------------------------------- /static/tests/system_info.network_interfaces.request.json: -------------------------------------------------------------------------------- 1 | { "v": "1", "id": 0, "target": "endpoint", "source": "X", "method": "system_info.network_interfaces", "params": {}} 2 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/cloudkick_agent_custom_plugin_2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status warn" 4 | echo "metric logged_users int 7" 5 | echo "metric active_processes int 200" 6 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/cloudkick_agent_custom_plugin_2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status warn" 4 | echo "metric logged_users int 7" 5 | echo "metric active_processes int 200" 6 | -------------------------------------------------------------------------------- /hostinfo/debug/HOSTNAME.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"HOSTNAME", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "hostname": "generic-hostname" 6 | }, 7 | "timestamp":1452033979000 8 | } -------------------------------------------------------------------------------- /static/tests/hostinfo/apache2_VhostConfig_out.txt: -------------------------------------------------------------------------------- 1 | [{"docroot":"/var/www/html"}, 2 | {"error_log":"${APACHE_LOG_DIR}/error.log"}, 3 | {"access_log":"${APACHE_LOG_DIR}/access.log"}] 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/ip6tables_out.txt: -------------------------------------------------------------------------------- 1 | [{"type":"-P","chain":"INPUT","policy":"ACCEPT"},{"type":"-P","chain":"FORWARD","policy":"ACCEPT"},{"type":"-P","chain":"OUTPUT","policy":"ACCEPT"}] 2 | -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_ConfValidOrError_in.txt: -------------------------------------------------------------------------------- 1 | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 2 | nginx: configuration file /etc/nginx/nginx.conf test is successful 3 | -------------------------------------------------------------------------------- /static/tests/protocol/check_metrics.post.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 4, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": 0, 7 | "error": null, 8 | } 9 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/check_metrics.post.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 4, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": 0, 7 | "error": null, 8 | } 9 | -------------------------------------------------------------------------------- /static/tests/hostinfo/autoupdates_yum_in.txt: -------------------------------------------------------------------------------- 1 | Loaded: loaded (/usr/lib/systemd/system/yum-cron.service; enabled) 2 | Active: active (exited) since Thu 2015-08-13 03:06:32 UTC; 1 weeks 0 days ago 3 | -------------------------------------------------------------------------------- /static/tests/protocol/binary_upgrade.available.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 5, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "result": 0, 7 | "error": null 8 | } 9 | -------------------------------------------------------------------------------- /static/tests/protocol/bundle_upgrade.available.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 8, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "result": 0, 7 | "error": null 8 | } 9 | -------------------------------------------------------------------------------- /static/tests/protocol/check_schedule.changed.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 3, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "method": "check_schedule.changed" 7 | } 8 | -------------------------------------------------------------------------------- /static/tests/protocol/check_schedule.changed.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 3, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "result": 0, 7 | "error": null 8 | } 9 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/binary_upgrade.available.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 5, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "result": 0, 7 | "error": null 8 | } 9 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/bundle_upgrade.available.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 8, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "result": 0, 7 | "error": null 8 | } 9 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/check_schedule.changed.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 3, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "method": "check_schedule.changed" 7 | } 8 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/check_schedule.changed.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 3, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "result": 0, 7 | "error": null 8 | } 9 | -------------------------------------------------------------------------------- /static/tests/protocol/binary_upgrade.available.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 5, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "binary_upgrade.available" 7 | } 8 | -------------------------------------------------------------------------------- /static/tests/protocol/binary_upgrade.get_version.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 7, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "binary_upgrade.get_version" 7 | } 8 | -------------------------------------------------------------------------------- /static/tests/protocol/bundle_upgrade.available.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 8, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "bundle_upgrade.available" 7 | } 8 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/binary_upgrade.available.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 5, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "binary_upgrade.available" 7 | } 8 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/bundle_upgrade.available.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 8, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "bundle_upgrade.available" 7 | } 8 | -------------------------------------------------------------------------------- /cmake/repo/reprepro.in: -------------------------------------------------------------------------------- 1 | Codename: cloudmonitoring 2 | Components: main 3 | Architectures: i386 amd64 source 4 | Origin: Rackspace 5 | Description: Rackspace Cloud Monitoring Agent 6 | SignWith: D05AB914 7 | -------------------------------------------------------------------------------- /static/tests/protocol/bundle_upgrade.get_version.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 9, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "bundle_upgrade.get_version" 7 | } 8 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/binary_upgrade.get_version.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 7, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "binary_upgrade.get_version" 7 | } 8 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/bundle_upgrade.get_version.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 9, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "bundle_upgrade.get_version" 7 | } 8 | -------------------------------------------------------------------------------- /cmake/package/rpm/preun.in: -------------------------------------------------------------------------------- 1 | # Uninstall the service links on uninstall 2 | if [ "$1" = "0" ] ; then 3 | /sbin/service @APP_NAME@ stop >/dev/null 2>&1 || : 4 | /sbin/chkconfig --del @APP_NAME@ 5 | fi 6 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/cloudkick_agent_custom_plugin_1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status err Service is not responding" 4 | echo "metric logged_users int 7" 5 | echo "metric active_processes int 200" 6 | -------------------------------------------------------------------------------- /static/tests/protocol/check_schedule.get.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 2, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "check_schedule.get", 7 | "params": null 8 | } 9 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/cloudkick_agent_custom_plugin_1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status err Service is not responding" 4 | echo "metric logged_users int 7" 5 | echo "metric active_processes int 200" 6 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/check_schedule.get.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 2, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "check_schedule.get", 7 | "params": null 8 | } 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | lit 3 | lit.exe 4 | luvi 5 | luvi.exe 6 | luvit 7 | luvi-sigar 8 | luvi-sigar.exe 9 | rackspace-monitoring-agent 10 | tests/tmpdir 11 | deps 12 | GPATH 13 | GRTAGS 14 | GTAGS 15 | /.idea -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | std = "luajit" 2 | globals = { 3 | "p", "exports", "process", "args", "_ENV", 4 | "virgo", 5 | "virgo_paths", 'TEST_DIR' 6 | } 7 | unused_args = false 8 | ignore = { "122", "4.2", "431", "631" } 9 | -------------------------------------------------------------------------------- /static/tests/hostinfo/apache2_apacheOut_out.txt: -------------------------------------------------------------------------------- 1 | [{"version":"Apache/2.4.10 (Ubuntu)"}, 2 | {"mpm":"event"}, 3 | {"config_path":"/etc/apache2"}, 4 | {"config_file":"apache2.conf"}, 5 | {"syntax_ok":true}] 6 | -------------------------------------------------------------------------------- /static/tests/protocol/heartbeat.post.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 1, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": { 7 | "timestamp": 1325645515246 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/lots_of_data.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "status Everything is OK" 4 | for i in `seq 1 10000`; do 5 | echo "metric logged_users_${i} int 7" 6 | done 7 | echo "metric logged_users_aaa int 7" 8 | -------------------------------------------------------------------------------- /static/tests/hostinfo/kernel_modules_in.txt: -------------------------------------------------------------------------------- 1 | nf_conntrack_ipv4 16384 4 - Live 0xffffffffc02d9000 2 | x_tables 36864 6 xt_conntrack,xt_tcpudp,iptable_filter,ip_tables,ip6table_filter,ip6_tables, Live 0xffffffffc028b000 3 | -------------------------------------------------------------------------------- /static/tests/hostinfo/remote_services_out.txt: -------------------------------------------------------------------------------- 1 | [{"inode":"3422453","recvq":"0","user":"0","protocol":"tcp","foreign_addr":"0.0.0.0:*","pid":"13523","state":"LISTEN","sendq":"0","proccess":"tty.js","local_addr":"0.0.0.0:80"}] -------------------------------------------------------------------------------- /static/tests/protocol/handshake.hello.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 0, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": { 7 | "heartbeat_interval": 1000 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/handshake.hello.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 0, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": { 7 | "heartbeat_interval": 1000 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/heartbeat.post.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 1, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": { 7 | "timestamp": 1325645515246 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/plugin_custom_arguments.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status arguments test" 4 | i=0 5 | 6 | for var in "$@" 7 | do 8 | echo "metric $var string $i" 9 | i=$((i+1)) 10 | done 11 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/repeated_status_line.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status First status line" 4 | echo "status Second status line" 5 | echo "metric logged_users int 7" 6 | echo "metric active_processes int 200" 7 | -------------------------------------------------------------------------------- /static/tests/hostinfo/php_VersionAndError_out.txt: -------------------------------------------------------------------------------- 1 | [{ 2 | "version":{ 3 | "type":"PHP", 4 | "version":"5.6.4-4ubuntu6.2" 5 | }},{ 6 | "version":{ 7 | "type":"HipHop", 8 | "version":"3.9.1" 9 | }}] 10 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/plugin_custom_arguments.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status arguments test" 4 | i=0 5 | 6 | for var in "$@" 7 | do 8 | echo "metric $var string $i" 9 | i=$((i+1)) 10 | done 11 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/repeated_status_line.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status First status line" 4 | echo "status Second status line" 5 | echo "metric logged_users int 7" 6 | echo "metric active_processes int 200" 7 | -------------------------------------------------------------------------------- /static/tests/hostinfo/wordpress_Plugins_in.txt: -------------------------------------------------------------------------------- 1 | Plugin Name: Akismet 2 | Plugin URI: http://akismet.com/ 3 | Description: Used by millions, Akismet is quite possibly the best way in the world to prot$ 4 | Version: 3.1.3 5 | -------------------------------------------------------------------------------- /static/tests/monitoring-agent-localhost.cfg: -------------------------------------------------------------------------------- 1 | monitoring_id agentA 2 | monitoring_token 0000000000000000000000000000000000000000000000000000000000000000.7777 3 | monitoring_endpoints 127.0.0.1:50041,127.0.0.1:50051,127.0.0.1:50061 4 | -------------------------------------------------------------------------------- /tests/fixtures/monitoring-agent-localhost.cfg: -------------------------------------------------------------------------------- 1 | monitoring_id agentA 2 | monitoring_token 0000000000000000000000000000000000000000000000000000000000000000.7777 3 | monitoring_endpoints 127.0.0.1:50041,127.0.0.1:50051,127.0.0.1:50061 4 | -------------------------------------------------------------------------------- /tests/test-hostname.lua: -------------------------------------------------------------------------------- 1 | require('tap')(function(test) 2 | test('test hostname', function() 3 | local hostname = require('../hostname') 4 | local name = hostname() 5 | p(name) 6 | assert(#name > 0) 7 | end) 8 | end) 9 | -------------------------------------------------------------------------------- /hostinfo/debug/AUTOUPDATES.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"AUTOUPDATES", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "status":"disabled", 6 | "update_method":"unattended_upgrades" 7 | }], 8 | "timestamp":1441066692000 9 | } -------------------------------------------------------------------------------- /static/tests/custom_plugins/plugin_units.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Total logged users: 66" 4 | echo "metric host1.logged_users int 66 users" 5 | echo "metric host1.data_out int 1024 bytes" 6 | echo "metric host1.no_units int 1" 7 | -------------------------------------------------------------------------------- /static/tests/protocol/bundle_upgrade.get_version.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 9, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "error": null, 7 | "result": { 8 | "version": "1.0.2.19" 9 | } 10 | } -------------------------------------------------------------------------------- /tests/fixtures/protocol/bundle_upgrade.get_version.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 9, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "error": null, 7 | "result": { 8 | "version": "1.0.2.19" 9 | } 10 | } -------------------------------------------------------------------------------- /static/tests/protocol/binary_upgrade.get_version.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 7, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "error": null, 7 | "result": { 8 | "version": "5.0.0.1" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /static/tests/protocol/invalid-version/handshake.hello.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "2147483647", 3 | "id": 0, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": { 7 | "heartbeat_interval": 1000 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/plugin_units.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Total logged users: 66" 4 | echo "metric host1.logged_users int 66 users" 5 | echo "metric host1.data_out int 1024 bytes" 6 | echo "metric host1.no_units int 1" 7 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/binary_upgrade.get_version.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 7, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "error": null, 7 | "result": { 8 | "version": "5.0.0.1" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/invalid-version/handshake.hello.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "2147483647", 3 | "id": 0, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": { 7 | "heartbeat_interval": 1000 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | configuration: Release 2 | 3 | matrix: 4 | fast_finish: true 5 | 6 | build_script: 7 | - Make.bat 8 | 9 | test_script: 10 | - Make.bat test 11 | 12 | notifications: 13 | 14 | services: 15 | - mssql2012sp1 16 | -------------------------------------------------------------------------------- /static/tests/checks/zookeeper_response_broken.txt: -------------------------------------------------------------------------------- 1 | zk_version 3.4.4--1, built on 09/24/2012 22:48 GMT 2 | zk_avg_latenc bar 3 | zk_max_late 4 | zk_packets_receiv342 5 | zk_packets_sen50 6 | zk_num_alive_connections 4 44zk_num_alive_conntections 4 7 | -------------------------------------------------------------------------------- /static/tests/protocol/heartbeat.post.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 1, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "heartbeat.post", 7 | "params": { 8 | "timestamp": 1325645515246 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/fixtures/checks/zookeeper_response_broken.txt: -------------------------------------------------------------------------------- 1 | zk_version 3.4.4--1, built on 09/24/2012 22:48 GMT 2 | zk_avg_latenc bar 3 | zk_max_late 4 | zk_packets_receiv342 5 | zk_packets_sen50 6 | zk_num_alive_connections 4 44zk_num_alive_conntections 4 7 | -------------------------------------------------------------------------------- /cmake/package/debian/service.upstart.in: -------------------------------------------------------------------------------- 1 | # @APP_NAME@ 2 | 3 | start on stopped rc RUNLEVEL=[2345] 4 | stop on runlevel [!2345] 5 | env TMPDIR=/var/lib 6 | 7 | respawn 8 | exec @APP_NAME@ --exit-on-upgrade --production -l /var/log/@APP_NAME@.log 2>&1 9 | -------------------------------------------------------------------------------- /static/tests/data/sample.state: -------------------------------------------------------------------------------- 1 | {"version":1,"checks":[{"state":"OK","nextrun":1337269654,"period":150,"id":"chH7UgrXOH"},{"state":"OK","nextrun":1337269504,"period":30,"id":"chYTLSQ2yh"},{"state":"OK","nextrun":1337269504,"period":30,"id":"chYTLSQ2yf"}]} 2 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/heartbeat.post.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 1, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "heartbeat.post", 7 | "params": { 8 | "timestamp": 1325645515246 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /remote/package.lua: -------------------------------------------------------------------------------- 1 | return { 2 | name = "virgo-proto/checks", 3 | version = "0.0.0", 4 | private = true, 5 | dependencies = { 6 | "creationix/coro-net@1.1.1", 7 | "creationix/coro-http@1.2.1", 8 | "luvit/tap@0.1.1", 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/plugin_dimensions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Total logged users: 66" 4 | echo "metric host1.logged_users int 10" 5 | echo "metric host2.logged_users int 17" 6 | echo "metric host3.logged_users int 10" 7 | echo "metric host4.logged_users int 22" 8 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/plugin_dimensions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Total logged users: 66" 4 | echo "metric host1.logged_users int 10" 5 | echo "metric host2.logged_users int 17" 6 | echo "metric host3.logged_users int 10" 7 | echo "metric host4.logged_users int 22" 8 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | from debian:8 2 | maintainer Ryan Phillips 3 | 4 | RUN apt-get update && \ 5 | apt-get -y upgrade && \ 6 | apt-get install -y git build-essential cmake curl 7 | 8 | RUN mkdir -p /src 9 | WORKDIR /src 10 | 11 | CMD /bin/bash 12 | -------------------------------------------------------------------------------- /cmake/package/rpm/rpm-sign.exp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/expect -f 2 | 3 | ### rpm-sign.exp -- Sign RPMs by sending the passphrase. 4 | 5 | eval spawn rpm --addsign $argv 6 | expect -exact "Enter pass phrase: " 7 | send -- "Secret passphrase\r" 8 | expect eof 9 | 10 | ## end of rpm-sign.exp 11 | -------------------------------------------------------------------------------- /static/tests/hostinfo/lsyncd_in.txt: -------------------------------------------------------------------------------- 1 | root root root root 1 lsyncd /etc/lsyncd/lsyncd.conf.lua 2 | root root root root 1 lsyncd /etc/lsyncd/lsyncd.conf.lua 3 | root root root root 0 rackspace-monitoring-agent -e hostinfo_runner -x lsyncd 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_VersionAndConfigureOptions_in.txt: -------------------------------------------------------------------------------- 1 | nginx version: nginx/1.6.2 (Ubuntu) 2 | configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --prefix=/usr/share/nginx --with-http_image_filter_module 3 | -------------------------------------------------------------------------------- /static/tests/hostinfo/pam_in.txt: -------------------------------------------------------------------------------- 1 | account [success=1 new_authtok_reqd=done default=ignore] pam_unix.so 2 | account required pam_permit.so 3 | session required pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0 4 | @include common-session-noninteractive 5 | -------------------------------------------------------------------------------- /cmake/package/logrotate/script.in: -------------------------------------------------------------------------------- 1 | /var/log/@APP_NAME@.log { 2 | missingok 3 | rotate 12 4 | size 10M 5 | compress 6 | delaycompress 7 | notifempty 8 | create 640 root adm 9 | postrotate 10 | kill -HUP `cat /var/run/@APP_NAME@.pid` 11 | endscript 12 | } 13 | -------------------------------------------------------------------------------- /cmake/package/systemd/service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | After=network.target 3 | Wants=network-online.target 4 | 5 | [Service] 6 | ExecStart=/usr/bin/@APP_NAME@ -l /var/log/@APP_NAME@.log --production --exit-on-upgrade 7 | Restart=always 8 | RestartSec=5 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /hostinfo/debug/CRON.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"CRON", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "dom":"*", 6 | "m":"*", 7 | "command":"/usr/bin/znc >/dev/null 2>&1", 8 | "h":"*", 9 | "dow":"*", 10 | "mon":"*" 11 | }], 12 | "timestamp":1441066692000 13 | } -------------------------------------------------------------------------------- /hostinfo/debug/LSYNCD.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"LSYNCD", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "config_file":"/etc/lsyncd/lsyncd2.conf.lua", 6 | "bin":"/usr/local/bin/lsyncd", 7 | "isInstalled": "true", 8 | "status":"true" 9 | }, 10 | "timestamp":1441054458000 11 | } 12 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/plugin_1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Everything is OK" 4 | echo "metric logged_users int 7" 5 | echo "metric active_processes int 200" 6 | echo "metric avg_wait_time float 100.7" 7 | echo "metric something string foo bar foo" 8 | echo "metric packet_count gauge 150000" 9 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/plugin_1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Everything is OK" 4 | echo "metric logged_users int 7" 5 | echo "metric active_processes int 200" 6 | echo "metric avg_wait_time float 100.7" 7 | echo "metric something string foo bar foo" 8 | echo "metric packet_count gauge 150000" 9 | -------------------------------------------------------------------------------- /static/tests/hostinfo/last_logins_in.txt: -------------------------------------------------------------------------------- 1 | root pts/0 secure-bastion.d Mon Aug 24 22:07 still logged in 2 | root pts/0 secure-bastion.d Mon Aug 24 19:47 - 20:23 (00:36) 3 | reboot system boot 3.19.0-23-generi Thu Aug 13 02:58 - 22:25 (11+19:26) 4 | wtmp begins Thu Aug 13 02:58:41 2015 5 | -------------------------------------------------------------------------------- /hostinfo/debug/FSTAB.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"FSTAB", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "mount_point":"/", 6 | "options":"errors=remount-ro,noatime,barrier=0", 7 | "file_system":"/dev/xvda1", 8 | "pass":"0", 9 | "type":"ext4" 10 | }, 11 | "timestamp":1441066693000 12 | } -------------------------------------------------------------------------------- /hostinfo/debug/DATE.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"DATE", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "date":{ 6 | "day":"01", 7 | "year":"2015", 8 | "month":"09" 9 | }, 10 | "time":"00:18:12", 11 | "timezone":"UTC" 12 | }], 13 | "timestamp":1441066692000 14 | } -------------------------------------------------------------------------------- /static/tests/hostinfo/nginx_VersionAndConfigureOptions_out.txt: -------------------------------------------------------------------------------- 1 | [{"version":"1.6.2"}, 2 | {"configure_arguments": 3 | ["--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2'", 4 | "--prefix=/usr/share/nginx", 5 | "--with-http_image_filter_module"] 6 | }] 7 | -------------------------------------------------------------------------------- /hostinfo/debug/MAGENTO.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"MAGENTO", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "2001:4800:7817:101:be76:4eff:fe05:2e7":{ 6 | "path":"/var/www/html/app/Mage.php", 7 | "version":"1.9.0.1", 8 | "edition":"Community" 9 | } 10 | }, 11 | "timestamp":1442017465000 12 | } 13 | -------------------------------------------------------------------------------- /static/tests/hostinfo/remote_services_in.txt: -------------------------------------------------------------------------------- 1 | Active Internet connections (only servers) 2 | Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name 3 | tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 3422453 13523/tty.js 4 | -------------------------------------------------------------------------------- /static/tests/protocol/rate-limiting/rate-limit-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 4, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "error": { 7 | "type": "rateLimitReached", 8 | "code": 400, 9 | "message": "Rate limit has been reached (%s requests in 24 hours), please try again later." 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /hostinfo/debug/CONNECTIONS.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"CONNECTIONS", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "address":"162.209.76.3" 6 | },{ 7 | "address":"162.209.76.1" 8 | },{ 9 | "address":"162.209.76.2" 10 | },{ 11 | "address":"10.182.0.1" 12 | }], 13 | "timestamp":1441066692000 14 | } -------------------------------------------------------------------------------- /tests/fixtures/protocol/rate-limiting/rate-limit-error.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 4, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "error": { 7 | "type": "rateLimitReached", 8 | "code": 400, 9 | "message": "Rate limit has been reached (%s requests in 24 hours), please try again later." 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /hostinfo/debug/SYSTEM.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"SYSTEM", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "arch":"x86_64", 6 | "version":"3.19.0-23-generic", 7 | "vendor_name":"Linux", 8 | "vendor":"Ubuntu", 9 | "name":"Linux", 10 | "vendor_version":"15.04" 11 | }], 12 | "timestamp":1441066692000 13 | } -------------------------------------------------------------------------------- /cmake/package/debian/prerm.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | case "$1" in 3 | remove) 4 | # Stop the agent if we are removing 5 | service @APP_NAME@ stop || : 6 | ;; 7 | upgrade) 8 | : 9 | ;; 10 | purge) 11 | : 12 | ;; 13 | *) 14 | echo "Unrecognized prerm argument '$1'" 15 | ;; 16 | esac 17 | -------------------------------------------------------------------------------- /hostinfo/debug/FILESYSTEM_STATE.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"FILESYSTEM_STATE", "OS":"linux"}} 2 | 3 | { 4 | "timestamp": 1466474297000, 5 | "error": null, 6 | "info": [ 7 | { 8 | "devices_ro": "", 9 | "devices_rw": "/dev/xvda1", 10 | "total_ro": 0, 11 | "total_rw": 1 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /static/tests/checks/mssql_database.txt: -------------------------------------------------------------------------------- 1 | #TYPE System.Data.DataRow 2 | "Name","Value","Type" 3 | "state_desc","ONLINE","string" 4 | "recovery_model_desc","SIMPLE","string" 5 | "page_verify_option_desc","CHECKSUM","string" 6 | "state","0","int" 7 | "recovery_model","3","int" 8 | "page_verify_option","2","int" 9 | "size","512","int" 10 | "growth","10","int" 11 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/invalid_metric_lines_1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Invalid metric lines" 4 | echo "metric metric1 intfoo 10" 5 | echo "metric metric2 double 10" 6 | echo "metric metric3 sometype 10" 7 | echo "metric foo bar foo" 8 | echo "metric foo int" 9 | echo "metric foo" 10 | echo "metric metric7 string test bar" 11 | echo "metric metric8 int 100 200" 12 | -------------------------------------------------------------------------------- /cmake/package/freebsd/rackspace-monitoring-agent.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . /etc/rc.subr 4 | 5 | name=rackspace-monitoring-agent 6 | rcvar=rackspace_monitoring_agent_enable 7 | logfile="/var/log/${name}.log" 8 | pidfile="/var/run/${name}.pid" 9 | start_cmd="/usr/sbin/daemon -p ${pidfile} /usr/bin/${name} --logfile ${logfile}" 10 | 11 | load_rc_config $name 12 | run_rc_command "$1" 13 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/invalid_metric_lines_2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Invalid metric lines 2" 4 | echo "metric foo int" 5 | echo "metric metric1 intfoo 10" 6 | echo "metric metric2 double 10" 7 | echo "metric metric3 sometype 10" 8 | echo "metric foo bar foo" 9 | echo "metric foo" 10 | echo "metric metric7 string test bar" 11 | echo "metric metric8 int 100 200" 12 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/partial_output_with_sleep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Everything is OK" 4 | echo "metric logged_users int 7" 5 | sleep 0.2 6 | echo -n "metric active_processes " 7 | sleep 0.5 8 | echo "int 200" 9 | echo "metric avg_wait_time float 100.7" 10 | echo "metric something string foo bar foo" 11 | sleep 1 12 | echo "metric packet_count gauge 150000" 13 | -------------------------------------------------------------------------------- /static/tests/hostinfo/kernel_modules_out.txt: -------------------------------------------------------------------------------- 1 | [{"mem_size":"16384","memOffset":"0xffffffffc02d9000","instanceCount":"4","state":"Live","name":"nf_conntrack_ipv4","dependencies":["-"]},{"mem_size":"36864","memOffset":"0xffffffffc028b000","instanceCount":"6","state":"Live","name":"x_tables","dependencies":["xt_conntrack","xt_tcpudp","iptable_filter","ip_tables","ip6table_filter","ip6_tables"]}] 2 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/invalid_metric_lines_1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Invalid metric lines" 4 | echo "metric metric1 intfoo 10" 5 | echo "metric metric2 double 10" 6 | echo "metric metric3 sometype 10" 7 | echo "metric foo bar foo" 8 | echo "metric foo int" 9 | echo "metric foo" 10 | echo "metric metric7 string test bar" 11 | echo "metric metric8 int 100 200" 12 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/invalid_metric_lines_2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Invalid metric lines 2" 4 | echo "metric foo int" 5 | echo "metric metric1 intfoo 10" 6 | echo "metric metric2 double 10" 7 | echo "metric metric3 sometype 10" 8 | echo "metric foo bar foo" 9 | echo "metric foo" 10 | echo "metric metric7 string test bar" 11 | echo "metric metric8 int 100 200" 12 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/partial_output_with_sleep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Everything is OK" 4 | echo "metric logged_users int 7" 5 | sleep 0.2 6 | echo -n "metric active_processes " 7 | sleep 0.5 8 | echo "int 200" 9 | echo "metric avg_wait_time float 100.7" 10 | echo "metric something string foo bar foo" 11 | sleep 1 12 | echo "metric packet_count gauge 150000" 13 | -------------------------------------------------------------------------------- /hostinfo/debug/DISK.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"DISK", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "name":"/dev/xvda1", 6 | "wtime":14780952, 7 | "rtime":6938324, 8 | "read_bytes":25219298304, 9 | "write_bytes":23091617792, 10 | "time":2257456, 11 | "writes":1714790, 12 | "reads":846247 13 | }], 14 | "timestamp":1441066692000 15 | } -------------------------------------------------------------------------------- /static/tests/custom_plugins/invalid_metric_lines_3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Invalid metric lines 3" 4 | echo "metric metric8 int 100 200 bytes" 5 | echo "metric foo int" 6 | echo "metric metric1 intfoo 10" 7 | echo "metric metric2 double 10" 8 | echo "metric metric3 sometype 10" 9 | echo "metric foo bar foo" 10 | echo "metric foo" 11 | echo "metric metric7 string test bar" 12 | -------------------------------------------------------------------------------- /static/tests/protocol/handshake.hello.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 0, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "handshake.hello", 7 | "params": { 8 | "token": "MYTOKEN", 9 | "agent_id": "MYUID", 10 | "agent_name": "Rackspace Monitoring Agent", 11 | "process_version": "1.0.0", 12 | "bundle_version": "1.0.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /static/tests/protocol/invalid-process-version/handshake.hello.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 0, 4 | "target": "agentA", 5 | "source": "endpoint", 6 | "error": { 7 | "code": 400, 8 | "message": "Agent version 9.0.1 is too old, please upgrade to 10.0.0. http://docs.rackspace.com/cm/api/v1.0/cm-agent/content/Upgrading.html" 9 | }, 10 | "result": null 11 | } 12 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/invalid_metric_lines_3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Invalid metric lines 3" 4 | echo "metric metric8 int 100 200 bytes" 5 | echo "metric foo int" 6 | echo "metric metric1 intfoo 10" 7 | echo "metric metric2 double 10" 8 | echo "metric metric3 sometype 10" 9 | echo "metric foo bar foo" 10 | echo "metric foo" 11 | echo "metric metric7 string test bar" 12 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/invalid-process-version/handshake.hello.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 0, 4 | "target": "agentA", 5 | "source": "endpoint", 6 | "error": { 7 | "code": 400, 8 | "message": "Agent version 9.0.1 is too old, please upgrade to 10.0.0. http://docs.rackspace.com/cm/api/v1.0/cm-agent/content/Upgrading.html" 9 | }, 10 | "result": null 11 | } 12 | -------------------------------------------------------------------------------- /static/tests/hostinfo/connections_netstat_out.txt: -------------------------------------------------------------------------------- 1 | [{"local_port":"80","state":"LISTEN","foreign_address":"0.0.0.0","foreign_port":"*","local_address":"0.0.0.0"}, 2 | {"local_port":"22","state":"ESTABLISHED","foreign_address":"43.229.53.20","foreign_port":"47836","local_address":"162.209.76.174"}, 3 | {"local_port":"22","state":"LISTEN","foreign_address":"::","foreign_port":"*","local_address":"::"}] 4 | -------------------------------------------------------------------------------- /static/tests/hostinfo/fail2ban_bannedstats_out.txt: -------------------------------------------------------------------------------- 1 | [{"status":"Unban","ip":"43.229.53.20","jail":"sshd"}, 2 | {"status":"Ban","ip":"43.229.53.20","jail":"sshd"}, 3 | {"status":"Unban","ip":"43.229.53.20","jail":"sshd"}, 4 | {"status":"Ban","ip":"43.229.53.20","jail":"sshd"}, 5 | {"status":"Ban","ip":"43.229.53.20","jail":"sshd"}, 6 | {"status":"Unban","ip":"43.229.53.20","jail":"sshd"}] 7 | -------------------------------------------------------------------------------- /static/tests/protocol/invalid-bundle-version/handshake.hello.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 0, 4 | "target": "agentA", 5 | "source": "endpoint", 6 | "error": { 7 | "code": 400, 8 | "message": "Agent bundle version 9.0.2 is too old, please upgrade to 10.0.0. http://docs.rackspace.com/cm/api/v1.0/cm-agent/content/Upgrading.html" 9 | }, 10 | "result": null 11 | } 12 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/handshake.hello.request.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 0, 4 | "source": "agentA", 5 | "target": "endpoint", 6 | "method": "handshake.hello", 7 | "params": { 8 | "token": "MYTOKEN", 9 | "agent_id": "MYUID", 10 | "agent_name": "Rackspace Monitoring Agent", 11 | "process_version": "1.0.0", 12 | "bundle_version": "1.0.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/invalid-bundle-version/handshake.hello.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 0, 4 | "target": "agentA", 5 | "source": "endpoint", 6 | "error": { 7 | "code": 400, 8 | "message": "Agent bundle version 9.0.2 is too old, please upgrade to 10.0.0. http://docs.rackspace.com/cm/api/v1.0/cm-agent/content/Upgrading.html" 9 | }, 10 | "result": null 11 | } 12 | -------------------------------------------------------------------------------- /static/tests/protocol/check_schedule.get.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 2, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": { 7 | "checks": { 8 | "id": "ch1234", 9 | "type": "agent.cpu", 10 | "details": { "foo": "foo" }, 11 | "period": 30, 12 | "timeout": 30, 13 | "disabled": false 14 | } 15 | }, 16 | "error": null 17 | } 18 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/check_schedule.get.response.json: -------------------------------------------------------------------------------- 1 | { 2 | "v": "1", 3 | "id": 2, 4 | "source": "endpoint", 5 | "target": "agentA", 6 | "result": { 7 | "checks": { 8 | "id": "ch1234", 9 | "type": "agent.cpu", 10 | "details": { "foo": "foo" }, 11 | "period": 30, 12 | "timeout": 30, 13 | "disabled": false 14 | } 15 | }, 16 | "error": null 17 | } 18 | -------------------------------------------------------------------------------- /static/tests/custom_plugins/invalid_metric_lines_4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Invalid metric lines 4" 4 | echo "some unknown line" 5 | echo "metric metric8 int 100 200" 6 | echo "metric foo int" 7 | echo "metric metric1 intfoo 10" 8 | echo "metric metric2 double 10" 9 | echo "metric metric3 sometype 10" 10 | echo "metric foo bar foo" 11 | echo "metric foo" 12 | echo "metric metric7 string test bar" 13 | -------------------------------------------------------------------------------- /tests/fixtures/custom_plugins/invalid_metric_lines_4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "status Invalid metric lines 4" 4 | echo "some unknown line" 5 | echo "metric metric8 int 100 200" 6 | echo "metric foo int" 7 | echo "metric metric1 intfoo 10" 8 | echo "metric metric2 double 10" 9 | echo "metric metric3 sometype 10" 10 | echo "metric foo bar foo" 11 | echo "metric foo" 12 | echo "metric metric7 string test bar" 13 | -------------------------------------------------------------------------------- /tests/fixtures/hostinfo/autoupdates_yum_enabled.txt: -------------------------------------------------------------------------------- 1 | Redirecting to /bin/systemctl status yum-cron.service 2 | yum-cron.service - Run automatic yum updates as a cron job 3 | Loaded: loaded (/usr/lib/systemd/system/yum-cron.service; enabled) 4 | Active: active (exited) since Thu 2015-08-13 03:06:32 UTC; 1 weeks 0 days ago 5 | Main PID: 12055 (code=exited, status=0/SUCCESS) 6 | CGroup: /system.slice/yum-cron.service 7 | -------------------------------------------------------------------------------- /hostinfo/debug/IP6TABLES.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"IP6TABLES", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "type":"-P", 6 | "chain":"INPUT", 7 | "policy":"ACCEPT" 8 | },{ 9 | "type":"-P", 10 | "chain":"FORWARD", 11 | "policy":"ACCEPT" 12 | },{ 13 | "type":"-P", 14 | "chain":"OUTPUT", 15 | "policy":"ACCEPT" 16 | }], 17 | "timestamp":1441066692000 18 | } -------------------------------------------------------------------------------- /contrib/docker/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -t agent . 4 | 5 | OUTPUT_FILE=rackspace-monitoring-agent-root.tar.gz 6 | # Create a UUID to identify the build 7 | CONTAINER_UUID=`uuidgen` 8 | 9 | docker run agent echo $CONTAINER_UUID 10 | CONTAINER=`docker ps -a --no-trunc |grep $CONTAINER_UUID|awk '{print $1}'|head -n1` 11 | echo $CONTAINER 12 | docker export $CONTAINER | gzip > ${OUTPUT_FILE} 13 | docker rm $CONTAINER 14 | -------------------------------------------------------------------------------- /static/tests/hostinfo/pam_out.txt: -------------------------------------------------------------------------------- 1 | [{"module_name":"pam_unix.so","module_interface":"account","control_flags":"success=1 new_authtok_reqd=done default=ignore","module_arguments":""},{"module_name":"pam_permit.so","module_interface":"account","control_flags":"required","module_arguments":""},{"module_name":"pam_env.so","module_interface":"session","control_flags":"required","module_arguments":"readenv=1 envfile=/etc/default/locale user_readenv=0"}] -------------------------------------------------------------------------------- /static/tests/hostinfo/php_ApacheError_in.txt: -------------------------------------------------------------------------------- 1 | [Mon Sep 14 06:42:33.410121 2015] [mpm_prefork:notice] [pid 7681] AH00163: Apache/2.4.10 (Ubuntu) $ 2 | [Mon Sep 14 06:42:33.410150 2015] [core:notice] [pid 7681] AH00094: Command line: '/usr/sbin/apach$ 3 | [Mon Sep 14 08:40:48.077779 2015] [:error] [pid 12621] [client 185.49.14.190:43000] script '/var/w$ 4 | [Mon Sep 14 11:26:16.753165 2015] [mpm_prefork:notice] [pid 7681] AH00169: caught SIGTERM, shuttin$ 5 | -------------------------------------------------------------------------------- /static/tests/hostinfo/php_VersionAndError_in.txt: -------------------------------------------------------------------------------- 1 | PHP 5.6.4-4ubuntu6.2 (cli) (built: Jul 2 2015 15:29:28) 2 | Copyright (c) 1997-2014 The PHP Group 3 | Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies 4 | with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies 5 | HipHop VM 3.9.1 (rel) 6 | Compiler: tags/HHVM-3.9.1-0-g0f72cfc2f0a01fdfeb72fbcfeb247b72998a66db 7 | Repo schema: 6416960c150a4a4726fda74b659105ded8819d9c 8 | -------------------------------------------------------------------------------- /contrib/confd-examples/my_http.yaml: -------------------------------------------------------------------------------- 1 | type : remote.http 2 | label : Website check 1 3 | timeout : 30 4 | period : 90 5 | target_alias : default 6 | details : 7 | url : http://www.foo.com 8 | method : GET 9 | monitoring_zones_poll: 10 | - mzord 11 | alarms : 12 | alarm1 : 13 | label : http connect alarm 14 | notification_plan_id : npTechnicalContactsEmail 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | addons: 4 | apt: 5 | sources: 6 | - kalakris-cmake 7 | packages: 8 | - cmake 9 | - gdb 10 | - luarocks 11 | 12 | sudo: false 13 | 14 | before_script: 15 | - luarocks install --local luacheck 16 | - export PATH=~/.luarocks/bin:$PATH 17 | 18 | script: 19 | - make lint 20 | - make 21 | - make test 22 | 23 | notifications: 24 | email: 25 | - ryan.phillips@rackspace.com 26 | irc: 27 | - chat.freenode.net#virgo-dev 28 | -------------------------------------------------------------------------------- /static/tests/hostinfo/connections_netstat_in.txt: -------------------------------------------------------------------------------- 1 | Active Internet connections (servers and established) 2 | Proto Recv-Q Send-Q Local Address Foreign Address State User Inode 3 | tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 3422453 4 | tcp 0 0 162.209.76.174:22 43.229.53.20:47836 ESTABLISHED 0 6187287 5 | tcp6 0 0 :::22 :::* LISTEN 0 15123 6 | -------------------------------------------------------------------------------- /static/tests/hostinfo/magento_out.txt: -------------------------------------------------------------------------------- 1 | [{"version":{"name":"major","version":"1"}}, 2 | {"version":{"name":"minor","version":"9"}}, 3 | {"version":{"name":"revision","version":"0"}}, 4 | {"version":{"name":"patch","version":"1"}}, 5 | {"editionList":{"EDITION_COMMUNITY":"Community"}}, 6 | {"editionList":{"EDITION_ENTERPRISE":"Enterprise"}}, 7 | {"editionList":{"EDITION_PROFESSIONAL":"Professional"}}, 8 | {"editionList":{"EDITION_GO":"Go"}}, 9 | {"editionAssign":"EDITION_COMMUNITY"}] 10 | -------------------------------------------------------------------------------- /hostinfo/debug/MEMORY.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"MEMORY", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "used_percent":58.364510524827, 6 | "swap_free":0, 7 | "free":22614016, 8 | "swap_page_out":0, 9 | "swap_used":0, 10 | "swap_total":0, 11 | "actual_used":295849984, 12 | "swap_page_in":0, 13 | "total":506900480, 14 | "free_percent":41.635489475173, 15 | "ram":488, 16 | "actual_free":211050496, 17 | "used":484286464 18 | }, 19 | "timestamp":1441066692000 20 | } -------------------------------------------------------------------------------- /remote/utils.lua: -------------------------------------------------------------------------------- 1 | local uv = require('uv') 2 | function exports.getaddrinfo(host, port, family) 3 | local thread = coroutine.running() 4 | uv.getaddrinfo(host, port, { 5 | socktype = "stream", 6 | family = family, 7 | }, function (err, results) 8 | if err then 9 | return assert(coroutine.resume(thread, nil, err .. ": while looking up '" .. host .. "'")) 10 | end 11 | return assert(coroutine.resume(thread, results[1].addr, results[1].port)) 12 | end) 13 | return coroutine.yield() 14 | end 15 | -------------------------------------------------------------------------------- /static/tests/hostinfo/php_ApacheError_out.txt: -------------------------------------------------------------------------------- 1 | [{"error_lines":"[Mon Sep 14 06:42:33.410121 2015] [mpm_prefork:notice] [pid 7681] AH00163: Apache/2.4.10 (Ubuntu) $"}, 2 | {"error_lines":"[Mon Sep 14 06:42:33.410150 2015] [core:notice] [pid 7681] AH00094: Command line: '/usr/sbin/apach$"}, 3 | {"error_lines":"[Mon Sep 14 08:40:48.077779 2015] [:error] [pid 12621] [client 185.49.14.190:43000] script '/var/w$"}, 4 | {"error_lines":"[Mon Sep 14 11:26:16.753165 2015] [mpm_prefork:notice] [pid 7681] AH00169: caught SIGTERM, shuttin$"}] -------------------------------------------------------------------------------- /static/tests/hostinfo/postfix_Config_in.txt: -------------------------------------------------------------------------------- 1 | inet_interfaces = all 2 | inet_protocols = all 3 | mydestination = kostco-rmapg-ubuntu-2, localhost.localdomain, , localhost 4 | mydomain = localdomain 5 | myhostname = kostco-rmapg-ubuntu-2 6 | mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 7 | mynetworks_style = subnet 8 | myorigin = $myhostname 9 | alias_database = hash:/etc/aliases 10 | alias_maps = hash:/etc/aliases 11 | config_directory = /etc/postfix 12 | queue_directory = /var/spool/postfix 13 | mail_version = 2.11.3 14 | -------------------------------------------------------------------------------- /static/tests/hostinfo/ip4routes.txt: -------------------------------------------------------------------------------- 1 | Kernel IP routing table 2 | Destination Gateway Genmask Flags MSS Window irtt Iface 3 | 0.0.0.0 162.209.76.1 0.0.0.0 UG 0 0 0 eth0 4 | 10.176.0.0 10.182.0.1 255.240.0.0 UG 0 0 0 eth1 5 | 10.182.0.0 0.0.0.0 255.255.128.0 U 0 0 0 eth1 6 | 10.208.0.0 10.182.0.1 255.240.0.0 UG 0 0 0 eth1 7 | 162.209.76.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 8 | -------------------------------------------------------------------------------- /tests/fixtures/hostinfo/ip4routes.txt: -------------------------------------------------------------------------------- 1 | Kernel IP routing table 2 | Destination Gateway Genmask Flags MSS Window irtt Iface 3 | 0.0.0.0 162.209.76.1 0.0.0.0 UG 0 0 0 eth0 4 | 10.176.0.0 10.182.0.1 255.240.0.0 UG 0 0 0 eth1 5 | 10.182.0.0 0.0.0.0 255.255.128.0 U 0 0 0 eth1 6 | 10.208.0.0 10.182.0.1 255.240.0.0 UG 0 0 0 eth1 7 | 162.209.76.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 8 | -------------------------------------------------------------------------------- /hostinfo/debug/CPU.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"CPU", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "soft_irq":37990, 6 | "name":"cpu.0", 7 | "vendor":"AMD", 8 | "user":7423040, 9 | "model":"Opteron", 10 | "total_sockets":1, 11 | "total_cores":1, 12 | "nice":0, 13 | "wait":1652660, 14 | "idle":1616783100, 15 | "total":1629332070, 16 | "stolen":1318580, 17 | "irq":4400, 18 | "sys":2112300, 19 | "mhz":2100 20 | }], 21 | "timestamp":1441066692000 22 | } -------------------------------------------------------------------------------- /static/tests/hostinfo/postfix_Config_out.txt: -------------------------------------------------------------------------------- 1 | [{"inet_interfaces":"all"}, 2 | {"inet_protocols":"all"}, 3 | {"mydestination":"kostco-rmapg-ubuntu-2, localhost.localdomain, , localhost"}, 4 | {"mydomain":"localdomain"}, 5 | {"myhostname":"kostco-rmapg-ubuntu-2"}, 6 | {"mynetworks":"127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128"}, 7 | {"myorigin":"$myhostname"}, 8 | {"alias_database":"hash:/etc/aliases"}, 9 | {"config_directory":"/etc/postfix"}, 10 | {"queue_directory":"/var/spool/postfix"}, 11 | {"mail_version":"2.11.3"}] 12 | -------------------------------------------------------------------------------- /static/tests/checks/zookeeper_response.txt: -------------------------------------------------------------------------------- 1 | zk_version 3.4.4--1, built on 09/24/2012 22:48 GMT 2 | zk_avg_latency 0 3 | zk_max_latency 38 4 | zk_min_latency 0 5 | zk_packets_received 182451 6 | zk_packets_sent 182450 7 | zk_num_alive_connections 4 8 | zk_outstanding_requests 0 9 | zk_server_state leader 10 | zk_znode_count 78 11 | zk_watch_count 0 12 | zk_ephemerals_count 0 13 | zk_approximate_data_size 3091 14 | zk_open_file_descriptor_count 33 15 | zk_max_file_descriptor_count 4096 16 | zk_followers 2 17 | zk_synced_followers 2 18 | zk_pending_syncs 0 19 | -------------------------------------------------------------------------------- /tests/fixtures/checks/zookeeper_response.txt: -------------------------------------------------------------------------------- 1 | zk_version 3.4.4--1, built on 09/24/2012 22:48 GMT 2 | zk_avg_latency 0 3 | zk_max_latency 38 4 | zk_min_latency 0 5 | zk_packets_received 182451 6 | zk_packets_sent 182450 7 | zk_num_alive_connections 4 8 | zk_outstanding_requests 0 9 | zk_server_state leader 10 | zk_znode_count 78 11 | zk_watch_count 0 12 | zk_ephemerals_count 0 13 | zk_approximate_data_size 3091 14 | zk_open_file_descriptor_count 33 15 | zk_max_file_descriptor_count 4096 16 | zk_followers 2 17 | zk_synced_followers 2 18 | zk_pending_syncs 0 19 | -------------------------------------------------------------------------------- /static/tests/hostinfo/last_logins_out.txt: -------------------------------------------------------------------------------- 1 | [{ 2 | "logged_in":{ 3 | "user":"root", 4 | "login_time":"Mon Aug 24 22:07", 5 | "host":"secure-bastion.d" 6 | } 7 | },{ 8 | "previous_logins": { 9 | "host":"secure-bastion.d", 10 | "login_time":"Mon Aug 24 19:47", 11 | "duration":"00:36", 12 | "user":"root", 13 | "logout_time":"20:23" 14 | } 15 | },{ 16 | "bootups":{ 17 | "type":"reboot", 18 | "kernel":"3.19.0-23-generi" 19 | } 20 | },{ 21 | "data_collection_start":"Thu Aug 13 02:58:41 2015" 22 | }] 23 | -------------------------------------------------------------------------------- /package.lua: -------------------------------------------------------------------------------- 1 | return { 2 | name = "rackspace-monitoring-agent", 3 | version = "2.6.23", 4 | luvi = { 5 | version = "2.7.6-2-sigar", 6 | flavor = "sigar", 7 | url = "https://github.com/virgo-agent-toolkit/luvi/releases/download/v%s-sigar/luvi-%s-%s" 8 | }, 9 | dependencies = { 10 | "rphillips/options@0.0.5", 11 | "virgo-agent-toolkit/rackspace-monitoring-client@0.3", 12 | "virgo-agent-toolkit/virgo@2.1.10", 13 | "kaustavha/luvit-walk@1", 14 | }, 15 | files = { 16 | "**.lua", 17 | "!tests", 18 | "!contrib", 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /static/tests/hostinfo/fail2ban_bannedstats_in.txt: -------------------------------------------------------------------------------- 1 | 2015-08-27 18:49:05,849 fail2ban.actions [12228]: NOTICE [sshd] Unban 43.229.53.20 2 | 2015-08-27 19:24:15,683 fail2ban.actions [12228]: NOTICE [sshd] Ban 43.229.53.20 3 | 2015-08-27 19:34:16,643 fail2ban.actions [12228]: NOTICE [sshd] Unban 43.229.53.20 4 | 2015-08-27 20:14:40,828 fail2ban.actions [12228]: NOTICE [sshd] Ban 43.229.53.20 5 | 2015-08-27 20:55:13,275 fail2ban.actions [12228]: NOTICE [sshd] Ban 43.229.53.20 6 | 2015-08-27 21:05:14,238 fail2ban.actions [12228]: NOTICE [sshd] Unban 43.229.53.20 7 | -------------------------------------------------------------------------------- /static/tests/hostinfo/apache2_VhostOutput_out.txt: -------------------------------------------------------------------------------- 1 | [{"current_vhost":"*:80"}, 2 | {"conf":"/etc/apache2/sites-enabled/000-default.conf:1", 3 | "vhost":"2001:4800:7812:514:be76:4eff:fe05:678d"}, 4 | {"vhost":"2001:4800:7812:514:be76:4eff:fe05:678d", 5 | "conf":"/etc/apache2/sites-enabled/000-default.conf:1", 6 | "port":"80"}, 7 | {"vhost":"example.com", 8 | "conf":"/etc/apache2/sites-enabled/example.com.conf:1", 9 | "port":"80"}, 10 | {"vhost":"test.com", 11 | "conf":"/etc/apache2/sites-enabled/test.com.conf:1", 12 | "port":"80"}, 13 | {"user":"www-data"}] 14 | -------------------------------------------------------------------------------- /contrib/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM stackbrew/ubuntu:14.04 2 | 3 | RUN apt-get update && \ 4 | apt-get install -y wget && \ 5 | wget -O meta.deb http://meta.packages.cloudmonitoring.rackspace.com/ubuntu-14.04-x86_64/rackspace-cloud-monitoring-meta-stable_1.0_all.deb && \ 6 | dpkg -i meta.deb && \ 7 | apt-get update && \ 8 | apt-get -y install rackspace-monitoring-agent && \ 9 | apt-get -y autoremove && \ 10 | apt-get clean 11 | 12 | RUN rm -rf /var/lib/apt/lists/* 13 | 14 | RUN apt-get -y autoremove && \ 15 | apt-get clean 16 | 17 | CMD ['/usr/bin/rackspace-monitoring-agent'] 18 | -------------------------------------------------------------------------------- /static/tests/hostinfo/iptables_in.txt: -------------------------------------------------------------------------------- 1 | -P INPUT ACCEPT 2 | -P FORWARD ACCEPT 3 | -P OUTPUT ACCEPT 4 | -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT 5 | -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT 6 | -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT 7 | -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT 8 | -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT 9 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT 10 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT 11 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 143 -j ACCEPT 12 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 143 -j ACCEPT 13 | -------------------------------------------------------------------------------- /cmake/WinUpload.cmake: -------------------------------------------------------------------------------- 1 | if (MSI_OUTPUT_LEGACY) 2 | add_custom_target(packageupload 3 | COMMAND rclone mkdir ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 4 | COMMAND rclone copy ${MSI_OUTPUT} ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 5 | COMMAND copy ${MSI_OUTPUT} ${MSI_OUTPUT_LEGACY} 6 | COMMAND rclone copy ${MSI_OUTPUT_LEGACY} ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 7 | ) 8 | else(MSI_OUTPUT_LEGACY) 9 | add_custom_target(packageupload 10 | COMMAND rclone mkdir ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 11 | COMMAND rclone copy ${MSI_OUTPUT} ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 12 | ) 13 | endif(MSI_OUTPUT_LEGACY) 14 | -------------------------------------------------------------------------------- /static/tests/hostinfo/fail2ban_activitylog_out.txt: -------------------------------------------------------------------------------- 1 | ["2015-08-27 18:49:05,849 fail2ban.actions [12228]: NOTICE [sshd] Unban 43.229.53.20", 2 | "2015-08-27 19:24:15,683 fail2ban.actions [12228]: NOTICE [sshd] Ban 43.229.53.20", 3 | "2015-08-27 19:34:16,643 fail2ban.actions [12228]: NOTICE [sshd] Unban 43.229.53.20", 4 | "2015-08-27 20:14:40,828 fail2ban.actions [12228]: NOTICE [sshd] Ban 43.229.53.20", 5 | "2015-08-27 20:55:13,275 fail2ban.actions [12228]: NOTICE [sshd] Ban 43.229.53.20", 6 | "2015-08-27 21:05:14,238 fail2ban.actions [12228]: NOTICE [sshd] Unban 43.229.53.20"] 7 | -------------------------------------------------------------------------------- /static/tests/checks/mssql_sql_statistics.txt: -------------------------------------------------------------------------------- 1 | #TYPE Selected.Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample 2 | "Name","Value","Type" 3 | "batch_requests_per_sec","0","int" 4 | "forced_parameterizations_per_sec","0","int" 5 | "auto_param_attempts_per_sec","0","int" 6 | "failed_auto_params_per_sec","0","int" 7 | "safe_auto_params_per_sec","0","int" 8 | "unsafe_auto_params_per_sec","0","int" 9 | "sql_compilations_per_sec","0","int" 10 | "sql_re_compilations_per_sec","0","int" 11 | "sql_attention_rate","0","int" 12 | "guided_plan_executions_per_sec","0","int" 13 | "misguided_plan_executions_per_sec","0","int" 14 | -------------------------------------------------------------------------------- /hostinfo/debug/WORDPRESS.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"WORDPRESS", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "docroots":{ 6 | "example.com":"/var/www/example.com/public_html", 7 | "2001:4800:7817:101:be76:4eff:fe05:2e7":"/var/www/html" 8 | }, 9 | "found":{ 10 | "2001:4800:7817:101:be76:4eff:fe05:2e7":{ 11 | "path":"/var/www/html/", 12 | "version":["4.3"], 13 | "plugins":[{ 14 | "name":"Hello", 15 | "version":"1.6" 16 | },{ 17 | "name":"Akismet", 18 | "version":"3.1.3" 19 | }] 20 | } 21 | } 22 | }, 23 | "timestamp":1442252803000 24 | } 25 | -------------------------------------------------------------------------------- /schedule/init.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | return require('./scheduler') 18 | -------------------------------------------------------------------------------- /cmake/RepRepro.cmake: -------------------------------------------------------------------------------- 1 | if (DEFINED FORCE_REPO_NAME) 2 | set(REPO_NAME ${FORCE_REPO_NAME}) 3 | else() 4 | set(REPO_NAME ${LINUX_NAME_LOWER}-${LINUX_VER}-${CMAKE_SYSTEM_PROCESSOR}) 5 | endif() 6 | set(REPO_PATH ${CMAKE_BINARY_DIR}/${REPO_NAME}) 7 | message("Creating ${REPO_NAME} Repository") 8 | configure_file(${REPOSITORY_SCRIPTS}/reprepro.in ${REPO_PATH}/conf/distributions) 9 | add_custom_target(packagerepo 10 | COMMAND reprepro -b ${REPO_PATH} includedeb ${REPO_RPM_NAME} *.deb 11 | ) 12 | add_custom_target(packagerepoupload 13 | COMMAND rclone mkdir ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT}/${REPO_NAME} 14 | COMMAND rclone copy ${REPO_PATH} ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT}/${REPO_NAME} 15 | ) 16 | -------------------------------------------------------------------------------- /static/tests/checks/mssql_memory_manager.txt: -------------------------------------------------------------------------------- 1 | #TYPE Selected.Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample 2 | "Name","Value","Type" 3 | "connection_memory_(kb)","336","int" 4 | "granted_workspace_memory_(kb)","0","int" 5 | "lock_memory_(kb)","104","int" 6 | "lock_blocks_allocated","622","int" 7 | "lock_owner_blocks_allocated","622","int" 8 | "lock_blocks","0","int" 9 | "lock_owner_blocks","0","int" 10 | "maximum_workspace_memory_(kb)","1084920","int" 11 | "memory_grants_outstanding","0","int" 12 | "memory_grants_pending","0","int" 13 | "optimizer_memory_(kb)","984","int" 14 | "sql_cache_memory_(kb)","1584","int" 15 | "target_server_memory_(kb)","1443840","int" 16 | "total_server_memory_(kb)","9728","int" 17 | -------------------------------------------------------------------------------- /hostinfo/debug/PHP.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"PHP", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "modules":["bcmath","bz2","calendar","Core","ctype","curl","date","dba","dom","ereg","exif","fileinfo","filter","ftp","gd","gettext","hash","iconv","json","libxml","mbstring","mcrypt","mhash","mysql","mysqli","openssl","pcntl","pcre","PDO","pdo_mysql","Phar","posix","readline","Reflection","session","shmop","SimpleXML","soap","sockets","SPL","ssh2","standard","sysvmsg","sysvsem","sysvshm","tokenizer","wddx","xml","xmlreader","xmlwriter","Zend OPcache","zip","zlib","Zend OPcache"], 6 | "version":{ 7 | "type":"PHP", 8 | "version":"5.6.4-4ubuntu6.2" 9 | }, 10 | "log_files":"/var/log/apache2/*error.log*" 11 | }, 12 | "timestamp":1442261499000 13 | } 14 | -------------------------------------------------------------------------------- /cmake/package/rpm/postinst.in: -------------------------------------------------------------------------------- 1 | # This adds the proper /etc/rc*.d links for the script 2 | [ -x /sbin/chkconfig ] && /sbin/chkconfig --add @APP_NAME@ 3 | 4 | mkdir -p /var/lib/@APP_NAME@ 5 | mkdir -p /usr/lib/@APP_NAME@/plugins 6 | 7 | # Restart agent on upgrade 8 | if [ "$1" = "2" ] ; then 9 | if [ -x "/bin/systemctl" ] ; then 10 | /bin/systemctl reload @APP_NAME@.service >/dev/null 2>&1 || true 11 | /bin/systemctl enable @APP_NAME@.service >/dev/null 2>&1 || true 12 | if [ -f "/etc/rackspace-monitoring-agent.cfg" ] ; then 13 | /bin/systemctl restart @APP_NAME@.service >/dev/null 2>&1 || true 14 | fi 15 | else 16 | /sbin/service @APP_NAME@ stop >/dev/null 2>&1 || : 17 | /sbin/service @APP_NAME@ start >/dev/null 2>&1 || : 18 | fi 19 | fi 20 | -------------------------------------------------------------------------------- /contrib/confd-examples/znc_process_monitoring_plugin.yaml: -------------------------------------------------------------------------------- 1 | # The following plugin needs to be in the file system: /usr/lib/rackspace-monitoring-agent/plugins/ 2 | # https://github.com/racker/rackspace-monitoring-agent-plugins-contrib/blob/master/process_mon.sh 3 | # This example is monitoring a process with "znc" in its name. 4 | type: agent.plugin 5 | label: ZNC process 6 | disabled: false 7 | period: 60 8 | timeout: 30 9 | details: 10 | file: process_mon.sh 11 | args: [znc] 12 | alarms: 13 | znc-running: 14 | label: ZNC running 15 | notification_plan_id: npTechnicalContactsEmail 16 | criteria: | 17 | if (metric['process_mon'] == 0) { 18 | return new AlarmStatus(CRITICAL, 'ZNC is not running!'); 19 | } 20 | return new AlarmStatus(OK, 'ZNC is running'); 21 | -------------------------------------------------------------------------------- /hostinfo/nil.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2014 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | 18 | --[[ Info ]]-- 19 | local Info = HostInfo:extend() 20 | function Info:initialize() 21 | HostInfo.initialize(self) 22 | end 23 | 24 | function Info:getType() 25 | return 'NIL' 26 | end 27 | 28 | return Info 29 | -------------------------------------------------------------------------------- /hostinfo/debug/POSTFIX.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"POSTFIX", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "current_configuration":{ 6 | "inet_protocols":"all", 7 | "alias_database":"hash:/etc/aliases", 8 | "myhostname":"kostco-rmapg-ubuntu-2", 9 | "inet_interfaces":"all", 10 | "mynetworks":"[::1]/128", 11 | "mydestination":"localhost", 12 | "config_directory":"/etc/postfix", 13 | "queue_directory":"/var/spool/postfix", 14 | "mydomain":"localdomain", 15 | "mail_version":"2.11.3", 16 | "myorigin":"$myhostname" 17 | }, 18 | "mail_queue_size":{ 19 | "deferred":0, 20 | "active":35, 21 | "incoming":0, 22 | "hold":0, 23 | "corrupt":0, 24 | "bounce":0 25 | }, 26 | "process":{ 27 | "PID":"3593", 28 | "process":"/usr/lib/postfix/master" 29 | } 30 | }, 31 | "timestamp":1442342588000 32 | } 33 | -------------------------------------------------------------------------------- /cmake/CreateRepo.cmake: -------------------------------------------------------------------------------- 1 | if (DEFINED FORCE_REPO_NAME) 2 | set(REPO_NAME ${FORCE_REPO_NAME}) 3 | else() 4 | set(REPO_NAME ${LINUX_NAME_LOWER}-${LINUX_VER}-${CMAKE_SYSTEM_PROCESSOR}) 5 | endif() 6 | set(REPO_PATH ${CMAKE_BINARY_DIR}/${REPO_NAME}) 7 | message("Making repository ${REPO_NAME}") 8 | add_custom_target(packagerepo 9 | COMMAND mkdir -p ${REPO_PATH} 10 | COMMAND cp ${CMAKE_BINARY_DIR}/*.rpm ${REPO_PATH} 11 | COMMAND rm -f ~/.rpmmacros 12 | COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/cmake/package/rpm/rpm_macros_gpg ~/.rpmmacros 13 | COMMAND rpm --addsign ${REPO_PATH}/*.rpm 14 | COMMAND createrepo ${REPO_PATH} 15 | COMMAND gpg --batch --detach-sign --armor ${REPO_PATH}/repodata/repomd.xml 16 | ) 17 | add_custom_target(packagerepoupload 18 | COMMAND rclone mkdir ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT}/${REPO_NAME} 19 | COMMAND rclone copy ${REPO_PATH} ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT}/${REPO_NAME} 20 | ) 21 | -------------------------------------------------------------------------------- /staging.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2014 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local function isStaging() 18 | virgo.config = virgo.config or {} 19 | local b = virgo.config['monitoring_use_staging'] 20 | b = process.env.STAGING or (b and b:lower() == 'true') 21 | if b then 22 | process.env.STAGING = 1 23 | end 24 | return b 25 | end 26 | 27 | exports.isStaging = isStaging 28 | -------------------------------------------------------------------------------- /static/tests/checks/mssql_buffer_manager.txt: -------------------------------------------------------------------------------- 1 | #TYPE Selected.Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample 2 | "Name","Value","Type" 3 | "buffer_cache_hit_ratio","99.5061728395062","int" 4 | "page_lookups_per_sec","400.681975364276","int" 5 | "free_list_stalls_per_sec","0","int" 6 | "free_pages","186","int" 7 | "total_pages","1216","int" 8 | "target_pages","180480","int" 9 | "database_pages","355","int" 10 | "reserved_pages","0","int" 11 | "stolen_pages","675","int" 12 | "lazy_writes_per_sec","0","int" 13 | "readahead_pages_per_sec","0","int" 14 | "page_reads_per_sec","1.97867642155198","int" 15 | "page_writes_per_sec","0","int" 16 | "checkpoint_pages_per_sec","0","int" 17 | "awe_lookup_maps_per_sec","0","int" 18 | "awe_stolen_maps_per_sec","0","int" 19 | "awe_write_maps_per_sec","0","int" 20 | "awe_unmap_calls_per_sec","0","int" 21 | "awe_unmap_pages_per_sec","0","int" 22 | "page_life_expectancy","112719","int" 23 | -------------------------------------------------------------------------------- /check/null.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2012 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local BaseCheck = require('./base').BaseCheck 18 | 19 | local NullCheck = BaseCheck:extend() 20 | 21 | function NullCheck:initialize(params) 22 | BaseCheck.initialize(self, params) 23 | end 24 | 25 | function NullCheck:getType() 26 | return "NULL" 27 | end 28 | 29 | function NullCheck:run(callback) 30 | end 31 | 32 | exports.NullCheck = NullCheck 33 | -------------------------------------------------------------------------------- /static/tests/hostinfo/iptables_out.txt: -------------------------------------------------------------------------------- 1 | [{"type":"-P","chain":"INPUT","policy":"ACCEPT"},{"type":"-P","chain":"FORWARD","policy":"ACCEPT"},{"type":"-P","chain":"OUTPUT","policy":"ACCEPT"},{"type":"-A","chain":"INPUT","policy":"INPUT -p tcp -m tcp --dport 8080 -j ACCEPT"},{"type":"-A","chain":"INPUT","policy":"INPUT -p tcp -m tcp --dport 8080 -j ACCEPT"},{"type":"-A","chain":"INPUT","policy":"INPUT -p tcp -m tcp --dport 8080 -j ACCEPT"},{"type":"-A","chain":"INPUT","policy":"INPUT -p tcp -m tcp --dport 8080 -j ACCEPT"},{"type":"-A","chain":"INPUT","policy":"INPUT -p tcp -m tcp --dport 80 -j ACCEPT"},{"type":"-A","chain":"INPUT","policy":"INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT"},{"type":"-A","chain":"INPUT","policy":"INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT"},{"type":"-A","chain":"INPUT","policy":"INPUT -p tcp -m state --state NEW -m tcp --dport 143 -j ACCEPT"},{"type":"-A","chain":"INPUT","policy":"INPUT -p tcp -m state --state NEW -m tcp --dport 143 -j ACCEPT"}] 2 | -------------------------------------------------------------------------------- /tests/fixtures/hostinfo/cron.txt: -------------------------------------------------------------------------------- 1 | # Edit this file to introduce tasks to be run by cron. 2 | # 3 | # Each task to run has to be defined through a single line 4 | # indicating with different fields when the task will be run 5 | # and what command to run for the task 6 | # 7 | # To define the time you can provide concrete values for 8 | # minute (m), hour (h), day of month (dom), month (mon), 9 | # and day of week (dow) or use '*' in these fields (for 'any').# 10 | # Notice that tasks will be started based on the cron's system 11 | # daemon's notion of time and timezones. 12 | # 13 | # Output of the crontab jobs (including errors) is sent through 14 | # email to the user the crontab file belongs to (unless redirected). 15 | # 16 | # For example, you can run a backup of all your user accounts 17 | # at 5 a.m every week with: 18 | # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ 19 | # 20 | # For more information see the manual pages of crontab(5) and cron(8) 21 | # 22 | # m h dom mon dow command 23 | * * * * * /usr/bin/znc >/dev/null 2>&1 24 | 25 | -------------------------------------------------------------------------------- /cmake/WinSign.cmake: -------------------------------------------------------------------------------- 1 | # Windows Signing 2 | set(CODESIGNING_KEYFILE "$ENV{RACKSPACE_CODESIGNING_KEYFILE}") 3 | if (CODESIGNING_KEYFILE STREQUAL "") 4 | # Sign with Test Key 5 | set(CODESIGNING_KEYFILE "${PACKAGE_SCRIPTS}/windows/testss.pfx") 6 | endif() 7 | 8 | find_path( 9 | SIGNTOOL_PATH 10 | NAMES "signtool.exe" 11 | PATHS 12 | "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.1A\\bin" 13 | "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\bin" 14 | NO_DEFAULT_PATH 15 | ) 16 | message("SignTool.exe found in: ${SIGNTOOL_PATH}") 17 | 18 | add_custom_target( 19 | SignExe 20 | COMMAND "${SIGNTOOL_PATH}\\signtool.exe" sign /d ${APP_NAME_INSTALL} /v /f ${CODESIGNING_KEYFILE} ${APP_NAME_INSTALL} 21 | DEPENDS ${APP_NAME_INSTALL} 22 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 23 | ) 24 | 25 | add_custom_target( 26 | SignPackage 27 | COMMAND "${SIGNTOOL_PATH}\\signtool.exe" sign /d ${APP_NAME_INSTALL} /v /f ${CODESIGNING_KEYFILE} ${MSI_OUTPUT} 28 | DEPENDS ${MSI_OUTPUT} 29 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 30 | ) 31 | 32 | -------------------------------------------------------------------------------- /hostinfo/debug/LOGIN.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"LOGIN", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "LOG_UNKFAIL_ENAB":"no", 6 | "TTYPERM":"0600", 7 | "USERGROUPS_ENAB":"yes", 8 | "SYSLOG_SG_ENAB":"yes", 9 | "DEFAULT_HOME":"yes", 10 | "PASS_MIN_DAYS":"0", 11 | "LOGIN_TIMEOUT":"60", 12 | "UID_MAX":"60000", 13 | "GID_MAX":"60000", 14 | "GID_MIN":"1000", 15 | "KILLCHAR":"025", 16 | "LOGIN_RETRIES":"5", 17 | "ENV_PATH":"PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games", 18 | "TTYGROUP":"tty", 19 | "MAIL_DIR":"/var/mail", 20 | "PASS_MAX_DAYS":"99999", 21 | "UMASK":"022", 22 | "PASS_WARN_AGE":"7", 23 | "HUSHLOGIN_FILE":".hushlogin", 24 | "CHFN_RESTRICT":"rwh", 25 | "UID_MIN":"1000", 26 | "FTMP_FILE":"/var/log/btmp", 27 | "FAILLOG_ENAB":"yes", 28 | "ENV_SUPATH":"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 29 | "ENCRYPT_METHOD":"SHA512", 30 | "ERASECHAR":"0177", 31 | "SU_NAME":"su", 32 | "SYSLOG_SU_ENAB":"yes", 33 | "LOG_OK_LOGINS":"no" 34 | }, 35 | "timestamp":1441066692000 36 | } -------------------------------------------------------------------------------- /hostname.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local ffi = require('ffi') 18 | local los = require('los') 19 | 20 | ffi.cdef [[ 21 | int gethostname(char *name, unsigned int namelen); 22 | ]] 23 | 24 | local lib 25 | if los.type() == 'win32' then 26 | lib = ffi.load('ws2_32') 27 | else 28 | lib = ffi.C 29 | end 30 | 31 | return function(maxlen) 32 | maxlen = maxlen or 255 33 | local buf = ffi.new("uint8_t[?]", maxlen) 34 | local res = lib.gethostname(buf, maxlen) 35 | assert(res == 0) 36 | return ffi.string(buf) 37 | end 38 | -------------------------------------------------------------------------------- /static/tests/hostinfo/magento_in.txt: -------------------------------------------------------------------------------- 1 | 'major' => '1', 2 | 'minor' => '9', 3 | 'revision' => '0', 4 | 'patch' => '1', 5 | 'stability' => '', 6 | 'number' => '', 7 | 'scope_code' => $code, 8 | 'scope_type' => $type, 9 | 'options' => $options, 10 | self::dispatchEvent('mage_run_exception', array('exception' => $e)); 11 | $options = array('etc_dir' => $options); 12 | * Magento edition constants 13 | const EDITION_COMMUNITY = 'Community'; 14 | const EDITION_ENTERPRISE = 'Enterprise'; 15 | const EDITION_PROFESSIONAL = 'Professional'; 16 | const EDITION_GO = 'Go'; 17 | static private $_currentEdition = self::EDITION_COMMUNITY; 18 | return self::$_currentEdition; 19 | self::$_currentEdition = $options['edition']; 20 | -------------------------------------------------------------------------------- /static/tests/checks/redis_2.4_response.txt: -------------------------------------------------------------------------------- 1 | $962 2 | redis_version:2.4.8 3 | redis_git_sha1:00000000 4 | redis_git_dirty:0 5 | arch_bits:64 6 | multiplexing_api:epoll 7 | gcc_version:4.6.1 8 | process_id:27099 9 | uptime_in_seconds:29 10 | uptime_in_days:0 11 | lru_clock:654643 12 | used_cpu_sys:0.02 13 | used_cpu_user:0.02 14 | used_cpu_sys_children:0.00 15 | used_cpu_user_children:0.00 16 | connected_clients:1 17 | connected_slaves:0 18 | client_longest_output_list:0 19 | client_biggest_input_buf:0 20 | blocked_clients:0 21 | used_memory:7126416 22 | used_memory_human:6.80M 23 | used_memory_rss:8273920 24 | used_memory_peak:7126384 25 | used_memory_peak_human:6.80M 26 | mem_fragmentation_ratio:1.16 27 | mem_allocator:jemalloc-2.2.5 28 | loading:0 29 | aof_enabled:0 30 | changes_since_last_save:0 31 | bgsave_in_progress:0 32 | last_save_time:1348723681 33 | bgrewriteaof_in_progress:0 34 | total_connections_received:1 35 | total_commands_processed:0 36 | expired_keys:0 37 | evicted_keys:0 38 | keyspace_hits:0 39 | keyspace_misses:0 40 | pubsub_channels:0 41 | pubsub_patterns:0 42 | latest_fork_usec:0 43 | vm_enabled:0 44 | role:master 45 | db0:keys=3,expires=0 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /tests/fixtures/checks/redis_2.4_response.txt: -------------------------------------------------------------------------------- 1 | $962 2 | redis_version:2.4.8 3 | redis_git_sha1:00000000 4 | redis_git_dirty:0 5 | arch_bits:64 6 | multiplexing_api:epoll 7 | gcc_version:4.6.1 8 | process_id:27099 9 | uptime_in_seconds:29 10 | uptime_in_days:0 11 | lru_clock:654643 12 | used_cpu_sys:0.02 13 | used_cpu_user:0.02 14 | used_cpu_sys_children:0.00 15 | used_cpu_user_children:0.00 16 | connected_clients:1 17 | connected_slaves:0 18 | client_longest_output_list:0 19 | client_biggest_input_buf:0 20 | blocked_clients:0 21 | used_memory:7126416 22 | used_memory_human:6.80M 23 | used_memory_rss:8273920 24 | used_memory_peak:7126384 25 | used_memory_peak_human:6.80M 26 | mem_fragmentation_ratio:1.16 27 | mem_allocator:jemalloc-2.2.5 28 | loading:0 29 | aof_enabled:0 30 | changes_since_last_save:0 31 | bgsave_in_progress:0 32 | last_save_time:1348723681 33 | bgrewriteaof_in_progress:0 34 | total_connections_received:1 35 | total_commands_processed:0 36 | expired_keys:0 37 | evicted_keys:0 38 | keyspace_hits:0 39 | keyspace_misses:0 40 | pubsub_channels:0 41 | pubsub_patterns:0 42 | latest_fork_usec:0 43 | vm_enabled:0 44 | role:master 45 | db0:keys=3,expires=0 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /static/tests/hostinfo/apache2_VhostOutput_in.txt: -------------------------------------------------------------------------------- 1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 2001:4800:7812:514:be76:4eff:fe05:678d. Set the 'ServerName' directive globally to suppress this message 2 | VirtualHost configuration: 3 | *:80 is a NameVirtualHost 4 | default server 2001:4800:7812:514:be76:4eff:fe05:678d (/etc/apache2/sites-enabled/000-default.conf:1) 5 | port 80 namevhost 2001:4800:7812:514:be76:4eff:fe05:678d (/etc/apache2/sites-enabled/000-default.conf:1) 6 | port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.conf:1) 7 | alias www.example.com 8 | port 80 namevhost test.com (/etc/apache2/sites-enabled/test.com.conf:1) 9 | alias www.test.com 10 | ServerRoot: "/etc/apache2" 11 | Main DocumentRoot: "/var/www/html" 12 | Main ErrorLog: "/var/log/apache2/error.log" 13 | Mutex default: dir="/var/lock/apache2" mechanism=fcntl 14 | Mutex watchdog-callback: using_defaults 15 | PidFile: "/var/run/apache2/apache2.pid" 16 | Define: DUMP_VHOSTS 17 | Define: DUMP_RUN_CFG 18 | User: name="www-data" id=33 19 | Group: name="www-data" id=33 20 | -------------------------------------------------------------------------------- /tests/test-check-load-average.lua: -------------------------------------------------------------------------------- 1 | local los = require('los') 2 | local LoadAverageCheck = require('../check').LoadAverageCheck 3 | require('tap')(function(test) 4 | test('test check load average', function(expect) 5 | local check = LoadAverageCheck:new({id='foo',period=30}) 6 | assert(not check._lastResult) 7 | check:run(function(result) 8 | if los.type() == "win32" then 9 | -- Check isn't portable to win32, but make sure it still reports unavailable correctly. 10 | assert(result ~= nil) 11 | assert(check._lastResult == nil) 12 | assert(result['_state'] == "unavailable") 13 | assert(result['_status'] == "Load Average checks are not supported on Windows.") 14 | else 15 | assert(result ~= nil) 16 | assert(result['_state'], "available") 17 | local m = result:getMetrics()['none'] 18 | assert(m) 19 | assert(m['1m']) 20 | assert(m['5m']) 21 | assert(m['15m']) 22 | assert(tonumber(m['5m']['v'])) 23 | assert(m['5m']['t'] == 'double') 24 | assert(check._lastResult ~= nil) 25 | assert(#check._lastResult:serialize() > 0) 26 | end 27 | end) 28 | end) 29 | end) 30 | -------------------------------------------------------------------------------- /tests/test-protocol.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local AgentProtocolConnection = require('virgo/protocol/connection') 18 | local loggingUtil = require ('virgo/util/logging') 19 | local stream = require('stream') 20 | 21 | require('tap')(function(test) 22 | test('test completion key', function() 23 | local sock = stream.Readable:new() 24 | sock._read = function() end 25 | local conn = AgentProtocolConnection:new(loggingUtil.makeLogger(), 'MYID', 'TOKEN', 'GUID', sock) 26 | assert('GUID:1' == conn:_completionKey('1')) 27 | assert('hello:1' == conn:_completionKey('hello', '1')) 28 | end) 29 | end) 30 | -------------------------------------------------------------------------------- /tests/run.lua: -------------------------------------------------------------------------------- 1 | local options = {} 2 | options.version = require('../package').version 3 | options.paths = {} 4 | 5 | require('luvit')(function(...) 6 | require('virgo')(options, function(...) 7 | local tap = require("tap") 8 | local uv = require('uv') 9 | local constants = require('../constants') 10 | constants:setGlobal('TESTS_ACTIVE', true) 11 | 12 | local function runAll() 13 | local req = uv.fs_scandir("tests") 14 | repeat 15 | local ent = uv.fs_scandir_next(req) 16 | if not ent then 17 | -- run the tests! 18 | tap(true) 19 | end 20 | local match = string.match(ent, "^test%-(.*).lua$") 21 | if match then 22 | local file = './test-' .. match 23 | tap(match) 24 | require(file) 25 | end 26 | until not ent 27 | end 28 | 29 | local function runFile(testModule) 30 | local file = './test-' .. testModule 31 | tap(testModule) 32 | require(file) 33 | tap(true) 34 | end 35 | 36 | local testModule = process.env['TEST_MODULE'] 37 | if testModule then 38 | runFile(testModule) 39 | else 40 | runAll() 41 | end 42 | end) 43 | end) 44 | -------------------------------------------------------------------------------- /static/tests/hostinfo/cve.txt: -------------------------------------------------------------------------------- 1 | * fix for CVE-2014-2855 - rsync denial of service 2 | - debian/patches/CVE-2014-3634.patch: limit PRI values in 3 | - CVE-2014-3634 4 | - CVE-2014-3683 5 | - debian/patches/CVE-2014-9680.patch: sanity check TZ env variable in 6 | - CVE-2014-9680 7 | + CVE-2015-0261: missing bounds checks in IPv6 Mobility printer. 8 | + CVE-2015-2153: missing bounds checks in RPKI/RTR printer. 9 | + CVE-2015-2154: missing bounds checks in ISOCLNS printer. 10 | + CVE-2015-2155: missing bounds checks in ForCES printer. 11 | in the PPP dissector (CVE-2014-9140). 12 | + CVE-2014-8767: missing bounds checks in OLSR dissector (closes: #770434). 13 | + CVE-2014-8768: missing bounds checks in Geonet dissector 14 | + CVE-2014-8769: missing bounds checks in AOVD dissector (closes: #770424). 15 | - This fixes CVE-2014-9114: blkid command injection 16 | see https://security-tracker.debian.org/tracker/CVE-2014-9114 17 | - This fixes CVE-2014-9114: blkid command injection 18 | see https://security-tracker.debian.org/tracker/CVE-2014-9114 19 | * debian/changelog mention CVE-2014-4877 in 1.16-1 20 | - No longer create local symbolic links by default CVE-2014-4877 21 | -------------------------------------------------------------------------------- /tests/fixtures/hostinfo/cve.txt: -------------------------------------------------------------------------------- 1 | * fix for CVE-2014-2855 - rsync denial of service 2 | - debian/patches/CVE-2014-3634.patch: limit PRI values in 3 | - CVE-2014-3634 4 | - CVE-2014-3683 5 | - debian/patches/CVE-2014-9680.patch: sanity check TZ env variable in 6 | - CVE-2014-9680 7 | + CVE-2015-0261: missing bounds checks in IPv6 Mobility printer. 8 | + CVE-2015-2153: missing bounds checks in RPKI/RTR printer. 9 | + CVE-2015-2154: missing bounds checks in ISOCLNS printer. 10 | + CVE-2015-2155: missing bounds checks in ForCES printer. 11 | in the PPP dissector (CVE-2014-9140). 12 | + CVE-2014-8767: missing bounds checks in OLSR dissector (closes: #770434). 13 | + CVE-2014-8768: missing bounds checks in Geonet dissector 14 | + CVE-2014-8769: missing bounds checks in AOVD dissector (closes: #770424). 15 | - This fixes CVE-2014-9114: blkid command injection 16 | see https://security-tracker.debian.org/tracker/CVE-2014-9114 17 | - This fixes CVE-2014-9114: blkid command injection 18 | see https://security-tracker.debian.org/tracker/CVE-2014-9114 19 | * debian/changelog mention CVE-2014-4877 in 1.16-1 20 | - No longer create local symbolic links by default CVE-2014-4877 21 | -------------------------------------------------------------------------------- /contrib/confd-examples/my_fs.yaml: -------------------------------------------------------------------------------- 1 | type : agent.filesystem 2 | label : Check for Main Disk 3 | disabled : false 4 | period : 60 5 | timeout : 30 6 | details : 7 | target : / 8 | alarms : 9 | techs : 10 | label : disk used alarm 11 | notification_plan_id : npTechnicalContactsEmail 12 | criteria : | 13 | if (percentage(metric['used'], metric['total']) > 90) { 14 | return new AlarmStatus(CRITICAL, 'Less than 10% free space left.'); 15 | } 16 | if (percentage(metric['used'], metric['total']) > 80) { 17 | return new AlarmStatus(WARNING, 'Less than 20% free space left.'); 18 | } 19 | its : 20 | label : disk used alarm 21 | notification_plan_id : npInformationTechEmail 22 | criteria : | 23 | if (percentage(metric['used'], metric['total']) > 95) { 24 | return new AlarmStatus(CRITICAL, 'Less than 5% free space left.'); 25 | } 26 | if (percentage(metric['used'], metric['total']) > 90) { 27 | return new AlarmStatus(WARNING, 'Less than 10% free space left.'); 28 | } 29 | -------------------------------------------------------------------------------- /hostinfo/date.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local HostInfo = require('./base').HostInfo 18 | 19 | --[[ Date ]]-- 20 | local Info = HostInfo:extend() 21 | function Info:initialize() 22 | HostInfo.initialize(self) 23 | end 24 | function Info:_run(callback) 25 | local it = os.date('%H:%M:%S %Y %m %d %Z'):gmatch('%S+') 26 | local fields = {} 27 | fields.time = it() 28 | fields.date = {} 29 | fields.date.year = it() 30 | fields.date.month = it() 31 | fields.date.day = it() 32 | fields.timezone = it() 33 | table.insert(self._params, fields) 34 | callback() 35 | end 36 | 37 | function Info:getType() 38 | return 'DATE' 39 | end 40 | 41 | return Info 42 | 43 | -------------------------------------------------------------------------------- /hostinfo/who.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2014 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local sigar = require('sigar') 18 | 19 | --[[ Who is logged In ]]-- 20 | local Info = HostInfo:extend() 21 | 22 | function Info:initialize() 23 | HostInfo.initialize(self) 24 | end 25 | function Info:_run(callback) 26 | local ctx = sigar:new() 27 | local who = ctx:who() 28 | for i=1, #who do 29 | local obj = {} 30 | for _, v in pairs({'user', 'device', 'time', 'host'}) do 31 | obj[v] = who[i][v] 32 | end 33 | table.insert(self._params, obj) 34 | end 35 | callback() 36 | end 37 | 38 | function Info:getType() 39 | return 'WHO' 40 | end 41 | 42 | return Info 43 | -------------------------------------------------------------------------------- /static/tests/hostinfo/apache2_apacheOut_in.txt: -------------------------------------------------------------------------------- 1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 2001:4800:7812:514:be76:4eff:fe05:678d. Set the 'ServerName' directive globally to suppress this message 2 | Server version: Apache/2.4.10 (Ubuntu) 3 | Server built: Jul 24 2015 17:25:18 4 | Server's Module Magic Number: 20120211:37 5 | Server loaded: APR 1.5.1, APR-UTIL 1.5.4 6 | Compiled using: APR 1.5.1, APR-UTIL 1.5.4 7 | Architecture: 64-bit 8 | Server MPM: event 9 | threaded: yes (fixed thread count) 10 | forked: yes (variable process count) 11 | Server compiled with.... 12 | -D APR_HAS_SENDFILE 13 | -D APR_HAS_MMAP 14 | -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) 15 | -D APR_USE_SYSVSEM_SERIALIZE 16 | -D APR_USE_PTHREAD_SERIALIZE 17 | -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT 18 | -D APR_HAS_OTHER_CHILD 19 | -D AP_HAVE_RELIABLE_PIPED_LOGS 20 | -D DYNAMIC_MODULE_LIMIT=256 21 | -D HTTPD_ROOT="/etc/apache2" 22 | -D SUEXEC_BIN="/usr/lib/apache2/suexec" 23 | -D DEFAULT_PIDLOG="/var/run/apache2.pid" 24 | -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" 25 | -D DEFAULT_ERRORLOG="logs/error_log" 26 | -D AP_TYPES_CONFIG_FILE="mime.types" 27 | -D SERVER_CONFIG_FILE="apache2.conf" 28 | Syntax OK 29 | -------------------------------------------------------------------------------- /cmake/package/sysv-redhat/script.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # chkconfig: 345 85 15 - start or stop process definition within the boot process 4 | # description: @APP_DESCRIPTION@ 5 | # processname: @APP_NAME@ 6 | # pidfile: /var/run/@APP_NAME@.pid 7 | 8 | NAME=@APP_NAME@ 9 | DAEMON=/usr/bin/@APP_NAME@ 10 | PIDFILE=/var/run/@APP_NAME@.pid 11 | LOG=/var/log/@APP_NAME@.log 12 | export TMPDIR=/var/lib 13 | 14 | # Source function library. This creates the operating environment for the process to be started 15 | . /etc/init.d/functions 16 | 17 | case "$1" in 18 | start) 19 | echo -n "Starting $DAEMON: " 20 | daemon $DAEMON -D -p $PIDFILE -l $LOG --production --restart-sysv-on-upgrade 21 | echo 22 | touch /var/lock/subsys/process-name 23 | ;; 24 | stop) 25 | echo -n "Shutting down $DAEMON: " 26 | killproc $DAEMON 27 | echo 28 | rm -f $PIDFILE 29 | ;; 30 | status) 31 | status $DAEMON 32 | ;; 33 | restart) 34 | $0 stop 35 | $0 start 36 | ;; 37 | reload) 38 | echo -n "Reloading $DAEMON: " 39 | killproc $DAEMON -HUP 40 | echo 41 | ;; 42 | *) 43 | echo "Usage: $0 {start|stop|restart|reload|status}" 44 | exit 1 45 | esac 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /hostinfo/debug/IP4ROUTES.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"IP4ROUTES", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "mss":"0", 6 | "genmask":"0.0.0.0", 7 | "irtt":"0", 8 | "flags":"UG", 9 | "destination":"0.0.0.0", 10 | "gateway":"162.209.76.1", 11 | "iface":"eth0", 12 | "window":"0" 13 | },{ 14 | "mss":"0", 15 | "genmask":"255.240.0.0", 16 | "irtt":"0", 17 | "flags":"UG", 18 | "destination":"10.176.0.0", 19 | "gateway":"10.182.0.1", 20 | "iface":"eth1", 21 | "window":"0" 22 | },{ 23 | "mss":"0", 24 | "genmask":"255.255.128.0", 25 | "irtt":"0", 26 | "flags":"U", 27 | "destination":"10.182.0.0", 28 | "gateway":"0.0.0.0", 29 | "iface":"eth1", 30 | "window":"0" 31 | },{ 32 | "mss":"0", 33 | "genmask":"255.240.0.0", 34 | "irtt":"0", 35 | "flags":"UG", 36 | "destination":"10.208.0.0", 37 | "gateway":"10.182.0.1", 38 | "iface":"eth1", 39 | "window":"0" 40 | },{ 41 | "mss":"0", 42 | "genmask":"255.255.255.0", 43 | "irtt":"0", 44 | "flags":"U", 45 | "destination":"162.209.76.0", 46 | "gateway":"0.0.0.0", 47 | "iface":"eth0", 48 | "window":"0" 49 | }], 50 | "timestamp":1441066693000 51 | } -------------------------------------------------------------------------------- /check/windows/init.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2013 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local WindowsPerfOSCheck = require('./os').WindowsPerfOSCheck 18 | local MSSQLServer = require('./sqlserver') 19 | 20 | local exports = {} 21 | 22 | exports.checks = { 23 | WindowsPerfOSCheck = WindowsPerfOSCheck, 24 | MSSQLServerVersionCheck = MSSQLServer.MSSQLServerVersionCheck, 25 | MSSQLServerDatabaseCheck = MSSQLServer.MSSQLServerDatabaseCheck, 26 | MSSQLServerBufferManagerCheck = MSSQLServer.MSSQLServerBufferManagerCheck, 27 | MSSQLServerSQLStatisticsCheck = MSSQLServer.MSSQLServerSQLStatisticsCheck, 28 | MSSQLServerMemoryManagerCheck = MSSQLServer.MSSQLServerMemoryManagerCheck, 29 | MSSQLServerPlanCacheCheck = MSSQLServer.MSSQLServerPlanCacheCheck 30 | } 31 | 32 | return exports 33 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | APP_FILES=$(shell find . -type f -name '*.lua') 2 | LIT_VERSION=3.7.3 3 | TARGET=build/rackspace-monitoring-agent 4 | LUVI?=./luvi 5 | LIT?=./lit 6 | LUVISIGAR?=luvi-sigar 7 | PREFIX?=/usr/bin 8 | 9 | all: $(TARGET) 10 | 11 | $(LUVISIGAR): 12 | [ ! -x luvi-sigar ] && $(LIT) get-luvi -o luvi-sigar || exit 0 13 | 14 | $(TARGET): lit $(LUVISIGAR) $(APP_FILES) 15 | cmake -H. -Bbuild 16 | cmake --build build 17 | build/rackspace-monitoring-agent -v 18 | 19 | install: $(TARGET) 20 | install -m 777 $(TARGET) $(PREFIX)/ 21 | 22 | test: lit $(LUVISIGAR) 23 | rm -rf tests/tmpdir && mkdir tests/tmpdir 24 | $(LIT) install 25 | ./luvi-sigar . -m tests/run.lua 26 | 27 | clean: 28 | rm -rf lit luvi luvi-sigar build 29 | 30 | lit: 31 | curl -L https://github.com/luvit/lit/raw/${LIT_VERSION}/get-lit.sh | sh 32 | 33 | lint: 34 | find . ! -path './deps/**' ! -path './tests/**' -name '*.lua' | xargs luacheck 35 | 36 | package: 37 | cmake -H. -Bbuild 38 | cmake --build build -- package 39 | 40 | packagerepo: 41 | cmake --build build -- packagerepo 42 | 43 | packagerepoupload: 44 | cmake --build build -- packagerepoupload 45 | 46 | siggen: 47 | cmake --build build -- siggen 48 | 49 | siggenupload: 50 | cmake --build build -- siggenupload 51 | 52 | .PHONY: clean lint package packagerepo packagerepoupload siggen siggenupload install 53 | -------------------------------------------------------------------------------- /tests/fixtures/protocol/init.lua: -------------------------------------------------------------------------------- 1 | local path = require('path') 2 | local fs = require('fs') 3 | local string = require('string') 4 | local JSON = require('json') 5 | 6 | local fixtures = nil 7 | 8 | local strip_newlines = function(str) 9 | return str:gsub("\n", " ") 10 | end 11 | 12 | local load_fixtures = function(dir) 13 | local fixtures = {} 14 | local files = fs.readdirSync(dir) 15 | 16 | for i, v in ipairs(files) do 17 | local _, _, name = string.find(v, '(.*).json') 18 | if name ~= nil then 19 | local json = fs.readFileSync(path.join(dir, v)) 20 | json = strip_newlines(json) 21 | fixtures[name] = json 22 | end 23 | end 24 | 25 | return fixtures 26 | end 27 | 28 | local base = path.join('agents', 'monitoring', 'tests', 'fixtures', 'protocol') 29 | 30 | fixtures = load_fixtures(base) 31 | fixtures['invalid-version'] = load_fixtures(path.join(base, 'invalid-version')) 32 | fixtures['invalid-process-version'] = load_fixtures(path.join(base, 'invalid-process-version')) 33 | fixtures['invalid-bundle-version'] = load_fixtures(path.join(base, 'invalid-bundle-version')) 34 | fixtures['rate-limiting'] = load_fixtures(path.join(base, 'rate-limiting')) 35 | 36 | fixtures.prepareJson = function(msg) 37 | local data = JSON.stringify(msg) 38 | return strip_newlines(data) 39 | end 40 | 41 | return fixtures 42 | -------------------------------------------------------------------------------- /endpoint.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2014 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local constants = require('./constants') 18 | local staging = require('./staging') 19 | local endpoint = require('virgo/client/endpoint') 20 | 21 | local function getEndpointSRV() 22 | if staging.isStaging() then 23 | return constants:get('DEFAULT_MONITORING_SRV_QUERIES_STAGING') 24 | end 25 | return constants:get('DEFAULT_MONITORING_SRV_QUERIES') 26 | end 27 | 28 | local function getServiceNetSRV() 29 | if staging.isStaging() then 30 | return constants:get('SNET_MONITORING_TEMPLATE_SRV_QUERIES_STAGING') 31 | end 32 | return constants:get('SNET_MONITORING_TEMPLATE_SRV_QUERIES') 33 | end 34 | 35 | exports.Endpoint = endpoint.Endpoint 36 | exports.getEndpointSRV = getEndpointSRV 37 | exports.getServiceNetSRV = getServiceNetSRV 38 | -------------------------------------------------------------------------------- /hostinfo/system.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2014 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local sigar = require('sigar') 18 | 19 | --[[ System Info ]]-- 20 | local Info = HostInfo:extend() 21 | 22 | function Info:initialize() 23 | HostInfo.initialize(self) 24 | end 25 | function Info:_run(callback) 26 | local ctx, sysinfo 27 | ctx = sigar:new() 28 | sysinfo = ctx:sysinfo() 29 | table.insert(self._params, { 30 | name = sysinfo.name, 31 | arch = sysinfo.arch, 32 | version = sysinfo.version, 33 | vendor = sysinfo.vendor, 34 | vendor_version = sysinfo.vendor_version, 35 | vendor_name = sysinfo.vendor_name or sysinfo.vendor_version 36 | }) 37 | callback() 38 | end 39 | 40 | function Info:getType() 41 | return 'SYSTEM' 42 | end 43 | 44 | return Info 45 | -------------------------------------------------------------------------------- /hostinfo/debug/DELETED_LIBS.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"DELETED_LIBS", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "deleted_lib_name":"/dev/zero", 6 | "used_by_process":"sshd" 7 | },{ 8 | "deleted_lib_name":"/dev/zero", 9 | "used_by_process":"sshd" 10 | },{ 11 | "deleted_lib_name":"/[aio]", 12 | "used_by_process":"mysqld" 13 | },{ 14 | "deleted_lib_name":"/[aio]", 15 | "used_by_process":"mysqld" 16 | },{ 17 | "deleted_lib_name":"/[aio]", 18 | "used_by_process":"mysqld" 19 | },{ 20 | "deleted_lib_name":"/[aio]", 21 | "used_by_process":"mysqld" 22 | },{ 23 | "deleted_lib_name":"/[aio]", 24 | "used_by_process":"mysqld" 25 | },{ 26 | "deleted_lib_name":"/[aio]", 27 | "used_by_process":"mysqld" 28 | },{ 29 | "deleted_lib_name":"/[aio]", 30 | "used_by_process":"mysqld" 31 | },{ 32 | "deleted_lib_name":"/[aio]", 33 | "used_by_process":"mysqld" 34 | },{ 35 | "deleted_lib_name":"/[aio]", 36 | "used_by_process":"mysqld" 37 | },{ 38 | "deleted_lib_name":"/[aio]", 39 | "used_by_process":"mysqld" 40 | },{ 41 | "deleted_lib_name":"/[aio]", 42 | "used_by_process":"mysqld" 43 | },{ 44 | "deleted_lib_name":"/[aio]", 45 | "used_by_process":"mysqld" 46 | }], 47 | "timestamp":1441066693000 48 | } -------------------------------------------------------------------------------- /check/load_average.lua: -------------------------------------------------------------------------------- 1 | local los = require('los') 2 | local BaseCheck = require('./base').BaseCheck 3 | local CheckResult = require('./base').CheckResult 4 | local logging = require('logging') 5 | local sigar = require('sigar') 6 | 7 | local LoadAverageCheck = BaseCheck:extend() 8 | 9 | function LoadAverageCheck:initialize(params) 10 | BaseCheck.initialize(self, params) 11 | end 12 | 13 | function LoadAverageCheck:getType() 14 | return 'agent.load_average' 15 | end 16 | 17 | function LoadAverageCheck:run(callback) 18 | local s = sigar:new() 19 | local err, load = pcall(function() return s:load() end) 20 | local checkResult = CheckResult:new(self, {}) 21 | 22 | -- Check the os to make sure if it is supported 23 | if los.type() == 'win32' then 24 | logging.error("Load Average checks are not supported on Windows.") 25 | checkResult:setStatus('unavailable') 26 | checkResult:setError('Load Average checks are not supported on Windows.') 27 | callback(checkResult) 28 | return 29 | end 30 | 31 | if err == true then 32 | for key, value in pairs(load) do 33 | checkResult:addMetric(key, nil, 'double', value) 34 | end 35 | else 36 | checkResult:setError(load) 37 | end 38 | 39 | self._lastResult = checkResult 40 | callback(checkResult) 41 | end 42 | 43 | local exports = {} 44 | exports.LoadAverageCheck = LoadAverageCheck 45 | return exports 46 | -------------------------------------------------------------------------------- /hostinfo/filesystem_state.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2016 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local gatherReadWriteReadOnlyInfo = require('../ro').gatherReadWriteReadOnlyInfo 17 | 18 | local HostInfo = require('./base').HostInfo 19 | 20 | --[[ Filesystem RO Info ]]-- 21 | local Info = HostInfo:extend() 22 | function Info:initialize() 23 | HostInfo.initialize(self) 24 | end 25 | function Info:_run(callback) 26 | local fs_list_ro, fs_list_rw = gatherReadWriteReadOnlyInfo() 27 | self._params = { 28 | total_ro = #fs_list_ro, 29 | total_rw = #fs_list_rw, 30 | devices_ro = table.concat(fs_list_ro, ','), 31 | devices_rw = table.concat(fs_list_rw, ',') 32 | } 33 | callback() 34 | end 35 | 36 | function Info:getType() 37 | return 'FILESYSTEM_STATE' 38 | end 39 | 40 | function Info:getPlatforms() 41 | return {'linux'} 42 | end 43 | 44 | return Info 45 | -------------------------------------------------------------------------------- /static/tests/checks/mssql_plan_cache.txt: -------------------------------------------------------------------------------- 1 | #TYPE Selected.Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample 2 | "Name","Value","Type" 3 | "temporary_tables_&_table_variables_cache_hit_ratio","0","int" 4 | "temporary_tables_&_table_variables_cache_pages","2","int" 5 | "temporary_tables_&_table_variables_cache_object_counts","0","int" 6 | "temporary_tables_&_table_variables_cache_objects_in_use","0","int" 7 | "extended_stored_procedures_cache_hit_ratio","0","int" 8 | "extended_stored_procedures_cache_pages","2","int" 9 | "extended_stored_procedures_cache_object_counts","0","int" 10 | "extended_stored_procedures_cache_objects_in_use","0","int" 11 | "bound_trees_cache_hit_ratio","63.6363636363636","int" 12 | "bound_trees_cache_pages","1","int" 13 | "bound_trees_cache_object_counts","0","int" 14 | "bound_trees_cache_objects_in_use","0","int" 15 | "sql_plans_cache_hit_ratio","33.3333333333333","int" 16 | "sql_plans_cache_pages","199","int" 17 | "sql_plans_cache_object_counts","0","int" 18 | "sql_plans_cache_objects_in_use","0","int" 19 | "object_plans_cache_hit_ratio","0","int" 20 | "object_plans_cache_pages","1","int" 21 | "object_plans_cache_object_counts","0","int" 22 | "object_plans_cache_objects_in_use","0","int" 23 | "total_cache_hit_ratio","51.3513513513513","int" 24 | "total_cache_pages","205","int" 25 | "total_cache_object_counts","0","int" 26 | "total_cache_objects_in_use","0","int" 27 | -------------------------------------------------------------------------------- /cmake/Sign.cmake: -------------------------------------------------------------------------------- 1 | if (DEFINED FORCE_REPO_NAME) 2 | set(REPO_NAME ${FORCE_REPO_NAME}) 3 | else() 4 | set(REPO_NAME ${LINUX_NAME_LOWER}-${LINUX_VER}-${CMAKE_SYSTEM_PROCESSOR}) 5 | endif() 6 | 7 | set(_SIGNATURE_NAME ${REPO_NAME}-${APP_NAME}-${VERSION_SHORT}) 8 | set(_SIGNATURE_EXE_RAW ${CMAKE_BINARY_DIR}/${APP_NAME}) 9 | set(SIGNATURE_EXE ${CMAKE_BINARY_DIR}/${_SIGNATURE_NAME}) 10 | set(SIGNATURE_SIG ${CMAKE_BINARY_DIR}/${_SIGNATURE_NAME}.sig) 11 | file(WRITE ${CMAKE_BINARY_DIR}/VERSION "${VERSION_SHORT}\n") 12 | get_filename_component(_SIGNATURE_KEY_PATH ${SIGNATURE_KEY} ABSOLUTE) 13 | if(EXISTS ${_SIGNATURE_KEY_PATH}) 14 | add_custom_target(siggen 15 | COMMAND openssl dgst -sha256 -sign ${_SIGNATURE_KEY_PATH} ${_SIGNATURE_EXE_RAW} > ${SIGNATURE_SIG} 16 | COMMAND cp -f ${_SIGNATURE_EXE_RAW} ${SIGNATURE_EXE} 17 | ) 18 | add_custom_target(siggenupload 19 | COMMAND rclone mkdir ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 20 | COMMAND rclone copy ${SIGNATURE_EXE} ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 21 | COMMAND rclone copy ${SIGNATURE_SIG} ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 22 | COMMAND rclone copy ${CMAKE_BINARY_DIR}/VERSION ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 23 | COMMAND rclone copy ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG ${REPO_UPLOAD_CLOUD}:${VERSION_SHORT} 24 | ) 25 | else() 26 | add_custom_target(siggen echo no ~/server.key found) 27 | add_custom_target(siggenupload echo no upload specified) 28 | endif() 29 | -------------------------------------------------------------------------------- /cmake/package/debian/postinst.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -f /etc/init.d/@APP_NAME@ ] ; then 4 | update-rc.d @APP_NAME@ defaults 91 09 5 | fi 6 | 7 | mkdir -p /var/lib/@APP_NAME@ 8 | mkdir -p /etc/@APP_NAME@.conf.d 9 | mkdir -p /usr/lib/@APP_NAME@/plugins 10 | 11 | legacy_start() { 12 | /etc/init.d/@APP_NAME@ stop || : 13 | 14 | # Cleanup init's mess if it fails to stop 15 | PIDFILE=/var/run/@APP_NAME@.pid 16 | start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE --name rackspace-monit --signal KILL 17 | 18 | # Start only if we find a config file in place 19 | if [ -f /etc/@APP_NAME@.cfg ]; then 20 | /etc/init.d/@APP_NAME@ start || : 21 | fi 22 | 23 | exit $? 24 | } 25 | 26 | systemd_start() { 27 | systemctl reload @APP_NAME@.service >/dev/null 2>&1 || true 28 | systemctl enable @APP_NAME@.service >/dev/null 2>&1 || true 29 | if [ -f "/etc/rackspace-monitoring-agent.cfg" ] ; then 30 | systemctl restart @APP_NAME@.service >/dev/null 2>&1 || true 31 | fi 32 | } 33 | 34 | case "$1" in 35 | configure) 36 | if which systemctl > /dev/null; then 37 | systemd_start 38 | elif [ -x "/etc/init.d/@APP_NAME@" ] || [ -e "/etc/init/@APP_NAME@.conf" ]; then 39 | legacy_start 40 | fi 41 | ;; 42 | remove) 43 | service @APP_NAME@ stop || : 44 | rm -f /var/run/@APP_NAME@.pid 45 | ;; 46 | upgrade) 47 | ;; 48 | *) 49 | echo "Unrecognized postinst argument '$1'" 50 | ;; 51 | esac 52 | -------------------------------------------------------------------------------- /remote/index.lua: -------------------------------------------------------------------------------- 1 | local uv = require('uv') 2 | 3 | local modules = { 4 | tcp = require('./tcp'), 5 | http = require('./http'), 6 | ping = require('./ping'), 7 | } 8 | 9 | return function (attributes, config, callback) 10 | local fn = assert(modules[attributes.module], "Missing module") 11 | 12 | local done 13 | local handles = {} 14 | local result = { id = attributes.id } 15 | 16 | -- Register a uv_handle to be cleaned up when done. 17 | local function register(handle) 18 | if done then 19 | return handle:close() 20 | end 21 | handles[#handles + 1] = handle 22 | end 23 | 24 | -- Set part of the result data. 25 | local function set(key, value) 26 | result[key] = value 27 | end 28 | 29 | -- Called when done with optional error reason 30 | local function finish(err) 31 | if done then return end 32 | done = true 33 | for i = 1, #handles do 34 | if not handles[i]:is_closing() then handles[i]:close() end 35 | end 36 | result.error = err 37 | return callback(err, result) 38 | end 39 | 40 | local timer = uv.new_timer() 41 | register(timer) 42 | timer:start(attributes.timeout, 0, function () 43 | return finish("ETIMEOUT: Check did not finish within " .. attributes.timeout .. "ms") 44 | end) 45 | 46 | coroutine.wrap(function () 47 | local success, err = pcall(fn, attributes, config, register, set) 48 | if not success then 49 | return finish(err) 50 | end 51 | return finish() 52 | end)() 53 | end 54 | -------------------------------------------------------------------------------- /static/tests/hostinfo/apache2_VhostConfig_in.txt: -------------------------------------------------------------------------------- 1 | 2 | # The ServerName directive sets the request scheme, hostname and port that 3 | # the server uses to identify itself. This is used when creating 4 | # redirection URLs. In the context of virtual hosts, the ServerName 5 | # specifies what hostname must appear in the request's Host: header to 6 | # match this virtual host. For the default virtual host (this file) this 7 | # value is not decisive as it is used as a last resort host regardless. 8 | # However, you must set it for any further virtual host explicitly. 9 | #ServerName www.example.com 10 | 11 | ServerAdmin webmaster@localhost 12 | DocumentRoot /var/www/html 13 | 14 | # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 15 | # error, crit, alert, emerg. 16 | # It is also possible to configure the loglevel for particular 17 | # modules, e.g. 18 | #LogLevel info ssl:warn 19 | 20 | ErrorLog ${APACHE_LOG_DIR}/error.log 21 | CustomLog ${APACHE_LOG_DIR}/access.log combined 22 | 23 | # For most configuration files from conf-available/, which are 24 | # enabled or disabled at a global level, it is possible to 25 | # include a line for only one particular virtual host. For example the 26 | # following line enables the CGI configuration for this host only 27 | # after it has been globally disabled with "a2disconf". 28 | #Include conf-available/serve-cgi-bin.conf 29 | 30 | -------------------------------------------------------------------------------- /tests/code_cert.test.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2012 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local codeCert = [[ 18 | -----BEGIN PUBLIC KEY----- 19 | MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAmmCdKFi6X1mpk5AU6EEH 20 | exou9NTRyiQVaHmTQvyPu6rd9krXB47/TgBDXcGIstkhFkGLwAh3cHDEPEF2jEcw 21 | W27S+/MvQdVgC4SJaN83pmk6ZYOvr0AX6zmPschoLxl84AT9xKHhFJuH5X1eCzP5 22 | DY1rAvNLdB9lFC/DM8m2AySwKHc1kAPhs//j6RPcI8R37yDOEta7e/ikhbAwnOFv 23 | /rs3Aob/nYE0ql2CMpO68uU9vbDYQt2bFdiX/zau402Zi9kU1lAaeNBNM0UP9thU 24 | /SSOYuDFqy+XbRVvItLhjvo5hP46GOw9GLz9ICQQohiXjC33e4Hs8sq2XkM+jYyk 25 | DGRiPEtVwt95x9h/ReCYJowJzJWnaSvQKEPNQaMvwGCV5ZLZ0IlI8cqS3m+ns4ZK 26 | gTQDQjeRJADz0JY3jBpBhLebH2HfrYJGp3EWC7CdhhTvYXN5ZkBK6A7xkzPY0mZj 27 | RAvS5K417LkAc+G0gO6qyJtXplkL4G/Q07Vdt8zc7ZAg5rbGWY83lw8E/7h0Gpu2 28 | JXfANZzdPKiV5P2tB6ZEwdxTABY/kHEk0u0WoPjqqgNv9I/zwLCbjefon8RcIJ5D 29 | EXXm9DibcaCpRYUkq5redFXDG8VHVzYVce2CJdrko8GvWUIOsAh0Y4CbyrXgXepV 30 | BvDtjEvMJUJ/iI33Ytzi6w0CAwEAAQ== 31 | -----END PUBLIC KEY----- 32 | ]] 33 | 34 | 35 | local exports = {} 36 | exports.codeCert = codeCert 37 | return exports 38 | -------------------------------------------------------------------------------- /tests/fixtures/procmounts.txt: -------------------------------------------------------------------------------- 1 | rootfs / rootfs rw 0 0 2 | sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 3 | proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 4 | udev /dev devtmpfs rw,relatime,size=10240k,nr_inodes=255394,mode=755 0 0 5 | devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 6 | tmpfs /run tmpfs rw,nosuid,relatime,size=409696k,mode=755 0 0 7 | /dev/xvda1 / ext4 rw,noatime,nobarrier,errors=remount-ro,data=ordered,hello_world 0 0 8 | securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0 9 | tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0 10 | tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 11 | cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0 12 | cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0 13 | cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0 14 | cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0 15 | cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0 16 | cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0 17 | systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=29,pgrp=1,timeout=0,minproto=5,maxproto=5,direct 0 0 18 | tmpfs /tmp tmpfs rw 0 0 19 | xenfs /proc/xen xenfs rw,relatime 0 0 20 | mqueue /dev/mqueue mqueue rw,relatime 0 0 21 | debugfs /sys/kernel/debug debugfs rw,relatime 0 0 22 | tmpfs /run/user/1001 tmpfs rw,nosuid,nodev,relatime,size=204848k,mode=700,uid=1001,gid=1001 0 0 23 | -------------------------------------------------------------------------------- /tests/fixtures/init.lua: -------------------------------------------------------------------------------- 1 | local los = require('los') 2 | local fs = require('fs') 3 | local path = require('path') 4 | 5 | local get_static 6 | 7 | local load_fixtures = function(dir, is_json) 8 | local finder = is_json and '(.*)' or '(.*).json' 9 | -- Convert the \ to / so path.posix works 10 | if los.type() == 'win32' then 11 | dir = dir:gsub("\\", "/") 12 | end 13 | local fixtures = {} 14 | local files = fs.readdirSync(dir) 15 | for _, v in ipairs(files) do 16 | local filePath = path.join(dir, v) 17 | if fs.statSync(filePath).type == 'file' then 18 | local fixture = fs.readFileSync(filePath) 19 | if is_json then 20 | fixture = fixture:gsub("\n", " ") 21 | end 22 | fixtures[v] = fixture 23 | end 24 | end 25 | return fixtures 26 | end 27 | 28 | local base = path.join('static', 'tests', 'protocol') 29 | 30 | exports = load_fixtures(base, true) 31 | exports['invalid-version'] = load_fixtures(path.join(base, 'invalid-version'), true) 32 | exports['invalid-process-version'] = load_fixtures(path.join(base, 'invalid-process-version'), true) 33 | exports['invalid-bundle-version'] = load_fixtures(path.join(base, 'invalid-bundle-version'), true) 34 | exports['rate-limiting'] = load_fixtures(path.join(base, 'rate-limiting'), true) 35 | exports['custom_plugins'] = load_fixtures(path.join('static','tests', 'custom_plugins')) 36 | exports['checks'] = load_fixtures(path.join('static','tests', 'checks')) 37 | exports['upgrade'] = load_fixtures(path.join('static','tests', 'upgrade')) 38 | exports['hostinfo'] = load_fixtures(path.join('static','tests', 'hostinfo')) 39 | return exports 40 | -------------------------------------------------------------------------------- /hostinfo/disk.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local sigar = require('sigar') 18 | local sigarutil = require('virgo/util/sigar') 19 | 20 | --[[ Info ]]-- 21 | local Info = HostInfo:extend() 22 | function Info:initialize() 23 | HostInfo.initialize(self) 24 | end 25 | function Info:_run(callback) 26 | local ctx, disks, usage_fields 27 | ctx = sigar:new() 28 | disks = sigarutil.diskTargets(ctx) 29 | usage_fields = { 30 | 'read_bytes', 31 | 'reads', 32 | 'rtime', 33 | 'time', 34 | 'write_bytes', 35 | 'writes', 36 | 'wtime' 37 | } 38 | for i=1, #disks do 39 | local name = disks[i]:name() 40 | local usage = disks[i]:usage() 41 | if name and usage then 42 | local obj = {} 43 | for _, v in pairs(usage_fields) do 44 | obj[v] = usage[v] 45 | end 46 | obj['name'] = name 47 | table.insert(self._params, obj) 48 | end 49 | end 50 | callback() 51 | end 52 | 53 | function Info:getType() 54 | return 'DISK' 55 | end 56 | 57 | return Info 58 | -------------------------------------------------------------------------------- /hostinfo/debug/NGINX_CONFIG.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"NGINX_CONFIG", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "vhosts":{ 6 | "example.com":{ 7 | "domain":"example.com", 8 | "listen":"80 default_server", 9 | "docroot":"/var/www/example.com/public_html" 10 | } 11 | }, 12 | "version":"1.6.2", 13 | "includes":["/etc/nginx/mime.types","/etc/nginx/conf.d/*.conf","/etc/nginx/sites-enabled/*"], 14 | "status":0, 15 | "conf_path":"/etc/nginx/nginx.conf", 16 | "prefix":"/usr/share/nginx", 17 | "configure_arguments":["--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now'","--prefix=/usr/share/nginx","--conf-path=/etc/nginx/nginx.conf","--http-log-path=/var/log/nginx/access.log","--error-log-path=/var/log/nginx/error.log","--lock-path=/var/lock/nginx.lock","--pid-path=/run/nginx.pid","--http-client-body-temp-path=/var/lib/nginx/body","--http-fastcgi-temp-path=/var/lib/nginx/fastcgi","--http-proxy-temp-path=/var/lib/nginx/proxy","--http-scgi-temp-path=/var/lib/nginx/scgi","--http-uwsgi-temp-path=/var/lib/nginx/uwsgi","--with-debug","--with-pcre-jit","--with-ipv6","--with-http_ssl_module","--with-http_stub_status_module","--with-http_realip_module","--with-http_auth_request_module","--with-http_addition_module","--with-http_dav_module","--with-http_geoip_module","--with-http_gzip_static_module","--with-http_image_filter_module","--with-http_spdy_module","--with-http_sub_module","--with-http_xslt_module","--with-mail","--with-mail_ssl_module"] 18 | }, 19 | "timestamp":1442249607000 20 | } 21 | -------------------------------------------------------------------------------- /hostinfo/memory.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local sigar = require('sigar') 18 | 19 | --[[ Info ]]-- 20 | local Info = HostInfo:extend() 21 | 22 | function Info:initialize() 23 | HostInfo.initialize(self) 24 | end 25 | function Info:_run(callback) 26 | local ctx = sigar:new() 27 | local swapinfo = ctx:swap() 28 | local data = ctx:mem() 29 | local data_fields = { 30 | 'actual_free', 31 | 'actual_used', 32 | 'free', 33 | 'free_percent', 34 | 'ram', 35 | 'total', 36 | 'used', 37 | 'used_percent' 38 | } 39 | local swap_metrics = { 40 | 'total', 41 | 'used', 42 | 'free', 43 | 'page_in', 44 | 'page_out' 45 | } 46 | if data then 47 | for _, v in pairs(data_fields) do 48 | self._params[v] = data[v] 49 | end 50 | end 51 | if swapinfo then 52 | for _, k in pairs(swap_metrics) do 53 | self._params['swap_' .. k] = swapinfo[k] 54 | end 55 | end 56 | callback() 57 | end 58 | 59 | function Info:getType() 60 | return 'MEMORY' 61 | end 62 | 63 | return Info 64 | -------------------------------------------------------------------------------- /check/windows/entry_handlers.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2013 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local string = require('string') 18 | 19 | local exports = {} 20 | 21 | -- Example Entry Handler for converting an entry to a metric 22 | exports.prototype = function(self, entry) 23 | local metric = nil 24 | if entry.Name ~= nil then 25 | metric = { 26 | Name = entry.Name, 27 | Dimension = nil, 28 | Type = 'string', 29 | Value = entry.Value, 30 | unit = '' 31 | } 32 | end 33 | return metric 34 | end 35 | 36 | -- Simple Entry Handler to support integers 37 | exports.simple = function(self, entry) 38 | local metric = nil 39 | if entry.Name then 40 | local type_map = { 41 | int='int64' 42 | } 43 | 44 | local type = 'string' 45 | if type_map[string.lower(entry.Type)] then 46 | type = type_map[string.lower(entry.Type)] 47 | end 48 | 49 | metric = { 50 | Name = entry.Name, 51 | Dimension = nil, 52 | Type = type, 53 | Value = entry.Value, 54 | unit = '' 55 | } 56 | end 57 | return metric 58 | end 59 | 60 | return exports 61 | -------------------------------------------------------------------------------- /client/virgo_client.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local AgentClient = require('virgo/client').AgentClient 18 | 19 | local check = require('../check') 20 | local logging = require('logging') 21 | local table = require('table') 22 | 23 | local VirgoAgentClient = AgentClient:extend() 24 | function VirgoAgentClient:initialize(options, connectionStream, types) 25 | AgentClient.initialize(self, options, connectionStream, types) 26 | end 27 | 28 | function VirgoAgentClient:setScheduler(scheduler) 29 | self._scheduler = scheduler 30 | end 31 | 32 | function VirgoAgentClient:scheduleManifest(manifest) 33 | local checks = self:_createChecks(manifest) 34 | self._scheduler:rebuild(checks, function() 35 | self._log(logging.DEBUG, 'Reloaded manifest') 36 | end) 37 | end 38 | 39 | function VirgoAgentClient:_createChecks(manifest) 40 | local checks = {} 41 | 42 | for i, _ in ipairs(manifest.checks) do 43 | local check = check.create(manifest.checks[i]) 44 | if check then 45 | table.insert(checks, check) 46 | end 47 | end 48 | 49 | return checks 50 | end 51 | 52 | return VirgoAgentClient 53 | -------------------------------------------------------------------------------- /features.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local FEATURE_UPGRADES = { name = 'upgrades', version = '1.0.0' } 17 | local FEATURE_CONFD = { name = 'confd', version = '1.0.0' } 18 | local FEATURE_HEALTH = { name = 'health', version = '1.0.0' } 19 | 20 | local FEATURES = { 21 | FEATURE_UPGRADES, 22 | FEATURE_CONFD, 23 | FEATURE_HEALTH 24 | } 25 | 26 | local function disable(name, remove) 27 | for i, v in pairs(FEATURES) do 28 | if v.name == name then 29 | if remove then 30 | table.remove(FEATURES, i) 31 | else 32 | v.disabled = true 33 | end 34 | break 35 | end 36 | end 37 | end 38 | 39 | local function get(name) 40 | if not name then return FEATURES end 41 | for _, v in pairs(FEATURES) do 42 | if v.name == name then return v end 43 | end 44 | return 45 | end 46 | 47 | local function disableWithOption(option, name, remove) 48 | if not option then return end 49 | option = option:lower() 50 | if option == 'disabled' or option == 'false' then 51 | disable(name, remove) 52 | end 53 | end 54 | 55 | exports.get = get 56 | exports.disable = disable 57 | exports.disableWithOption = disableWithOption 58 | -------------------------------------------------------------------------------- /ro.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2016 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local GetOptionsStringForFs = require('./check/filesystem').GetOptionsStringForFs 18 | local sigar = require('sigar') 19 | local split = require('virgo/util/misc').split 20 | 21 | local s = sigar:new() 22 | 23 | local function gatherReadWriteReadOnlyInfo() 24 | local fses = s:filesystems() 25 | local fs_list_ro = {} 26 | local fs_list_rw = {} 27 | for i=1, #fses do 28 | local fs = fses[i] 29 | local info = fs:info() 30 | local options = GetOptionsStringForFs(info['dir_name']) 31 | local type_name = info['type_name'] 32 | if options then 33 | for _, option in pairs(split(options, '[^,%s]+')) do 34 | if option == 'ro' and (type_name == 'local' or type_name == 'remote') then 35 | table.insert(fs_list_ro, info['dev_name']) 36 | break 37 | elseif option == 'rw' and (type_name == 'local' or type_name == 'remote') then 38 | table.insert(fs_list_rw, info['dev_name']) 39 | break 40 | end 41 | end 42 | end 43 | end 44 | return fs_list_ro, fs_list_rw 45 | end 46 | 47 | exports.gatherReadWriteReadOnlyInfo = gatherReadWriteReadOnlyInfo 48 | -------------------------------------------------------------------------------- /hostinfo/cpu.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local sigar = require('sigar') 18 | 19 | --[[ Info ]]-- 20 | local Info = HostInfo:extend() 21 | function Info:initialize() 22 | HostInfo.initialize(self) 23 | end 24 | function Info:_run(callback) 25 | local ctx = sigar:new() 26 | local cpus = ctx:cpus() 27 | for i=1, #cpus do 28 | local obj = {} 29 | local info = cpus[i]:info() 30 | local data = cpus[i]:data() 31 | local name = 'cpu.' .. i - 1 32 | local data_fields = { 33 | 'idle', 34 | 'irq', 35 | 'nice', 36 | 'soft_irq', 37 | 'stolen', 38 | 'sys', 39 | 'total', 40 | 'user', 41 | 'wait' 42 | } 43 | local info_fields = { 44 | 'mhz', 45 | 'model', 46 | 'total_cores', 47 | 'total_sockets', 48 | 'vendor' 49 | } 50 | 51 | for _, v in pairs(data_fields) do 52 | obj[v] = data[v] 53 | end 54 | for _, v in pairs(info_fields) do 55 | obj[v] = info[v] 56 | end 57 | 58 | obj['name'] = name 59 | table.insert(self._params, obj) 60 | end 61 | callback() 62 | end 63 | 64 | function Info:getType() 65 | return 'CPU' 66 | end 67 | 68 | return Info 69 | -------------------------------------------------------------------------------- /hostinfo/debug/APACHE2.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"APACHE2", "OS":"linux"}} 2 | 3 | { 4 | "metrics":{ 5 | "vhosts":{ 6 | "*:80":{ 7 | "example.com":{ 8 | "vhost":"example.com", 9 | "errorlog":"${APACHE_LOG_DIR}/error.log", 10 | "docroot":"/var/www/example.com/public_html", 11 | "accesslogs":"${APACHE_LOG_DIR}/access.log", 12 | "conf":"/etc/apache2/sites-enabled/example.com.conf:1", 13 | "port":"80" 14 | }, 15 | "test.com":{ 16 | "vhost":"test.com", 17 | "errorlog":"${APACHE_LOG_DIR}/error.log", 18 | "docroot":"/var/www/test.com/public_html", 19 | "accesslogs":"${APACHE_LOG_DIR}/access.log", 20 | "conf":"/etc/apache2/sites-enabled/test.com.conf:1", 21 | "port":"80" 22 | }, 23 | "2001:4800:7812:514:be76:4eff:fe05:678d":{ 24 | "vhost":"2001:4800:7812:514:be76:4eff:fe05:678d", 25 | "errorlog":"", 26 | "docroot":"/var/www/html", 27 | "accesslogs":"", 28 | "conf":"/etc/apache2/sites-enabled/magento.conf:1", 29 | "port":"80" 30 | }, 31 | "default":{ 32 | "vhost":"example.com", 33 | "errorlog":"${APACHE_LOG_DIR}/error.log", 34 | "docroot":"/var/www/example.com/public_html", 35 | "accesslogs":"", 36 | "conf":"/etc/apache2/sites-enabled/example.com.conf:1" 37 | } 38 | } 39 | }, 40 | "version":"Apache/2.4.10 (Ubuntu)", 41 | "cients":"0", 42 | "user":"www-data", 43 | "mpm":"prefork", 44 | "config_file":"/etc/apache2/apache2.conf", 45 | "bin":"/usr/sbin/apache2ctl", 46 | "syntax_ok":true, 47 | "estimatedRAMperpreforkchild":null, 48 | "config_path":"/etc/apache2" 49 | }, 50 | "timestamp":1441066693000 51 | } -------------------------------------------------------------------------------- /tests/setup.tcl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env expect 2 | #exp_internal 1 3 | set timeout 10 4 | 5 | set config [lindex $argv 0] 6 | set agent [lindex $argv 1] 7 | set zip [lindex $argv 2] 8 | 9 | if { $config == "" || $agent == ""|| $zip == ""} { 10 | puts "Usage: " 11 | exit 1 12 | } 13 | set fp [open $config "r"] 14 | set data [read $fp] 15 | set data [split $data "\n"] 16 | set user [lindex $data 0] 17 | set key [lindex $data 1] 18 | 19 | if { $user == "" || $key == ""} { 20 | puts "$config must contain exactly:\nusername\npassword" 21 | exit 1 22 | } 23 | 24 | spawn -noecho "$agent" -z "$zip" --setup 25 | expect "Username: " 26 | send "$user\r" 27 | expect "API Key or Password: " 28 | send "$key\r" 29 | 30 | expect { 31 | timeout { 32 | puts "timed out. Maybe an agent is already running?" 33 | exit 1 34 | } 35 | "Select Option (e.g., 1, 2): " { 36 | send "1\r" 37 | } 38 | -indices -re {Agent already associated Entity with id=([a-zA-Z0-9]+) and label=} { 39 | set entity_id $expect_out(1,string) 40 | wait 41 | puts "\ndeleteing entity: $entity_id" 42 | wait 43 | eval spawn "raxmon-entities-delete --id=$entity_id" 44 | wait 45 | spawn -noecho /racker/virgo/monitoring-agent -z /racker/virgo/monitoring.zip --setup 46 | expect "Username: " 47 | send "$user\r" 48 | expect "API Key or Password: " 49 | send "$key\r" 50 | expect "Select Option (e.g., 1, 2): " 51 | send "1\r" 52 | } 53 | } 54 | 55 | set entity_id "" 56 | 57 | expect { 58 | timeout { puts "could not find entity id"; exit 1} 59 | -indices -re {New Entity Created: ([a-zA-Z0-9]+)} { set entity_id $expect_out(1,string) } 60 | } 61 | 62 | if { $entity_id == ""} { 63 | puts "could not find entity id" 64 | exit 1 65 | } 66 | 67 | puts "all done" 68 | -------------------------------------------------------------------------------- /hostinfo/all.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2014 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | return { 18 | require('./nginx_config'), 19 | require('./connections'), 20 | require('./iptables'), 21 | require('./ip6tables'), 22 | require('./autoupdates'), 23 | require('./passwd'), 24 | require('./pam'), 25 | require('./cron'), 26 | require('./kernel_modules'), 27 | require('./cpu'), 28 | require('./disk'), 29 | require('./filesystem'), 30 | require('./filesystem_state'), 31 | require('./login'), 32 | require('./memory'), 33 | require('./network'), 34 | require('./nil'), 35 | require('./packages'), 36 | require('./procs'), 37 | require('./system'), 38 | require('./who'), 39 | require('./date'), 40 | require('./sysctl'), 41 | require('./sshd'), 42 | require('./fstab'), 43 | require('./fileperms'), 44 | require('./services'), 45 | require('./deleted_libs'), 46 | require('./cve'), 47 | require('./last_logins'), 48 | require('./remote_services'), 49 | require('./ip4routes'), 50 | require('./ip6routes'), 51 | require('./apache2'), 52 | require('./fail2ban'), 53 | require('./lsyncd'), 54 | require('./wordpress'), 55 | require('./magento'), 56 | require('./php'), 57 | require('./postfix'), 58 | require('./hostname'), 59 | require('./lshw') 60 | } 61 | -------------------------------------------------------------------------------- /hostinfo/debug/REMOTE_SERVICES.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"REMOTE_SERVICES", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "inode":"7082402", 6 | "recvq":"0", 7 | "user":"108", 8 | "protocol":"tcp", 9 | "foreign_addr":"0.0.0.0:*", 10 | "pid":"2270", 11 | "state":"LISTEN", 12 | "sendq":"0", 13 | "proccess":"mysqld", 14 | "local_addr":"127.0.0.1:3306" 15 | },{ 16 | "inode":"7070912", 17 | "recvq":"0", 18 | "user":"0", 19 | "protocol":"tcp", 20 | "foreign_addr":"0.0.0.0:*", 21 | "pid":"25824", 22 | "state":"LISTEN", 23 | "sendq":"0", 24 | "proccess":"nginx", 25 | "local_addr":"0.0.0.0:80" 26 | },{ 27 | "inode":"3417764", 28 | "recvq":"0", 29 | "user":"0", 30 | "protocol":"tcp", 31 | "foreign_addr":"0.0.0.0:*", 32 | "pid":"12502", 33 | "state":"LISTEN", 34 | "sendq":"0", 35 | "proccess":"tty.js", 36 | "local_addr":"0.0.0.0:8080" 37 | },{ 38 | "inode":"15114", 39 | "recvq":"0", 40 | "user":"0", 41 | "protocol":"tcp", 42 | "foreign_addr":"0.0.0.0:*", 43 | "pid":"1252", 44 | "state":"LISTEN", 45 | "sendq":"0", 46 | "proccess":"sshd", 47 | "local_addr":"0.0.0.0:22" 48 | },{ 49 | "inode":"7070913", 50 | "recvq":"0", 51 | "user":"0", 52 | "protocol":"tcp6", 53 | "foreign_addr":":::*", 54 | "pid":"25824", 55 | "state":"LISTEN", 56 | "sendq":"0", 57 | "proccess":"nginx", 58 | "local_addr":":::80" 59 | },{ 60 | "inode":"15123", 61 | "recvq":"0", 62 | "user":"0", 63 | "protocol":"tcp6", 64 | "foreign_addr":":::*", 65 | "pid":"1252", 66 | "state":"LISTEN", 67 | "sendq":"0", 68 | "proccess":"sshd", 69 | "local_addr":":::22" 70 | }], 71 | "timestamp":1441066693000 72 | } -------------------------------------------------------------------------------- /hostinfo/debug/IPTABLES.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"IPTABLES", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "type":"-P", 6 | "chain":"INPUT", 7 | "policy":"ACCEPT" 8 | },{ 9 | "type":"-P", 10 | "chain":"FORWARD", 11 | "policy":"ACCEPT" 12 | },{ 13 | "type":"-P", 14 | "chain":"OUTPUT", 15 | "policy":"ACCEPT" 16 | },{ 17 | "type":"-N", 18 | "chain":"f2b-sshd" 19 | },{ 20 | "type":"-A", 21 | "chain":"INPUT", 22 | "policy":"INPUT -p tcp -m multiport --dports 22 -j f2b-sshd" 23 | },{ 24 | "type":"-A", 25 | "chain":"INPUT", 26 | "policy":"INPUT -p tcp -m tcp --dport 8080 -j ACCEPT" 27 | },{ 28 | "type":"-A", 29 | "chain":"INPUT", 30 | "policy":"INPUT -p tcp -m tcp --dport 8080 -j ACCEPT" 31 | },{ 32 | "type":"-A", 33 | "chain":"INPUT", 34 | "policy":"INPUT -p tcp -m tcp --dport 8080 -j ACCEPT" 35 | },{ 36 | "type":"-A", 37 | "chain":"INPUT", 38 | "policy":"INPUT -p tcp -m tcp --dport 8080 -j ACCEPT" 39 | },{ 40 | "type":"-A", 41 | "chain":"INPUT", 42 | "policy":"INPUT -p tcp -m tcp --dport 80 -j ACCEPT" 43 | },{ 44 | "type":"-A", 45 | "chain":"INPUT", 46 | "policy":"INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT" 47 | },{ 48 | "type":"-A", 49 | "chain":"INPUT", 50 | "policy":"INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT" 51 | },{ 52 | "type":"-A", 53 | "chain":"INPUT", 54 | "policy":"INPUT -p tcp -m state --state NEW -m tcp --dport 143 -j ACCEPT" 55 | },{ 56 | "type":"-A", 57 | "chain":"INPUT", 58 | "policy":"INPUT -p tcp -m state --state NEW -m tcp --dport 143 -j ACCEPT" 59 | },{ 60 | "type":"-A", 61 | "chain":"f2b-sshd", 62 | "policy":"" 63 | }], 64 | "timestamp":1441066692000 65 | } -------------------------------------------------------------------------------- /client/virgo_connection_stream.lua: -------------------------------------------------------------------------------- 1 | local Scheduler = require('../schedule').Scheduler 2 | 3 | local ConnectionStream = require("virgo/client/connection_stream").ConnectionStream 4 | local loggingUtil = require('virgo/util/logging') 5 | local logging = require('logging') 6 | local fmt = require('string').format 7 | 8 | local VirgoConnectionStream = ConnectionStream:extend() 9 | function VirgoConnectionStream:initialize(id, token, guid, upgradeEnabled, options, features, types, codeCert) 10 | ConnectionStream.initialize(self, id, token, guid, upgradeEnabled, options, features, types, codeCert) 11 | self._log = loggingUtil.makeLogger('agent') 12 | self._scheduler = Scheduler:new() 13 | self._scheduler:on('check.completed', function(check, checkResult) 14 | -- Add the minimum check period 15 | checkResult:setMinimumCheckPeriod(self._scheduler:getMinimumCheckPeriod()) 16 | -- Send the metrics 17 | self:_sendMetrics(check, checkResult) 18 | end) 19 | self._scheduler:on('check.deleted', function(check) 20 | self._log(logging.INFO, fmt('Deleted Check (id=%s, iid=%s)', 21 | check.id, check:getInternalId())) 22 | end) 23 | self._scheduler:on('check.created', function(check) 24 | self._log(logging.INFO, fmt('Created Check (id=%s, iid=%s)', 25 | check.id, check:getInternalId())) 26 | end) 27 | self._scheduler:on('check.modified', function(check) 28 | self._log(logging.INFO, fmt('Modified Check (id=%s, iid=%s)', 29 | check.id, check:getInternalId())) 30 | end) 31 | end 32 | 33 | function VirgoConnectionStream:_createConnection(options) 34 | local client = ConnectionStream._createConnection(self, options) 35 | client:setScheduler(self._scheduler) 36 | return client 37 | end 38 | 39 | function VirgoConnectionStream:_sendMetrics(check, checkResult) 40 | local client = self:getClient() 41 | if client then 42 | client.protocol:request('check_metrics.post', check, checkResult) 43 | end 44 | end 45 | 46 | return VirgoConnectionStream 47 | -------------------------------------------------------------------------------- /check/memory.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2012 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local sigar = require('sigar') 18 | 19 | local BaseCheck = require('./base').BaseCheck 20 | local CheckResult = require('./base').CheckResult 21 | local MemoryCheck = BaseCheck:extend() 22 | local s = sigar:new() 23 | 24 | function MemoryCheck:initialize(params) 25 | BaseCheck.initialize(self, params) 26 | end 27 | 28 | function MemoryCheck:getType() 29 | return 'agent.memory' 30 | end 31 | 32 | function MemoryCheck:run(callback) 33 | -- Perform Check 34 | local meminfo = s:mem() 35 | local swapinfo = s:swap() 36 | local checkResult = CheckResult:new(self, {}) 37 | local metrics = { 38 | actual_used = 'bytes', 39 | free = 'bytes', 40 | total = 'bytes', 41 | ram = 'megabytes', 42 | actual_free = 'bytes', 43 | used = 'bytes' 44 | } 45 | local swap_metrics = { 46 | total = 'bytes', 47 | used = 'bytes', 48 | free = 'bytes', 49 | page_in = 'bytes', 50 | page_out = 'bytes' 51 | } 52 | 53 | for key, unit in pairs(metrics) do 54 | checkResult:addMetric(key, nil, 'gauge', meminfo[key], unit) 55 | end 56 | 57 | for key, unit in pairs(swap_metrics) do 58 | checkResult:addMetric('swap_' .. key, nil, 'gauge', swapinfo[key], unit) 59 | end 60 | 61 | -- Return Result 62 | self._lastResult = checkResult 63 | callback(checkResult) 64 | end 65 | 66 | local exports = {} 67 | exports.MemoryCheck = MemoryCheck 68 | return exports 69 | -------------------------------------------------------------------------------- /remote/test-ping.lua: -------------------------------------------------------------------------------- 1 | local runCheck = require('./index') 2 | require('tap')(function (test) 3 | test("Ping localhost IPv4", function (expect) 4 | runCheck({ 5 | id = 45, 6 | target = "localhost", 7 | module = "ping", 8 | resolver = "IPv4", 9 | timeout = 20000, 10 | }, { 11 | count = 10, 12 | delay = 100, 13 | }, expect(function (err, data) 14 | p(err, data) 15 | assert(not err, err) 16 | end)) 17 | end) 18 | 19 | test("Ping localhost IPv6", function (expect) 20 | runCheck({ 21 | id = 46, 22 | target = "localhost", 23 | module = "ping", 24 | resolver = "IPv6", 25 | timeout = 20000, 26 | }, { 27 | count = 10, 28 | delay = 100, 29 | }, expect(function (err, data) 30 | p(err, data) 31 | assert(not err, err) 32 | end)) 33 | end) 34 | 35 | test("Ping luvit.io", function (expect) 36 | runCheck({ 37 | id = 44, 38 | target = "luvit.io", 39 | module = "ping", 40 | timeout = 20000, 41 | }, { 42 | count = 10, 43 | delay = 100, 44 | }, expect(function (err, data) 45 | p(err, data) 46 | assert(not err, err) 47 | end)) 48 | end) 49 | 50 | test("Ping luvit.io ipv4 only", function (expect) 51 | runCheck({ 52 | id = 44, 53 | target = "luvit.io", 54 | module = "ping", 55 | resolver = "IPv4", 56 | timeout = 20000, 57 | }, { 58 | count = 5, 59 | delay = 100, 60 | }, expect(function (err, data) 61 | p(err, data) 62 | assert(not err, err) 63 | end)) 64 | end) 65 | 66 | test("Ping luvit.io ipv6 only", function (expect) 67 | runCheck({ 68 | id = 44, 69 | target = "luvit.io", 70 | module = "ping", 71 | resolver = "IPv6", 72 | timeout = 20000, 73 | }, { 74 | count = 5, 75 | delay = 100, 76 | }, expect(function (err, data) 77 | p(err, data) 78 | assert(not err, err) 79 | end)) 80 | end) 81 | 82 | end) 83 | -------------------------------------------------------------------------------- /hostinfo/debug/NETWORK.json: -------------------------------------------------------------------------------- 1 | {"Debug":{"InfoType":"NETWORK", "OS":"linux"}} 2 | 3 | { 4 | "metrics":[{ 5 | "broadcast":"0.0.0.0", 6 | "mtu":65536, 7 | "address6":"::1", 8 | "rx_packets":16, 9 | "tx_bytes":1184, 10 | "rx_dropped":0, 11 | "tx_carrier":0, 12 | "tx_errors":0, 13 | "tx_overruns":0, 14 | "rx_errors":0, 15 | "tx_collisions":0, 16 | "tx_dropped":0, 17 | "hwaddr":"00:00:00:00:00:00", 18 | "netmask":"255.0.0.0", 19 | "address":"127.0.0.1", 20 | "rx_overruns":0, 21 | "flags":73, 22 | "type":"Local Loopback", 23 | "tx_packets":16, 24 | "name":"lo", 25 | "rx_bytes":1184 26 | },{ 27 | "broadcast":"162.209.76.255", 28 | "mtu":1500, 29 | "address6":"fe80::be76:4eff:fe05:678d", 30 | "rx_packets":3742720, 31 | "tx_bytes":567469458, 32 | "rx_dropped":0, 33 | "tx_carrier":0, 34 | "tx_errors":0, 35 | "tx_overruns":0, 36 | "rx_errors":0, 37 | "tx_collisions":0, 38 | "tx_dropped":0, 39 | "hwaddr":"BC:76:4E:05:67:8D", 40 | "netmask":"255.255.255.0", 41 | "address":"162.209.76.174", 42 | "rx_overruns":0, 43 | "flags":2115, 44 | "type":"Ethernet", 45 | "tx_packets":3454449, 46 | "name":"eth0", 47 | "rx_bytes":1418347018 48 | },{ 49 | "broadcast":"10.182.127.255", 50 | "mtu":1500, 51 | "address6":"fe80::be76:4eff:fe05:6cc5", 52 | "rx_packets":2510, 53 | "tx_bytes":469200, 54 | "rx_dropped":0, 55 | "tx_carrier":0, 56 | "tx_errors":0, 57 | "tx_overruns":0, 58 | "rx_errors":0, 59 | "tx_collisions":0, 60 | "tx_dropped":0, 61 | "hwaddr":"BC:76:4E:05:6C:C5", 62 | "netmask":"255.255.128.0", 63 | "address":"10.182.6.39", 64 | "rx_overruns":0, 65 | "flags":2115, 66 | "type":"Ethernet", 67 | "tx_packets":2357, 68 | "name":"eth1", 69 | "rx_bytes":331680 70 | }], 71 | "timestamp":1441066692000 72 | } -------------------------------------------------------------------------------- /check/filesystem_state.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2016 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local gatherReadWriteReadOnlyInfo = require('../ro').gatherReadWriteReadOnlyInfo 17 | local BaseCheck = require('./base').BaseCheck 18 | local CheckResult = require('./base').CheckResult 19 | local table = require('table') 20 | local los = require('los') 21 | 22 | local FileSystemStateCheck = BaseCheck:extend() 23 | 24 | local UNITS = { 25 | total = 'total', 26 | devices = 'devices' 27 | } 28 | 29 | function FileSystemStateCheck:initialize(params) 30 | BaseCheck.initialize(self, params) 31 | end 32 | 33 | function FileSystemStateCheck:getType() 34 | return 'agent.filesystem_state' 35 | end 36 | 37 | function FileSystemStateCheck:run(callback) 38 | local checkResult = CheckResult:new(self, {}) 39 | if los.type() ~= 'linux' then 40 | checkResult:setStatus("err " .. self:getType() .. " available only on Linux platforms") 41 | self._lastResult = checkResult 42 | return callback(checkResult) 43 | end 44 | local fs_list_ro, fs_list_rw = gatherReadWriteReadOnlyInfo() 45 | checkResult:addMetric('total_ro', nil, nil, #fs_list_ro, UNITS['total']) 46 | checkResult:addMetric('total_rw', nil, nil, #fs_list_rw, UNITS['total']) 47 | checkResult:addMetric('devices_ro', nil, nil, table.concat(fs_list_ro, ','), UNITS['devices']) 48 | checkResult:addMetric('devices_rw', nil, nil, table.concat(fs_list_rw, ','), UNITS['devices']) 49 | callback(checkResult) 50 | end 51 | 52 | exports.FileSystemStateCheck = FileSystemStateCheck 53 | -------------------------------------------------------------------------------- /cmake/package/debian/service.init.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: @APP_NAME@ 4 | # Required-Start: $network 5 | # Required-Stop: $network 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | ### END INIT INFO 9 | 10 | NAME=@APP_NAME@ 11 | DAEMON=/usr/bin/@APP_NAME@ 12 | PIDFILE=/var/run/@APP_NAME@.pid 13 | LOG=/var/log/@APP_NAME@.log 14 | export TMPDIR=/var/lib 15 | 16 | [ -r /etc/default/@APP_NAME@ ] && . /etc/default/@APP_NAME@ 17 | test -f $DAEMON || exit 0 18 | 19 | # If upstart is installed, use it instead 20 | if [ -x /lib/init/upstart-job ]; then 21 | /lib/init/upstart-job @APP_NAME@ $@ 22 | exit $? 23 | fi 24 | 25 | . /lib/lsb/init-functions 26 | 27 | case "$1" in 28 | start) log_daemon_msg "Starting $NAME" "$NAME" 29 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --startas $DAEMON -- -D -p $PIDFILE -l $LOG --production --restart-sysv-on-upgrade $EXTRA_OPTS 30 | log_end_msg $? 31 | ;; 32 | stop) log_daemon_msg "Stopping $NAME" "$NAME" 33 | start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON 34 | log_end_msg $? 35 | ;; 36 | restart) log_daemon_msg "Restarting $NAME" "$NAME" 37 | start-stop-daemon --stop --retry 5 --quiet --pidfile $PIDFILE --exec $DAEMON 38 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --startas $DAEMON -- -D -p $PIDFILE -l $LOG --production --restart-sysv-on-upgrade $EXTRA_OPTS 39 | log_end_msg $? 40 | ;; 41 | status) 42 | log_action_begin_msg "Checking $NAME" 43 | if pidofproc -p "$PIDFILE" >/dev/null; then 44 | log_action_end_msg 0 "running" 45 | exit 0 46 | else 47 | if [ -e "$PIDFILE" ]; then 48 | log_action_end_msg 1 "failed to start" 49 | exit 1 50 | else 51 | log_action_end_msg 0 "not running" 52 | exit 3 53 | fi 54 | fi 55 | ;; 56 | *) log_action_msg "Usage: /etc/init.d/@APP_NAME@ {start|stop|status|restart}" 57 | exit 2 58 | ;; 59 | esac 60 | exit 0 61 | -------------------------------------------------------------------------------- /hostinfo/hostname.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local misc = require('./misc') 18 | local Transform = require('stream').Transform 19 | 20 | -------------------------------------------------------------------------------------------------------------------- 21 | local Reader = Transform:extend() 22 | function Reader:initialize() 23 | Transform.initialize(self, {objectMode = true}) 24 | end 25 | 26 | function Reader:_transform(line, cb) 27 | self:push({hostname = line}) 28 | return cb() 29 | end 30 | -------------------------------------------------------------------------------------------------------------------- 31 | 32 | --[[ Fetch this servers hostname ]]-- 33 | local Info = HostInfo:extend() 34 | function Info:initialize(params) 35 | HostInfo.initialize(self) 36 | end 37 | 38 | function Info:_run(callback) 39 | local command = 'hostname' 40 | local outTable, errTable = {}, {} 41 | 42 | local function finalCb() 43 | self:_pushParams(errTable, outTable) 44 | return callback() 45 | end 46 | 47 | local child = misc.run('sh', {'-c', command}) 48 | local reader = Reader:new() 49 | child:pipe(reader) 50 | reader:on('error', function(err) misc.safeMerge(errTable, err) end) 51 | reader:on('data', function(datum) misc.safeMerge(outTable, datum) end) 52 | reader:once('end', finalCb) 53 | end 54 | 55 | function Info:getPlatforms() 56 | return {'linux'} 57 | end 58 | 59 | function Info:getType() 60 | return 'HOSTNAME' 61 | end 62 | 63 | exports.Info = Info 64 | exports.Reader = Reader 65 | -------------------------------------------------------------------------------- /hostinfo/network.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local sigar = require('sigar') 18 | local table = require('table') 19 | 20 | 21 | --[[ Info ]]-- 22 | local Info = HostInfo:extend() 23 | 24 | function Info:initialize() 25 | HostInfo.initialize(self) 26 | end 27 | function Info:_run(callback) 28 | local ctx = sigar:new() 29 | local netifs = ctx:netifs() 30 | for i=1,#netifs do 31 | local info = netifs[i]:info() 32 | local usage = netifs[i]:usage() 33 | local name = info.name 34 | local obj = {} 35 | 36 | local info_fields = { 37 | 'address', 38 | 'address6', 39 | 'broadcast', 40 | 'flags', 41 | 'hwaddr', 42 | 'mtu', 43 | 'name', 44 | 'netmask', 45 | 'type' 46 | } 47 | local usage_fields = { 48 | 'rx_packets', 49 | 'rx_bytes', 50 | 'rx_errors', 51 | 'rx_overruns', 52 | 'rx_dropped', 53 | 'tx_packets', 54 | 'tx_bytes', 55 | 'tx_errors', 56 | 'tx_overruns', 57 | 'tx_dropped', 58 | 'tx_collisions', 59 | 'tx_carrier', 60 | } 61 | 62 | if info then 63 | for _, v in pairs(info_fields) do 64 | obj[v] = info[v] 65 | end 66 | end 67 | if usage then 68 | for _, v in pairs(usage_fields) do 69 | obj[v] = usage[v] 70 | end 71 | end 72 | obj['name'] = name 73 | table.insert(self._params, obj) 74 | end 75 | callback() 76 | end 77 | 78 | function Info:getType() 79 | return 'NETWORK' 80 | end 81 | 82 | return Info 83 | -------------------------------------------------------------------------------- /hostinfo/sshd.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local HostInfo = require('./base').HostInfo 18 | local run = require('./misc').run 19 | local Transform = require('stream').Transform 20 | 21 | -------------------------------------------------------------------------------------------------------------------- 22 | local Reader = Transform:extend() 23 | function Reader:initialize() 24 | Transform.initialize(self, {objectMode = true}) 25 | end 26 | 27 | function Reader:_transform(line, cb) 28 | line = line:gsub("^%s*(.-)%s*$", "%1") 29 | local _, _, key, value = line:find("(.*)%s(.*)") 30 | if key then self:push({[key] = value}) end 31 | cb() 32 | end 33 | -------------------------------------------------------------------------------------------------------------------- 34 | 35 | local Info = HostInfo:extend() 36 | 37 | function Info:_run(callback) 38 | local outTable, errTable = {}, {} 39 | local cmd, args = 'sshd', {'-T'} 40 | 41 | local function finalCb() 42 | self:_pushParams(errTable, outTable) 43 | return callback() 44 | end 45 | 46 | local child = run(cmd, args) 47 | local reader = Reader:new() 48 | child:pipe(reader) 49 | reader:on('data', function(data) 50 | for k, v in pairs(data) do 51 | outTable[k] = v 52 | end 53 | end) 54 | reader:on('error', function(data) table.insert(errTable, data) end) 55 | reader:once('end', finalCb) 56 | end 57 | 58 | function Info:getPlatforms() 59 | return {'linux', 'darwin'} 60 | end 61 | 62 | function Info:getType() 63 | return 'SSHD' 64 | end 65 | 66 | exports.Info = Info 67 | exports.Reader = Reader 68 | -------------------------------------------------------------------------------- /hostinfo/filesystem.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local sigar = require('sigar') 18 | local GetOptionsStringForFs = require('../check/filesystem').GetOptionsStringForFs 19 | 20 | --[[ Filesystem Info ]]-- 21 | local Info = HostInfo:extend() 22 | function Info:initialize() 23 | HostInfo.initialize(self) 24 | end 25 | function Info:_run(callback) 26 | local ctx = sigar:new() 27 | local fses = ctx:filesystems() 28 | for i=1, #fses do 29 | local obj = {} 30 | local fs = fses[i] 31 | local info = fs:info() 32 | local usage = fs:usage() 33 | if info then 34 | local info_fields = { 35 | 'dir_name', 36 | 'dev_name', 37 | 'sys_type_name', 38 | 'options', 39 | } 40 | for _, v in pairs(info_fields) do 41 | if v == 'options' then 42 | local opts = GetOptionsStringForFs(info.dir_name) 43 | if opts then 44 | obj[v] = opts 45 | else 46 | obj[v] = info[v] 47 | end 48 | else 49 | obj[v] = info[v] 50 | end 51 | end 52 | end 53 | 54 | if usage then 55 | local usage_fields = { 56 | 'total', 57 | 'free', 58 | 'used', 59 | 'avail', 60 | 'files', 61 | 'free_files', 62 | } 63 | for _, v in pairs(usage_fields) do 64 | obj[v] = usage[v] 65 | end 66 | end 67 | 68 | table.insert(self._params, obj) 69 | end 70 | callback() 71 | end 72 | 73 | function Info:getType() 74 | return 'FILESYSTEM' 75 | end 76 | 77 | return Info 78 | -------------------------------------------------------------------------------- /hostinfo/sysctl.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local HostInfo = require('./base').HostInfo 18 | local run = require('./misc').run 19 | local Transform = require('stream').Transform 20 | 21 | -------------------------------------------------------------------------------------------------------------------- 22 | local Reader = Transform:extend() 23 | 24 | function Reader:initialize() 25 | Transform.initialize(self, {objectMode = true}) 26 | end 27 | 28 | function Reader:_transform(line, cb) 29 | line = line:gsub("^%s*(.-)%s*$", "%1") 30 | local _, _, key, value = line:find("([^=^%s]+)%s*=%s*([^=]*)") 31 | if key and value then self:push({[key] = value}) end 32 | cb() 33 | end 34 | -------------------------------------------------------------------------------------------------------------------- 35 | local Info = HostInfo:extend() 36 | 37 | function Info:_run(callback) 38 | local outTable, errTable = {}, {} 39 | local cmd, args = 'sysctl', {'-A'} 40 | 41 | local function finalCb() 42 | self:_pushParams(errTable, outTable) 43 | return callback() 44 | end 45 | 46 | local child = run(cmd, args) 47 | local reader = Reader:new() 48 | child:pipe(reader) 49 | reader:on('data', function(data) 50 | for k, v in pairs(data) do 51 | outTable[k] = v 52 | end 53 | end) 54 | reader:on('error', function(data) table.insert(errTable, data) end) 55 | reader:once('end', finalCb) 56 | end 57 | 58 | function Info:getPlatforms() 59 | return {'linux', 'darwin', 'freebsd', 'openbsd', 'netbsd'} 60 | end 61 | 62 | function Info:getType() 63 | return 'SYSCTL' 64 | end 65 | 66 | exports.Info = Info 67 | exports.Reader = Reader -------------------------------------------------------------------------------- /hostinfo/lshw.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2017 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local jsonParse = require('json').parse 18 | local uv = require('uv') 19 | 20 | --[[ Info ]]-- 21 | local Info = HostInfo:extend() 22 | function Info:initialize() 23 | HostInfo.initialize(self) 24 | end 25 | 26 | function Info:_run(callback) 27 | self._params = {} 28 | local params = self._params 29 | local child, pid 30 | local stdout = uv.new_pipe(false) 31 | local count = 2 32 | 33 | local function finish(err) 34 | if not child:is_closing() then child:close() end 35 | if not stdout:is_closing() then stdout:close() end 36 | return callback(err) 37 | end 38 | 39 | child, pid = uv.spawn("lshw", { 40 | args = {"-json"}, 41 | stdio = {nil, stdout} 42 | }, function (code, signal) 43 | if code ~= 0 then 44 | return finish("lshw exited with exit code " .. code) 45 | end 46 | count = count - 1 47 | if count == 0 then 48 | finish() 49 | end 50 | end) 51 | if not child then 52 | stdout:close() 53 | if pid:match("^ENOENT:") then 54 | error "Cannot find `lshw` in system path" 55 | end 56 | error(pid) 57 | end 58 | local chunks = {} 59 | stdout:read_start(function (err, chunk) 60 | assert(not err, err) 61 | if chunk then 62 | chunks[#chunks + 1] = chunk 63 | return 64 | end 65 | params.info = jsonParse(table.concat(chunks)) 66 | count = count - 1 67 | if count == 0 then 68 | finish() 69 | end 70 | end) 71 | 72 | end 73 | 74 | function Info:getType() 75 | return 'LSHW' 76 | end 77 | 78 | function Info:getPlatforms() 79 | return {'linux'} 80 | end 81 | 82 | 83 | return Info 84 | -------------------------------------------------------------------------------- /hostinfo/login.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local misc = require('./misc') 18 | local Transform = require('stream').Transform 19 | 20 | -------------------------------------------------------------------------------------------------------------------- 21 | local Reader = Transform:extend() 22 | function Reader:initialize() 23 | Transform.initialize(self, {objectMode = true}) 24 | end 25 | 26 | function Reader:_transform(line, cb) 27 | local iter = line:gmatch("%S+") 28 | local key = iter() 29 | local val = iter() 30 | self:push({[key] = val}) 31 | return cb() 32 | end 33 | -------------------------------------------------------------------------------------------------------------------- 34 | 35 | --[[ Login ]]-- 36 | local Info = HostInfo:extend() 37 | function Info:initialize() 38 | HostInfo.initialize(self) 39 | end 40 | 41 | function Info:_run(callback) 42 | local filename = "/etc/login.defs" 43 | local outTable, errTable = {}, {} 44 | 45 | local function finalCb() 46 | self:_pushParams(errTable, outTable) 47 | return callback() 48 | end 49 | 50 | local readStream = misc.read(filename) 51 | local reader = Reader:new() 52 | -- Catch no file found errors 53 | readStream:on('error', function(err) 54 | misc.safeMerge(errTable, err) 55 | return finalCb() 56 | end) 57 | readStream:pipe(reader) 58 | reader:on('data', function(data) misc.safeMerge(outTable, data) end) 59 | reader:on('error', function(err) misc.safeMerge(errTable, err) end) 60 | reader:once('end', finalCb) 61 | end 62 | 63 | function Info:getPlatforms() 64 | return {'linux'} 65 | end 66 | 67 | function Info:getType() 68 | return 'LOGIN' 69 | end 70 | 71 | exports.Info = Info 72 | exports.Reader = Reader -------------------------------------------------------------------------------- /remote/http-auth.lua: -------------------------------------------------------------------------------- 1 | -- TODO: publish this to lit for others to use 2 | 3 | local base64 = require('openssl').base64 4 | local digest = require('openssl').digest.digest 5 | 6 | -- For HTTP basic auth, simply omit authProps entirely. 7 | -- For HTTP Digest auth, pass in pre-parsed auth properties 8 | -- authProps accepts the following keys: 9 | -- method (GET, POST, PUT, etc...) 10 | -- uri (example /dir/index.html) 11 | -- realm (example user@example.com) 12 | -- nonce (server-generated random value) 13 | -- opaque - (server-generated opaque value) 14 | -- qop - optional(auth or auth-int) 15 | -- algorithm - optional(MD5 or MD5-sess) 16 | -- body optional(entitybody for MD5-sess) 17 | return function (username, password, authProps) 18 | if not authProps then 19 | return "Basic " .. 20 | base64(username .. ":" .. password):gsub("\n", "") 21 | end 22 | 23 | local nc = "00000001" 24 | local cnonce = string.format("%08x", math.random(0x100000000)) 25 | 26 | local ha1, ha2, response 27 | 28 | -- Calculate HA1 29 | ha1 = digest("md5", table.concat({ 30 | username, authProps.realm, password 31 | }, ":")) 32 | if authProps.algorithm == "MD5-sess" then 33 | ha1 = digest("md5", table.concat({ 34 | ha1, authProps.nonce, cnonce 35 | }, ":")) 36 | end 37 | 38 | -- Calculate HA2 39 | if authProps.qop == "auth-int" then 40 | ha2 = digest("md5", table.concat({ 41 | authProps.method, authProps.uri, 42 | digest("md5", authProps.body) 43 | }, ":")) 44 | else 45 | if authProps.qop then authProps.qop = "auth" end 46 | ha2 = digest("md5", table.concat({ 47 | authProps.method, authProps.uri 48 | }, ":")) 49 | end 50 | 51 | -- Calculate Response 52 | if authProps.qop then 53 | response = digest("md5", table.concat({ 54 | ha1, authProps.nonce, nc, cnonce, authProps.qop, ha2, 55 | }, ":")) 56 | else 57 | response = digest("md5", table.concat({ 58 | ha1, authProps.nonce, ha2 59 | }, ":")) 60 | end 61 | 62 | -- Form Authorization header value 63 | return string.format('Digest ' .. 64 | ' username="%s", realm="%s", nonce="%s", uri="%s",' .. 65 | ' response="%s", opaque="%s", qop=%s, nc=%s, cnonce="%s"', 66 | username, authProps.realm, authProps.nonce, authProps.uri, 67 | response, authProps.opaque, authProps.qop, nc, cnonce) 68 | 69 | end 70 | -------------------------------------------------------------------------------- /tests/fixtures/hostinfo/deleted_libs.txt: -------------------------------------------------------------------------------- 1 | lsof 30608 root cwd DIR 202,1 4096 663141 /root/rackspace-monitoring-agent 2 | lsof 30608 root rtd DIR 202,1 4096 2 / 3 | lsof 30608 root txt REG 202,1 163224 405760 /usr/bin/lsof 4 | lsof 30608 root mem REG 202,1 3165552 393365 /usr/lib/locale/locale-archive 5 | lsof 30608 root mem REG 202,1 1869392 917554 /lib/x86_64-linux-gnu/libc-2.21.so 6 | lsof 30608 root mem REG 202,1 154376 917540 /lib/x86_64-linux-gnu/ld-2.21.so 7 | lsof 30608 root 0u CHR 136,0 0t0 3 /dev/pts/0 8 | lsof 30608 root 1u CHR 136,0 0t0 3 /dev/pts/0 9 | lsof 30608 root 2u CHR 136,0 0t0 3 /dev/pts/0 10 | lsof 30608 root 3r DIR 0,4 0 1 /proc 11 | lsof 30608 root 4r DIR 0,4 0 3510928 /proc/30608/fd 12 | lsof 30608 root 5w FIFO 0,9 0t0 3510933 pipe 13 | lsof 30608 root 6r FIFO 0,9 0t0 3510934 pipe 14 | lsof 30609 root cwd DIR 202,1 4096 663141 /root/rackspace-monitoring-agent 15 | lsof 30609 root rtd DIR 202,1 4096 2 / 16 | lsof 30609 root txt REG 202,1 163224 405760 /usr/bin/lsof 17 | lsof 30609 root mem REG 202,1 3165552 393365 /usr/lib/locale/locale-archive 18 | lsof 30609 root mem REG 202,1 1869392 917554 /lib/x86_64-linux-gnu/libc-2.21.so 19 | lsof 30609 root mem REG 202,1 154376 917540 /lib/x86_64-linux-gnu/ld-2.21.so 20 | lsof 30609 root 4r FIFO 0,9 0t0 3510933 pipe 21 | lsof 30609 root 7w FIFO 0,9 0t0 3510934 pipe 22 | -------------------------------------------------------------------------------- /hostinfo/services.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local table = require('table') 18 | local fs = require('fs') 19 | local async = require('async') 20 | local fmt = string.format 21 | 22 | --[[ Installed services info ]]-- 23 | local Info = HostInfo:extend() 24 | 25 | 26 | function Info:_run(callback) 27 | local init, initd, system, systemv, systemd, errTable, outTable 28 | init = '/etc/init/' 29 | initd = '/etc/init.d' 30 | system = '/usr/lib/systemd/system' 31 | systemd = { 32 | '/etc/systemd/system/multi-user.target.wants/', 33 | '/etc/systemd/system/basic.target.wants/' 34 | } 35 | systemv = '/etc/rc3.d' 36 | errTable, outTable = {}, {} 37 | 38 | local function scanDir(path, key, cb) 39 | fs.readdir(path, function(err, data) 40 | if err then 41 | table.insert(errTable, fmt('Error reading services directory: %s . You can probably ignore this error', err)) 42 | return cb() 43 | end 44 | outTable[key] = data 45 | return cb() 46 | end) 47 | end 48 | 49 | async.parallel({ 50 | function(cb) 51 | scanDir(init, 'init', cb) 52 | end, 53 | function(cb) 54 | scanDir(initd, 'initd', cb) 55 | end, 56 | function(cb) 57 | scanDir(system, 'system', cb) 58 | end, 59 | function(cb) 60 | scanDir(systemv, 'systemv', cb) 61 | end, 62 | function(cb) 63 | scanDir(systemd[1], 'systemd', cb) 64 | end, 65 | function(cb) 66 | scanDir(systemd[2], 'systemd', cb) 67 | end 68 | }, function() 69 | self:_pushParams(errTable, outTable) 70 | return callback() 71 | end) 72 | end 73 | 74 | function Info:getType() 75 | return 'SERVICES' 76 | end 77 | 78 | function Info:getPlatforms() 79 | return {'linux'} 80 | end 81 | 82 | return Info 83 | -------------------------------------------------------------------------------- /hostinfo/ip6routes.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local HostInfo = require('./base').HostInfo 18 | local run = require('./misc').run 19 | local Transform = require('stream').Transform 20 | 21 | -------------------------------------------------------------------------------------------------------------------- 22 | local Reader = Transform:extend() 23 | 24 | function Reader:initialize() 25 | Transform.initialize(self, {objectMode = true}) 26 | end 27 | 28 | function Reader:_transform(line, cb) 29 | local iter = line:gmatch("%S+") 30 | local firstw = iter() 31 | if firstw ~= 'Destination' and firstw ~= 'Kernel' then 32 | self:push({ 33 | destination = firstw, 34 | next_hop = iter(), 35 | flag = iter(), 36 | met = iter(), 37 | ref = iter(), 38 | use = iter(), 39 | iface = iter() 40 | }) 41 | end 42 | cb() 43 | end 44 | -------------------------------------------------------------------------------------------------------------------- 45 | 46 | local Info = HostInfo:extend() 47 | function Info:initialize() 48 | HostInfo.initialize(self) 49 | end 50 | 51 | function Info:_run(callback) 52 | local errTable, outTable = {}, {} 53 | local cmd, args = 'netstat', {'-nr6'} 54 | 55 | local function finalCb() 56 | self:_pushParams(errTable, outTable) 57 | return callback() 58 | end 59 | 60 | local child = run(cmd, args) 61 | local reader = Reader:new() 62 | child:pipe(reader) 63 | reader:on('data', function(data) table.insert(outTable, data) end) 64 | reader:on('error', function(data) table.insert(errTable, data) end) 65 | reader:once('end', finalCb) 66 | end 67 | 68 | function Info:getPlatforms() 69 | return {'linux'} 70 | end 71 | 72 | function Info:getType() 73 | return 'IP6ROUTES' 74 | end 75 | 76 | exports.Info = Info 77 | exports.Reader = Reader 78 | -------------------------------------------------------------------------------- /hostinfo/fstab.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ]]-- 16 | local HostInfo = require('./base').HostInfo 17 | local read = require('./misc').read 18 | local Transform = require('stream').Transform 19 | -------------------------------------------------------------------------------------------------------------------- 20 | local Reader = Transform:extend() 21 | function Reader:initialize() 22 | Transform.initialize(self, {objectMode = true}) 23 | end 24 | 25 | function Reader:_transform(line, cb) 26 | local out = {} 27 | local iter = line:gmatch("%S+") 28 | local types = {'file_system', 'mount_point', 'type', 'options', 'pass' } 29 | for i = 1, #types do 30 | out[types[i]] = iter() 31 | end 32 | self:push(out) 33 | return cb() 34 | end 35 | -------------------------------------------------------------------------------------------------------------------- 36 | 37 | --[[ Check fstab ]]-- 38 | local Info = HostInfo:extend() 39 | function Info:initialize() 40 | HostInfo.initialize(self) 41 | end 42 | 43 | function Info:_run(callback) 44 | local filename = '/etc/fstab' 45 | local ouTable, errTable = {}, {} 46 | 47 | local function finalCb() 48 | self:_pushParams(errTable, ouTable) 49 | return callback() 50 | end 51 | 52 | local readStream = read(filename) 53 | local reader = Reader:new() 54 | -- Catch no file found errors 55 | readStream:on('error', function(err) 56 | table.insert(errTable, err) 57 | return finalCb() 58 | end) 59 | readStream:pipe(reader) 60 | reader:on('data', function(data) table.insert(ouTable, data) end) 61 | reader:on('error', function(err) table.insert(errTable, err) end) 62 | reader:once('end', finalCb) 63 | end 64 | 65 | function Info:getPlatforms() 66 | return {'linux'} 67 | end 68 | 69 | function Info:getType() 70 | return 'FSTAB' 71 | end 72 | 73 | exports.Info = Info 74 | exports.Reader = Reader -------------------------------------------------------------------------------- /hostinfo/ip4routes.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local HostInfo = require('./base').HostInfo 18 | local run = require('./misc').run 19 | local Transform = require('stream').Transform 20 | 21 | -------------------------------------------------------------------------------------------------------------------- 22 | local Reader = Transform:extend() 23 | 24 | function Reader:initialize() 25 | Transform.initialize(self, {objectMode = true}) 26 | end 27 | 28 | function Reader:_transform(line, cb) 29 | local iter = line:gmatch("%S+") 30 | local firstw = iter() 31 | if firstw ~= 'Destination' and firstw ~= 'Kernel' then 32 | self:push({ 33 | destination = firstw, 34 | gateway = iter(), 35 | genmask = iter(), 36 | flags = iter(), 37 | mss = iter(), 38 | window = iter(), 39 | irtt = iter(), 40 | iface = iter() 41 | }) 42 | end 43 | cb() 44 | end 45 | 46 | -------------------------------------------------------------------------------------------------------------------- 47 | 48 | local Info = HostInfo:extend() 49 | function Info:initialize() 50 | HostInfo.initialize(self) 51 | end 52 | 53 | function Info:_run(callback) 54 | local errTable, outTable = {}, {} 55 | local cmd, args = 'netstat', {'-nr4'} 56 | 57 | local function finalCb() 58 | self:_pushParams(errTable, outTable) 59 | return callback() 60 | end 61 | 62 | local child = run(cmd, args) 63 | local reader = Reader:new() 64 | child:pipe(reader) 65 | reader:on('data', function(data) table.insert(outTable, data) end) 66 | reader:on('error', function(data) table.insert(errTable, data) end) 67 | reader:once('end', finalCb) 68 | end 69 | 70 | function Info:getPlatforms() 71 | return {'linux'} 72 | end 73 | 74 | function Info:getType() 75 | return 'IP4ROUTES' 76 | end 77 | 78 | exports.Info = Info 79 | exports.Reader = Reader -------------------------------------------------------------------------------- /static/tests/hostinfo/fail2ban_activitylog_in.txt: -------------------------------------------------------------------------------- 1 | 2015-08-27 18:35:32,782 fail2ban.server [12228]: INFO Changed logging target to /var/log/fail2ban.log for$ 2 | 2015-08-27 18:35:32,840 fail2ban.database [12228]: INFO Connected to fail2ban persistent database '/var/lib$ 3 | 2015-08-27 18:35:32,900 fail2ban.database [12228]: WARNING New database created. Version '2' 4 | 2015-08-27 18:35:32,902 fail2ban.jail [12228]: INFO Creating new jail 'sshd' 5 | 2015-08-27 18:35:33,144 fail2ban.jail [12228]: INFO Jail 'sshd' uses pyinotify 6 | 2015-08-27 18:35:33,166 fail2ban.filter [12228]: INFO Set jail log file encoding to UTF-8 7 | 2015-08-27 18:35:33,171 fail2ban.jail [12228]: INFO Initiated 'pyinotify' backend 8 | 2015-08-27 18:35:33,179 fail2ban.actions [12228]: INFO Set banTime = 600 9 | 2015-08-27 18:35:33,179 fail2ban.filter [12228]: INFO Set findtime = 600 10 | 2015-08-27 18:35:33,224 fail2ban.filter [12228]: INFO Added logfile = /var/log/auth.log 11 | 2015-08-27 18:35:33,242 fail2ban.filter [12228]: INFO Set maxRetry = 5 12 | 2015-08-27 18:35:33,243 fail2ban.filter [12228]: INFO Set jail log file encoding to UTF-8 13 | 2015-08-27 18:35:33,244 fail2ban.filter [12228]: INFO Set maxlines = 10 14 | 2015-08-27 18:35:33,310 fail2ban.server [12228]: INFO Jail sshd is not a JournalFilter instance 15 | 2015-08-27 18:35:33,318 fail2ban.jail [12228]: INFO Jail 'sshd' started 16 | 2015-08-27 18:39:02,454 fail2ban.filter [12228]: INFO [sshd] Found 43.229.53.20 17 | 2015-08-27 18:39:02,456 fail2ban.filter [12228]: INFO [sshd] Found 58.218.211.166 18 | 2015-08-27 18:39:02,463 fail2ban.filter [12228]: INFO [sshd] Found 43.229.53.20 19 | 2015-08-27 18:39:02,476 fail2ban.filter [12228]: INFO [sshd] Found 58.218.211.166 20 | 2015-08-27 18:49:05,849 fail2ban.actions [12228]: NOTICE [sshd] Unban 43.229.53.20 21 | 2015-08-27 19:24:15,683 fail2ban.actions [12228]: NOTICE [sshd] Ban 43.229.53.20 22 | 2015-08-27 19:34:16,643 fail2ban.actions [12228]: NOTICE [sshd] Unban 43.229.53.20 23 | 2015-08-27 20:14:40,828 fail2ban.actions [12228]: NOTICE [sshd] Ban 43.229.53.20 24 | 25 | 2015-08-27 20:55:13,275 fail2ban.actions [12228]: NOTICE [sshd] Ban 43.229.53.20 26 | 2015-08-27 21:05:14,238 fail2ban.actions [12228]: NOTICE [sshd] Unban 43.229.53.20 27 | -------------------------------------------------------------------------------- /check/windows/os.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2013 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | 17 | local WindowsPowershellCmdletCheck = require('./winbase').WindowsPowershellCmdletCheck 18 | local string = require('string') 19 | 20 | local WindowsPerfOSCheck = WindowsPowershellCmdletCheck:extend() 21 | 22 | function WindowsPerfOSCheck:initialize(params) 23 | local cmd = "(get-wmiobject -ErrorVariable virgo_err Win32_PerfFormattedData_PerfOS_System).Properties | Select Name, Value, Type | ConvertTo-Csv" 24 | 25 | WindowsPowershellCmdletCheck.initialize(self, cmd, params) 26 | end 27 | 28 | function WindowsPerfOSCheck:getType() 29 | return 'agent.windows_perfos' 30 | end 31 | 32 | function WindowsPerfOSCheck:handle_entry(entry) 33 | local metric = nil 34 | if entry.Name then 35 | local blacklist = { 36 | Caption=true, 37 | Description=true, 38 | Name=true, 39 | Frequency_Object=true, 40 | Frequency_PerfTime=true, 41 | Frequency_Sys100NS=true, 42 | Timestamp_Object=true, 43 | Timestamp_PerfTime=true, 44 | Timestamp_Sys100NS=true 45 | } 46 | local type_map = { 47 | uint8='uint32', 48 | uint16='uint32', 49 | uint32='uint32', 50 | uint64='uint64', 51 | sint8='int32', 52 | sint16='int32', 53 | sint32='int32', 54 | sint64='int64', 55 | real32='double', 56 | real64='double' 57 | } 58 | 59 | if not blacklist[entry.Name] then 60 | local type = 'string' 61 | if type_map[string.lower(entry.Type)] then 62 | type = type_map[string.lower(entry.Type)] 63 | end 64 | 65 | metric = { 66 | Name = entry.Name, 67 | Dimension = nil, 68 | Type = type, 69 | Value = entry.Value, 70 | unit = '' 71 | } 72 | end 73 | end 74 | return metric 75 | end 76 | 77 | 78 | local exports = {} 79 | exports.WindowsPerfOSCheck = WindowsPerfOSCheck 80 | return exports 81 | -------------------------------------------------------------------------------- /hostinfo/procs.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Copyright 2015 Rackspace 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS-IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | --]] 16 | local HostInfo = require('./base').HostInfo 17 | local sigar = require('sigar') 18 | 19 | --[[ Process Info ]]-- 20 | local Info = HostInfo:extend() 21 | 22 | function Info:initialize() 23 | HostInfo.initialize(self) 24 | end 25 | function Info:_run(callback) 26 | local ctx, procs 27 | ctx = sigar:new() 28 | procs = ctx:procs() 29 | for i=1, #procs do 30 | local pid = procs[i] 31 | local proc = ctx:proc(pid) 32 | local obj = {} 33 | obj.pid = pid 34 | 35 | local t = proc:exe() 36 | if t then 37 | local exe_fields = { 38 | 'name', 39 | 'cwd', 40 | 'root' 41 | } 42 | for _, v in pairs(exe_fields) do 43 | obj['exe_' .. v] = t[v] 44 | end 45 | end 46 | 47 | t = proc:time() 48 | if t then 49 | local time_fields = { 50 | 'start_time', 51 | 'user', 52 | 'sys', 53 | 'total' 54 | } 55 | for _, v in pairs(time_fields) do 56 | obj['time_' .. v] = t[v] 57 | end 58 | end 59 | 60 | t = proc:state() 61 | if t then 62 | local proc_fields = { 63 | 'name', 64 | 'ppid', 65 | 'priority', 66 | 'nice', 67 | 'threads' 68 | } 69 | for _, v in pairs(proc_fields) do 70 | obj['state_' .. v] = t[v] 71 | end 72 | end 73 | 74 | t = proc:mem() 75 | if t then 76 | local memory_fields = { 77 | 'size', 78 | 'resident', 79 | 'share', 80 | 'major_faults', 81 | 'minor_faults', 82 | 'page_faults' 83 | } 84 | for _, v in pairs(memory_fields) do 85 | obj['memory_' .. v] = t[v] 86 | end 87 | end 88 | 89 | table.insert(self._params, obj) 90 | end 91 | callback() 92 | end 93 | 94 | function Info:getType() 95 | return 'PROCS' 96 | end 97 | 98 | return Info 99 | --------------------------------------------------------------------------------