You must be a MyPeek member to download our extensibility solutions. Click here to learn more about the benefits of membership and find out how to sign up for free.
You must have a valid maintenance contract to download this file.
If you are not a LiveAction Maintenance Customer but would like to purchase a Maintenance contract for your LiveAction product please click here for sales information.
Category : Scripts
Submitted By : spacepacket
Downloaded : 127 Times
Rating : Not Yet Rated
View Comments (1)
This is a command line utility for the OmniEngine that displays all of the flows and their stats for a named capture.The OmniEngine can be local or remote. If the named capture does not exist, it is created with the specified adapter.
This program depends on OmniScript 5.2.11 or later.
The Visual Studio Solution and the executable can be downloaded by maintenance members.
Run the program with no arguments to get the usage
Sample Usage: flowstats capture1 "Local Area Connection" 10.4.2.59 root root
#include "stdafx.h" #import "EPRCmdAPI.tlb" rename("value", "val") using namespace EPRCmdAPI; int _tmain(int argc, _TCHAR* argv[]) { if (argc == 1) { wprintf( L"usage: flowstats capturename [adaptername] [hostname] [username] [password]rn" ); return 0; } _bstr_t bstrCaptureName = L"Capture"; if (argc > 1) bstrCaptureName = argv[1]; CComBSTR bstrAdapterName = L"Local Area Connection"; if (argc > 2) bstrAdapterName = argv[2]; CComBSTR bstrHostName; if (argc > 3) bstrHostName = argv[3]; CComBSTR bstrUserName; if (argc > 4) bstrUserName = argv[4]; CComBSTR bstrPassword; if (argc > 5) bstrPassword = argv[5]; HRESULT hr; hr = CoInitializeEx(NULL, 0); if ( FAILED( hr ) ) { wprintf( L"Failed to initialize COM.rn" ); return -1; } // create a block inside the coinitialize { CComPtrspCmdMgr; hr = spCmdMgr.CoCreateInstance( _T( "EPRCmdAPI.WPRemoteCmdMgr" ) ); if (FAILED(hr)) { wprintf( L"Failed to initialize OmniScriptrn" ); return -1; } if (bstrHostName.Length() == 0) { hr = spCmdMgr->Connect( L"localhost", 6367, 30000 ); } else { CComBSTR bstrAuth( L"" ); CComBSTR bstrDomain( L"" ); hr = spCmdMgr->ConnectWithCred( BSTR( bstrHostName ), 6367, BSTR( bstrAuth ), BSTR( bstrDomain ), BSTR( bstrUserName ), BSTR( bstrPassword ), 30000 ); } if (FAILED(hr)) { wprintf( L"Failed to connect to OmniEnginern" ); return -1; } IPeekRemoteCaptureListPtr spCaptureListPtr; spCaptureListPtr = spCmdMgr->GetCaptureList( ); BOOL bExists = FALSE; LONG lCount = spCaptureListPtr->GetCount(); IPeekRemoteCaptureInfoPtr spCaptureInfo; _bstr_t bstrCapture; for (long i=0; i < lCount; i++ ) { spCaptureInfo = spCaptureListPtr->GetItem( i ); _bstr_t bstrCaptureName2 = spCaptureInfo->GetName(); if (bstrCaptureName == bstrCaptureName2) { bstrCapture = spCaptureInfo->GetID(); bExists = TRUE; break; } } if (bExists == FALSE) { bstrCapture = spCmdMgr->CreateNewCapture( bstrCaptureName, TRUE, FALSE, 0, 0, 0, 0, 0, FALSE, 0, 512, BSTR( bstrAdapterName ) ); hr = spCmdMgr->StartCapture( bstrCapture ); if (FAILED(hr)) { wprintf( L"Failed to start capturern" ); return -1; } } IPeekConversationListPtr spConversationListPtr; spConversationListPtr = spCmdMgr->GetConversationListAll( bstrCapture ); long nCount = spConversationListPtr->GetCount(); _tprintf( _T("Source IP Destination IP Packets In Packets Out Bytes In Bytes Outrn") ); for (int i=0; i < nCount; i++) { IPeekConversationStatPtr spFlow = spConversationListPtr->GetItem( i ); _bstr_t bstrSrcIP = spFlow->GetSrcIPAddress(); _bstr_t bstrDstIP = spFlow->GetDestIPAddress(); double nPacketsReceived = spFlow->GetPacketsReceived(); double nPacketsSent = spFlow->GetPacketsSent(); double nBytesReceived = spFlow->GetBytesReceived(); double nBytesSent = spFlow->GetBytesSent(); _tprintf( _T("%-15s %-15s %15.0f %15.0f %15.0f %15.0frn"), (LPCTSTR)bstrSrcIP, (LPCTSTR)bstrDstIP, nPacketsReceived, nPacketsSent, nBytesReceived, nBytesSent); } } CoUninitialize(); return 0; }
Comments
Doesn't work
Posted by: Kevin Burns on Tuesday, October 5th, 2010 at 12:17 PM