LOGGING MODIFY
From TDiWiki
This is another example of a "mass change" script. This script is designed to be run on a single Console or a Group of Consoles, and will modify the Log Directory field and the Auto-Purge Logs field. See the lines marked with comments (“set the … field”) to see where you would input your desired settings.
[edit] Script Properties
Name: LOGGING_MODIFY
Description: Mass change the Logging Directory and Auto-Purge Logs fields for Consoles.
Profile: CONSOLE_MANAGER
Timeout: 30 (seconds)
[edit] Run Type
Run on Consoles
Run on Groups
[edit] Script Text
// * Copyright 1999-2011 TDi Technologies, Inc. All rights reserved. *
// * The information in this software is subject to change without *
// * notice and should not be construed as a commitment by TDi. *
// * Created: 1/9/2012 *
if (action.Console) {
var conName;
var myCon;
conName = action[action.type]; // get the name of the group the script was run on
myCon = Console.get(conName);
log("CONWRKS", "Script run from the " + conName + " Console.");
log("CONWRKS", "Edit the console: " + myCon.name);
try {
myCon.logdir = "/opt/ConsoleWorks/Default/log"; // set the log directory field
myCon.autopurge_log = "10"; // set the Auto-Purge Logs field
myCon.save();
}
catch(error) {
log("CONWRKS", "Error Description: " + error.message);
}
} else if (action.Group) {
var groupName;
var myGroup;
var groupCons;
groupName = action[action.type]; // get the name of the group the script was run on
myGroup =Group.get(groupName);
log("CONWRKS", "Script run from the " + groupName + " group.");
// get the consoles that are a part of the group
groupCons = myGroup.getConsoles();
for (console in groupCons)
{
log("CONWRKS", "Edit the console: " + groupCons[console].name);
try {
groupCons[console].logdir = "/opt/ConsoleWorks/Default/log"; // set the log directory field
groupCons[console].autopurge_log = "10"; // set the Auto-Purge Logs field
groupCons[console].save();
}
catch(error) {
log("CONWRKS", "Error Description: " + error.message);
}
}
} else {
log("CONWRKS", "This script is intended to be run only on groups!"); // this script is intended to be run only on groups
}
