summaryrefslogtreecommitdiffstats
path: root/charts.d
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2015-11-20 01:19:29 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2015-11-20 01:19:29 +0200
commitf86722e7a092f5d1c6c7815499bd61866c75045c (patch)
tree1449a86a8220a42909192ba1508c9d31bfe2b3c1 /charts.d
parent93921bbb7cd15c3f3a4e4f52386cf3611eadd8d0 (diff)
normalized all charts.d plugins
Diffstat (limited to 'charts.d')
-rwxr-xr-xcharts.d/airsearches.chart.sh31
-rwxr-xr-xcharts.d/cpu_apps.chart.sh10
-rwxr-xr-xcharts.d/cpufreq.chart.sh4
-rwxr-xr-xcharts.d/crsproxy.chart.sh36
-rwxr-xr-xcharts.d/mem_apps.chart.sh4
-rwxr-xr-xcharts.d/mysql.chart.sh14
-rwxr-xr-xcharts.d/nut.chart.sh2
-rwxr-xr-xcharts.d/opensips.chart.sh46
-rwxr-xr-xcharts.d/postfix.chart.sh2
-rwxr-xr-xcharts.d/sensors.chart.sh8
10 files changed, 88 insertions, 69 deletions
diff --git a/charts.d/airsearches.chart.sh b/charts.d/airsearches.chart.sh
index 0e41531085..c3ff22f399 100755
--- a/charts.d/airsearches.chart.sh
+++ b/charts.d/airsearches.chart.sh
@@ -6,35 +6,52 @@ airsearches_update_every=15
airsearches_get() {
wget 2>/dev/null -O - "$airsearches_url" |\
- sed -e "s|<br />|\n|g" -e "s|: |=|g" -e "s| \+|_|g" |\
+ sed -e "s|<br />|\n|g" -e "s|: |=|g" -e "s| \+|_|g" -e "s/^/airsearches_/g" |\
tr "[A-Z]\.\!@#\$%^&*()_+\-" "[a-z]_____________" |\
- egrep "^[a-z0-9_]+=[0-9]+$" |\
- sort -u
+ egrep "^airsearches_[a-z0-9_]+=[0-9]+$"
}
airsearches_check() {
+ # make sure we have all the commands we need
+ require_cmd wget || return 1
+
+ # make sure we are configured
+ if [ -z "$airsearches_url" ]
+ then
+ echo >&2 "$PROGRAM_NAME: airsearches: not configured. Please set airsearches_url='url' in $confd/airsearches.conf"
+ return 1
+ fi
+
# 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"
+ echo >&2 "$PROGRAM_NAME: airsearches: cannot fetch the url: $airsearches_url. Please set airsearches_url='url' in $confd/airsearches.conf"
return 1
fi
+ # if the admin did not give any commands
+ # find the available ones
if [ -z "$airsearches_cmds" ]
then
- airsearches_cmds="`airsearches_get | cut -d '=' -f 1`"
+ airsearches_cmds="$(airsearches_get | cut -d '=' -f 1 | sed "s/^airsearches_//g" | sort -u)"
echo
fi
+
+ # did we find any commands?
if [ -z "$airsearches_cmds" ]
then
- echo >&2 "airsearches: cannot find command list automatically. Please set airsearches_cmds='...' in $confd/airsearches.conf"
+ echo >&2 "$PROGRAM_NAME: airsearches: cannot find command list automatically. Please set airsearches_cmds='...' in $confd/airsearches.conf"
return 1
fi
+
+ # ok we can do it
return 0
}
airsearches_create() {
+ [ -z "$airsearches_cmds" ] && return 1
+
# create the charts
local x=
echo "CHART airsearches.affiliates '' 'Air Searches per affiliate' 'requests / min' airsearches '' stacked 20000 $airsearches_update_every"
@@ -55,7 +72,7 @@ airsearches_update() {
# remember: KEEP IT SIMPLE AND SHORT
# get the values from airsearches
- eval "`airsearches_get | sed "s/^/airsearches_/g"`"
+ eval "$(airsearches_get)"
# write the result of the work.
local x=
diff --git a/charts.d/cpu_apps.chart.sh b/charts.d/cpu_apps.chart.sh
index 5f36e86582..d0165ad331 100755
--- a/charts.d/cpu_apps.chart.sh
+++ b/charts.d/cpu_apps.chart.sh
@@ -1,10 +1,14 @@
#!/bin/sh
-cpu_apps_apps="netdata asterisk squid apache2 mysqld dovecot cupsd sshd named clamd smbd"
+# THIS PLUGIN IS OBSOLETE
+# USE apps.plugin INSTEAD
+
+# a space separated list of command to monitor
+cpu_apps_apps=
# these are required for computing memory in bytes and cpu in seconds
#cpu_apps_pagesize="`getconf PAGESIZE`"
-cpu_apps_clockticks="`getconf CLK_TCK`"
+cpu_apps_clockticks="$(getconf CLK_TCK)"
cpu_apps_update_every=60
@@ -15,7 +19,7 @@ cpu_apps_check() {
if [ -z "$cpu_apps_apps" ]
then
- echo >&2 "cpu_apps: Please set cpu_apps_apps='command1 command2 ...' in $confd/cpu_apps_apps.conf"
+ echo >&2 "$PROGRAM_NAME: cpu_apps: Please set cpu_apps_apps='command1 command2 ...' in $confd/cpu_apps_apps.conf"
return 1
fi
return 0
diff --git a/charts.d/cpufreq.chart.sh b/charts.d/cpufreq.chart.sh
index 083a7ed292..1fce11e3f9 100755
--- a/charts.d/cpufreq.chart.sh
+++ b/charts.d/cpufreq.chart.sh
@@ -22,8 +22,8 @@ cpufreq_check() {
# - 0 to enable the chart
# - 1 to disable the chart
- [ ! -z "$( cpufreq_find_all_files $cpufreq_sys_dir )" ] && return 0
- return 1
+ [ -z "$( cpufreq_find_all_files $cpufreq_sys_dir )" ] && return 1
+ return 0
}
# _create is called once, to create the charts
diff --git a/charts.d/crsproxy.chart.sh b/charts.d/crsproxy.chart.sh
index 711b257dff..f3f9c6df73 100755
--- a/charts.d/crsproxy.chart.sh
+++ b/charts.d/crsproxy.chart.sh
@@ -1,26 +1,46 @@
#!/bin/sh
-crsproxy_url="http://127.0.0.1:7999/counters?"
-crsproxy_cmds=""
+crsproxy_url=
+crsproxy_cmds=
crsproxy_update_every=15
+crsproxy_get() {
+ wget 2>/dev/null -O - "$crsproxy_url" |\
+ sed \
+ -e "s/ \+/ /g" \
+ -e "s/\./_/g" \
+ -e "s/ =/=/g" \
+ -e "s/= /=/g" \
+ -e "s/^/crsproxy_/g" |\
+ egrep "^crsproxy_[a-zA-Z][a-zA-Z0-9_]*=[0-9]+$"
+}
+
crsproxy_check() {
+ if [ -z "$crsproxy_url" ]
+ then
+ echo >&2 "$PROGRAM_NAME: crsproxy: not configured. Please set crsproxy_url='url' in $confd/crsproxy.conf"
+ return 1
+ fi
+
# check once if the url works
wget 2>/dev/null -O /dev/null "$crsproxy_url"
if [ ! $? -eq 0 ]
then
- echo >&2 "crsproxy: cannot fetch the url: $crsproxy_url. Please set crsproxy_url='url' in $confd/crsproxy.conf"
+ echo >&2 "$PROGRAM_NAME: crsproxy: cannot fetch the url: $crsproxy_url. Please set crsproxy_url='url' in $confd/crsproxy.conf"
return 1
fi
+ # if the user did not request specific commands
+ # find the commands available
if [ -z "$crsproxy_cmds" ]
then
- crsproxy_cmds="`wget 2>/dev/null -O - "$crsproxy_url" | egrep "^cmd_[a-zA-Z][a-zA-Z0-9]_[a-z_]+ *= *[0-9]+$" | cut -d '_' -f 2 | sort -u`"
- echo
+ crsproxy_cmds="$(crsproxy_get | cut -d '=' -f 1 | sed "s/^crsproxy_cmd_//g" | sort -u)"
fi
+
+ # if no commands are available
if [ -z "$crsproxy_cmds" ]
then
- echo >&2 "crsproxy: cannot find command list automatically. Please set crsproxy_cmds='...' in $confd/crsproxy.conf"
+ echo >&2 "$PROGRAM_NAME: crsproxy: cannot find command list automatically. Please set crsproxy_cmds='...' in $confd/crsproxy.conf"
return 1
fi
return 0
@@ -74,9 +94,7 @@ crsproxy_update() {
# remember: KEEP IT SIMPLE AND SHORT
# get the values from crsproxy
- eval "`wget 2>/dev/null -O - "$crsproxy_url" |\
- sed -e "s/ \+/ /g" -e "s/\./_/g" -e "s/ = /=/g" -e "s/^/crsproxy_/g" |\
- egrep "^crsproxy_[a-zA-Z][a-zA-Z0-9_]*=[0-9]+$"`"
+ eval "$(crsproxy_get)"
# write the result of the work.
diff --git a/charts.d/mem_apps.chart.sh b/charts.d/mem_apps.chart.sh
index 3afa4ad325..d3a786e935 100755
--- a/charts.d/mem_apps.chart.sh
+++ b/charts.d/mem_apps.chart.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-mem_apps_apps="netdata asterisk squid apache2 mysqld dovecot cupsd sshd named clamd smbd"
+mem_apps_apps=
# these are required for computing memory in bytes and cpu in seconds
#mem_apps_pagesize="`getconf PAGESIZE`"
@@ -15,7 +15,7 @@ mem_apps_check() {
if [ -z "$mem_apps_apps" ]
then
- echo >&2 "mem_apps: Please set mem_apps_apps='command1 command2 ...' in $confd/mem_apps_apps.conf"
+ echo >&2 "$PROGRAM_NAME: mem_apps: not configured. Please set mem_apps_apps='command1 command2 ...' in $confd/mem_apps_apps.conf"
return 1
fi
return 0
diff --git a/charts.d/mysql.chart.sh b/charts.d/mysql.chart.sh
index 934e3bda89..b9bb93775d 100755
--- a/charts.d/mysql.chart.sh
+++ b/charts.d/mysql.chart.sh
@@ -28,9 +28,6 @@ mysql_check() {
local x m mysql_cmd
- require_cmd egrep || return 1
- require_cmd sed || return 1
-
[ -z "${mysql_cmd}" ] && mysql_cmd="$(which mysql)"
if [ ${#mysql_opts[@]} -eq 0 ]
@@ -45,13 +42,13 @@ mysql_check() {
[ -z "${mysql_cmds[$m]}" ] && mysql_cmds[$m]="$mysql_cmd"
if [ -z "${mysql_cmds[$m]}" ]
then
- echo >&2 "mysql: cannot get mysql command for '$m'. Please set mysql_cmds[$m]='/path/to/mysql', in $confd/mysql.conf"
+ echo >&2 "$PROGRAM_NAME: mysql: cannot get mysql command for '$m'. Please set mysql_cmds[$m]='/path/to/mysql', in $confd/mysql.conf"
fi
x="$(mysql_get "${mysql_cmds[$m]}" ${mysql_opts[$m]} | grep "^Connections[[:space:]]")"
if [ ! $? -eq 0 -o -z "$x" ]
then
- echo >&2 "mysql: cannot get global status for '$m'. Please set mysql_opts[$m]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
+ echo >&2 "$PROGRAM_NAME: mysql: cannot get global status for '$m'. Please set mysql_opts[$m]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
unset mysql_cmds[$m]
unset mysql_opts[$m]
unset mysql_ids[$m]
@@ -63,7 +60,8 @@ mysql_check() {
if [ ${#mysql_opts[@]} -eq 0 ]
then
- echo >&2 "mysql: no mysql servers found. Please set mysql_opts[name]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
+ echo >&2 "$PROGRAM_NAME: mysql: no mysql servers found. Please set mysql_opts[name]='options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
+ return 1
fi
return 0
@@ -157,7 +155,7 @@ mysql_update() {
unset mysql_ids[$m]
unset mysql_opts[$m]
unset mysql_cmds[$m]
- echo >&2 "mysql: failed to get values for '$m', disabling it."
+ echo >&2 "$PROGRAM_NAME: mysql: failed to get values for '$m', disabling it."
continue
fi
@@ -209,7 +207,7 @@ END
VALUESEOF
done
- [ ${#mysql_ids[@]} -eq 0 ] && echo >&2 "mysql: no mysql servers left active." && return 1
+ [ ${#mysql_ids[@]} -eq 0 ] && echo >&2 "$PROGRAM_NAME: mysql: no mysql servers left active." && return 1
return 0
}
diff --git a/charts.d/nut.chart.sh b/charts.d/nut.chart.sh
index d756c82374..1a60524115 100755
--- a/charts.d/nut.chart.sh
+++ b/charts.d/nut.chart.sh
@@ -27,9 +27,7 @@ nut_check() {
local x
- require_cmd timeout || return 1
require_cmd upsc || return 1
- require_cmd awk || return 1
[ -z "$nut_ups" ] && nut_ups="$( nut_get_all )"
diff --git a/charts.d/opensips.chart.sh b/charts.d/opensips.chart.sh
index 3066ec8edb..60ca728749 100755
--- a/charts.d/opensips.chart.sh
+++ b/charts.d/opensips.chart.sh
@@ -1,14 +1,15 @@
#!/bin/sh
opensips_opts="fifo get_statistics all"
-opensips_cmd="opensipsctl"
+opensips_cmd=
opensips_update_every=5
opensips_timeout=2
opensips_get_stats() {
timeout $opensips_timeout "$opensips_cmd" $opensips_opts |\
grep "^\(core\|dialog\|net\|registrar\|shmem\|siptrace\|sl\|tm\|uri\|usrloc\):[a-zA-Z0-9_ -]\+[[:space:]]*=[[:space:]]*[0-9]\+[[:space:]]*$" |\
- sed -e "s|-|_|g" \
+ sed \
+ -e "s|-|_|g" \
-e "s|:|_|g" \
-e "s|[[:space:]]\+=[[:space:]]\+|=|g" \
-e "s|[[:space:]]\+$||" \
@@ -22,13 +23,18 @@ opensips_get_stats() {
}
opensips_check() {
- require_cmd timeout || return 1
+ # if the user did not provide an opensips_cmd
+ # try to find it in the system
+ if [ -z "$opensips_cmd" ]
+ then
+ require_cmd opensipsctl || return 1
+ fi
- # check once if the url works
+ # check once if the command works
local x="$(opensips_get_stats | grep "^opensips_core_")"
if [ ! $? -eq 0 -o -z "$x" ]
then
- echo >&2 "opensips: cannot get global status. Please set opensips_opts='options' whatever needed to get connected to opensips server, in $confd/opensips.conf"
+ echo >&2 "$PROGRAM_NAME: opensips: cannot get global status. Please set opensips_opts='options' whatever needed to get connected to opensips server, in $confd/opensips.conf"
return 1
fi
@@ -141,7 +147,6 @@ opensips_update() {
# do all the work to collect / calculate the values
# for each dimension
- # remember: KEEP IT SIMPLE AND SHORT
# 1. get the counters page from opensips
# 2. sed to remove spaces; replace . with _; remove spaces around =; prepend each line with: local opensips_
@@ -149,10 +154,9 @@ opensips_update() {
# local opensips_client_http_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
# local opensips_server_all_ then one or more of these a-z 0-9 _ then = and one of more of 0-9
# 4. then execute this as a script with the eval
- #
- # be very carefull with eval:
- # prepare the script and always grep at the end the lines that are usefull, so that
- # even if something goes wrong, no other code can be executed
+ # be very carefull with eval:
+ # prepare the script and always grep at the end the lines that are usefull, so that
+ # even if something goes wrong, no other code can be executed
unset \
opensips_dialog_active_dialogs \
@@ -214,65 +218,54 @@ opensips_update() {
eval "local $(opensips_get_stats)"
[ $? -ne 0 ] && return 1
- [ $opensips_command_failed -eq 1 ] && echo >&2 "opensips: failed to get values, disabling." && return 1
+ [ $opensips_command_failed -eq 1 ] && echo >&2 "$PROGRAM_NAME: opensips: failed to get values, disabling." && return 1
# write the result of the work.
cat <<VALUESEOF
-
BEGIN opensips.dialogs_active $1
SET dialog_active_dialogs = $opensips_dialog_active_dialogs
SET dialog_early_dialogs = $opensips_dialog_early_dialogs
END
-
BEGIN opensips.users $1
SET usrloc_registered_users = $opensips_usrloc_registered_users
SET usrloc_location_users = $opensips_usrloc_location_users
SET usrloc_location_contacts = $opensips_usrloc_location_contacts
SET usrloc_location_expires = $opensips_usrloc_location_expires
END
-
BEGIN opensips.registrar $1
SET registrar_accepted_regs = $opensips_registrar_accepted_regs
SET registrar_rejected_regs = $opensips_registrar_rejected_regs
END
-
BEGIN opensips.transactions $1
SET tm_UAS_transactions = $opensips_tm_UAS_transactions
SET tm_UAC_transactions = $opensips_tm_UAC_transactions
END
-
BEGIN opensips.core_rcv $1
SET core_rcv_requests = $opensips_core_rcv_requests
SET core_rcv_replies = $opensips_core_rcv_replies
END
-
BEGIN opensips.core_fwd $1
SET core_fwd_requests = $opensips_core_fwd_requests
SET core_fwd_replies = $opensips_core_fwd_replies
END
-
BEGIN opensips.core_drop $1
SET core_drop_requests = $opensips_core_drop_requests
SET core_drop_replies = $opensips_core_drop_replies
END
-
BEGIN opensips.core_err $1
SET core_err_requests = $opensips_core_err_requests
SET core_err_replies = $opensips_core_err_replies
END
-
BEGIN opensips.core_bad $1
SET core_bad_URIs_rcvd = $opensips_core_bad_URIs_rcvd
SET core_unsupported_methods = $opensips_core_unsupported_methods
SET core_bad_msg_hdr = $opensips_core_bad_msg_hdr
END
-
BEGIN opensips.tm_replies $1
SET tm_received_replies = $opensips_tm_received_replies
SET tm_relayed_replies = $opensips_tm_relayed_replies
SET tm_local_replies = $opensips_tm_local_replies
END
-
BEGIN opensips.transactions_status $1
SET tm_2xx_transactions = $opensips_tm_2xx_transactions
SET tm_3xx_transactions = $opensips_tm_3xx_transactions
@@ -280,11 +273,9 @@ SET tm_4xx_transactions = $opensips_tm_4xx_transactions
SET tm_5xx_transactions = $opensips_tm_5xx_transactions
SET tm_6xx_transactions = $opensips_tm_6xx_transactions
END
-
BEGIN opensips.transactions_inuse $1
SET tm_inuse_transactions = $opensips_tm_inuse_transactions
END
-
BEGIN opensips.sl_replies $1
SET sl_1xx_replies = $opensips_sl_1xx_replies
SET sl_2xx_replies = $opensips_sl_2xx_replies
@@ -296,28 +287,23 @@ SET sl_sent_replies = $opensips_sl_sent_replies
SET sl_sent_err_replies = $opensips_sl_sent_err_replies
SET sl_received_ACKs = $opensips_sl_received_ACKs
END
-
BEGIN opensips.dialogs $1
SET dialog_processed_dialogs = $opensips_dialog_processed_dialogs
SET dialog_expired_dialogs = $opensips_dialog_expired_dialogs
SET dialog_failed_dialogs = $opensips_dialog_failed_dialogs
END
-
BEGIN opensips.net_waiting $1
SET net_waiting_udp = $opensips_net_waiting_udp
SET net_waiting_tcp = $opensips_net_waiting_tcp
END
-
BEGIN opensips.uri_checks $1
SET uri_positive_checks = $opensips_uri_positive_checks
SET uri_negative_checks = $opensips_uri_negative_checks
END
-
BEGIN opensips.traces $1
SET siptrace_traced_requests = $opensips_siptrace_traced_requests
SET siptrace_traced_replies = $opensips_siptrace_traced_replies
END
-
BEGIN opensips.shmem $1
SET shmem_total_size = $opensips_shmem_total_size
SET shmem_used_size = $opensips_shmem_used_size
@@ -325,7 +311,6 @@ SET shmem_real_used_size = $opensips_shmem_real_used_size
SET shmem_max_used_size = $opensips_shmem_max_used_size
SET shmem_free_size = $opensips_shmem_free_size
END
-
BEGIN opensips.shmem_fragments $1
SET shmem_fragments = $opensips_shmem_fragments
END
@@ -333,4 +318,3 @@ VALUESEOF
return 0
}
-
diff --git a/charts.d/postfix.chart.sh b/charts.d/postfix.chart.sh
index 1086ad54ee..0a246da626 100755
--- a/charts.d/postfix.chart.sh
+++ b/charts.d/postfix.chart.sh
@@ -32,7 +32,7 @@ postfix_check() {
if [ -z "$postfix_postqueue" -o ! -x "$postfix_postqueue" ]
then
- echo >&2 "postfix: cannot find postqueue. Please set 'postfix_postqueue=/path/to/postqueue' in $confd/postfix.conf"
+ echo >&2 "$PROGRAM_NAME: postfix: cannot find postqueue. Please set 'postfix_postqueue=/path/to/postqueue' in $confd/postfix.conf"
return 1
fi
diff --git a/charts.d/sensors.chart.sh b/charts.d/sensors.chart.sh
index 76032a660c..f4ab1b240a 100755
--- a/charts.d/sensors.chart.sh
+++ b/charts.d/sensors.chart.sh
@@ -39,8 +39,8 @@ sensors_check() {
# - 0 to enable the chart
# - 1 to disable the chart
- [ ! -z "$( sensors_find_all_files $sensors_sys_dir )" ] && return 0
- return 1
+ [ -z "$( sensors_find_all_files $sensors_sys_dir )" ] && echo >&2 "$PROGRAM_NAME: sensors: no sensors found in '$sensors_sys_dir'." && return 1
+ return 0
}
sensors_check_files() {
@@ -55,7 +55,7 @@ sensors_check_files() {
v=$(( v + 1 - 1 ))
[ $v -ne 0 ] && echo "$f" && continue
- echo >&2 "charts.d: sensors: $f gives zero values"
+ echo >&2 "$PROGRAM_NAME: sensors: $f gives zero values"
done
}
@@ -74,7 +74,7 @@ sensors_check_temp_type() {
v=$(( v + 1 - 1 ))
[ $v -ne 0 ] && echo "$f" && continue
- echo >&2 "charts.d: sensors: $f is disabled"
+ echo >&2 "$PROGRAM_NAME: sensors: $f is disabled"
done
}