Page 2 of 3

Re: Bandwidth monitoring

Posted: Thu Feb 27, 2014 7:23 am
by nottheadmin
Appreciate the help, when do you think sreinhardt will be able to look at this, just so i know when to plan for it?

Thanks
M

Re: Bandwidth monitoring

Posted: Thu Feb 27, 2014 11:12 am
by sreinhardt
I was planning on it yesterday, but had a few things come up. Hopefully I can have it done by mid afternoon for you!

Re: Bandwidth monitoring

Posted: Thu Feb 27, 2014 12:02 pm
by sreinhardt
OK, so here is what works for me, see if this suites your needs.

Use this to get your interface names:

Code: Select all

./check_wmi_plus.pl -H 192.168.5.xxx -u [domain/user] -p [password] --nokeepstate -m checknetwork
Then run this to test the interface initially, and configure warning and critical values as needed:

Code: Select all

./check_wmi_plus.pl -H 192.168.5.xxx -u [domain/user] -p [password] --nokeepstate -m checknetwork -a 'Intel[R] 82579LM Gigabit Network Connection'
If I wanted to warn on bytes sent per second, I would use the command (notice the removal of --nokeepstate):

Code: Select all

./check_wmi_plus.pl -H 192.168.5.xxx -u [domain/user] -p [password] -m checknetwork -a 'Intel[R] 82579LM Gigabit Network Connection' -w _BytesSentPersec=200
This is all of the help the plugin provides on additional parameters and warning/critical values to check.

Code: Select all

checknetwork
   These network checks use WMI Raw counters to calculate values over a given timeperiod.
   This is much more accurate than taking Formatted WMI values.
   ARG1  Specify with network adapter the stats are collected for.
      The name of the network adaptors as seen from WMI are similar to what is seen in the output of the
      ipconfig/all command on Windows. However, its not exactly the same. Run without -a to list the adapter
      names according to WMI. Typically you need to use '' around the adapter name when specifying.
      eg -a 'Intel[R] PRO_1000 T Server Adapter _2 - Packet Scheduler Miniport'
   DELAY  (optional) specifies the number of seconds over which the utilisation is calculated. The longer you can make this without timing out, the more accurate it will be. If specifying longer values. You may also need to use the -t parameter to set a longer script timeout. Only valid if also specifying --nokeepstate ie you are not using the state keeping feature. We recommend that you do keep state and hence do not use --nokeepstate.
   WARN/CRIT  can be used as described below.
      Valid Warning/Critical Fields are: CurrentBandwidth (Default), _PacketsSentPersec, _PacketsReceivedPersec, OutputQueueLength, PacketsReceivedErrors, _BytesSentPersec, _BytesReceivedPersec
   BYTEFACTOR  defaults to 1000 for this mode. You can override this if you wish.

Re: Bandwidth monitoring

Posted: Mon Mar 03, 2014 5:53 am
by nottheadmin
Thanks Spenser, I had a play with this. My goal is to log bandwidth use so that at the end of the month, I can see how much bandwidth we used.

I can list the adapters

Code: Select all

 ./check_wmi_plus.pl -H anotherhost-u domain/user -p password --nokeepstate -m checknetwork
Valid Adapter Names are:
HP Ethernet 1Gb 4-port 331FLR Adapter
HP Ethernet 1Gb 4-port 331FLR Adapter _2
HP Ethernet 1Gb 4-port 331FLR Adapter _3
HP Ethernet 1Gb 4-port 331FLR Adapter _4
Specify the -a parameter with an adapter name. Use ' ' around the adapter name.
For example: -a 'HP Ethernet 1Gb 4-port 331FLR Adapter'
ok,

Code: Select all

[root@localhost libexec]# ./check_wmi_plus.pl -H hostsname -u domain/user -p password --nokeepstate -m checknetwork -a 'HP Ethernet 1Gb 4-port 331FLR Adapter'
UNKNOWN - Plugin Timed out (15 sec)
I'm getting this with a few different hosts.

Any ideas?

Perhaps WMI is not the best way to do this, it seems plagued with unhelpful errors and timeouts

Thanks
Matt

Re: Bandwidth monitoring

Posted: Mon Mar 03, 2014 1:39 pm
by lmiltchev
Have you tried increasing the timeout?

Code: Select all

./check_wmi_plus.pl -H hostsname -u domain/user -p password --nokeepstate -m checknetwork -a 'HP Ethernet 1Gb 4-port 331FLR Adapter' -t 180
Does this time out as well?

Re: Bandwidth monitoring

Posted: Tue Mar 04, 2014 10:11 am
by nottheadmin
Ah ok, yes, now i get some results :D

Code: Select all

OK - Interface: HP NC373i Multifunction Gigabit Server Adapter (Speed:1.000Gbit/s                                                                                                                                      Rate=4.642KB/sec, Byte Receive Rate=7.406KB/sec, Packet Send Rate=21.000packet/s                                                                                                                                     Receive Rate=39.000packet/sec, Output Queue Length=0, Packets Received Errors=0|'                                                                                                                                     ersec'=4642; '_BytesReceivedPersec'=7406; '_PacketsSentPersec'=21; '_PacketsRecei                                                                                                                                     39; 'OutputQueueLength'=0; 'PacketsReceivedErrors'=0;
Now what I want is to be able to produce graphs.

eg, bandwidth used in GB's over a period of time.

Also, to run this check, do I add it in manually into Service Management?, using the check command pulldown menu and adding the arguments?

Thanks for your help with this so far, it is appreciated.

Re: Bandwidth monitoring

Posted: Tue Mar 04, 2014 5:06 pm
by sreinhardt
Yes you would need to add the services\command arguments manually within CCM. Getting the overall usage is probably going to be more tricky though. You probably would want to write a wrapper script that combines the data over a period of time. Otherwise I would suggest looking into nagios network analyzer, as it is specifically geared towards this type of information.

Re: Bandwidth monitoring

Posted: Wed Mar 05, 2014 4:52 am
by nottheadmin
Thanks Spenser.

A couple more questions if i may.

When adding this as a check in CCM>Services>Service Management, $ARG5$, in my case the -t 180 timeout, is not passed through.


Code: Select all

 COMMAND: /usr/local/nagios/libexec/check_wmi_plus.pl -H hostname -u mydom.com/user -p password --nokeepstate -m checknetwork -a 'HP NC373i Multifunction Gigabit Server Adapter'
OUTPUT: UNKNOWN - Plugin Timed out (15 sec)
Here is a screenshot of the config but with the passwords etc.. changed.

Image

Second question, do you have a link for some info on wrapping in this into a script, an example maybe?

Thanks
M

Re: Bandwidth monitoring

Posted: Wed Mar 05, 2014 11:31 am
by sreinhardt
To include $ARG5$ you will need to modify the command definition to include $ARG5$ and not stop at arg4. Alternatively, you can just append it to the end of arg4 and it should apply just the same.

Unfortunately I do no have any examples for this specifically. I think the route I would take is to write a shell script that accepts hostname\IP, interface name, and timeout. Then you can use those to call the plugin as normal but from the script. Once you get the results back of the current usage, you could add this amount to a file in /tmp or /var, etc, and continue to return this result to nagios for a cumulative bandwidth total. That is just an initial "outloud" thought process of how I would go about handling what you are looking to do.

Re: Bandwidth monitoring

Posted: Thu Mar 06, 2014 6:42 am
by nottheadmin
understood, i'll add that to my list of things to do, if and when i get it working i'll post it back here in case in helps someone else. :)

new question just came up so will start a new thread for that.