diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2014-05-30 21:21:39 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2014-05-30 21:21:39 +0300 |
commit | c666fc44f51dc7c488a74d90a8073de43ea93ac0 (patch) | |
tree | 211d0a1a4a7feb3b8540419a33d03a3f6b4baad1 /charts.d | |
parent | 4bb4aaaa10a9325373f4039419581f74fa31aa62 (diff) |
added support for different update frequency per chart in charts.d.plugin
Diffstat (limited to 'charts.d')
-rwxr-xr-x | charts.d/airsearches.chart.sh | 74 | ||||
-rwxr-xr-x | charts.d/cpu_apps.chart.sh | 4 | ||||
-rwxr-xr-x | charts.d/crsproxy.chart.sh | 43 | ||||
-rwxr-xr-x | charts.d/example.chart.sh | 4 | ||||
-rwxr-xr-x | charts.d/load_average.chart.sh | 4 | ||||
-rwxr-xr-x | charts.d/mem_apps.chart.sh | 4 | ||||
-rwxr-xr-x | charts.d/postfix.chart.sh | 7 | ||||
-rwxr-xr-x | charts.d/squid.chart.sh | 19 |
8 files changed, 122 insertions, 37 deletions
diff --git a/charts.d/airsearches.chart.sh b/charts.d/airsearches.chart.sh new file mode 100755 index 0000000000..1e4e6cd74c --- /dev/null +++ b/charts.d/airsearches.chart.sh @@ -0,0 +1,74 @@ +#!/bin/sh + +airsearches_url="https://services.viva.gr/vivatravelwcf_v2/airsabre/webtesting/searchcounters.ashx" +airsearches_cmds="" +airsearches_update_every=60 + +airsearches_get() { + wget 2>/dev/null -O - "$airsearches_url" |\ + sed -e "s|<br />|\n|g" -e "s|: |=|g" -e "s| \+|_|g" |\ + tr "[A-Z]\.\!@#\$%^&*()_+\-" "[a-z]_____________" |\ + egrep "^[a-z0-9_]+=[0-9]+$" |\ + sort -u +} + +airsearches_check() { + # check once if the url works + wget 2>/dev/null -O /dev/null "$airsearches_url" + if [ ! $? -eq 0 ] + then + echo >&2 "airsearches: cannot fetch the url: $airsearches_url. Please set airsearches_url='url' in $confd/airsearches.conf" + return 1 + fi + + if [ -z "$airsearches_cmds" ] + then + airsearches_cmds="`airsearches_get | cut -d '=' -f 1`" + echo + fi + if [ -z "$airsearches_cmds" ] + then + echo >&2 "airsearches: cannot find command list automatically. Please set airsearches_cmds='...' in $confd/airsearches.conf" + return 1 + fi + return 0 +} + +airsearches_create() { + # create the charts + local x= + echo "CHART airsearches.affiliates '' 'Air Searches per affiliate' 'requests / $airsearches_update_every secs' airsearches '' stacked 20000 $airsearches_update_every" + for x in $airsearches_cmds + do + echo "DIMENSION $x '' incremental 1 1" + done + + return 0 +} + +airsearches_update() { + # the first argument to this function is the microseconds since last update + # pass this parameter to the BEGIN statement (see bellow). + + # do all the work to collect / calculate the values + # for each dimension + # remember: KEEP IT SIMPLE AND SHORT + + # get the values from airsearches + eval "`airsearches_get | sed "s/^/airsearches_/g"`" + + # write the result of the work. + local x= + + echo "BEGIN airsearches.affiliates $1" + for x in $airsearches_cmds + do + eval "v=\$airsearches_$x" + echo "SET $x = $v" + done + echo "END" + + airsearches_dt=0 + + return 0 +} diff --git a/charts.d/cpu_apps.chart.sh b/charts.d/cpu_apps.chart.sh index 1733b7dce4..735ac30b3e 100755 --- a/charts.d/cpu_apps.chart.sh +++ b/charts.d/cpu_apps.chart.sh @@ -6,6 +6,8 @@ cpu_apps_apps="netdata asterisk squid apache2 mysqld dovecot cupsd sshd named cl #cpu_apps_pagesize="`getconf PAGESIZE`" cpu_apps_clockticks="`getconf CLK_TCK`" +cpu_apps_update_every=60 + cpu_apps_check() { # this should return: # - 0 to enable the chart @@ -23,7 +25,7 @@ cpu_apps_bc_finalze= cpu_apps_create() { - echo "CHART apps.cpu '' 'Apps CPU' 'milliseconds/s' apps apps stacked 20001 $update_every" + echo "CHART apps.cpu '' 'Apps CPU' 'milliseconds / $cpu_apps_update_every sec' apps apps stacked 20001 $cpu_apps_update_every" local x= for x in $cpu_apps_apps diff --git a/charts.d/crsproxy.chart.sh b/charts.d/crsproxy.chart.sh index 6aa306a234..6d5b83b30a 100755 --- a/charts.d/crsproxy.chart.sh +++ b/charts.d/crsproxy.chart.sh @@ -2,6 +2,7 @@ crsproxy_url="http://127.0.0.1:7999/counters?" crsproxy_cmds="" +crsproxy_update_every=60 crsproxy_check() { # check once if the url works @@ -28,36 +29,36 @@ crsproxy_check() { crsproxy_create() { # create the charts cat <<EOF -CHART crsproxy.connected '' "CRS Proxy Connected Clients" "clients" crsproxy '' line 20000 $update_every -DIMENSION web '' absolute-no-interpolation 1 1 -DIMENSION native '' absolute-no-interpolation 1 1 -DIMENSION virtual '' absolute-no-interpolation 1 1 -CHART crsproxy.requests '' "CRS Proxy Requests Rate" "requests/s" crsproxy '' area 20001 $update_every -DIMENSION web '' incremental-no-interpolation 1 1 -DIMENSION native '' incremental-no-interpolation -1 1 -CHART crsproxy.clients '' "CRS Proxy Clients Rate" "clients/s" crsproxy '' area 20010 $update_every -DIMENSION web '' incremental-no-interpolation 1 1 -DIMENSION native '' incremental-no-interpolation -1 1 -DIMENSION virtual '' incremental-no-interpolation 1 1 -CHART crsproxy.replies '' "CRS Replies Rate" "replies/s" crsproxy '' area 20020 $update_every -DIMENSION ok '' incremental-no-interpolation 1 1 -DIMENSION failed '' incremental-no-interpolation -1 1 -CHART crsproxy.bconnections '' "Back-End Connections Rate" "connections/s" crsproxy '' area 20030 $update_every -DIMENSION ok '' incremental-no-interpolation 1 1 -DIMENSION failed '' incremental-no-interpolation -1 1 +CHART crsproxy.connected '' "CRS Proxy Connected Clients" "clients" crsproxy '' line 20000 $crsproxy_update_every +DIMENSION web '' absolute 1 1 +DIMENSION native '' absolute 1 1 +DIMENSION virtual '' absolute 1 1 +CHART crsproxy.requests '' "CRS Proxy Requests Rate" "requests / $crsproxy_update_every sec" crsproxy '' area 20001 $crsproxy_update_every +DIMENSION web '' incremental 1 1 +DIMENSION native '' incremental -1 1 +CHART crsproxy.clients '' "CRS Proxy Clients Rate" "clients / $crsproxy_update_every sec" crsproxy '' area 20010 $crsproxy_update_every +DIMENSION web '' incremental 1 1 +DIMENSION native '' incremental -1 1 +DIMENSION virtual '' incremental 1 1 +CHART crsproxy.replies '' "CRS Replies Rate" "replies / $crsproxy_update_every sec" crsproxy '' area 20020 $crsproxy_update_every +DIMENSION ok '' incremental 1 1 +DIMENSION failed '' incremental -1 1 +CHART crsproxy.bconnections '' "Back-End Connections Rate" "connections / $crsproxy_update_every sec" crsproxy '' area 20030 $crsproxy_update_every +DIMENSION ok '' incremental 1 1 +DIMENSION failed '' incremental -1 1 EOF local x= - echo "CHART crsproxy.commands '' 'CRS Commands Requests' 'requests/s' crsproxy '' stacked 20100 $update_every" + echo "CHART crsproxy.commands '' 'CRS Commands Requests' 'requests / $crsproxy_update_every sec' crsproxy '' stacked 20100 $crsproxy_update_every" for x in $crsproxy_cmds do - echo "DIMENSION $x '' incremental-no-interpolation 1 1" + echo "DIMENSION $x '' incremental 1 1" done - echo "CHART crsproxy.commands_failed '' 'CRS Failed Commands' 'replies/s' crsproxy '' stacked 20110 $update_every" + echo "CHART crsproxy.commands_failed '' 'CRS Failed Commands' 'replies / $crsproxy_update_every sec' crsproxy '' stacked 20110 $crsproxy_update_every" for x in $crsproxy_cmds do - echo "DIMENSION $x '' incremental-no-interpolation 1 1" + echo "DIMENSION $x '' incremental 1 1" done return 0 diff --git a/charts.d/example.chart.sh b/charts.d/example.chart.sh index 369769c11d..0f6251ad80 100755 --- a/charts.d/example.chart.sh +++ b/charts.d/example.chart.sh @@ -1,5 +1,7 @@ #!/bin/sh +example_update_every= + example_check() { # this should return: # - 0 to enable the chart @@ -11,7 +13,7 @@ example_check() { example_create() { # create the chart with 3 dimensions cat <<EOF -CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" random random stacked 5000 $update_every +CHART example.random '' "Random Numbers Stacked Chart" "% of random numbers" random random stacked 5000 $example_update_every DIMENSION random1 '' percentage-of-absolute-row 1 1 DIMENSION random2 '' percentage-of-absolute-row 1 1 DIMENSION random3 '' percentage-of-absolute-row 1 1 diff --git a/charts.d/load_average.chart.sh b/charts.d/load_average.chart.sh index e2c72494a9..6e5d5e0572 100755 --- a/charts.d/load_average.chart.sh +++ b/charts.d/load_average.chart.sh @@ -1,5 +1,7 @@ #!/bin/sh +load_average_update_every= + load_average_check() { # this should return: # - 0 to enable the chart @@ -11,7 +13,7 @@ load_average_check() { load_average_create() { # create a chart with 3 dimensions cat <<EOF -CHART example.load '' "System Load Average" "load" load load line 500 $update_every +CHART example.load '' "System Load Average" "load" load load line 500 $load_average_update_every DIMENSION load1 '1 min' absolute 1 100 DIMENSION load5 '5 mins' absolute 1 100 DIMENSION load15 '15 mins' absolute 1 100 diff --git a/charts.d/mem_apps.chart.sh b/charts.d/mem_apps.chart.sh index 75618d748e..3afa4ad325 100755 --- a/charts.d/mem_apps.chart.sh +++ b/charts.d/mem_apps.chart.sh @@ -6,6 +6,8 @@ mem_apps_apps="netdata asterisk squid apache2 mysqld dovecot cupsd sshd named cl #mem_apps_pagesize="`getconf PAGESIZE`" #mem_apps_clockticks="`getconf CLK_TCK`" +mem_apps_update_every= + mem_apps_check() { # this should return: # - 0 to enable the chart @@ -23,7 +25,7 @@ mem_apps_bc_finalze= mem_apps_create() { - echo "CHART apps.mem '' 'Apps Memory' MB apps apps stacked 20000 $update_every" + echo "CHART apps.mem '' 'Apps Memory' MB apps apps stacked 20000 $mem_apps_update_every" local x= for x in $mem_apps_apps diff --git a/charts.d/postfix.chart.sh b/charts.d/postfix.chart.sh index 4132962224..e55ca15906 100755 --- a/charts.d/postfix.chart.sh +++ b/charts.d/postfix.chart.sh @@ -1,6 +1,7 @@ #!/bin/sh postfix_postqueue= +postfix_update_every=60 postfix_check() { # this should return: @@ -36,9 +37,9 @@ postfix_check() { postfix_create() { cat <<EOF -CHART postfix.qemails '' "Postfix Queue Emails" "emails" postfix postfix line 5000 $update_every -DIMENSION emails '' absolute-no-interpolation 1 1 -CHART postfix.qsize '' "Postfix Queue Emails Size" "emails size in KB" postfix postfix area 5001 $update_every +CHART postfix.qemails '' "Postfix Queue Emails" "emails" postfix postfix line 5000 $postfix_update_every +DIMENSION emails '' absolute 1 1 +CHART postfix.qsize '' "Postfix Queue Emails Size" "emails size in KB" postfix postfix area 5001 $postfix_update_every DIMENSION size '' absolute 1 1 EOF diff --git a/charts.d/squid.chart.sh b/charts.d/squid.chart.sh index f1d958b688..a9bcea2a5d 100755 --- a/charts.d/squid.chart.sh +++ b/charts.d/squid.chart.sh @@ -1,6 +1,7 @@ #!/bin/sh squid_url="http://127.0.0.1:8080/squid-internal-mgr/counters" +squid_update_every=5 squid_check() { # check once if the url works @@ -17,23 +18,23 @@ squid_check() { squid_create() { # create the charts cat <<EOF -CHART squid.clients_net '' "Squid Client Bandwidth" "kilobits/s" squid '' area 20001 $update_every +CHART squid.clients_net '' "Squid Client Bandwidth" "kilobits / $squid_update_every sec" squid '' area 20001 $squid_update_every DIMENSION client_http_kbytes_in in incremental 8 1 DIMENSION client_http_kbytes_out out incremental -8 1 DIMENSION client_http_hit_kbytes_out hits incremental -8 1 -CHART squid.clients_requests '' "Squid Client Requests" "requests/s" squid '' line 20003 $update_every -DIMENSION client_http_requests requests incremental-no-interpolation 1 1 -DIMENSION client_http_hits hits incremental-no-interpolation 1 1 -DIMENSION client_http_errors errors incremental-no-interpolation -1 1 +CHART squid.clients_requests '' "Squid Client Requests" "requests / $squid_update_every sec" squid '' line 20003 $squid_update_every +DIMENSION client_http_requests requests incremental 1 1 +DIMENSION client_http_hits hits incremental 1 1 +DIMENSION client_http_errors errors incremental -1 1 -CHART squid.servers_net '' "Squid Server Bandwidth" "kilobits/s" squid '' area 20002 $update_every +CHART squid.servers_net '' "Squid Server Bandwidth" "kilobits / $squid_update_every sec" squid '' area 20002 $squid_update_every DIMENSION server_all_kbytes_in in incremental 8 1 DIMENSION server_all_kbytes_out out incremental -8 1 -CHART squid.servers_requests '' "Squid Server Requests" "requests/s" squid '' line 20004 $update_every -DIMENSION server_all_requests requests incremental-no-interpolation 1 1 -DIMENSION server_all_errors errors incremental-no-interpolation -1 1 +CHART squid.servers_requests '' "Squid Server Requests" "requests / $squid_update_every sec" squid '' line 20004 $squid_update_every +DIMENSION server_all_requests requests incremental 1 1 +DIMENSION server_all_errors errors incremental -1 1 EOF return 0 |