Header RSS Feed
 
» Nagios Plugins

Nagios Plugin: check_win_net_usage (Windows Network Usage)

Last Update: December 15, 2015

This plugin uses check_nt, which is part of the official Nagios plugin collection. However with check_nt you only get to check one value (e.g. Bytes sent/s), if one wants to create graphics with Bytes_in and Bytes_out, there is need to bundle two checks in one. This is where this plugin plays its part. It launches two check_nt checks (one for Bytes sent/s and one for Bytes received/s) and bundles both checks to one common output.

Download check_win_net_usage.sh check_win_net_usage.sh
Download plugin and save it in your Nagios plugin folder (e.g. /usr/local/nagios/libexec)
10365 downloads so far...

Version History
20111116 First version released
20120126 Bugfix in port check
20121010 Bugfix in password handling
20121019 Handling Connection Error (thanks Hermit)
20151126 Verify interface parameter was set
20151127 Handling connection error on second connection, too
20151127 Fix perfdata format
20151215 Add network interface detection (-d parameter)

Requirements
1) check_nt plugin
2) NSClient++ installed on Windows host
3) Set variable 'pluginlocation' at the begin of the plugin to your Nagios plugins path (e.g. /usr/local/nagios/libexec)

------------------------

Usage

On the command line as nagios user:

/usr/local/nagios/libexec # ./check_win_net_usage.sh -H mywindows.server.local -p 12489 -i "VMware Accelerated AMD PCNet Adapter" -o KB
Network OK - 14 Bytes Received/sec, 4 Bytes Sent/sec|bytes_in=14608;bytes_out=4196

------------------------

Definition of the parameters

-H Hostname of Windows server to check
-p Listening port of NSClient++ on target server (default 12489)
-s Password in case NSClient++ was defined to use a password
-i Name of network interface to use (not ethX, check Windows performance GUI)
-o Choose output of value in KB, MB (default Byte)
-d Detect network interfaces on target host
--help Help text

------------------------

Command definition in Nagios/Icinga 1.x (commands.cfg):

# check_win_net_usage - Output in Bytes/s
define command {
command_name check_win_net_usage
command_line $USER1$/check_win_net_usage.sh -H $HOSTADDRESS$ -i $ARG1$ $ARG2$
}

# check_win_net_usage - Output in KBytes/s
define command {
command_name check_win_net_usage
command_line $USER1$/check_win_net_usage.sh -H $HOSTADDRESS$ -i $ARG1$ -o KB $ARG2$
}

Service checks in Nagios/Icinga 1.x:

# Check Windows Network
define service{
use generic-service
host_name windows1
service_description Network Usage
check_command check_win_net_usage!"VMware Accelerated AMD PCNet Adapter"
}

In this example, we use all default settings. The name of the interface to check is "VMware Accelerated AMD PCNet Adapter".

# Check Windows Network
define service{
use generic-service
host_name windows1
service_description Network Usage
check_command check_win_net_usage!"VMware Accelerated AMD PCNet Adapter"!-p 1248
}

In this second example, NSClient++ is listening on port 1248. Default is 12489.

# Check Windows Network
define service{
use generic-service
host_name windows1
service_description Network Usage
check_command check_win_net_usage!"VMware Accelerated AMD PCNet Adapter"!-p 1248 -s passw -o MB
}

Here, NSClient++ listens to port 1248 and requires the password 'passw' to allow remote checks. Furthermore we want the output in MBytes/s instead of Bytes/s.

------------------------

Command definition in Icinga 2.x:

# check_win_net_usage definition by Claudio Kuenzler (default output in KB)
object CheckCommand "check_win_net_usage" {
  import "plugin-check-command"
  command = [ PluginDir + "/check_win_net_usage.sh" ]

  arguments = {
    "-H" = "$win_net_usage_address$"
    "-p" = "$win_net_usage_port$"
    "-s" = "$win_net_usage_password$"
    "-i" = "$win_net_usage_interface$"
    "-o" = "$win_net_usage_output$"
  }

  vars.win_net_usage_address = "$address$"
  vars.win_net_usage_port = "1248"
  vars.win_net_usage_output = "KB"
}

Service check in Icinga 2.x (with Apply rule):

# Apply Rule for Windows Network IO by Claudio Kuenzler apply Service "Network IO " for (interface in host.vars.interfaces) {
  import "generic-service"

  check_command = "check_win_net_usage"
  vars.win_net_usage_interface = interface

  assign where host.address && host.vars.os == "Windows"
  ignore where host.vars.applyignore.networkio == true
}

Host object definition Icinga 2.x (which will be used by the Apply rule):

# object Host "windowshost" {   import "generic-host"
  address = "10.10.10.50"
  vars.os = "Windows"
  vars.interfaces = [ "vmxnet3 Ethernet Adapter _5" ]
}

------------------------

How to find the correct name of the network interface:

1) From the documentation of NSClient++ (CheckCounter):

Q: How do you list all instances of a counter?
A: Use the listCounterInstances command e.g. check_nrpe -c listCounterInstances -a "Network Interface"

2) Or check manually in Windows by using the 'Performance' application GUI.

3) Another pretty way is to use the Windows command typeperf.exe to list all available network interfaces:

typeperf.exe -qx | find "Network Interface"

4) Since version 20151215 the -d parameter allows to detect the network interface names on the Windows target:

./check_win_net_usage.sh -H windowshost -p 1248 -d
vmxnet3 Ethernet Adapter _5

------------------------

Nagiosgraph screenshot:


Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

6979 Days
until Death of Computers
Why?