Howto Manage More Than One Device: Difference between revisions

From Phobos Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 12: Line 12:
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:
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:
<syntaxhighlight lang="dos">@echo off</syntaxhighlight>.
<syntaxhighlight lang="dos">@echo off</syntaxhighlight>.
== 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:
<syntaxhighlight lang="dos">
@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


== Get Setups ==
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
</syntaxhighlight>
This script expects four arguments: IP address, SSH username and password and arbitrary string to identify the saved file.
== Get Version ==
== Get Version ==
== Update Software ==
== Update Software ==

Revision as of 09:13, 29 October 2013

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 arbitrary string to identify the saved file.

Get Version

Update Software