SysOrb Network Monitoring System Administrator's Guide: For version 3.6.0 | ||
---|---|---|
Prev | Chapter 12. SysOrb Tool | Next |
In this section we will present two scripts which automate the extraction of all data in SysOrb (except Incident Logs) through the sysorb-tool.
One script is for bash, and should work with all Unix'es where bash is installed. The other script is for Windows.
Example 12-1. Example extracting all data using bash
#!/bin/bash # # Change these variables to match your setup. # SOTOOL="/usr/bin/sysorb-tool" USERNAME=admin PASSWORD=admtest DOMAIN=. SERVER=localhost # This directory will be created by the script. If such a file or # directory already exists, it will be deleted. OUTPUTDIR=output STDCMDLINE="${SOTOOL} -l ${USERNAME} -P ${PASSWORD} -s ${SERVER} -d ${DOMAIN}" # Prepare the output directory. if [ -e "$OUTPUTDIR" ]; then rm -rf "$OUTPUTDIR" fi; mkdir -p "$OUTPUTDIR" # The outer loop extracts a list of all the nodes on the server. $STDCMDLINE listnodes -r -o iN . | while read i; do # The id of the node is the characters before the first space NODEID=`echo $i | cut -d ' ' -f 1` # The name of the node is the rest of the characters. Remember to # translate /'es to _, as /'es are illegal in filenames. NODENAME=`echo $i | cut -d ' ' -f 2- | tr / _` echo "Exporting $NODENAME" # The inner loop extracts all the checks on one of the nodes $STDCMDLINE listchecks -o iN -i $NODEID | while read j; do # The check's id and the checks name, is extracted in the same # way as the nodes. CHECKID=`echo $j | cut -d ' ' -f 1` CHECKNAME=`echo $j | cut -d ' ' -f 2- | tr / _` # Extract all data for the check. If there is only need for a # period of data, the -b and -e options to the select command # can be used, together with the unix date command. $STDCMDLINE -f "$OUTPUTDIR/$NODENAME - $CHECKNAME".csv select -i $CHECKID done; done;
Example 12-2. Example extracting all data on Windows
@ECHO off REM The parameters to the sysorb-tool. The current one logs in as the user REM admin with the password admtest in the domain . on the server localhost SET params="-l admin -P admtest -d . -s localhost" REM Change sotool to point to the path of the SysOrb tool. SET sotool="%ProgramFiles%\SysOrb Server\sysorb-tool.exe" REM Execute the sysorb-tool in order to extract the list of all the domains. %sotool% %params% -f %tmp%\nodes.txt listnodes -r -o iN . REM Now use the nodes.txt file as a parameter to the for loop FOR /F "tokens=1*" %%i IN (%tmp%\nodes.txt) DO ( REM echo Processing node %%j REM Extract a list of all checks present on the node %sotool% %params% -f %tmp%\%%i-checks.txt listchecks -o iN -i %%i REM If there are no checks on the node, the file will not be created. IF EXIST %tmp%\%%i-checks.txt ( FOR /F "tokens=1*" %%k IN (%tmp%\%%i-checks.txt) DO ( ECHO Extracting data for %%l on %%j to file %%k.csv REM Store the name of the check in the first line REM of the CSV file. ECHO Node,CheckName > %%k.csv ECHO %%j,%%l >> %%k.csv REM Extract the data for the check. %sotool% %params% select -i %%k >> %%k.csv ) DEL /F %tmp%\%%i-checks.txt ) ) rem DEL /F %tmp%\nodes.txt