]> arthur.barton.de Git - netdata.git/blobdiff - charts.d/squid.chart.sh
more elastic opensipsctl output match
[netdata.git] / charts.d / squid.chart.sh
index 55ece266ea6a3ec50cc2a582ac3c0eb6bbdad77f..3e72ba6df507d7442b01a565bcb4f073db80f113 100755 (executable)
@@ -1,21 +1,15 @@
-#!/bin/sh
+# no need for shebang - this file is loaded from charts.d.plugin
 
 squid_host=
 squid_port=
 squid_url=
 squid_timeout=2
-squid_update_every=5
+squid_update_every=2
+squid_priority=60000
 
 squid_get_stats_internal() {
        local host="$1" port="$2" url="$3"
-
-       nc -w $squid_timeout $host $port <<EOF
-GET $url HTTP/1.0
-Host: $host:$port
-Accept: */*
-User-Agent: netdata (charts.d/squid.chart.sh)
-
-EOF
+       squidclient -h $host -p $port $url
 }
 
 squid_get_stats() {
@@ -46,8 +40,8 @@ squid_autodetect() {
 }
 
 squid_check() {
-       require_cmd nc    || return 1
-       require_cmd sed   || return 1
+       require_cmd squidclient || return 1
+       require_cmd sed || return 1
        require_cmd egrep || return 1
 
        if [ -z "$squid_host" -o -z "$squid_port" -o -z "$squid_url" ]
@@ -69,25 +63,25 @@ squid_check() {
 squid_create() {
        # create the charts
        cat <<EOF
-CHART squid.clients_net '' "Squid Client Bandwidth" "kilobits / sec" squid '' area 20001 $squid_update_every
-DIMENSION client_http_kbytes_in in incremental 8 $((1 * squid_update_every))
-DIMENSION client_http_kbytes_out out incremental -8 $((1 * squid_update_every))
-DIMENSION client_http_hit_kbytes_out hits incremental -8 $((1 * squid_update_every))
-
-CHART squid.clients_requests '' "Squid Client Requests" "requests / sec" squid '' line 20003 $squid_update_every
-DIMENSION client_http_requests requests incremental 1 $((1 * squid_update_every))
-DIMENSION client_http_hits hits incremental 1 $((1 * squid_update_every))
-DIMENSION client_http_errors errors incremental -1 $((1 * squid_update_every))
-
-CHART squid.servers_net '' "Squid Server Bandwidth" "kilobits / sec" squid '' area 20002 $squid_update_every
-DIMENSION server_all_kbytes_in in incremental 8 $((1 * squid_update_every))
-DIMENSION server_all_kbytes_out out incremental -8 $((1 * squid_update_every))
-
-CHART squid.servers_requests '' "Squid Server Requests" "requests / sec" squid '' line 20004 $squid_update_every
-DIMENSION server_all_requests requests incremental 1 $((1 * squid_update_every))
-DIMENSION server_all_errors errors incremental -1 $((1 * squid_update_every))
+CHART squid_local.clients_net '' "Squid Client Bandwidth" "kilobits / sec" clients squid.clients.net area $((squid_priority + 1)) $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_local.clients_requests '' "Squid Client Requests" "requests / sec" clients squid.clients.requests line $((squid_priority + 3)) $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_local.servers_net '' "Squid Server Bandwidth" "kilobits / sec" servers squid.servers.net area $((squid_priority + 2)) $squid_update_every
+DIMENSION server_all_kbytes_in in incremental 8 1
+DIMENSION server_all_kbytes_out out incremental -8 1
+
+CHART squid_local.servers_requests '' "Squid Server Requests" "requests / sec" servers squid.servers.requests line $((squid_priority + 4)) $squid_update_every
+DIMENSION server_all_requests requests incremental 1 1
+DIMENSION server_all_errors errors incremental -1 1
 EOF
-       
+
        return 0
 }
 
@@ -117,24 +111,24 @@ squid_update() {
 
        # write the result of the work.
        cat <<VALUESEOF
-BEGIN squid.clients_net $1
+BEGIN squid_local.clients_net $1
 SET client_http_kbytes_in = $squid_client_http_kbytes_in
 SET client_http_kbytes_out = $squid_client_http_kbytes_out
 SET client_http_hit_kbytes_out = $squid_client_http_hit_kbytes_out
 END
 
-BEGIN squid.clients_requests $1
+BEGIN squid_local.clients_requests $1
 SET client_http_requests = $squid_client_http_requests
 SET client_http_hits = $squid_client_http_hits
 SET client_http_errors = $squid_client_http_errors
 END
 
-BEGIN squid.servers_net $1
+BEGIN squid_local.servers_net $1
 SET server_all_kbytes_in = $squid_server_all_kbytes_in
 SET server_all_kbytes_out = $squid_server_all_kbytes_out
 END
 
-BEGIN squid.servers_requests $1
+BEGIN squid_local.servers_requests $1
 SET server_all_requests = $squid_server_all_requests
 SET server_all_errors = $squid_server_all_errors
 END