sadm_subnet_lookup.py

3 minute read

NAME

sadm_subnet_lookup.py
Scan selected network subnet and store results in database

SYNOPSIS

sadm_subnet_lookup.py [-d 0-9] [-h] [-v]
$SADMIN/bin/sadm_subnet_lookup.py - v3.4
Posted 2021-05-29 - Updated 2021-05-31
Supported on Linux
Can only be run on SADMIN Server.

DESCRIPTION

The purpose of this script is to scan the network subnet you specified and check the following things :

  • Did the IP respond to a ping request
  • Is there a hostname assigned to the IP
  • What is the Mac address of the IP
  • Did the Mac address or the hostname change since the last scan

With this information on hand, you can view what IP are in use, what IP have a DNS entry and what IP are free to use, useful no ?

This is an example of the kind of results you can expect when clicking on “Network” in the heading of the page. Subnet Scan Web Results

You specify the network subnet you want to scan in the SADMIN configuration file. Subnet to scan In this example, we are scanning one subnet (192.168.1.0/24), but we can specify up to four subnets.

Back to the top

EXAMPLE

$ sudo sadm_subnet_lookup.py 
================================================================================
Starting sadm_subnet_lookup.py V3.4 - SADM Lib. V3.18
Server Name: holmes.maison.ca - Type: Linux
O/S: Centos  7.9.2009 - Code Name: Core
==================================================
 
Current host interface name     : em1
Possible IP on 192.168.1.0/24   : 256 
Network netmask                 : 255.255.255.0

Running fping and output to /sadmin/dat/net/fping.txt
The fping finished with success.

192.168.1.1      Ping worked, update ping date from 2021-05-31 13:31:30 to 2021-05-31 14:08:13
192.168.1.1      No MAC address changed ('84:16:f9:21:31:cc')
192.168.1.1      [ OK ] Database updated
192.168.1.2      Ping worked, update ping date from 2021-05-31 13:31:30 to 2021-05-31 14:08:13
192.168.1.2      No MAC address changed ('98:10:e8:f4:00:c5')
192.168.1.2      [ OK ] Database updated
192.168.1.3      Ping worked, update ping date from 2021-05-31 13:31:30 to 2021-05-31 14:08:13
192.168.1.3      No MAC address changed ('a0:99:9b:08:f5:11')
192.168.1.3      [ OK ] Database updated
...
...
192.168.1.253    Ping didn't worked, leave last ping date as it is.
192.168.1.253    No MAC address changed ('')
192.168.1.253    [ OK ] Database updated
192.168.1.254    Ping didn't worked, leave last ping date as it is.
192.168.1.254    No MAC address changed ('')
192.168.1.254    [ OK ] Database updated
 
==================================================
Script return code: 0
Script execution time is 00:00:25
Trim /sadmin/dat/rch/holmes_sadm_subnet_lookup.rch to 35 lines.
Alert requested if script fail.
Trim /sadmin/log/holmes_sadm_subnet_lookup.log to 500 lines.
Mon May 31 14:08:26 2021 - End of sadm_subnet_lookup.py
================================================================================

Back to the top

ENVIRONMENT

  • The “$SADMIN” environment variable must be defined and contains the root directory of the SADMIN tools (normally /opt/sadmin). It should be already done, the setup script have updated the ‘/etc/profile.d/sadmin.sh’ and the ‘/etc/environment’ files.
  • The SADMIN configuration file, is needed and loaded in memory at the beginning of every scripts. This file should already exist and contains your SADMIN configuration and preference setting.
  • For Shell script the Shell Library is used and for Python script the Python Library is used.

EXIT STATUS

Exit Code Description
0 An exit status of zero indicates success.
1 Failure is indicated by a nonzero value, typically ‘1’.

AUTHOR

Jacques Duplessis
Any suggestions or bug report can be submitted at the support page

Copyright © 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
This is free software, you are free to change and redistribute it.
There is NO WARRANTY to the extent permitted by law.

SEE ALSO

sadmin.cfg - SADMIN main configuration file
sadm_server-sunrise.sh - Collect & process data produced by all actives clients
sadm_server_housekeeping.sh - Enforce security SADMIN Web interface & crontab files sadm_daily_farm_fetch.sh - Collect Hardware/Software/Performance data from actives servers
sadm_database_update.py - Take data collected from clients and update database
sadm_nmon_rrd_update.sh - Daily performance database update
sadm_subnet-lookup.py - Scan network selected subnet & store info in database
sadm_backupdb.sh - Backup one or all MySQL/MariaDB databases on the system
sadm_client_sunset.sh - Clients end of day housekeeping and producing system information files
sadm_client_housekeeping.sh - Purge old log,rch,nmon files and check $SADMIN permission