Returns host name to default after device disconnected
Introduction:
Often Nodegrid users set the serial port to detect hostname of the connected device to help identify the device in the access page. When the target device is removed the host name remained on the access page. This page helps the user to automatically change the name back to default name.
Solution:
Scripts are used to run on the disconnect event (307) to replace the hostname back to default for the serial ports.
Steps:
go to the Nodegrid and into "/etc/scripts/auditing" folder create the script Event307.sh as below and makes it an executable script.
The script gets the device name and look for the default serial port name. If the name is not blank then replace the hostname with the default.
- #!/bin/bash
- # This script is meant as a sample to event's action script.
- # Whenever an event ocurrs, it will execute this script passing the Event
- # number as the first argument plus all the arguments that this events
- # pass to SNMP TRAP. See Nodegrid-TRAP-MIB.mib to see all args for each event.
- EVENT_NUMBER="$1" #argument 1 is always the event number
- ARGUMENT2="$2" #depends on the event
- ARGUMENT3="$3" #depends on the event
- ARG_COUNT="$#" #depends on the event
- devName="$2"
- output=$(su - admin -c "cli show /settings/devices/$devName/access")
- serialPort=$(echo "$output" | awk '/local serial port:/{print $4}')
- if [ -n $serialPort ]; then
- su - admin -c "cli -f -"<<EOF
- cd /settings/devices/
- rename $devName
- set new_name=$serialPort
- commit
- EOF
- fi
- exit 0
In the Nodegrid Web UI, go to "Auditing::Events::Event List" click on "307" Event then add the Event307.sh script in the "Action Script".
Related Articles
Enabling Hostname Detection
Hostname Detection allows automatic discovery of target devices based on login banners and prompt. Discovered hostname will be used as target name in system. Follow the link for how to video Enabling Hostname Detection
Enabling Hostname Detection
Hostname Detection allows automatic discovery of target devices based on login banners and prompt. Discovered hostname will be used as target name in system. Configuration via WebUI 1. Login as admin and go to Access. 2. Select the port. For an ...
How to Configure IPSec Host to Host tunnel with Certificate
Version 0.1 (02 May 2018) Overview Host to Host configurations allow two nodes to established a tunnel between them. The encrypted communication will be limited just to the two nodes involved. Figure 11: Host to Host Configuration Example Details ...
Creating a Hostname Detection String
Hostname detection string let you customize de hostname detection function to suit your business and device needs. Learn how to customize a hostname detection string to auto-discover target devices on ZPE Systems' Nodegrid Manager Follow the link for ...
How to Configure IPSec Host to Host Tunnel with RSA Keys
Version 0.1 (02 May 2018) Overview Host to Host configurations allow two nodes to establish a tunnel between them. The encrypted communication will be limited just to the two nodes involved. Figure 11: Host to Host Configuration Example Details Host ...