Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the 'core.tcp_info' command to the exporter #16

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ Flags:
URI on which to scrape kamailio. E.g.
"unix:/var/run/kamailio/kamailio_ctl" or
"tcp://localhost:2049"
-m, --kamailio.methods="tm.stats,sl.stats,core.shmmem,core.uptime"
-m, --kamailio.methods="tm.stats,sl.stats,core.shmmem,core.uptime,core.tcp_info"
karstenjakobsen marked this conversation as resolved.
Show resolved Hide resolved
Comma-separated list of methods to call. E.g.
"tm.stats,sl.stats". Implemented:
tm.stats,sl.stats,core.shmmem,core.uptime,dispatcher.list
tm.stats,sl.stats,core.shmmem,core.uptime,core.tcp_info,dispatcher.list
-t, --kamailio.timeout=5s Timeout for trying to get stats from kamailio.
```

Expand Down Expand Up @@ -66,6 +66,12 @@ If you are using the [DISPATCHER](http://kamailio.org/docs/modules/stable/module
./kamailio_exporter -m "tm.stats,sl.stats,core.shmmem,core.uptime,dispatcher.list"
```

If you want more information regarding TCP and TLS connections, you can use `core.tcp_info` as well:

```bash
./kamailio_exporter -m "tm.stats,sl.stats,core.shmmem,core.uptime,core.tcp_info"
```

List of exposed metrics:
```
# HELP kamailio_core_shmmem_fragments Number of fragments in shared memory.
Expand Down Expand Up @@ -114,6 +120,18 @@ List of exposed metrics:
# TYPE kamailio_tm_stats_waiting gauge
# HELP kamailio_up Was the last scrape successful.
# TYPE kamailio_up gauge
# HELP kamailio_core_tcp_info_readers Total TCP readers.
# TYPE kamailio_core_tcp_info_readers gauge
# HELP kamailio_core_tcp_info_max_connections Maximum TCP connections.
# TYPE kamailio_core_tcp_info_max_connections gauge
# HELP kamailio_core_tcp_info_max_tls_connections Maximum TLS connections.
# TYPE kamailio_core_tcp_info_max_tls_connections gauge
# HELP kamailio_core_tcp_info_max_opened_connections Opened TCP connections.
# TYPE kamailio_core_tcp_info_max_opened_connections gauge
# HELP kamailio_core_tcp_info_max_opened_tls_connections Opened TLS connections.
# TYPE kamailio_core_tcp_info_max_opened_tls_connections gauge
# HELP kamailio_core_tcp_info_max_write_queued_bytes Write queued bytes.
# TYPE kamailio_core_tcp_info_max_write_queued_bytes gauge
```

## Compiling
Expand Down
20 changes: 20 additions & 0 deletions collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ kamcmd> core.shmmem
max_used: 13323296
fragments: 44546
}
kamcmd> core.tcp_info
{
readers: 8
max_connections: 4096
max_tls_connections: 2048
opened_connections: 595
opened_tls_connections: 401
write_queued_bytes: 0
}
*/

// Collector implements prometheus.Collector (see below).
Expand Down Expand Up @@ -122,6 +131,7 @@ var (
"sl.stats",
"core.shmmem",
"core.uptime",
"core.tcp_info",
"dispatcher.list",
}

Expand Down Expand Up @@ -153,6 +163,14 @@ var (
"core.uptime": {
NewMetricCounter("uptime", "Uptime in seconds.", "core.uptime"),
},
"core.tcp_info": {
NewMetricGauge("readers", "Total TCP readers.", "core.tcp_info"),
NewMetricGauge("max_connections", "Maximum TCP connections", "core.tcp_info"),
NewMetricGauge("max_tls_connections", "Maximum TLS connections.", "core.tcp_info"),
NewMetricGauge("opened_connections", "Opened TCP connections.", "core.tcp_info"),
NewMetricGauge("opened_tls_connections", "Opened TLS connections.", "core.tcp_info"),
NewMetricGauge("write_queued_bytes", "Write queued bytes.", "core.tcp_info"),
},
"dispatcher.list": {
NewMetricGauge("target", "Target status.", "dispatcher.list"),
},
Expand Down Expand Up @@ -401,6 +419,8 @@ func (c *Collector) scrapeMethod(method string) (map[string][]MetricValue, error
}
case "core.shmmem":
fallthrough
case "core.tcp_info":
fallthrough
case "core.uptime":
for _, item := range items {
i, _ := item.Value.Int()
Expand Down