Howto Manage More Than One Device

From Phobos Wiki
Revision as of 09:21, 29 October 2013 by Roland (talk | contribs)
Jump to navigation Jump to search

Here we explain how to manage multiple devices on Microsoft Windows. These scripts are provided as a starting point for administrators managing Martem devices in bulk. You can allways create your own, copy paste scripts found here or, just look at gws.exe "SSH Log" as a starting point.

Ping All

First lets see if all device are on the wire. For this it is easy to use ping utility. This script:

@echo off
start cmd /k ping 10.0.0.35 -t -w 2000
start cmd /k ping 10.0.0.36 -t -w 2000
start cmd /k ping 10.0.0.99 -t -w 2000

starts three windosws and starts to ping in each window different host. In this case line 2 starts a window for 10.0.0.35, line 3 starts a window for 10.0.0.36 and in line 4 starts a window for 10.0.0.99. If you want to add more hosts add lines after:

@echo off

.

Get Setups

Now that we know who is on the wire it is time to backup setups. For this there are two scripts. First one is ReadSetup.bat:

@echo off

echo Check for arguments

if "%1" == "" ( 
	goto usage
)

if "%2" == "" ( 
	goto usage
)

if "%3" == "" ( 
	goto usage
)

if "%4" == "" ( 
	goto usage
)

set RTU_ADDR=%1
set USER_NAME=%2
set USER_PW=%3

set DATETS=%date%
set TIMETS_IN=%time%
set TIMETS=%TIMETS_IN: =0%
set YEAR=%DATETS:~-4,10%
set MDAY=%DATETS:~2,2%
set MONTH=%DATETS:~-7,2%
set HOUR=%TIMETS:~0,2%
set MIN=%TIMETS:~3,2%
set SEC=%TIMETS:~6,2%

set SETUP_FILE_PREFIX=%4-%YEAR%.%MONTH%.%MDAY%-%HOUR%.%MIN%.%SEC%

echo Get configuration for RTU at %RTU_ADDR%

echo Get gwSetup.bin and save it to %SETUP_FILE_PREFIX%_gwSetup.bin
pscp.exe -pw %USER_PW% %USER_NAME%@%RTU_ADDR%:/usr/local/etc/telem/gwSetup.bin %SETUP_FILE_PREFIX%-gwSetup.bin

echo Get setup.tar.xz and save it to %SETUP_FILE_PREFIX%_setup.tar.xz
pscp.exe -pw %USER_PW% %USER_NAME%@%RTU_ADDR%:/usr/local/etc/telem/setup.tar.xz %SETUP_FILE_PREFIX%-setup.tar.xz

echo Done reading from RTU

exit /b
pause

:usage
echo All arguments were not specified. Print the usage information.
echo Usage: %0 rtu_ip_addr user pw setupfile_name
echo Example: %0 192.168.0.111 martem Xooviet0 MyDevice
pause
exit /b

This script expects four arguments: IP address, SSH username and password and prefix to identify the saved file. ReadSetup.bat is called from unother script where IP addresses and etc are specified. For instance:

@echo off
start cmd /k ReadSetup 10.0.0.99 martem Xooviet0 GW6_10.0.0.99
start cmd /k ReadSetup 10.0.0.35 martem Xooviet0 GW6e_10.0.0.35
start cmd /k ReadSetup 10.0.0.36 martem Xooviet0 GW6e_10.0.0.36

reads setups for three devices in addresses 10.0.0.99, 10.0.0.35 and 10.0.0.36. On file system you get version 3 and version 4 files, for instance:

GW6_10.0.0.99-2013.10.29-08.58.18-gwSetup.bin
GW6_10.0.0.99-2013.10.29-08.58.18-setup.tar.xz

Saved files are in the format prefix-DATE-AND-TIME-gwSetup.bin for version 3 and prefix-DATE-AND-TIME-setup.tar.xz for version 4

Get Version

Update Software