Howto Manage More Than One Device: Difference between revisions
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
start cmd /k ping 10.0.0.99 -t -w 2000 | start cmd /k ping 10.0.0.99 -t -w 2000 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
starts three | starts three windows 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 == | == Get Setups == |
Revision as of 09:32, 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.
In order to use these scripts you need to download plink.exe, pscp.exe and 7za.exe. It is assumed that these exe files are located in the same folder as scripts presented here.
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 windows 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
To get the firmware information there are two scripts ReadVersion.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 version info from RTU at %RTU_ADDR%
echo Get firmware.html and save it to %SETUP_FILE_PREFIX%_firmware.html
pscp.exe -pw %USER_PW% %USER_NAME%@%RTU_ADDR%:/var/www/firmware.html %SETUP_FILE_PREFIX%-firmware.html
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 version_file
echo Example: %0 192.168.0.111 martem Xooviet0 MyDevice
pause
exit /b
and GetVersion.bat
@echo off
start cmd /k ReadVersion 10.0.0.35 martem Xooviet0 GW6e_10.0.0.35
start cmd /k ReadVersion 10.0.0.36 martem Xooviet0 GW6e_10.0.0.36
start cmd /k ReadVersion 10.0.0.99 martem Xooviet0 GW6_10.0.0.99
ReadVersion.bat takes four arguments IP, SSH username and password and prefix. Files are saved with similar format as setup. For instance:
GW6_10.0.0.99-2013.10.29-09.00.22-firmware.html GW6e_10.0.0.35-2013.10.29-09.00.22-firmware.html GW6e_10.0.0.36-2013.10.29-09.00.22-firmware.html
Note that this works even if the web server is not enabled.