Returns host name to default after device disconnected

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.

  1. #!/bin/bash

  2. # This script is meant as a sample to event's action script.
  3. # Whenever an event ocurrs, it will execute this script passing the Event
  4. # number as the first argument plus all the arguments that this events
  5. # pass to SNMP TRAP. See Nodegrid-TRAP-MIB.mib to see all args for each event.

  6. EVENT_NUMBER="$1" #argument 1 is always the event number
  7. ARGUMENT2="$2" #depends on the event
  8. ARGUMENT3="$3" #depends on the event
  9. ARG_COUNT="$#" #depends on the event

  10. devName="$2"
  11. output=$(su - admin -c "cli show /settings/devices/$devName/access")
  12. serialPort=$(echo "$output" | awk '/local serial port:/{print $4}')
  13. if [ -n $serialPort ]; then

  14. su - admin -c "cli -f -"<<EOF
  15. cd /settings/devices/
  16. rename $devName
  17. set new_name=$serialPort
  18. commit
  19. EOF

  20. fi
  21. 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 ...