本文整理汇总了C++中Oam::getModuleInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ Oam::getModuleInfo方法的具体用法?C++ Oam::getModuleInfo怎么用?C++ Oam::getModuleInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oam
的用法示例。
在下文中一共展示了Oam::getModuleInfo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: sendResourceAlarm
/******************************************************************************************
* @brief sendResourceAlarm
*
* purpose: send a trap and log the process information
*
******************************************************************************************/
bool ServerMonitor::sendResourceAlarm(string alarmItem, ALARMS alarmID, int action, int usage)
{
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(" usage at percentage of ");
args.add(usage);
// get current module 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
if (alarmItem == "CPU")
serverMonitor.checkCPUAlarm(alarmItem, alarmID);
else if (alarmItem == "Local Disk" || alarmItem == "External")
serverMonitor.checkDiskAlarm(alarmItem, alarmID);
else if (alarmItem == "Local Memory")
serverMonitor.checkMemoryAlarm(alarmItem, alarmID);
else if (alarmItem == "Local Swap")
serverMonitor.checkSwapAlarm(alarmItem, alarmID);
// don't issue an alarm on thge dbroots is already issued by this or another server
if ( alarmItem.find(startup::StartUp::installDir() + "/data") == 0 ) {
// check if Alarm is already active from any module, don't resend
if ( !( oam.checkActiveAlarm(alarmID, "*", alarmItem)) ) {
SNMPManager alarmMgr;
// send alarm
alarmMgr.sendAlarmReport(alarmItem.c_str(), alarmID, action);
args.add(", Alarm set: ");
args.add(alarmID);
msg.format(args);
ml.logInfoMessage(msg);
return true;
}
else
return false;
}
else
{
// check if Alarm is already active from this module, 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);
msg.format(args);
ml.logInfoMessage(msg);
return true;
}
else
return false;
}
return true;
}
示例4: diskMonitor
/*****************************************************************************************
* @brief diskMonitor Thread
*
* purpose: Get current Local and External disk usage and report alarms
*
*****************************************************************************************/
void diskMonitor()
{
ServerMonitor serverMonitor;
Oam oam;
SystemConfig systemConfig;
ModuleTypeConfig moduleTypeConfig;
typedef std::vector<std::string> LocalFileSystems;
LocalFileSystems lfs;
struct statvfs buf;
// set defaults
int localDiskCritical = 90,
localDiskMajor = 80,
localDiskMinor = 70,
ExternalDiskCritical = 90,
ExternalDiskMajor = 80,
ExternalDiskMinor = 70;
// get module types
string moduleType;
int moduleID=-1;
string moduleName;
oamModuleInfo_t t;
try {
t = oam.getModuleInfo();
moduleType = boost::get<1>(t);
moduleID = boost::get<2>(t);
moduleName = boost::get<0>(t);
}
catch (exception& e) {}
bool Externalflag = false;
//check for external disk
DBrootList dbrootList;
if (moduleType == "pm") {
systemStorageInfo_t t;
t = oam.getStorageConfig();
if ( boost::get<0>(t) == "external")
Externalflag = true;
// get dbroot list and storage type from config file
DBRootConfigList dbrootConfigList;
oam.getPmDbrootConfig(moduleID, dbrootConfigList);
DBRootConfigList::iterator pt = dbrootConfigList.begin();
for( ; pt != dbrootConfigList.end() ; pt++)
{
int dbrootID = *pt;
string dbroot = "DBRoot" + oam.itoa(dbrootID);
string dbootdir;
try{
oam.getSystemConfig(dbroot, dbootdir);
}
catch(...) {}
if ( dbootdir.empty() || dbootdir == "" )
continue;
DBrootData dbrootData;
dbrootData.dbrootDir = dbootdir;
dbrootData.downFlag = false;
dbrootList.push_back(dbrootData);
}
}
string cloud = oam::UnassignedName;
try {
oam.getSystemConfig( "Cloud", cloud);
}
catch(...) {
cloud = oam::UnassignedName;
}
//get Gluster Config setting
string GlusterConfig = "n";
try {
oam.getSystemConfig( "GlusterConfig", GlusterConfig);
}
catch(...)
{
GlusterConfig = "n";
}
int diskSpaceCheck = 0;
while(true)
{
SystemStatus systemstatus;
try {
oam.getSystemStatus(systemstatus);
//.........这里部分代码省略.........
示例5: setSNMPModuleName
/*****************************************************************************************
* @brief setSNMPModuleName API
*
* purpose: Set SNMP Module name in the snmpdx.conf file
*
*****************************************************************************************/
void SNMPManager::setSNMPModuleName ()
{
// get current Module name
Oam oam;
string ModuleName;
oamModuleInfo_t st;
try {
st = oam.getModuleInfo();
ModuleName = boost::get<0>(st);
}
catch (...) {
ModuleName = "Unknown Report Module";
}
string agentName = SUB_AGENT;
string fileName;
makeFileName (agentName, fileName);
vector <string> lines;
ifstream oldFile (fileName.c_str());
if (!oldFile) throw runtime_error ("No configuration file found");
char line[200];
string buf;
string newLine;
string newLine1;
string delimiters = " ";
while (oldFile.getline(line, 200))
{
buf = line;
string::size_type pos = buf.find("ModuleNameStub",0);
if (pos != string::npos)
{
newLine = buf.substr(0, pos);
newLine.append(ModuleName);
string::size_type pos1 = buf.find("|",pos);
if (pos1 != string::npos)
{
newLine1 = buf.substr(pos1, 200);
newLine.append(newLine1);
}
buf = newLine;
}
// output to temp file
lines.push_back(buf);
}
oldFile.close();
unlink (fileName.c_str());
ofstream newFile (fileName.c_str());
// create new file
int fd = open(fileName.c_str(), O_RDWR|O_CREAT, 0666);
// Aquire an exclusive lock
if (flock(fd,LOCK_EX) == -1) {
throw runtime_error ("Lock SNMP configuration file error");
}
copy(lines.begin(), lines.end(), ostream_iterator<string>(newFile, "\n"));
newFile.close();
// Release lock
if (flock(fd,LOCK_UN) == -1)
{
throw runtime_error ("Release lock SNMP configuration file error");
}
close(fd);
}
示例6: main
int main(int argc, char** argv)
{
int c;
string pname(argv[0]);
bool vflg = false;
bool dflg = false;
bool xflg = false;
string configFile;
opterr = 0;
while ((c = getopt(argc, argv, "c:vdxh")) != EOF)
switch (c)
{
case 'v':
vflg = true;
break;
case 'd':
dflg = true;
break;
case 'c':
configFile = optarg;
break;
case 'x':
xflg = true;
break;
case 'h':
case '?':
default:
usage(pname);
return (c == 'h' ? 0 : 1);
break;
}
if ((argc - optind) < 3)
{
usage(pname);
return 1;
}
#ifdef COMMUNITY_KEYRANGE
//No OAM in CE...
dflg = true;
#endif
Oam oam;
oamModuleInfo_t t;
bool parentOAMModuleFlag = true;
string parentOAMModule = " ";
int serverInstallType = oam::INSTALL_COMBINE_DM_UM_PM;
//get local module info; validate running on Active Parent OAM Module
try {
t = oam.getModuleInfo();
parentOAMModuleFlag = boost::get<4>(t);
parentOAMModule = boost::get<3>(t);
serverInstallType = boost::get<5>(t);
}
catch (exception&) {
parentOAMModuleFlag = true;
}
if (!dflg && !parentOAMModuleFlag)
{
cerr << "Exiting, setConfig can only be run on the Active "
"OAM Parent Module '" << parentOAMModule << "'" << endl;
return 2;
}
Config* cf;
if (configFile.length() > 0)
cf = Config::makeConfig(configFile);
else
cf = Config::makeConfig();
if (vflg)
cout << "Using config file: " << cf->configFile() << endl;
if (xflg)
cf->delConfig(argv[optind + 0], argv[optind + 1]);
else
cf->setConfig(argv[optind + 0], argv[optind + 1], argv[optind + 2]);
cf->write();
if (dflg || serverInstallType == oam::INSTALL_COMBINE_DM_UM_PM)
return 0;
//get number of pms
string count = cf->getConfig("PrimitiveServers", "Count");
try {
oam.distributeConfigFile();
//sleep to give time for change to be distributed
sleep(atoi(count.c_str()));
}
catch (...) {
return 1;
}
return 0;
//.........这里部分代码省略.........
示例7: main
int main(int argc, char *argv[])
{
Oam oam;
string installDir(startup::StartUp::installDir());
Config* sysConfig = Config::makeConfig();
string SystemSection = "SystemConfig";
string InstallSection = "Installation";
bool HARDWARE = false;
bool SOFTWARE = false;
bool CONFIG = false;
bool DBMS = false;
bool RESOURCE = false;
bool LOG = false;
bool BULKLOG = false;
bool HADOOP = false;
//get current time and date
time_t now;
now = time(NULL);
struct tm tm;
localtime_r(&now, &tm);
char timestamp[200];
strftime (timestamp, 200, "%m:%d:%y-%H:%M:%S", &tm);
currentDate = timestamp;
char helpArg[3] = "-h";
// Get System Name
try{
oam.getSystemConfig("SystemName", systemName);
}
catch(...)
{
systemName = "unassigned";
}
// get Local Module Name and Server Install Indicator
string singleServerInstall;
oamModuleInfo_t st;
try {
st = oam.getModuleInfo();
localModule = boost::get<0>(st);
}
catch (...) {
cout << endl << "**** Failed : Failed to read Local Module Name" << endl;
exit(-1);
}
try{
oam.getSystemConfig("SingleServerInstall", singleServerInstall);
}
catch(...)
{
singleServerInstall = "y";
}
if (argc == 1) {
argv[1] = &helpArg[0];
argc = 2;
}
string DataFilePlugin;
try{
DataFilePlugin = sysConfig->getConfig(SystemSection, "DataFilePlugin");
}
catch(...)
{
cout << "ERROR: Problem accessing InfiniDB configuration file" << endl;
exit(-1);
}
for( int i = 1; i < argc; i++ )
{
if( string("-h") == argv[i] ) {
cout << endl;
cout << "'calpontSupport' generates a Set of System Support Report Files in a tar file" << endl;
cout << "called calpontSupportReport.'system-name'.tar.gz in the local directory." << endl;
cout << "It should be run on the server with the DBRM front-end." << endl;
cout << "Check the Admin Guide for additional information." << endl;
cout << endl;
cout << "Usage: calpontSupport [-h][-a][-hw][-s][-c][-db][-r][-l][-bl][-lc][-p 'root-password'][-mp 'mysql-root-password'][-de]";
// if hdfs set up print the hadoop option
if (!DataFilePlugin.empty())
cout << "[-hd]";
cout << endl;
cout << " -h help" << endl;
cout << " -a Output all Reports (excluding Bulk Logs Reports)" << endl;
cout << " -hw Output Hardware Reports only" << endl;
cout << " -s Output Software Reports only" << endl;
cout << " -c Output Configuration/Status Reports only" << endl;
cout << " -db Output DBMS Reports only" << endl;
cout << " -r Output Resource Reports only" << endl;
cout << " -l Output Calpont Log/Alarms Reports only" << endl;
cout << " -bl Output Calpont Bulk Log Reports only" << endl;
cout << " -lc Output Reports for Local Server only" << endl;
cout << " -p password (multi-server systems), root-password or 'ssh' to use 'ssh keys'" << endl;
cout << " -mp mysql root user password" << endl;
//.........这里部分代码省略.........
示例8: procmonMonitor
void procmonMonitor()
{
ServerMonitor serverMonitor;
Oam oam;
//wait before monitoring is started
sleep(60);
// get current server name
string moduleName;
oamModuleInfo_t st;
try {
st = oam.getModuleInfo();
moduleName = boost::get<0>(st);
}
catch (...) {
// Critical error, Log this event and exit
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("Failed to read local module Info");
msg.format(args);
ml.logCriticalMessage(msg);
exit(-1);
}
string msgPort = moduleName + "_ProcessMonitor";
int heartbeatCount = 0;
// loop forever monitoring Local Process Monitor
while(true)
{
ByteStream msg;
ByteStream::byte requestID = LOCALHEARTBEAT;
msg << requestID;
try
{
MessageQueueClient mqRequest(msgPort);
mqRequest.write(msg);
// wait 10 seconds for response
ByteStream::byte returnACK;
ByteStream::byte returnRequestID;
ByteStream::byte requestStatus;
ByteStream receivedMSG;
struct timespec ts = { 10, 0 };
try {
receivedMSG = mqRequest.read(&ts);
if (receivedMSG.length() > 0) {
receivedMSG >> returnACK;
receivedMSG >> returnRequestID;
receivedMSG >> requestStatus;
if ( returnACK == oam::ACK && returnRequestID == requestID) {
// ACK for this request
heartbeatCount = 0;
}
}
else
{
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: ProcMon Msg timeout!!!");
msg.format(args);
ml.logWarningMessage(msg);
heartbeatCount++;
if ( heartbeatCount > 2 ) {
//Process Monitor not responding, restart it
system("pkill ProcMon");
LoggingID lid(SERVER_MONITOR_LOG_ID);
MessageLog ml(lid);
Message msg;
Message::Args args;
args.add("procmonMonitor: Restarting ProcMon");
msg.format(args);
ml.logWarningMessage(msg);
sleep(60);
heartbeatCount = 0;
}
}
mqRequest.shutdown();
}
catch (SocketClosed &ex) {
string error = ex.what();
LoggingID lid(SERVER_MONITOR_LOG_ID);
//.........这里部分代码省略.........