Skip to content

Commit

Permalink
Merge pull request #71 from snetsystems/release-1.31-snet-jinhyeong
Browse files Browse the repository at this point in the history
Release 1.31 snet jinhyeong
  • Loading branch information
snetsystems authored Sep 25, 2024
2 parents 74eb195 + 551af5a commit c524fed
Show file tree
Hide file tree
Showing 45 changed files with 6,891 additions and 1,171 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
/vendor
.DS_Store
process.yml
/.vscode
/*.toml
/*.conf
resource.syso
Expand Down
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Server",
"type": "go",
"request": "launch",
"mode": "debug",
"showLog": true,
"buildFlags": "-ldflags='-X main.version=1.18.2-snet'",
"program": "${workspaceFolder}/cmd/telegraf",
"output": "windows/telegraf_debug.exe",
"env": {},
"args": [
// "--once", // just once run
"--test", // without output plugin
"--debug", // log level
"--input-filter=oracledb", // apply the oracledb input plugin only
"--config=${workspaceFolder}\\etc\\telegraf_win_test.conf" // "\\" for Windows path
]
}
]
}
25 changes: 25 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"go.toolsEnvVars": {
"GO111MODULE": "on"
},
"editor.renderControlCharacters": true,
"editor.largeFileOptimizations": false,
"editor.formatOnSave": true,
"editor.renderWhitespace": "none",
"editor.wordWrap": "on",
"files.eol": "\n",
"go.lintOnSave": "package",
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast"],
"go.formatTool": "goimports",
"go.enableCodeLens": {
"runtest": true
},
"prettier.singleQuote": true,
"prettier.bracketSpacing": false,
"prettier.semi": false,
"prettier.trailingComma": "es5",
"prettier.arrowParens": "avoid",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"diffEditor.ignoreTrimWhitespace": false
}
3 changes: 2 additions & 1 deletion cmd/telegraf/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ func (t *Telegraf) runAgent(ctx context.Context, reloadConfig bool) error {
c := t.cfg
var err error
if reloadConfig {
config.ResetSecrets()
if c, err = t.loadConfiguration(); err != nil {
return err
}
Expand Down Expand Up @@ -402,7 +403,7 @@ func (t *Telegraf) runAgent(ctx context.Context, reloadConfig bool) error {
log.Printf("I! Found %d secrets...", c.NumberSecrets)
msg := fmt.Sprintf("Insufficient lockable memory %dkb when %dkb is required.", available, required)
msg += " Please increase the limit for Telegraf in your Operating System!"
log.Printf("W! " + color.RedString(msg))
log.Print("W! " + color.RedString(msg))
}
}
ag := agent.NewAgent(c)
Expand Down
11 changes: 11 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,17 @@ func GetDefaultConfigPath() ([]string, error) {
" in $TELEGRAF_CONFIG_PATH, %s, %s, or %s/*.conf", homefile, etcfile, etcfolder)
}

// ResetSecrets clears all stored secrets by destroying each one, resetting the
// secret count to zero, and emptying the unlinkedSecrets list. This is used during
// Telegraf configuration reloads to remove any old secrets.
func ResetSecrets() {
for _, secret := range unlinkedSecrets {
secret.Destroy()
}
secretCount.Store(0)
unlinkedSecrets = nil
}

// isURL checks if string is valid url
func isURL(str string) bool {
u, err := url.Parse(str)
Expand Down
278 changes: 278 additions & 0 deletions etc/telegraf_win_test.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
# Global tags can be specified here in key="value" format.
[global_tags]
# dc = "us-east-1" # will tag all metrics with dc=us-east-1
# rack = "1a"
## Environment variables can be used as tags, and throughout the config file
# user = "$USER"


# Configuration for telegraf agent
[agent]
## Default data collection interval for all inputs
interval = "10s"
## Rounds collection interval to 'interval'
## ie, if interval="10s" then always collect on :00, :10, :20, etc.
round_interval = true

## Telegraf will send metrics to outputs in batches of at most
## metric_batch_size metrics.
## This controls the size of writes that Telegraf sends to output plugins.
metric_batch_size = 1000

## Maximum number of unwritten metrics per output. Increasing this value
## allows for longer periods of output downtime without dropping metrics at the
## cost of higher maximum memory usage.
metric_buffer_limit = 10000

## Collection jitter is used to jitter the collection by a random amount.
## Each plugin will sleep for a random time within jitter before collecting.
## This can be used to avoid many plugins querying things like sysfs at the
## same time, which can have a measurable effect on the system.
collection_jitter = "0s"

## Default flushing interval for all outputs. Maximum flush_interval will be
## flush_interval + flush_jitter
flush_interval = "10s"
## Jitter the flush interval by a random amount. This is primarily to avoid
## large write spikes for users running a large number of telegraf instances.
## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
flush_jitter = "0s"

## By default or when set to "0s", precision will be set to the same
## timestamp order as the collection interval, with the maximum being 1s.
## ie, when interval = "10s", precision will be "1s"
## when interval = "250ms", precision will be "1ms"
## Precision will NOT be used for service inputs. It is up to each individual
## service input to set the timestamp at the appropriate precision.
## Valid time units are "ns", "us" (or "µs"), "ms", "s".
precision = ""

## Log at debug level.
# debug = false
## Log only error level messages.
# quiet = false

## Log target controls the destination for logs and can be one of "file",
## "stderr" or, on Windows, "eventlog". When set to "file", the output file
## is determined by the "logfile" setting.
logtarget = "file"

## Name of the file to be logged to when using the "file" logtarget. If set to
## the empty string then logs are written to stderr.
logfile = "windows/telegraf.log"

## The logfile will be rotated after the time interval specified. When set
## to 0 no time based rotation is performed. Logs are rotated only when
## written to, if there is no log activity rotation may be delayed.
logfile_rotation_interval = "0d"

## The logfile will be rotated when it becomes larger than the specified
## size. When set to 0 no size based rotation is performed.
logfile_rotation_max_size = "20MB"

## Maximum number of rotated archives to keep, any older logs are deleted.
## If set to -1, no archives are removed.
logfile_rotation_max_archives = 3

## Override default hostname, if empty use os.Hostname()
hostname = "jack-office-host"
## If set to true, do no set the "host" tag in the telegraf agent.
omit_hostname = false


###############################################################################
# OUTPUT PLUGINS #
###############################################################################

# # Send telegraf metrics to file(s)
[[outputs.file]]
## Files to write to, "stdout" is a specially handled file.
files = ["stdout", "./metrics.out"]

## Use batch serialization format instead of line based delimiting. The
## batch format allows for the production of non line based output formats and
## may more efficiently encode metric groups.
# use_batch_format = false

## The file will be rotated after the time interval specified. When set
## to 0 no time based rotation is performed.
# rotation_interval = "0d"

## The logfile will be rotated when it becomes larger than the specified
## size. When set to 0 no size based rotation is performed.
# rotation_max_size = "0MB"

## Maximum number of rotated archives to keep, any older logs are deleted.
## If set to -1, no archives are removed.
# rotation_max_archives = 5

## Data format to output.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
data_format = "influx"

###############################################################################
# INPUT PLUGINS #
###############################################################################

[[inputs.win_perf_counters]]
[[inputs.win_perf_counters.object]]
# Processor usage, alternative to native, reports on a per core.
ObjectName = "Processor"
Instances = ["*"]
Counters = [
"% Idle Time",
"% Interrupt Time",
"% Privileged Time",
"% User Time",
"% Processor Time",
"% DPC Time",
]
Measurement = "win_cpu"
# Set to true to include _Total instance when querying for all (*).
IncludeTotal=true

[[inputs.win_perf_counters.object]]
# Disk times and queues
ObjectName = "LogicalDisk"
Instances = ["*"]
Counters = [
"% Idle Time",
"% Disk Time",
"% Disk Read Time",
"% Disk Write Time",
"% Free Space",
"Current Disk Queue Length",
"Free Megabytes",
]
Measurement = "win_disk"
# Set to true to include _Total instance when querying for all (*).
#IncludeTotal=false

[[inputs.win_perf_counters.object]]
ObjectName = "PhysicalDisk"
Instances = ["*"]
Counters = [
"Disk Read Bytes/sec",
"Disk Write Bytes/sec",
"Current Disk Queue Length",
"Disk Reads/sec",
"Disk Writes/sec",
"% Disk Time",
"% Disk Read Time",
"% Disk Write Time",
]
Measurement = "win_diskio"

[[inputs.win_perf_counters.object]]
ObjectName = "Network Interface"
Instances = ["*"]
Counters = [
"Bytes Received/sec",
"Bytes Sent/sec",
"Packets Received/sec",
"Packets Sent/sec",
"Packets Received Discarded",
"Packets Outbound Discarded",
"Packets Received Errors",
"Packets Outbound Errors",
]
Measurement = "win_net"

[[inputs.win_perf_counters.object]]
ObjectName = "System"
Counters = [
"Context Switches/sec",
"System Calls/sec",
"Processor Queue Length",
"System Up Time",
]
Instances = ["------"]
Measurement = "win_system"
# Set to true to include _Total instance when querying for all (*).
#IncludeTotal=false

[[inputs.win_perf_counters.object]]
# Example query where the Instance portion must be removed to get data back,
# such as from the Memory object.
ObjectName = "Memory"
Counters = [
"Available Bytes",
"Cache Faults/sec",
"Demand Zero Faults/sec",
"Page Faults/sec",
"Pages/sec",
"Transition Faults/sec",
"Pool Nonpaged Bytes",
"Pool Paged Bytes",
"Standby Cache Reserve Bytes",
"Standby Cache Normal Priority Bytes",
"Standby Cache Core Bytes",
]
# Use 6 x - to remove the Instance bit from the query.
Instances = ["------"]
Measurement = "win_mem"
# Set to true to include _Total instance when querying for all (*).
#IncludeTotal=false

[[inputs.win_perf_counters.object]]
# Example query where the Instance portion must be removed to get data back,
# such as from the Paging File object.
ObjectName = "Paging File"
Counters = [
"% Usage",
]
Instances = ["_Total"]
Measurement = "win_swap"

[[inputs.oracledb]]
## Connection string, e.g. easy connect string like
connection_string = "192.168.56.105:1521/xe"
# or oracle net connect descriptor string like
# (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orclpdb1)))
# connection_string = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.105)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE)))"
## Database credentials
username = "system"
password = "oracle"
## Role, either SYSDBA, SYSASM, SYSOPER or empty
role = ""
## Path to the Oracle Client library directory, optional.
# Should be used if there is no LD_LIBRARY_PATH variable
# or not possible to confugire it properly.
client_lib_dir = "C:/Oracle/instantclient_19_11"
## Define the toml config where the sql queries are stored
# Structure :
# [[inputs.oracledb.query]]
# sqlquery string
# script string
# schema string
# tag_columns array of strings
[[inputs.oracledb.query]]
# Query name, optional. Used in logging.
name = ""
# OracleDB sql query
sqlquery = "select n.wait_class as wait_class, round(m.time_waited/m.INTSIZE_CSEC,3) wait_value from v$waitclassmetric m, v$system_wait_class n where m.wait_class_id=n.wait_class_id and n.wait_class != 'Idle' union select 'CPU', round(value/100,3) wait_value from v$sysmetric where metric_name='CPU Usage Per Sec' and group_id=2 union select 'CPU_OS', round((prcnt.busy*parameter.cpu_count)/100,3) - aas.cpu from ( select value busy from v$sysmetric where metric_name='Host CPU Utilization (%)' and group_id=2 ) prcnt, ( select value cpu_count from v$parameter where name='cpu_count' ) parameter, ( select 'CPU', round(value/100,3) cpu from v$sysmetric where metric_name='CPU Usage Per Sec' and group_id=2) aas"
# The script option can be used to specify the .sql file path.
# If script and sqlquery options specified at same time, sqlquery will be used.
script = ""
# Schema name. If provided, then ALTER SESSION SET CURRENT_SCHEMA query will be executed
schema = ""
# Query execution timeout, in seconds.
timeout = 10
# Array of column names, which would be stored as tags
tag_columns = ["WAIT_CLASS"]
[[inputs.oracledb.query]]
# Query name, optional. Used in logging.
name = ""
# OracleDB sql query
sqlquery = "select n.wait_class wait_class, n.name wait_name, m.wait_count cnt, round(10*m.time_waited/nullif(m.wait_count,0),3) avgms from v$eventmetric m, v$event_name n where m.event_id=n.event_id and n.wait_class <> 'Idle' and m.wait_count > 0 order by 1"
# The script option can be used to specify the .sql file path.
# If script and sqlquery options specified at same time, sqlquery will be used.
script = ""
# Schema name. If provided, then ALTER SESSION SET CURRENT_SCHEMA query will be executed
schema = ""
# Query execution timeout, in seconds.
timeout = 10
# Array of column names, which would be stored as tags
tag_columns = ["WAIT_CLASS"]
Loading

0 comments on commit c524fed

Please sign in to comment.