CodedK
asked on
Router Uptime.
Hi.
How can i get router uptime ?
How can i get router uptime ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi theRealLoki, please tell me the commands .
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>Hi theRealLoki, please tell me the commands .
I need to know what router it is
for mine,
i go
telnet 102.32.0.10
"username"
"password"
"1"
try it in dos first and see if you have the info in there you need
Russel, yes i know this, this is why I asked if he wanted a generic method, and what his router was...
I need to know what router it is
for mine,
i go
telnet 102.32.0.10
"username"
"password"
"1"
try it in dos first and see if you have the info in there you need
Russel, yes i know this, this is why I asked if he wanted a generic method, and what his router was...
ASKER
>> Whats "1" ?
The post was mainly for CodedK's benefit, so it was understood that a generic method (for all routers) was not possible, at least not very easily.
Btw, is the IP addr you list in your example just an example? (its not in the private range of 10.x.x.x or 192.x.x.x) Just curious....
Russell
ASKER
Ok mine differs a little.
I got a "menu" command.
I got in and saw that no uptime info is available on general info menu.
Nevertheless on the browser page i can see info like uptime and other things that dont exist in telnet command.
~-~-~-~-~-~-~-~-~-~-~-~-~- ~-~-~-~-~- ~-~-~-~-~- ~-~-~-~-~- ~-~-~-~-~- ~-~-
This all question thing was more about GetAdapterInfo.
I wanted to know just one thing... a list of what GetAdapterInfo can bring...
I've managed to gather this info :
interface caption
index of the interfaces
type of interface
max transmission unit
speed of the interfaces
length of physical address
physical address of adapter
administrative status
operational status
read time operational status changed
octets received
unicast packets received
non unicast packets received
received packets discarded
erroneous packets received
unknown protocol packets received
octets sent
unicast packets sent
non unicast packets sent
outgoing packets discarded
erroneous packets sent
output queue length
length of bDescr more member
interface description
Address
If DHCP Enabled
Current Ip Address
Ip Address List
Gateway List
DHCP Server
Have Wins
Primary Wins Server
Secondary Wins Server
Lease Obtained
Lease Expires
~-~-~-~-~-~-~-~-~-~-~-~-~- ~-~-~-~-~- ~-~-~-~-~- ~-~-~-~-~- ~-~-~-~-~- ~-~-
Is there anything more info i can get ????
Some of that info raise errors, some not.
I thought that uptime would be easy to get...
I see that this is not the case... :)
I got a "menu" command.
I got in and saw that no uptime info is available on general info menu.
Nevertheless on the browser page i can see info like uptime and other things that dont exist in telnet command.
~-~-~-~-~-~-~-~-~-~-~-~-~-
This all question thing was more about GetAdapterInfo.
I wanted to know just one thing... a list of what GetAdapterInfo can bring...
I've managed to gather this info :
interface caption
index of the interfaces
type of interface
max transmission unit
speed of the interfaces
length of physical address
physical address of adapter
administrative status
operational status
read time operational status changed
octets received
unicast packets received
non unicast packets received
received packets discarded
erroneous packets received
unknown protocol packets received
octets sent
unicast packets sent
non unicast packets sent
outgoing packets discarded
erroneous packets sent
output queue length
length of bDescr more member
interface description
Address
If DHCP Enabled
Current Ip Address
Ip Address List
Gateway List
DHCP Server
Have Wins
Primary Wins Server
Secondary Wins Server
Lease Obtained
Lease Expires
~-~-~-~-~-~-~-~-~-~-~-~-~-
Is there anything more info i can get ????
Some of that info raise errors, some not.
I thought that uptime would be easy to get...
I see that this is not the case... :)
if snmp is not an option, and you don't mind this solution only working for your particular router, then you can use TIdHTTP and login to the router's web interface and scrape the uptime off that page.
rllibby should be able to point you in the right direction on how to do that... it's not something I've had much experience with :-)
rllibby should be able to point you in the right direction on how to do that... it's not something I've had much experience with :-)
The list of the field elements and their descriptions for the return buffer from GetAdaptersInfo can be found here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/ip_adapter_info.asp
This data only applies to the PC's network adapter interface. As to the router, have you Googled your router brand to see if you can locate any info regarding the command set available via remote admin?
Russell
ASKER
Its generic or nothing.... I dont want this app to work only in my pc. :)
ASKER
Wait a second Russell ... I am lost here :)
>>This data only applies to the PC's network adapter interface
I've connected my modem/router through usb and i get this info through getadaptersinfo.
I get all the adapters in my pc along with my modem... And i can get all that info like that.
>>This data only applies to the PC's network adapter interface
I've connected my modem/router through usb and i get this info through getadaptersinfo.
I get all the adapters in my pc along with my modem... And i can get all that info like that.
ASKER
I know that if i connect it through the lan card i wont see the router any more...
I will only see my lan card...Is that right ?
I will only see my lan card...Is that right ?
This should clear some of the confusion up:
- go to cmd prompt
- type > ipconfig /all
- read the results
This is the info you will get back from GetAdaptersInfo. It has nothing to do with the router and everything to do with the network interfaces. (be it usb, modem, loopback interface, or lan card). The only thing even related to the router will be the DHCP info, if your router is set up to hand out dynamic ip's
Russell
- go to cmd prompt
- type > ipconfig /all
- read the results
This is the info you will get back from GetAdaptersInfo. It has nothing to do with the router and everything to do with the network interfaces. (be it usb, modem, loopback interface, or lan card). The only thing even related to the router will be the DHCP info, if your router is set up to hand out dynamic ip's
Russell
ASKER
Where is the ball...?
Ok sorry for the mess i made :)
Lets say that i wanted to ask how can i get network adapter uptime :P
does this change anything or not ?
Ok sorry for the mess i made :)
Lets say that i wanted to ask how can i get network adapter uptime :P
does this change anything or not ?
ASKER
Thank you for the time and sorry for the mess :)
Increasing and splitting...
(Although i didnt understand much :) ) anyway thank you all for you time.
Increasing and splitting...
(Although i didnt understand much :) ) anyway thank you all for you time.
>> Lets say that i wanted to ask how can i get network adapter uptime :P
>> does this change anything or not ?
Absolutely. This information is available for each of the network interfaces on the PC, and this functionality works with Win98 on up. The only "undocumented" aspect is how to take the dwLastChange field and convert it into something meaningful, which I have done for you.
Enjoy,
Russell
----
program Project1;
{$APPTYPE CONSOLE}
//////////////////////////
// Include Units (IP Helper units: ftp://delphi-jedi.org/api/IPHlpAPI.zip)
//////////////////////////
uses
Windows,
SysUtils,
WinSock,
WinInet,
IpExport,
IpHlpApi,
IpTypes,
IpIfConst,
IpRtrMib;
// Totally undocumented as to how you take the DWORD value and convert it into a useable date time value.
function LastChangeTimeToDateTime(C
var lpSysTime: TSystemTime;
lpFileTime: TFileTime;
begin
// Get system time as file time
GetSystemTimeAsFileTime(lp
// Convert to useable format
Int64(lpFileTime):=Int64(l
// Check low part of date against change time
if (lpFileTime.dwLowDateTime < ChangeTime) then Dec(lpFileTime.dwHighDateT
// Set new low part
lpFileTime.dwLowDateTime:=
// Convert back to 100-nanosecond intervals
Int64(lpFileTime):=Int64(l
// Convert result to local time
FileTimeToLocalFileTime(lp
// Convert to system time
FileTimeToSystemTime(lpFil
// Convert to delphi date time
result:=SystemTimeToDateTi
end;
var
lpIfTable: PMibIfTable;
dtElapse: TDateTime;
wDays: Word;
wTime: Array [0..3] of Word;
dwSize: DWORD;
dwIndex: DWORD;
begin
dwSize:=0;
lpIfTable:=nil;
if (GetIfTable(lpIfTable, dwSize, False) = ERROR_INSUFFICIENT_BUFFER)
begin
lpIfTable:=AllocMem(dwSize
try
if (GetIfTable(lpIfTable, dwSize, True) = ERROR_SUCCESS) and (lpIfTable^.dwNumEntries > 0) then
begin
for dwIndex:=0 to Pred(lpIfTable^.dwNumEntri
begin
// Display the interface description
WriteLn(PChar(@lpIfTable^.
// Display the last change time
dtElapse:=Now-LastChangeTi
// Decode days
wDays:=Trunc(dtElapse);
// Remove days
dtElapse:=dtElapse - wDays;
// Decode time
DecodeTime(dtElapse, wTime[0], wTime[1], wTime[2], wTime[3]);
// Check days
if (wDays > 0) then
// Print with days
WriteLn('Duration : ', wDays, ' days, ', Format('%.2d:%.2d:%.2d', [wTime[0], wTime[1], wTime[2]]))
else
// Print without days
WriteLn('Duration : ', Format('%.2d:%.2d:%.2d', [wTime[0], wTime[1], wTime[2]]));
// Space
WriteLn;
end;
end;
finally
FreeMem(lpIfTable);
end;
end;
ReadLn;
end.
ASKER
Thank you Russell, i really wanted to ask that :
>>dwLastChange field and convert it into something meaningful
I thought that i was doing something wrong and i got this @#%@# values.
I also thought that since i got my router name(Description = SpeedTouch) among the list of Network Adapters
then a Modem/Router=a Network adapter. This is what i dont understand.
Thank you very much :)
>>dwLastChange field and convert it into something meaningful
I thought that i was doing something wrong and i got this @#%@# values.
I also thought that since i got my router name(Description = SpeedTouch) among the list of Network Adapters
then a Modem/Router=a Network adapter. This is what i dont understand.
Thank you very much :)
ASKER
Russell i've tried it...
For all network adapters (including my SpeedTouch) it shows the time that windows started.
For all network adapters (including my SpeedTouch) it shows the time that windows started.
Yep, thats usually the case. In case you curious, go to the following:
- My Computer
- My Network Places
- View Network Connections
- Select a connection
- Right Click
- Select Status
- Check the duration
If you want to test my program, disable then renable the connection and check again
Russell
ASKER