403Webshell
Server IP : 34.67.85.211  /  Your IP : 216.73.217.52
Web Server : Apache
System : Linux wordpress-1-vm 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05) x86_64
User : root ( 0)
PHP Version : 7.4.9
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/stackdriver/collectd/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/stackdriver/collectd/bin/stackdriver-read_agent_logging
#!/bin/sh
# Read metrics from the Stackdriver Logging agent. This expects the Prometheus
# text format. It currently only supports what's needed for the Stackdriver
# Logging agent.
#
# This script polls the metrics endpoint once and leaves. It used to run until
# aborted, but in some cases something was preventing it from terminating when
# collectd was restarted.
#
# Sample configuration stanza:
# <Plugin "exec">
#   # The script doesn't need any privileges, so run as 'nobody'.
#   Exec "nobody" "/opt/stackdriver/collectd/bin/read_agent_logging" "http://localhost:24231/metrics"
# </Plugin>

# Read first arg, with a safe default for testing.
URL="${1:-http://localhost:24231/metrics}"

# 1. If the Logging Agent uses REST.
# The part of the input that sed looks at looks like:
#
#   stackdriver_successful_requests_count{grpc="false",code="200"} 255
#
#   stackdriver_failed_requests_count{grpc="false",code="400"} 18
#   stackdriver_failed_requests_count{grpc="false",code="401"} 25
#   stackdriver_failed_requests_count{grpc="false",code="403"} 13
#   stackdriver_failed_requests_count{grpc="false",code="404"} 34
#   stackdriver_failed_requests_count{grpc="false",code="429"} 11
#
#   // OK.
#   stackdriver_ingested_entries_count{grpc="false",code="200"} 7050
#
#   // Bad Request.
#   stackdriver_dropped_entries_count{grpc="false",code="400"} 250
#   // Unauthorized.
#   stackdriver_dropped_entries_count{grpc="false",code="401"} 380
#   // Forbidden.
#   stackdriver_dropped_entries_count{grpc="false",code="403"} 210
#   // Not Found.
#   stackdriver_dropped_entries_count{grpc="false",code="404"} 480
#   // Too Many Requests.
#   stackdriver_dropped_entries_count{grpc="false",code="429"} 187
#
#   // Internal Server Error.
#   stackdriver_retried_entries_count{grpc="false",code="500"} 600
#   // Not Implemented.
#   stackdriver_retried_entries_count{grpc="false",code="501"} 290
#
# The expected output follows:
#   PUTVAL /agent-200/derive-request_count N:255
#
#   PUTVAL /agent-400/derive-request_count N:18
#   PUTVAL /agent-401/derive-request_count N:25
#   PUTVAL /agent-403/derive-request_count N:13
#   PUTVAL /agent-404/derive-request_count N:34
#   PUTVAL /agent-429/derive-request_count N:11
#
#   PUTVAL /agent-200/derive-log_entry_count N:7050
#
#   PUTVAL /agent-400/derive-log_entry_count N:250
#   PUTVAL /agent-401/derive-log_entry_count N:380
#   PUTVAL /agent-403/derive-log_entry_count N:210
#   PUTVAL /agent-404/derive-log_entry_count N:480
#   PUTVAL /agent-429/derive-log_entry_count N:187
#
#   PUTVAL /agent-500/derive-log_entry_retry_count N:600
#   PUTVAL /agent-501/derive-log_entry_retry_count N:290

# 2. If the Logging Agent uses gRPC.
# The part of the input that sed looks at looks like:
#
#   stackdriver_successful_requests_count{grpc="true",code="0"} 255
#
#   stackdriver_failed_requests_count{grpc="true",code="3"} 18
#   stackdriver_failed_requests_count{grpc="true",code="16"} 25
#   stackdriver_failed_requests_count{grpc="true",code="7"} 13
#   stackdriver_failed_requests_count{grpc="true",code="5"} 34
#   stackdriver_failed_requests_count{grpc="true",code="8"} 11
#
#   // OK.
#   stackdriver_ingested_entries_count{grpc="true",code="0"} 7050
#
#   // InvalidArgument.
#   stackdriver_dropped_entries_count{grpc="true",code="3"} 250
#   // Unauthenticated.
#   stackdriver_dropped_entries_count{grpc="true",code="16"} 38
#   // PermissionDenied.
#   stackdriver_dropped_entries_count{grpc="true",code="7"} 210
#   // NotFound.
#   stackdriver_dropped_entries_count{grpc="true",code="5"} 480
#   // ResourceExhausted.
#   stackdriver_retried_entries_count{grpc="true",code="8"} 187
#
#   // Internal.
#   stackdriver_retried_entries_count{grpc="true",code="13"} 600
#   // Unavailable.
#   stackdriver_retried_entries_count{grpc="true",code="14"} 290
#
# The expected output follows:
#   PUTVAL /agent-0/derive-request_count N:255
#
#   PUTVAL /agent-3/derive-request_count N:18
#   PUTVAL /agent-16/derive-request_count N:25
#   PUTVAL /agent-7/derive-request_count N:13
#   PUTVAL /agent-5/derive-request_count N:34
#   PUTVAL /agent-8/derive-request_count N:11
#
#   PUTVAL /agent-0/derive-log_entry_count N:7050
#
#   PUTVAL /agent-3/derive-log_entry_count N:250
#   PUTVAL /agent-16/derive-log_entry_count N:38
#   PUTVAL /agent-7/derive-log_entry_count N:210
#   PUTVAL /agent-5/derive-log_entry_count N:480
#   PUTVAL /agent-8/derive-log_entry_count N:187
#
#   PUTVAL /agent-13/derive-log_entry_retry_count N:600
#   PUTVAL /agent-14/derive-log_entry_retry_count N:290

# - Only pass to sed the Stackdriver metrics.
# - Drop the fractional part, if present; the output must be an integer counter.
# - Combine successful and failed submetrics into one with response code (200
#   for successful), in order to fit the schema that Stackdriver expects.
# - Make all nouns singular.
# - Successful metrics don't have a response code in the input, so set it
#   here.
# - The first two lines handle ingested/dropped entries as a corner case until
#   the agent starts exporting the partial errors for dropped entries, then
#   the rest of the sed expression should handle them generically.
exec curl --silent "${URL}" \
  | grep -E '^stackdriver_' \
  | sed -E \
    -e "s/^stackdriver_([a-zA-Z0-9_]*)(\{(.*code=\"([0-9]*)\")?.*\})? ([0-9]*)(\..*)?/PUTVAL ${COLLECTD_HOSTNAME}\/agent-\4\/derive-\1 N:\5/" \
    -e "s/(successful|failed)_requests_count/request_count/" \
    -e "s/(ingested|dropped)_entries_count/log_entry_count/" \
    -e "s/retried_entries_count/log_entry_retry_count/"

Youez - 2016 - github.com/yon3zu
LinuXploit