summaryrefslogtreecommitdiffstats
path: root/tests/alarm_repetition
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-11-28 04:53:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-11-28 04:53:08 +0000
commit315e0143f65da3485dcbcd2f6a3172a351618aec (patch)
treeb713ae472cffab249c95917c6fb6d242d54e0a87 /tests/alarm_repetition
parentAdding upstream version 1.18.1. (diff)
downloadnetdata-315e0143f65da3485dcbcd2f6a3172a351618aec.tar.xz
netdata-315e0143f65da3485dcbcd2f6a3172a351618aec.zip
Adding upstream version 1.19.0.upstream/1.19.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/alarm_repetition')
-rw-r--r--tests/alarm_repetition/alarm.sh89
-rw-r--r--tests/alarm_repetition/netdata.conf_with_repetition57
-rw-r--r--tests/alarm_repetition/netdata.conf_without_repetition57
-rw-r--r--tests/alarm_repetition/ram_with_repetition.conf64
-rw-r--r--tests/alarm_repetition/ram_without_repetition.conf63
5 files changed, 89 insertions, 241 deletions
diff --git a/tests/alarm_repetition/alarm.sh b/tests/alarm_repetition/alarm.sh
new file mode 100644
index 000000000..94e36fbe0
--- /dev/null
+++ b/tests/alarm_repetition/alarm.sh
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+#The health directory to put the alarms
+HEALTHDIR="/etc/netdata/health.d/"
+
+#output directory
+OUTDIR="workdir/"
+
+#url to do download
+QUERY="/api/v1/alarms?active"
+MURL="http://localhost:19999$QUERY"
+
+#error messages
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+NOCOLOR='\033[0m'
+
+MYCDIR="$(pwd)"
+CONFFILE="$MYCDIR/netdata.conf"
+
+change_alarm_file() {
+ if [ -f "$1" ]; then
+ rm "$1"
+ fi
+
+ #copy keeping the permissions
+ cp -a "$2" "$3"
+}
+
+netdata_test_download() {
+ OPT="-e"
+ if [ "$3" == "I" ]; then
+ OPT="-v"
+ fi
+
+ grep "HTTP/1.1 200 OK" "$1" 2>/dev/null 1>/dev/null
+ TEST="$?"
+ if [ "$TEST" -ne "0" ]; then
+ echo -e "${RED} Error to get the alarms. ${NOCOLOR}"
+ kill "$5"
+ rm "$HEALTHDIR/ram.conf"
+ exit 1
+ fi
+
+ COUNT=$(grep -w "\"last_repeat\":" "$2" | grep -c "$OPT" "\"0\"")
+ if [ "$COUNT" -eq "0" ]; then
+ echo -e "${RED} Netdata gave an unexpected result when alarm repetition is $4 ${NOCOLOR}"
+ killall "$5"
+ rm "$HEALTHDIR/ram.conf"
+ exit 1
+ fi
+
+ echo -e "${GREEN} I got the expected result ${NOCOLOR}"
+}
+
+get_the_logs() {
+ curl -v -k --create-dirs -o "$OUTDIR/$1.out" "$MURL" 2> "$OUTDIR/$1.err"
+ netdata_test_download "$OUTDIR/$1.err" "$OUTDIR/$1.out" "$2" "$3" "$4"
+}
+
+process_data() {
+ SEC=120
+ netdata -c "$CONFFILE" -D &
+ NETDATAPID=$!
+ echo -e "${NOCOLOR}Sleeping during $SEC seconds to create alarm entries"
+ sleep $SEC
+ get_the_logs "$1" "$2" "$3" "$NETDATAPID"
+ kill $NETDATAPID
+}
+
+mkdir "$OUTDIR"
+CREATEDIR="$?"
+if [ "$CREATEDIR" -ne "0" ]; then
+ echo -e "${RED}Cannot create the output directory, it already exists. The test will overwrite previous results. ${NOCOLOR}"
+fi
+
+change_alarm_file "./0" "ram_without_repetition.conf" "$HEALTHDIR/ram.conf"
+cp -a netdata.conf_without_repetition netdata.conf
+process_data "ram_without" "K" "not activated."
+rm netdata.conf
+
+change_alarm_file "$HEALTHDIR/ram.conf" "ram_with_repetition.conf" "$HEALTHDIR/ram.conf"
+cp -a netdata.conf_with_repetition netdata.conf
+process_data "ram_with" "I" "activated."
+rm netdata.conf
+
+echo -e "${GREEN} all the tests were sucessful ${NOCOLOR}"
+rm "$HEALTHDIR/ram.conf"
+rm -rf $OUTDIR
diff --git a/tests/alarm_repetition/netdata.conf_with_repetition b/tests/alarm_repetition/netdata.conf_with_repetition
deleted file mode 100644
index 5e02288db..000000000
--- a/tests/alarm_repetition/netdata.conf_with_repetition
+++ /dev/null
@@ -1,57 +0,0 @@
-# netdata configuration
-#
-# You can download the latest version of this file, using:
-#
-# wget -O /etc/netdata/netdata.conf http://localhost:19999/netdata.conf
-# or
-# curl -o /etc/netdata/netdata.conf http://localhost:19999/netdata.conf
-#
-# You can uncomment and change any of the options below.
-# The value shown in the commented settings, is the default value.
-#
-
-# global netdata configuration
-
-[global]
- #run as user = netdata
-
-[web]
- #ssl key = /etc/netdata/ssl/key2048.pem
- #ssl certificate = /etc/netdata/ssl/cert2048.pem
- mode = static-threaded
- # listen backlog = 4096
- default port = 19999
- #bind to = *=dashboard|registry|streaming|netdata.conf|badges|management *:20000=dashboard|registry|streaming|netdata.conf|badges|management^SSL=optional *:20001=dashboard|registry|streaming|netdata.conf|badges|management^SSL=force unix:/tmp/netdata/netdata.sock
- # web files owner = netdata
- # web files group = netdata
- #accept a streaming request every seconds = 2
-
-[plugins]
- proc = yes
- diskspace = no
- cgroups = no
- tc = no
- idlejitter = no
- enable running new plugins = no
- check for new plugins every = 60
- go.d = no
- node.d = no
- charts.d = no
- nfacct = no
- python.d = no
- apps = no
- fping = no
- cups = no
-
-[health]
- enabled = yes
- in memory max health log entries = 1000
- default repeat warning = 4s
- default repeat critical = 2s
-
-[registry]
- enabled = yes
- allow from = *
-
-[cloud]
- cloud base url = https://netdata.cloud
diff --git a/tests/alarm_repetition/netdata.conf_without_repetition b/tests/alarm_repetition/netdata.conf_without_repetition
deleted file mode 100644
index 80513ecb7..000000000
--- a/tests/alarm_repetition/netdata.conf_without_repetition
+++ /dev/null
@@ -1,57 +0,0 @@
-# netdata configuration
-#
-# You can download the latest version of this file, using:
-#
-# wget -O /etc/netdata/netdata.conf http://localhost:19999/netdata.conf
-# or
-# curl -o /etc/netdata/netdata.conf http://localhost:19999/netdata.conf
-#
-# You can uncomment and change any of the options below.
-# The value shown in the commented settings, is the default value.
-#
-
-# global netdata configuration
-
-[global]
- #run as user = netdata
-
-[web]
- #ssl key = /etc/netdata/ssl/key2048.pem
- #ssl certificate = /etc/netdata/ssl/cert2048.pem
- mode = static-threaded
- # listen backlog = 4096
- default port = 19999
- #bind to = *=dashboard|registry|streaming|netdata.conf|badges|management *:20000=dashboard|registry|streaming|netdata.conf|badges|management^SSL=optional *:20001=dashboard|registry|streaming|netdata.conf|badges|management^SSL=force unix:/tmp/netdata/netdata.sock
- # web files owner = netdata
- # web files group = netdata
- #accept a streaming request every seconds = 2
-
-[plugins]
- proc = yes
- diskspace = no
- cgroups = no
- tc = no
- idlejitter = no
- enable running new plugins = no
- check for new plugins every = 60
- go.d = no
- node.d = no
- charts.d = no
- nfacct = no
- python.d = no
- apps = no
- fping = no
- cups = no
-
-[health]
- enabled = yes
- in memory max health log entries = 1000
- #default repeat warning = 4s
- #default repeat critical = 2s
-
-[registry]
- enabled = yes
- allow from = *
-
-[cloud]
- cloud base url = https://netdata.cloud
diff --git a/tests/alarm_repetition/ram_with_repetition.conf b/tests/alarm_repetition/ram_with_repetition.conf
deleted file mode 100644
index c215a71d7..000000000
--- a/tests/alarm_repetition/ram_with_repetition.conf
+++ /dev/null
@@ -1,64 +0,0 @@
-# you can disable an alarm notification by setting the 'to' line to: silent
-
- alarm: used_ram_to_ignore
- on: system.ram
- os: linux freebsd
- hosts: *
- calc: ($zfs.arc_size.arcsz = nan)?(0):($zfs.arc_size.arcsz)
- every: 10s
- info: the amount of memory that is reported as used, but it is actually capable for resizing itself based on the system needs (eg. ZFS ARC)
-
- alarm: ram_in_use
- on: system.ram
- os: linux
- hosts: *
-# calc: $used * 100 / ($used + $cached + $free)
- calc: ($used - $used_ram_to_ignore) * 100 / ($used - $used_ram_to_ignore + $cached + $free)
- units: %
- every: 1s
- warn: $this > 1
- crit: $this > 5
- delay: down 15m multiplier 1.5 max 1h
- info: system RAM used
- to: sysadmin #alarms
- repeat: warning 30s critical 60s
-
- alarm: ram_available
- on: mem.available
- os: linux
- hosts: *
- calc: ($avail + $used_ram_to_ignore) * 100 / ($system.ram.used + $system.ram.cached + $system.ram.free + $system.ram.buffers)
- units: %
- every: 10s
- warn: $this < (($status >= $WARNING) ? (15) : (10))
- crit: $this < (($status == $CRITICAL) ? (10) : ( 5))
- delay: down 15m multiplier 1.5 max 1h
- info: estimated amount of RAM available for userspace processes, without causing swapping
- to: sysadmin #alarms
-
-## FreeBSD
-alarm: ram_in_use
- on: system.ram
- os: freebsd
-hosts: *
- calc: ($active + $wired + $laundry + $buffers - $used_ram_to_ignore) * 100 / ($active + $wired + $laundry + $buffers - $used_ram_to_ignore + $cache + $free + $inactive)
-units: %
-every: 10s
- warn: $this > (($status >= $WARNING) ? (80) : (90))
- crit: $this > (($status == $CRITICAL) ? (90) : (98))
-delay: down 15m multiplier 1.5 max 1h
- info: system RAM usage
- to: sysadmin #alarms
-
- alarm: ram_available
- on: system.ram
- os: freebsd
- hosts: *
- calc: ($free + $inactive + $used_ram_to_ignore) * 100 / ($free + $active + $inactive + $wired + $cache + $laundry + $buffers)
- units: %
- every: 10s
- warn: $this < (($status >= $WARNING) ? (15) : (10))
- crit: $this < (($status == $CRITICAL) ? (10) : ( 5))
- delay: down 15m multiplier 1.5 max 1h
- info: estimated amount of RAM available for userspace processes, without causing swapping
- to: sysadmin #alarms
diff --git a/tests/alarm_repetition/ram_without_repetition.conf b/tests/alarm_repetition/ram_without_repetition.conf
deleted file mode 100644
index edfc492e0..000000000
--- a/tests/alarm_repetition/ram_without_repetition.conf
+++ /dev/null
@@ -1,63 +0,0 @@
-# you can disable an alarm notification by setting the 'to' line to: silent
-
- alarm: used_ram_to_ignore
- on: system.ram
- os: linux freebsd
- hosts: *
- calc: ($zfs.arc_size.arcsz = nan)?(0):($zfs.arc_size.arcsz)
- every: 10s
- info: the amount of memory that is reported as used, but it is actually capable for resizing itself based on the system needs (eg. ZFS ARC)
-
- alarm: ram_in_use
- on: system.ram
- os: linux
- hosts: *
-# calc: $used * 100 / ($used + $cached + $free)
- calc: ($used - $used_ram_to_ignore) * 100 / ($used - $used_ram_to_ignore + $cached + $free)
- units: %
- every: 1s
- warn: $this > 1
- crit: $this > 5
- delay: down 15m multiplier 1.5 max 1h
- info: system RAM used
- to: sysadmin #alarms
-
- alarm: ram_available
- on: mem.available
- os: linux
- hosts: *
- calc: ($avail + $used_ram_to_ignore) * 100 / ($system.ram.used + $system.ram.cached + $system.ram.free + $system.ram.buffers)
- units: %
- every: 10s
- warn: $this < (($status >= $WARNING) ? (15) : (10))
- crit: $this < (($status == $CRITICAL) ? (10) : ( 5))
- delay: down 15m multiplier 1.5 max 1h
- info: estimated amount of RAM available for userspace processes, without causing swapping
- to: sysadmin #alarms
-
-## FreeBSD
-alarm: ram_in_use
- on: system.ram
- os: freebsd
-hosts: *
- calc: ($active + $wired + $laundry + $buffers - $used_ram_to_ignore) * 100 / ($active + $wired + $laundry + $buffers - $used_ram_to_ignore + $cache + $free + $inactive)
-units: %
-every: 10s
- warn: $this > (($status >= $WARNING) ? (80) : (90))
- crit: $this > (($status == $CRITICAL) ? (90) : (98))
-delay: down 15m multiplier 1.5 max 1h
- info: system RAM usage
- to: sysadmin #alarms
-
- alarm: ram_available
- on: system.ram
- os: freebsd
- hosts: *
- calc: ($free + $inactive + $used_ram_to_ignore) * 100 / ($free + $active + $inactive + $wired + $cache + $laundry + $buffers)
- units: %
- every: 10s
- warn: $this < (($status >= $WARNING) ? (15) : (10))
- crit: $this < (($status == $CRITICAL) ? (10) : ( 5))
- delay: down 15m multiplier 1.5 max 1h
- info: estimated amount of RAM available for userspace processes, without causing swapping
- to: sysadmin #alarms