本文整理汇总了C++中Oam类的典型用法代码示例。如果您正苦于以下问题:C++ Oam类的具体用法?C++ Oam怎么用?C++ Oam使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Oam类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test1
void test1() {
AlarmConfig alarmconfig;
Oam oamapi;
for( int alarmID = 1 ; alarmID < MAX_ALARM_ID; alarmID++)
{
oamapi.getAlarmConfig(alarmID, alarmconfig);
Svalue = alarmconfig.BriefDesc;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = alarmconfig.DetailedDesc;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = alarmconfig.Severity;
CPPUNIT_ASSERT(!Svalue.empty());
Ivalue = alarmconfig.Threshold;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = alarmconfig.Occurrences;
CPPUNIT_ASSERT(Ivalue != -1);
Svalue = alarmconfig.LastIssueTime;
CPPUNIT_ASSERT(!Svalue.empty());
}
};
示例2: test2
void test2() {
SystemModuleTypeConfig systemmoduletypeconfig;
Oam oamapi;
oamapi.getSystemConfig(systemmoduletypeconfig);
for( unsigned int i = 0 ; i < systemmoduletypeconfig.moduletypeconfig.size(); i++)
{
if( systemmoduletypeconfig.moduletypeconfig[i].ModuleType.empty() )
// end of list
break;
Svalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleType;
CPPUNIT_ASSERT(!Svalue.empty());
Svalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleDesc;
CPPUNIT_ASSERT(!Svalue.empty());
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCount;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUCriticalThreshold;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMajorThreshold;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMinorThreshold;
CPPUNIT_ASSERT(Ivalue != -1);
Ivalue = systemmoduletypeconfig.moduletypeconfig[i].ModuleCPUMinorClearThreshold;
CPPUNIT_ASSERT(Ivalue != -1);
}
};
示例3: main
int main(int argc, char *argv[])
{
Oam oam;
//get mysql user password
string mysqlpw = oam::UnassignedName;
try {
mysqlpw = oam.getMySQLPassword();
}
catch (...)
{
cout << oam::UnassignedName << endl;
exit (1);
}
if ( mysqlpw == oam::UnassignedName ) {
cout << oam::UnassignedName << endl;
exit (1);
}
cout << mysqlpw << endl;
try {
oam.setSystemConfig("MySQLPasswordConfig", "y");
}
catch(...) {}
exit (0);
}
示例4: mysqlSetup
void mysqlSetup()
{
Oam oam;
string cmd;
cmd = installDir + "/bin/post-mysqld-install --installdir=" + installDir;
int rtnCode = system(cmd.c_str());
if (WEXITSTATUS(rtnCode) != 0)
cout << "Error running post-mysqld-install" << endl;
//check for password set
//start in the same way that mysqld will be started normally.
//start in the same way that mysqld will be started normally.
try {
oam.actionMysqlCalpont(MYSQL_START);
}
catch(...)
{}
sleep(2);
string prompt = " *** Enter MySQL password > ";
for (;;)
{
// check if mysql is supported and get info
string calpontMysql = installDir + "/mysql/bin/mysql --defaults-file=" + installDir + "/mysql/my.cnf -u root ";
string cmd = calpontMysql + pwprompt + " -e 'status' > /tmp/idbmysql.log 2>&1";
system(cmd.c_str());
if (oam.checkLogStatus("/tmp/idbmysql.log", "ERROR 1045") ) {
mysqlpw = getpass(prompt.c_str());
mysqlpw = "'" + mysqlpw + "'";
pwprompt = "--password=" + mysqlpw;
prompt = " *** Password incorrect, please re-enter MySQL password > ";
}
else
{
if (!oam.checkLogStatus("/tmp/idbmysql.log", "InfiniDB") ) {
cout << endl << "ERROR: MySQL runtime error, exit..." << endl << endl;
system("cat /tmp/idbmysql.log");
exit (1);
}
else
{
try {
oam.actionMysqlCalpont(MYSQL_STOP);
}
catch(...)
{}
unlink("/tmp/idbmysql.log");
break;
}
}
}
cmd = installDir + "/bin/post-mysql-install " + pwprompt + " --installdir=" + installDir;
rtnCode = system(cmd.c_str());
if (WEXITSTATUS(rtnCode) != 0)
cout << "Error running post-mysql-install" << endl;
return;
}
示例5: test4
void test4() {
Oam oamapi;
oamapi.setProcessConfig("ProcessManager", "dm1", "BootLaunch", 10);
oamapi.getProcessConfig("ProcessManager", "dm1", "BootLaunch", Ivalue);
CPPUNIT_ASSERT(Ivalue == 10);
};
示例6: test10
void test10() {
Oam oamapi;
oamapi.setSystemConfig("ModuleCPUMajorThreshold1", 7500);
oamapi.getSystemConfig("ModuleCPUMajorThreshold1", Ivalue);
CPPUNIT_ASSERT(Ivalue == 7500);
};
示例7: test8
void test8() {
Oam oamapi;
oamapi.setSystemConfig("ModuleHeartbeatPeriod", 5);
oamapi.getSystemConfig("ModuleHeartbeatPeriod", Ivalue);
CPPUNIT_ASSERT(Ivalue == 5);
};
示例8: test5
void test5() {
Oam oamapi;
oamapi.setSystemConfig("SystemVersion", "V2.0.2.3");
oamapi.getSystemConfig("SystemVersion", Svalue);
CPPUNIT_ASSERT(Svalue == "V2.0.2.3");
};
示例9: CPPUNIT_ASSERT
/* void test3() {
ModuleConfig moduleconfig;
const string Modulename = "dm1";
Oam oamapi;
oamapi.getSystemConfig(Modulename, moduleconfig);
Svalue = moduleconfig.ModuleName;
CPPUNIT_ASSERT(!Svalue.empty());
};
*/
void test4() {
ModuleConfig moduleconfig;
Oam oamapi;
oamapi.getSystemConfig(moduleconfig);
Svalue = moduleconfig.ModuleName;
CPPUNIT_ASSERT(!Svalue.empty());
};
示例10: catch
/**
* Constructors/Destructors
*/
PredicateOperator::PredicateOperator()
{
Oam oam;
// get and set locale language
string systemLang = "C";
try
{
oam.getSystemConfig("SystemLang", systemLang);
}
catch (...)
{}
if ( systemLang != "en_US.UTF-8" &&
systemLang.find("UTF") != string::npos )
futf8 = true;
}
示例11: sendAlarm
/******************************************************************************************
* @brief sendAlarm
*
* purpose: send a trap and log the process information
*
******************************************************************************************/
void ServerMonitor::sendAlarm(string alarmItem, ALARMS alarmID, int action, float sensorValue)
{
ServerMonitor serverMonitor;
Oam oam;
//Log this event
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add(alarmItem);
args.add(", sensor value out-of-range: ");
args.add(sensorValue);
// get current server name
string moduleName;
oamModuleInfo_t st;
try {
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...) {
moduleName = "Unknown Server";
}
// check if there is an active alarm above the reporting theshold
// that needs to be cleared
serverMonitor.checkAlarm(alarmItem, alarmID);
// check if Alarm is already active, don't resend
if ( !( oam.checkActiveAlarm(alarmID, moduleName, alarmItem)) ) {
SNMPManager alarmMgr;
// send alarm
alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);
args.add(", Alarm set: ");
args.add(alarmID);
}
// output log
msg.format(args);
ml.logWarningMessage(msg);
return;
}
示例12: checkDiskAlarm
/******************************************************************************************
* @brief checkDiskAlarm
*
* purpose: check to see if an alarm(s) is set on Disk and clear if so
*
******************************************************************************************/
void ServerMonitor::checkDiskAlarm(string alarmItem, ALARMS alarmID)
{
Oam oam;
ServerMonitor serverMonitor;
// get current server name
string serverName;
oamModuleInfo_t st;
try {
st = oam.getModuleInfo();
serverName = boost::get<0>(st);
}
catch (...) {
serverName = "Unknown Server";
}
switch (alarmID) {
case NO_ALARM: // clear all alarms set if any found
if ( oam.checkActiveAlarm(DISK_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_HIGH);
if ( oam.checkActiveAlarm(DISK_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_MED);
if ( oam.checkActiveAlarm(DISK_USAGE_LOW, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_LOW);
break;
case DISK_USAGE_LOW: // clear high and medium alarms set if any found
if ( oam.checkActiveAlarm(DISK_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_HIGH);
if ( oam.checkActiveAlarm(DISK_USAGE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_MED);
break;
case DISK_USAGE_MED: // clear high alarms set if any found
if ( oam.checkActiveAlarm(DISK_USAGE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, DISK_USAGE_HIGH);
break;
default: // none to clear
break;
} // end of switch
return;
}
示例13: sendMsgShutdownServer
/******************************************************************************************
* @brief sendMsgShutdownServer
*
* purpose: send a Message to Shutdown server
*
******************************************************************************************/
void sendMsgShutdownServer()
{
Oam oam;
//Log this event
LoggingID lid;
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Fatal Hardware Alarm detected, Server being shutdown");
msg.format(args);
ml.logCriticalMessage(msg);
string serverName;
oamServerInfo_t st;
try {
st = oam.getServerInfo();
serverName = boost::get<0>(st);
}
catch (...) {
// o well, let's take out own action
if( IPMI_SUPPORT == 0)
system("init 0");
}
try
{
oam.shutdownServer(serverName, FORCEFUL, ACK_NO);
}
catch (exception& e)
{
// o well, let's take out own action
if( IPMI_SUPPORT == 0)
system("init 0");
}
}
示例14: checkAlarm
/******************************************************************************************
* @brief checkAlarm
*
* purpose: check to see if an alarm(s) is set on device and clear if so
*
******************************************************************************************/
void checkAlarm(string alarmItem, ALARMS alarmID)
{
Oam oam;
// get current server name
string serverName;
oamServerInfo_t st;
try {
st = oam.getServerInfo();
serverName = boost::get<0>(st);
}
catch (...) {
serverName = "Unknown Server";
}
switch (alarmID) {
case ALARM_NONE: // clear all alarms set if any found
if ( oam.checkActiveAlarm(HARDWARE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_HIGH);
if ( oam.checkActiveAlarm(HARDWARE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_MED);
if ( oam.checkActiveAlarm(HARDWARE_LOW, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_LOW);
break;
case HARDWARE_LOW: // clear high and medium alarms set if any found
if ( oam.checkActiveAlarm(HARDWARE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_HIGH);
if ( oam.checkActiveAlarm(HARDWARE_MED, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_MED);
break;
case HARDWARE_MED: // clear high alarms set if any found
if ( oam.checkActiveAlarm(HARDWARE_HIGH, serverName, alarmItem) )
// alarm set, clear it
clearAlarm(alarmItem, HARDWARE_HIGH);
break;
default: // none to clear
break;
} // end of switch
return;
}
示例15: main
int main(int argc, char *argv[])
{
Oam oam;
//check for port argument
string mysqlPort;
if (argc > 1) {
mysqlPort = argv[1];
// set mysql password
oam.changeMyCnf( "port", mysqlPort );
exit (0);
}
//my.cnf file
string mycnfFile = startup::StartUp::installDir() + "/mysql/my.cnf";
ifstream mycnffile (mycnfFile.c_str());
if (!mycnffile) {
cerr << "mycnfUpgrade - my.cnf file not found: " << mycnfFile << endl;
exit (1);
}
//my.cnf.rpmsave file
string mycnfsaveFile = startup::StartUp::installDir() + "/mysql/my.cnf.rpmsave";
ifstream mycnfsavefile (mycnfsaveFile.c_str());
if (!mycnfsavefile) {
cerr << "mycnfUpgrade - my.cnf.rpmsave file not found: " << mycnfsaveFile << endl;
exit (1);
}
//include arguments file
string includeFile = startup::StartUp::installDir() + "/bin/myCnf-include-args.text";
ifstream includefile (includeFile.c_str());
if (!includefile) {
cerr << "mycnfUpgrade - my.cnf include argument file not found: " << includeFile << endl;
exit (1);
}
//exclude arguments file
string excludeFile = startup::StartUp::installDir() + "/bin/myCnf-exclude-args.text";
ifstream excludefile (excludeFile.c_str());
if (!excludefile) {
cerr << "mycnfUpgrade - my.cnf exclude argument file not found: " << excludefile << endl;
exit (1);
}
//go though include list
char line[200];
string includeArg;
while (includefile.getline(line, 200))
{
includeArg = line;
//see if in my.cnf.rpmsave
ifstream mycnfsavefile (mycnfsaveFile.c_str());
char line[200];
string oldbuf;
while (mycnfsavefile.getline(line, 200))
{
oldbuf = line;
string::size_type pos = oldbuf.find(includeArg,0);
if ( pos != string::npos ) {
//check if this is commented out
if ( line[0] != '#' )
{
// no, find in my.cnf and replace
ifstream mycnffile (mycnfFile.c_str());
vector <string> lines;
char line1[200];
string newbuf;
while (mycnffile.getline(line1, 200))
{
newbuf = line1;
string::size_type pos = newbuf.find(includeArg,0);
if ( pos != string::npos )
newbuf = oldbuf;
//output to temp file
lines.push_back(newbuf);
}
//write out a new my.cnf
mycnffile.close();
unlink (mycnfFile.c_str());
ofstream newFile (mycnfFile.c_str());
//create new file
int fd = open(mycnfFile.c_str(), O_RDWR|O_CREAT, 0666);
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
newFile.close();
close(fd);
}
break;
}
}
}
//.........这里部分代码省略.........