0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Icinga2でVPNのセッション数を監視してみる

Last updated at Posted at 2020-07-03

まえがき

以前にIcinga2の導入について記載した。昨今のリモートワークによる利用者数の増加もあり、VPNがどれだけ利用されているか確認するため、Icinga2で監視することにした。

設定方法

Cisco ASAシリーズのVPN装置で、SSL-VPN、Web-VPN、IPsec-VPNの3種類の同時接続数をそれぞれ監視することにする。
また、同時にping監視も実施している。

CLIから疎通確認

# /usr/lib64/nagios/plugins/check_snmp -H 192.168.0.201 -C public -P 2c -o 1.3.6.1.4.1.9.9.392.1.3.35.0 

icinga2の設定

VPN装置に対してSNMPで状態を取得できるようにして、下記設定をIcinga2に追加する。OIDは適当に確認しておく。

/etc/icinga2/conf.d/template-vpn.conf
template Host "vpn-device" {
  check_command = "ping4"
  vars.agent_type = "snmp"
  vars.snmp_community = "public"
  vars.snmp_version = "2c"
}

apply Service "cisco-ipsec-sessions" {
  import "generic-service"

  check_command = "snmp"
  vars.snmp_oid = "1.3.6.1.4.1.9.9.392.1.3.26.0"
  vars.snmp_label = "ipsec-sessions"
  vars.check_command = "ipsec-sessions"
  assign where host.vars.category == "Cisco VPN"

  name = "ipsec-sessions"
}

apply Service "cisco-sslvpn-sessions" {
  import "generic-service"

  check_command = "snmp"
  vars.snmp_oid = "1.3.6.1.4.1.9.9.392.1.3.35.0"
  vars.snmp_label = "sslvpn-sessions"
  vars.check_command = "sslvpn-sessions"

  assign where host.vars.category == "Cisco VPN"

  name = "sslvpn-sessions"
}

apply Service "cisco-webvpn-sessions" {
  import "generic-service"

  check_command = "snmp"
  vars.snmp_oid = "1.3.6.1.4.1.9.9.392.1.3.38.0"
  vars.snmp_label = "webvpn-sessions"
  vars.check_command = "webvpn-sessions"

  assign where host.vars.category == "Cisco VPN"

  name = "webvpn-sessions"
}

VPN装置にVPNで始まるホスト名を付け、グループ化。

/etc/icinga2/conf.d/group-vpn.conf
object HostGroup "vpn-group" {
  display_name = "VPNグループ"
  assign where regex("^[VPN].*", host.name)
}

object Host "VPN001" {
  import "vpn-device"

  address = "192.168.0.201"
  vars.model = "ASA5500-X Series"
  vars.category = "Cisco VPN"
  notes = "hogehoge用VPN (VPN001)"
}

Icinga Web 2の設定

取得した時系列データをIcinga Web 2上でグラフ表示するための設定を行う。

/usr/share/icingaweb2/modules/graphite/templates/ipsec-sessions.ini
[ipsec-sessions.graph]
check_command = "ipsec-sessions"

[ipsec-sessions.metrics_filters]
value = "$service_name_template$.perfdata.ipsec-sessions.value"

[ipsec-sessions.urlparams]
areaAlpha = "0.5"
areaMode = "all"
lineWidth = "2"
min = "0"
yUnitSystem = "none"

[ipsec-sessions.functions]
value = "alias(color($metric$, '#1a7dd7'), 'IPSec-VPN sessions')"
/usr/share/icingaweb2/modules/graphite/templates/sslvpn-sessions.ini
[sslvpn-sessions.graph]
check_command = "sslvpn-sessions"

[sslvpn-sessions.metrics_filters]
value = "$service_name_template$.perfdata.sslvpn-sessions.value"

[sslvpn-sessions.urlparams]
areaAlpha = "0.5"
areaMode = "all"
lineWidth = "2"
min = "0"
yUnitSystem = "none"

[sslvpn-sessions.functions]
value = "alias(color($metric$, '#1a7dd7'), 'SSL-VPN sessions')"
/usr/share/icingaweb2/modules/graphite/templates/webvpn.sessions.ini
[webvpn-sessions.graph]
check_command = "webvpn-sessions"

[webvpn-sessions.metrics_filters]
value = "$service_name_template$.perfdata.webvpn-sessions.value"

[webvpn-sessions.urlparams]
areaAlpha = "0.5"
areaMode = "all"
lineWidth = "2"
min = "0"
yUnitSystem = "none"

[webvpn-sessions.functions]
value = "alias(color($metric$, '#1a7dd7'), 'Web-VPN sessions')"

監視結果

3ヵ月ほど監視してみた結果、このようなグラフとなった。実際には上記設定に加えてCPU使用率やuptimeも見るようにしているため、表示が異なっている。

Screenshot_2020-07-03 sslvpn-sessions DDTCFW003 サービス Icinga Web2.png

おまけ

snmpでうまく値が取れない場合

snmpでうまく値が取れない場合は、debuglogを有効にしてみる。

# icinga2 feature enable debuglog
# systemctl restart icinga2
# less /var/log/icinga2/debug.log
# icinga2 feature disable debuglog
# systemctl restart icinga2
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?