Knowledge Base

Knowlegebase articles

Welcome to SysOrb knowledge base. Her you will find detailed explanation on questions regarding SysOrb. The list is under continues development and new articles will be added. You can follow the links below or enter a "key word" to search all of the articles.

Automatic rescan of all nodes in a domain

Symptoms: 

In some situations it can be necessary to do rescans of a huge amount of nodes.
This can be a tedious task, since you then have to enter each node, and do the rescan manually.

Resolution: 

These scripts will make it possible to do a rescan of the entire domain.

Running on Windows, copy the following into file rescan.js, and place it in your SysOrbServer install directory. (typically: c:\Program Files\SysOrb Server)
Make sure that you edit the script to fit your setup
Run it like this: cscript /nologo rescan.js "domain_to_rescan"

// Win32 script to recursively rescan agents of a domain passed as argument
//
// Usage:
// cscript /nologo rescan.js domain_to_rescan
//
// Note: I will ask for rescan all nodes (even those that don't have agents)

// arguments for 'sysorb-tool' utility (SysOrb should be running)
// These arguments should be edited to fit the SysOrb installation.
var INDEXCGIPATH="http://localhost:8080/index.cgi"
var USER="admin"
var PASS="admtest"
var SERVER="localhost"
var PORT="3241"
var DOMAIN="."

if (WScript.Arguments.Count() == 0) {
     WScript.echo("Usage: cscript rescan.js domain_to_rescan");
   WScript.Quit(-1);
}

var domainToRescan = WScript.Arguments(0);

// Execute 'sysorb-tool' utility
var WshShell = new ActiveXObject("WScript.Shell");
var cmdline = "sysorb-tool -s " + SERVER + " -p " + PORT +" -d " + DOMAIN +
" -l " + USER + " -P " + PASS +
" listnodes -o ip -r \"" + domainToRescan + "\"";
//WScript.echo(cmdline);
var oExec = WshShell.Exec(cmdline);
while (!oExec.StdOut.AtEndOfStream) {
   var node = oExec.StdOut.ReadLine().split("\t");
   var nodeID = node[0];
   var nodePath = node[1];
   WScript.echo("Rescanning: " + nodePath);

   // Prepare to send GET request
   var http  = new ActiveXObject("Microsoft.XMLHTTP");

   var url = INDEXCGIPATH + "?path=1.2.2.4.4" +
   "&chkroot=" + nodeID + ".1" +
   "&node=" + nodeID +
   "&passwd=" + PASS +
   "&username=" + USER +
   "&tld=" + DOMAIN;

   //WScript.echo(url);

   // Opens the connection to the remote server.
   http.Open("GET", url, false);
   // Actually send the request
   http.Send();

   // Waiting 60s before rescanning next node...
   WScript.Sleep(60*1000);
}
if (oExec.ExitCode != 0) {
   WScript.StdErr.Write(oExec.StdErr.ReadAll());
   WScript.Quit(-1);
}
WScript.echo("Done.");
 

For linux based systems, copy the following into a file called rescan.sh

#!/bin/sh

# 
# Script to recursively rescan agents of a some domain
# Author: Evalesco A/S
#

INDEXCGIPATH=http://localhost:8080/index.cgi
SERVER=localhost
PORT=3241

#CURL_ARGS="-u user:passw"

export PATH=$PATH:$PWD

echo "-------------------------------------------"
echo "Will rescan SysOrb agents"
echo "-------------------------------------------"
echo
echo "Your credentials for SysOrb are needed."
echo -n "Username: " 
read USER
echo -n "Password: " 
stty -echo
read PASSWORD
stty echo
echo
echo "Domain to rescan (Example: testdomain.test)"
echo "-------------------------------------------"
echo -n "Domain: "
read DOMAIN
echo
echo "This will rescan the following servers:"

sysorb-tool -s "${SERVER}" -p "${PORT}" -l "${USER}" -P "${PASSWORD}" listnodes -o p -r "${DOMAIN}" || exit 1

echo
echo "-------------------------------------------"
read -p "Press enter to continue or ctrl+c to break the script..."
echo

echo "-------------------------------------------"
echo "Rescanning nodes"
echo "-------------------------------------------"
echo

sysorb-tool -s "${SERVER}" -p "${PORT}" -l "${USER}" -P "${PASSWORD}" listnodes -o ip -r "${DOMAIN}" |
while read NODEID NODEPATH
  do
    echo "`date`: Rescanning node ${NODEPATH}"
    curl ${CURL_ARGS} "${INDEXCGIPATH}?path=1.2.2.4.4&chkroot=${NODEID}.1&node=${NODEID}&passwd=${PASSWORD}&username=${USER}&tld=." >/dev/null 2>&1
    echo "Waiting 120s before rescanning next node..."
    sleep 120
  done

echo
echo "-------------------------------------------"
echo "Rescanning completed!"
echo "-------------------------------------------"
echo

exit 0