Author Topic: [Classic REXX] Network Map  (Read 13146 times)

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5368
  • Karma: +127/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #30 on: March 27, 2025, 11:08:51 pm »
OK, did that, rebooted to be sure. Still nothing detected by macaddr.cmd unless I have my machine in the hosts file.

Hi Dave,

A last and final suggestion trying to use rexxsocket
Can you give a try adding following codes just under the STC = 

Code: [Select]
    DO
        X = TRANSLATE( 'abcdefghijkl', host.i.macaddr, 'ab:cd:ef:gh:ij:kl' )
        SCT = SockSocket( 'AF_INET', 'SOCK_DGRAM', 'IPPROTO_UDP' );

        /* experimental */
TerminalAddr.!addr=host.i.ipaddr
Call SockGetHostByAddr TerminalAddr.!addr, "TerminalAddr.!"
If strip(TerminalAddr.!name)\='' then do
say "SockGetHost: "||TerminalAddr.!name||':' host.i.ipaddr||':' MAC;
host.i.name = TerminalAddr.!name
End 
/* end experimental */


If a name is returned, it should display SockGetHost: ....

No STC= here

Remy

  • Hero Member
  • *****
  • Posts: 878
  • Karma: +14/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #31 on: March 28, 2025, 01:23:51 am »
OK, did that, rebooted to be sure. Still nothing detected by macaddr.cmd unless I have my machine in the hosts file.

Hi Dave,

A last and final suggestion trying to use rexxsocket
Can you give a try adding following codes just under the STC = 

Code: [Select]
    DO
        X = TRANSLATE( 'abcdefghijkl', host.i.macaddr, 'ab:cd:ef:gh:ij:kl' )
        SCT = SockSocket( 'AF_INET', 'SOCK_DGRAM', 'IPPROTO_UDP' );

        /* experimental */
TerminalAddr.!addr=host.i.ipaddr
Call SockGetHostByAddr TerminalAddr.!addr, "TerminalAddr.!"
If strip(TerminalAddr.!name)\='' then do
say "SockGetHost: "||TerminalAddr.!name||':' host.i.ipaddr||':' MAC;
host.i.name = TerminalAddr.!name
End 
/* end experimental */


If a name is returned, it should display SockGetHost: ....

No STC= here

Hi well seen ! I did a finger check ( SCT and not STC )

I just tried to modify some codes, I could test it under my system with good result but I always have a hosname and couldn't test my updates fully yet.
Here is my macaddr.cmd

PS:  Computer (from host) means that host command was used while Computer (from sockets) means that hostname wasn't return and was build using sockets information to complete system hostname with intrf info used as default local home domaine 

You can add icons from following os2world link
https://www.os2world.com/forum/index.php/topic,3867.msg47719.html#msg47719
« Last Edit: March 28, 2025, 01:34:07 am by Remy »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5368
  • Karma: +127/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #32 on: March 28, 2025, 04:36:35 am »
OK, using your version of the script returns,
Code: [Select]
Scan started using env parameters: WOL(1) and NET(1)
Computer (from sockets):  ARCAOS-44454C4.lan      192.168.0.106
ARCAOS-44454C4: 192.168.0.106: 70:20:84:0e:35:53
wake on lan sent:        7020840e35537020840e35537020840e35537020840e35537020840
e35537020840e35537020840e35537020840e35537020840e35537020840e35537020840e3553702
0840e35537020840e35537020840e35537020840e35537020840e3553     

With a 25 second delay between the Computer line and the rest. The line wrap was left. And your last idea shows in the .lan suffix.

Remy

  • Hero Member
  • *****
  • Posts: 878
  • Karma: +14/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #33 on: March 28, 2025, 05:34:48 am »
OK, using your version of the script returns,
Code: [Select]
Scan started using env parameters: WOL(1) and NET(1)
Computer (from sockets):  ARCAOS-44454C4.lan      192.168.0.106
ARCAOS-44454C4: 192.168.0.106: 70:20:84:0e:35:53
wake on lan sent:        7020840e35537020840e35537020840e35537020840e35537020840
e35537020840e35537020840e35537020840e35537020840e35537020840e35537020840e3553702
0840e35537020840e35537020840e35537020840e35537020840e3553     

With a 25 second delay between the Computer line and the rest. The line wrap was left. And your last idea shows in the .lan suffix.

No more need to add your hosname and @ip into hosts file which has @localip only
The lan is taken because you intrf is on a lan (this is a commun default domain used for home domain when on lan)
All my equipment have ".lan" set by my internet router DNS when on, lan interface 

The 25s may be normal with WOL set to 1 making it scans all @ip up to  .255
I tried a litle modification to set as "UNDEFINEDxxx" equipment not having a hostname (could not try)
My last modification is to add UNDEFINEDxxx (xxx is the last qualifier of the @ip) for registered equipment without hostname and add into WPS parms of this UNDEFINED hostname the corresponding found @ip following hostname
I changed some process to use @ip if hostname has UNDEFINED into its name

I comment the 2 initial SET line into de macaddr.cmd and use those from config.sys
uncomment bof lines if you would like set these two vars without config.sys update
e.g.  remove /* and */ of both lines and set value to 1 or 0
/* 'SET WOL=1' */   
/* 'SET NET=1' */

Curious to know if undefined equipment are found with this update ?
(restriction, changing an equipment without the hostname with an other equipment without hostname and using the same @ip may be indicated using same icon title)

Update: NO good, have to review (a litle better but undefined didn't work as expected)     
« Last Edit: March 28, 2025, 07:52:13 am by Remy »

Remy

  • Hero Member
  • *****
  • Posts: 878
  • Karma: +14/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #34 on: March 28, 2025, 09:16:52 am »
Updated
« Last Edit: March 28, 2025, 08:23:41 pm by Remy »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5368
  • Karma: +127/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #35 on: March 28, 2025, 03:49:35 pm »
Updated

This one runs much faster with,
Code: [Select]
Scan started using env parameters: WOL(1) and NET(1)
Computer (from sockets):  HOST: unknown host ARCAOS-44454C4

Remy

  • Hero Member
  • *****
  • Posts: 878
  • Karma: +14/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #36 on: March 28, 2025, 08:26:49 pm »
Updated

This one runs much faster with,
Code: [Select]
Scan started using env parameters: WOL(1) and NET(1)
Computer (from sockets):  HOST: unknown host ARCAOS-44454C4

Oops, developper error (had deleted a line into the code)

Now, updated
I change UNDEFINEDxxx host name to use UHOST-xxx  with xxx the last @ip qualifier  (my router adds HOST-nnn with nnn an incremental number set to a connected @mac)

Hope it been better.

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 329
  • Karma: +7/-0
    • View Profile
Re: [Classic REXX] Network Map
« Reply #37 on: March 28, 2025, 08:52:27 pm »
Great update of the script Remy!  8)

It now tell me that the vacuum cleaner has gone offline for the night, but it managed to pull out the cable of the laptop today and ensured it went offline as well.

I comment the 2 initial SET line into de macaddr.cmd and use those from config.sys
uncomment bof lines if you would like set these two vars without config.sys update
e.g.  remove /* and */ of both lines and set value to 1 or 0
/* 'SET WOL=1' */   
/* 'SET NET=1' */

Just type
SET WOL=1
SET NET=1
on the command line before you run the script and those will be added to each object it create, thus not require any of them in config.sys

or create a program object "Refresh" pointing to the script, without any parameter, but with
WOL=1
NET=1
in the Environment tab (See each created network object for examples).


How about merging/reuse code for the various calls that resemble each other, and control them with parameters?
Perhaps explore the use of parsing templates:
PARSE VALUE ... WITH pre (fixed_variable1) mid (fixed_variable2) post

The idea was initially to build a network map of the devices found on the home LAN with info about them.
What uses can we explore here?
Shares would be one thing, but ... are there something else that one want and can be created?!

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5368
  • Karma: +127/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #38 on: March 28, 2025, 11:51:00 pm »
Updated

This one runs much faster with,
Code: [Select]
Scan started using env parameters: WOL(1) and NET(1)
Computer (from sockets):  HOST: unknown host ARCAOS-44454C4

Oops, developper error (had deleted a line into the code)

Now, updated
I change UNDEFINEDxxx host name to use UHOST-xxx  with xxx the last @ip qualifier  (my router adds HOST-nnn with nnn an incremental number set to a connected @mac)

Hope it been better.

This one took about 50 seconds to finish,
Code: [Select]
Scan started using env parameters: WOL(1) and NET(1)
Computer (from sockets):  HOST: unknown host ARCAOS-44454C4.lan    192.168.0.106

Uhost-106.lan: 192.168.0.106: 70:20:84:0e:35:53
wake on lan sent:        7020840e35537020840e35537020840e35537020840e ...
> WPS Refreshed for: Uhost-106.lan 192.168.0.106


Remy

  • Hero Member
  • *****
  • Posts: 878
  • Karma: +14/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #39 on: March 29, 2025, 09:58:14 am »
Hi !

Several changes
- When PC is booted and no activity was done on the network, ARP table has too less information in it (use of an initial ping resolves this)     
- reduced as possible the full scan time ( should be dropped to something nearly 12s )
- had to introduce several changes due I found that some registered @mac format could make some scan buggy (e.g. x :xx:x :xx:xx:x while xx:xx:xx:xx:xx:xx is expected)
- Add env var FLC for ARP flush (when this env is set to 1, a WPS object is created to allow full scan refresh following an arp flush

Regards
« Last Edit: March 31, 2025, 01:51:44 am by Remy »

Remy

  • Hero Member
  • *****
  • Posts: 878
  • Karma: +14/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #40 on: March 29, 2025, 10:12:08 am »
Great update of the script Remy!  8)

It now tell me that the vacuum cleaner has gone offline for the night, but it managed to pull out the cable of the laptop today and ensured it went offline as well.

I comment the 2 initial SET line into de macaddr.cmd and use those from config.sys
uncomment bof lines if you would like set these two vars without config.sys update
e.g.  remove /* and */ of both lines and set value to 1 or 0
/* 'SET WOL=1' */   
/* 'SET NET=1' */

Just type
SET WOL=1
SET NET=1
on the command line before you run the script and those will be added to each object it create, thus not require any of them in config.sys

or create a program object "Refresh" pointing to the script, without any parameter, but with
WOL=1
NET=1
in the Environment tab (See each created network object for examples).


How about merging/reuse code for the various calls that resemble each other, and control them with parameters?
Perhaps explore the use of parsing templates:
PARSE VALUE ... WITH pre (fixed_variable1) mid (fixed_variable2) post

The idea was initially to build a network map of the devices found on the home LAN with info about them.
What uses can we explore here?
Shares would be one thing, but ... are there something else that one want and can be created?!

Interesting project and seems to be enough like it is.
I found a good use :D
I have an audio streamer connected but not using it for a long time, it is no more usable through my control TAB and had to reboot the streamer
Now, I saw its status change and just refreshing it make the streamer wakeup...

Remy

  • Hero Member
  • *****
  • Posts: 878
  • Karma: +14/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #41 on: March 31, 2025, 07:32:58 pm »
Corrected some code and added gateway, uc identifier
Added a refresh icon without arp flash.
(to have both refesh pgm icons created, change for only one run:
/* 'SET WOL=1' */  to  'SET WOL=1'
/* 'SET NET=1' */  to  'SET NET=1'
/* 'SET FLC=1' */  to  'SET FLC=1'

At end of run, set this line as it was originally.

Restriction: display network devices @mac under one sub-node only

For icons: https://www.os2world.com/forum/index.php/topic,3867.msg47719.html#msg47719

     

Remy

  • Hero Member
  • *****
  • Posts: 878
  • Karma: +14/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #42 on: March 31, 2025, 08:56:16 pm »
I just had an idea !

Now, at first time run with FLC=1, a macaddr.cfg is created with a list of your home network devices in the form of  " @mac @ip hostname "
For UHost-xxx or names not well describing the device, you can change the hostname from into this cfg file
During the process, I only check for the corresponding @mac and not @ip and only those @mac having hostname changed, the change is taken and the icon will
display the user setted hostname but into the parameters, initial hostname is always left intact to allow correct process.

:D     
 
note, in my case, I replaced a host-002 sent by my Router/DNS to my Streamer real name.
« Last Edit: April 01, 2025, 01:35:11 pm by Remy »

Remy

  • Hero Member
  • *****
  • Posts: 878
  • Karma: +14/-1
    • View Profile
Re: [Classic REXX] Network Map
« Reply #43 on: April 01, 2025, 01:20:57 am »
Hi Jan-Erik
Sorry having added a lof of codes  ::)

Jan-Erik Lärka

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 329
  • Karma: +7/-0
    • View Profile
Re: [Classic REXX] Network Map
« Reply #44 on: April 01, 2025, 09:18:32 pm »
Hi Jan-Erik
Sorry having added a lof of codes  ::)

Ohh, yes, I soooOOooo crossed (NOT!) that you've improved the script further than one could hope for.

I''m actually very pleased that you've come up with all of these enhancements, but don't tell anyone I wrote that.  ;)