Hello Guest

Author Topic: Module for network traffic  (Read 1146 times)

0 Members and 1 Guest are viewing this topic.

Offline abel

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Module for network traffic
« on: June 27, 2016, 03:14:08 PM »

Hello,
I would like to know if anyone knows how to monitor traffic network card ( download and upload ) on a Windows client computer.
I tried several options but without success.
Thank you very much.

Offline nil

  • Administrator
  • Expert member
  • *****
  • Posts: 1294
  • Karma: 28
  • I can see everything... with my glasses :-)
    • View Profile
    • Pandora FMS
Re: Module for network traffic
« Reply #1 on: June 28, 2016, 02:58:18 PM »
Hi Abel,

Sure. If you take a look on nettraffic.vbs plugin you can modify the code to get detailed information per interface:

' nettraffic.vbs
' Pandora FMS Agent Plugin for Microsoft Windows (All platfforms)
' (c) 2014 Sancho Lerena <slerena@artica.es>
' Returns total bytes in network since bootup and % of network use
' ----------------------------------------------------------------
' usage: cscript //B nettraffic.vbs

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\Root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("select * from Win32_PerfRawData_Tcpip_NetworkInterface ")

BytesSUM = 0

For Each objItem in colItems
   bytesTotal = objitem.BytesTotalPersec * 8
   BytesSUM = BytesSUM + bytesTotal

Next

Wscript.StdOut.WriteLine "<module>"
Wscript.StdOut.WriteLine "    <name><![CDATA[Network_Usage_Bytes]]></name>"
Wscript.StdOut.WriteLine "    <description><![CDATA[Total network usage in bytes]]></description>"
Wscript.StdOut.WriteLine "    <unit>bytes/sec</unit>"
Wscript.StdOut.WriteLine "    <type>generic_data_inc</type>"
Wscript.StdOut.WriteLine "    <data><![CDATA[" & BytesSUM & "]]></data>"
Wscript.StdOut.WriteLine "</module>"

Wscript.StdOut.flush
' End script

This code get all the traffic from all the interfaces and put all together. In a specific system you can get the information on WMI token "Win32_PerfRawData_Tcpip_NetworkInterface" it returns, totalbytes, send and received in three diferent variables:

uint32 BytesReceivedPerSec;
uint32 BytesSentPerSec;
uint64 BytesTotalPerSec;

This script could be modified to return two modules, one per input and other for output, and/or get only data from one interface.
-- See you in the other screen.

Offline abel

  • Newbie
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
Re: Module for network traffic
« Reply #2 on: June 28, 2016, 03:31:27 PM »

I run the script that you uploaded in http://library.pandorafms.com/index.php?sec=Library&sec2=repository&lng=es&action=view_PUI&id_PUI=617 and no problems on the client computer .
When you insert the plug- in configuration file and restart the agent I do not see the module in pandora .
In the log file does not throw me any problem.
what am I doing wrong?.
this is the line in pandora.conf
module_plugin cscript //B "%PROGRAMFILES%\Pandora_Agent
\util\nic_traffic.vbs"

Trank you very much.

Offline nil

  • Administrator
  • Expert member
  • *****
  • Posts: 1294
  • Karma: 28
  • I can see everything... with my glasses :-)
    • View Profile
    • Pandora FMS
Re: Module for network traffic
« Reply #3 on: June 29, 2016, 12:39:59 AM »
This module returns a generic_data_inc value, this means you need at least two executions to show a value, because it shows the delta (the different between first execution and second), have you waited to see the second execution ?

If not, set the agent in debug mode, and put here the XML file to see what happen.

I run the script that you uploaded in http://library.pandorafms.com/index.php?sec=Library&sec2=repository&lng=es&action=view_PUI&id_PUI=617 and no problems on the client computer .
When you insert the plug- in configuration file and restart the agent I do not see the module in pandora .
In the log file does not throw me any problem.
what am I doing wrong?.
this is the line in pandora.conf
module_plugin cscript //B "%PROGRAMFILES%\Pandora_Agent
\util\nic_traffic.vbs"

Trank you very much.
-- See you in the other screen.