Operating System - HP-UX
1834513 Members
2326 Online
110068 Solutions
New Discussion

Are there any calls to get network speed?

 
SOLVED
Go to solution
shivakumara
Occasional Advisor

Are there any calls to get network speed?

Hi all,
I am writing C program to get networkspeed and collissions..etc. I know that from `netstat -i` I will get this information. But, for better programming I wanted to get from some calls(system/network). Even in hpbtlanconf file also this has not hardcoded. Can you please help me out.
Thanx in Advance

-shivu
7 REPLIES 7
rick jones
Honored Contributor

Re: Are there any calls to get network speed?

Try the DLPI manuals at http://docs.hp.com/ I think they will include an example of retrieving the statistics for a NIC and that may include the speed/duplex etc.

Or you can use the system() system call and parse lanadmin output.
there is no rest for the wicked yet the virtuous have no pillows
shivakumara
Occasional Advisor

Re: Are there any calls to get network speed?

Hi rick,
I scan dlpi.h file. There I couldn't find speed variables.. As well If I can take from system() of lanadmin, how can I pass the values simultaneously.
As you know lanadmin will throw menu, and Enter command prompt. Like the below
lan = LAN Interface Administration
menu = Display this menu
quit = Terminate the Administration
terse = Do not display command menu
verbose = Display command menu
Enter command:lan
Then It will throw
clear = Clear statistics registers
display = Display LAN Interface status and statistics registers
end = End LAN Interface Administration, return to Test Selection
menu = Display this menu
ppa = PPA Number of the LAN Interface
quit = Terminate the Administration, return to shell
reset = Reset LAN Interface to execute its selftest
specific = Go to Driver specific menu

Enter command:display

Now we will get the required informayion.

Now I need to put all these lanadmin, lan and display. so that I will get the required information.
Please guide me how can I give all these command in one shot and execute.

-shivu

Chauhan Amit
Respected Contributor
Solution

Re: Are there any calls to get network speed?

Check out these threads as well,

http://forums1.itrc.hp.com/service/forums/bizsupport/questionanswer.do?threadId=473449

http://forums1.itrc.hp.com/service/forums/bizsupport/questionanswer.do?threadId=24481

Hope this helps.

-Amit
If you are not a part of solution , then you are a part of problem
Ralph Grothe
Honored Contributor

Re: Are there any calls to get network speed?

There's no need to run lanadmin interactively.
It so only behaves when it isn't passed any arguments.
For instance if you want to get the speed and mode of the NIC lan1 you could run

$ /usr/sbin/lanadmin -sx 1
Speed = 100000000
Current Config = 100 Full-Duplex AUTONEG


If you don't find a better solution through some system lib (sorry, am no C systems hacker), or syscall, you could maybe wrap the above in an sys() or exec*() call.

Besides, what about SNMP?
You could install the free net-snmp suite and query the NICs' MIB stats from any node.
Only take two queries and devide by the interval to get a very crude interpolation of the packet rates.
Then from the MTU setting you could estimate the Byte rates.
You could even get the counters of inbound and outbound packets from a lanadmin call

$ /usr/sbin/lanadmin -g mibstats 1|awk -F= '/(In|Out)bound Octets/{print$NF}'
61706455
17558433

Of course you wouldn't do the parsing with an external awk call like above.
I've put something similar in a Perl script which has built-in parsing power.

HTH
Ralph

Madness, thy name is system administration
rick jones
Honored Contributor

Re: Are there any calls to get network speed?

You need to scan the DLPI Manuals, not the dlpi.h file (nor dlpi_ext.h IIRC). It is in the manuals that I think the example exists to retrieve information from the card programatically. http://docs.hp.com/
there is no rest for the wicked yet the virtuous have no pillows
Bill Hassell
Honored Contributor

Re: Are there any calls to get network speed?

Here's a single command to get the stats from lanadmin:

echo "lan \n ppa 1 \n display \n quitâ | lanadmin

lanadmin can take stdin as input so anything you can type into the menu, you can put on a single line and use a system() call to get the results.


Bill Hassell, sysadmin
rick jones
Honored Contributor

Re: Are there any calls to get network speed?

Bill's command will work with all lanadmin's regardless of vintage. If though you have a newer (for some definition of "new") you can say:

lanadmin -g mibstats

instead
there is no rest for the wicked yet the virtuous have no pillows