I was working with a customer who wanted to update the on-call pager number periodically. Alarm message are sent to that number.
Since the pager number changes don't adhere to a particular schedule, it didn't make sense to use a schedule-driven registry value.
The customer also didn't want to use the Manage Registry Variables dashboard in the Foglight UI, but rather wanted to make changes from the command line.
The solution to this challenge leverages a short Groovy script that is executed from the command line using 'fglcmd'.
To set the registry variable from the command line in Unix, use:
$ ./setOnCallPager.sh 5557570009
where setOnCallPager.sh looks like:
#!/bin/sh
# Set the default value of the following Foglight Registry Variable to the first argument
PagerRegVar='OnCallPager'
if [ -z "${FOGLIGHT_HOME}" ]; then
FOGLIGHT_HOME=/opt/foglight55
fi
${FOGLIGHT_HOME}/bin/fglcmd.sh -srv fmshost -port 8080 -usr fogusr -pwd fogpad -cmd script:run -f setRegistryValue.groovy $PagerRegVar $1
|
To set the registry variable from the command line in Windows, use:
> ./setOnCallPager.bat 5557570009
where setOnCallPager.bat looks like:
@REM Set the default value of the following Foglight Registry Variable to the first
set PagerRegVar=OnCallPager
if not defined FOGLIGHT_HOME set FOGLIGHT_HOME= C:\Quest_Software\Foglight55
%FOGLIGHT_HOME%\bin\fglcmd.bat -srv fmshost -port 8080 -usr foguser -pwd fogpwd -cmd script:run -f setRegistryValue.groovy %PagerRegVar% %1 |
Since Groovy is a cross-platform language, setRegistryValue.groovy is the same for both Unix and Windows:
// Call this groovy script with two arguments:
// 1. Registry Variable Name
// 2. Registry Variable Value
// The Global Default Value of the specified Registry Variable will be set to the given value
// The named Registry Variable will be created if it doesn’t exist
regVar=args[1]
regVal=args[2]
regSvc = server["RegistryService"]
regVariable = null
try {
regVariable = regSvc.getRegistryVariable(regVar)
}
catch (Exception rnfe) {
// create the Registry Variable if it doesn’t exist
regVariable = regSvc.createRegistryVariable(regVar, String)
regDefault=regVariable.createRegistryValue()
regDefault.setDefaultValue("uninitialized")
regVariable.setGlobalDefault(regDefault)
}
regVariableDefault = regVariable.getGlobalDefault()
defaultValue = regVariableDefault.getDefaultValue()
regVariableDefault.setDefaultValue(regVal)
regSvc.saveRegistryVariable(regVariable)
"Changed Registry Variable '"+regVar+"' from '"+defaultValue+"' to '"+regVal+"'."
|
You can run 'fglcmd' from any host, not just the FMS and monitored hosts.
In $FMSHOME/tools/, you'll find fglcmd.zip. You can extract this file on any host, and run it from there.
You'll need to have the JAVA_HOME environment variable set when you run it, because the package does not includes a JRE.