mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 02:20:17 +00:00
Disable some debug statements that were dumping Life Preserver logs into the webserver log file.
This commit is contained in:
@@ -33,7 +33,7 @@ void DProcess::procReady(){
|
||||
rawcmds = cmds;
|
||||
proclog.insert("cmd_list",QJsonArray::fromStringList(cmds));
|
||||
proclog.insert("process_id",ID);
|
||||
proclog.insert("state","pending");
|
||||
proclog.insert("state","pending");
|
||||
this->emit ProcUpdate(ID, proclog);
|
||||
uptimer->setSingleShot(false);
|
||||
uptimer->setInterval(2000); //2 second intervals for "pending" pings
|
||||
@@ -42,12 +42,12 @@ void DProcess::procReady(){
|
||||
|
||||
void DProcess::startProc(){
|
||||
cmds.removeAll(""); //make sure no empty commands
|
||||
if(cmds.isEmpty()){
|
||||
if(cmds.isEmpty()){
|
||||
proclog.insert("state","finished");
|
||||
proclog.insert("time_finished", QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||
proclog.remove("current_cmd");
|
||||
emit ProcFinished(ID, proclog);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
if(proclog.value("state").toString()=="pending"){
|
||||
//first cmd started
|
||||
@@ -66,7 +66,7 @@ void DProcess::startProc(){
|
||||
}
|
||||
|
||||
bool DProcess::isRunning(){
|
||||
return (this->state()!=QProcess::NotRunning);
|
||||
return (this->state()!=QProcess::NotRunning);
|
||||
}
|
||||
|
||||
bool DProcess::isDone(){
|
||||
@@ -90,10 +90,10 @@ void DProcess::cmdFinished(int ret, QProcess::ExitStatus status){
|
||||
//update the log before starting another command
|
||||
proclog.insert(cCmd, proclog.value(cCmd).toString().append(this->readAllStandardOutput()) );
|
||||
proclog.insert("return_codes/"+cCmd, QString::number(ret));
|
||||
|
||||
|
||||
//Now run any additional commands
|
||||
//qDebug() << "Proc Finished:" << ID << success << proclog;
|
||||
if(success && !cmds.isEmpty()){
|
||||
if(success && !cmds.isEmpty()){
|
||||
emit ProcUpdate(ID, proclog);
|
||||
startProc();
|
||||
}else{
|
||||
@@ -123,7 +123,7 @@ Dispatcher::Dispatcher(){
|
||||
}
|
||||
|
||||
Dispatcher::~Dispatcher(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
QJsonObject Dispatcher::listJobs(){
|
||||
@@ -153,7 +153,7 @@ QJsonObject Dispatcher::listJobs(){
|
||||
}
|
||||
out.insert(qname,obj);
|
||||
}
|
||||
} //end loop over queue types
|
||||
} //end loop over queue types
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ DProcess* Dispatcher::queueProcess(QString ID, QString cmd){
|
||||
return queueProcess(NO_QUEUE, ID, QStringList() << cmd);
|
||||
}
|
||||
DProcess* Dispatcher::queueProcess(QString ID, QStringList cmds){
|
||||
return queueProcess(NO_QUEUE, ID, cmds);
|
||||
return queueProcess(NO_QUEUE, ID, cmds);
|
||||
}
|
||||
DProcess* Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QString cmd){
|
||||
return queueProcess(queue, ID, QStringList() << cmd);
|
||||
@@ -220,11 +220,11 @@ DProcess* Dispatcher::createProcess(QString ID, QStringList cmds){
|
||||
|
||||
// === PRIVATE SLOTS ===
|
||||
void Dispatcher::mkProcs(Dispatcher::PROC_QUEUE queue, DProcess *P){
|
||||
//qDebug() << "mkProcs()";
|
||||
//qDebug() << "mkProcs()";
|
||||
QList<DProcess*> list = HASH.value(queue);
|
||||
list << P;
|
||||
//qDebug() << " - add to queue:" << queue;
|
||||
HASH.insert(queue,list);
|
||||
HASH.insert(queue,list);
|
||||
connect(P, SIGNAL(ProcFinished(QString, QJsonObject)), this, SLOT(ProcFinished(QString, QJsonObject)) );
|
||||
connect(P, SIGNAL(ProcUpdate(QString, QJsonObject)), this, SLOT(ProcUpdated(QString, QJsonObject)) );
|
||||
P->procReady();
|
||||
@@ -280,6 +280,6 @@ for(int i=0; i<enum_length; i++){
|
||||
}
|
||||
} //end loop over list
|
||||
}
|
||||
|
||||
} //end loop over queue types
|
||||
|
||||
} //end loop over queue types
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class DProcess : public QProcess{
|
||||
public:
|
||||
DProcess(QObject *parent = 0);
|
||||
~DProcess();
|
||||
|
||||
|
||||
QString ID;
|
||||
QStringList cmds;
|
||||
|
||||
@@ -50,14 +50,14 @@ signals:
|
||||
//Generic signals for subsystem usage (no direct proc access later)
|
||||
void ProcUpdate(QString, QJsonObject); // ID/log
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Dispatcher : public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum PROC_QUEUE { NO_QUEUE = 0, PKG_QUEUE, IOCAGE_QUEUE };
|
||||
#define enum_length 3 //This needs to be the number of items in the enum above
|
||||
|
||||
|
||||
Dispatcher();
|
||||
~Dispatcher();
|
||||
|
||||
@@ -78,7 +78,7 @@ public slots:
|
||||
private:
|
||||
// Queue file
|
||||
QString queue_file;
|
||||
|
||||
|
||||
//Internal lists
|
||||
QHash<PROC_QUEUE, QList<DProcess*> > HASH;
|
||||
|
||||
@@ -104,7 +104,7 @@ signals:
|
||||
//Signals for private usage
|
||||
void mkprocs(Dispatcher::PROC_QUEUE, DProcess*);
|
||||
void checkProcs();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -40,7 +40,7 @@ void EventWatcher::start(){
|
||||
// - Life Preserver Events
|
||||
WatcherUpdate(LPLOG); //load it initially (will also add it to the watcher);
|
||||
WatcherUpdate(LPERRLOG); //load it initially (will also add it to the watcher);
|
||||
|
||||
|
||||
filechecktimer->start();
|
||||
syschecktimer->start();
|
||||
QTimer::singleShot(60000, this, SLOT(CheckSystemState()) ); //wait 1 minute for networking to settle down first
|
||||
@@ -64,7 +64,7 @@ QString EventWatcher::typeToString(EventWatcher::EVENT_TYPE typ){
|
||||
QJsonValue EventWatcher::lastEvent(EVENT_TYPE type){
|
||||
CheckLogFiles();
|
||||
if(HASH.contains(type)){ return HASH.value(type); }
|
||||
else{ qDebug() << "No saved event:" << type; return QJsonValue(); }
|
||||
else{ return QJsonValue(); }
|
||||
}
|
||||
|
||||
// === PRIVATE ===
|
||||
@@ -127,7 +127,7 @@ void EventWatcher::DispatchEvent(QJsonObject obj){
|
||||
|
||||
// === PRIVATE SLOTS ===
|
||||
void EventWatcher::WatcherUpdate(const QString &path){
|
||||
if(!starting){ qDebug() << "Event Watcher Update:" << path; }
|
||||
//if(!starting){ qDebug() << "Event Watcher Update:" << path; }
|
||||
if(path==LPLOG){
|
||||
//Main Life Preserver Log File
|
||||
ReadLPLogFile();
|
||||
@@ -162,8 +162,8 @@ void EventWatcher::ReadLPLogFile(){
|
||||
if( !LPlogfile.open(QIODevice::ReadOnly) ){ return; } //could not open file
|
||||
QTextStream STREAM(&LPlogfile);
|
||||
qint64 LPlog_pos = CONFIG->value("internal/"+QString(WS_MODE ? "ws" : "tcp")+"/lp-log-pos",0).toLongLong();
|
||||
if(LPlog_pos>0 && QFileInfo(LPlogfile).created() < CONFIG->value("internal/"+QString(WS_MODE ? "ws" : "tcp")+"/lp-log-lastread").toDateTime() ){
|
||||
STREAM.seek(LPlog_pos);
|
||||
if(LPlog_pos>0 && QFileInfo(LPlogfile).created() < CONFIG->value("internal/"+QString(WS_MODE ? "ws" : "tcp")+"/lp-log-lastread").toDateTime() ){
|
||||
STREAM.seek(LPlog_pos);
|
||||
}
|
||||
QStringList info = STREAM.readAll().split("\n");
|
||||
//Now save the file pointer for later
|
||||
@@ -174,7 +174,7 @@ void EventWatcher::ReadLPLogFile(){
|
||||
for(int i=0; i<info.length(); i++){
|
||||
if(info[i].isEmpty()){ continue; }
|
||||
QString log = info[i];
|
||||
if(!starting){ qDebug() << "Read LP Log File Line:" << log; }
|
||||
// if(!starting){ qDebug() << "Read LP Log File Line:" << log; }
|
||||
//Divide up the log into it's sections
|
||||
QString timestamp = log.section(":",0,2).simplified();
|
||||
QString time = timestamp.section(" ",3,3).simplified();
|
||||
@@ -243,16 +243,15 @@ void EventWatcher::ReadLPLogFile(){
|
||||
HASH.insert(122, tr("Replication Failed") ); //summary
|
||||
HASH.insert(123, tt );
|
||||
HASH.insert(124, timestamp); //full timestamp
|
||||
HASH.insert(125, time); // time only
|
||||
HASH.insert(125, time); // time only
|
||||
HASH.insert(126, tr("Replication Error Log")+" <"+file+">" );
|
||||
sendLPEvent("replication", 7, timestamp+": "+tt);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void EventWatcher::ReadLPErrFile(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
void EventWatcher::ReadLPRepFile(){
|
||||
@@ -268,7 +267,7 @@ void EventWatcher::ReadLPRepFile(){
|
||||
//New file location
|
||||
stat.clear();
|
||||
repTotK.clear();
|
||||
lastSize.clear();
|
||||
lastSize.clear();
|
||||
}
|
||||
QStringList info = STREAM.readAll().split("\n");
|
||||
CONFIG->setValue("internal/"+QString(WS_MODE ? "ws" : "tcp")+"/lp-rep-pos",STREAM.pos());
|
||||
@@ -283,7 +282,7 @@ void EventWatcher::ReadLPRepFile(){
|
||||
else{ stat = line; } //only save the relevant/latest status line
|
||||
}
|
||||
if(!stat.isEmpty()){
|
||||
//qDebug() << "New Status Message:" << stat;
|
||||
//qDebug() << "New Status Message:" << stat;
|
||||
//Divide up the status message into sections
|
||||
stat.replace("\t"," ");
|
||||
QString dataset = stat.section(" ",2,2,QString::SectionSkipEmpty).section("/",0,0).simplified();
|
||||
@@ -343,7 +342,7 @@ void EventWatcher::CheckSystemState(){
|
||||
}
|
||||
obj.insert("hostname",oldhostname);
|
||||
|
||||
//Next Check zpools
|
||||
//Next Check zpools
|
||||
QJsonObject zpools = sysadm::ZFS::zpool_list();
|
||||
if(!zpools.isEmpty()){
|
||||
//Scan each pool for any bad indicators
|
||||
@@ -372,7 +371,7 @@ void EventWatcher::CheckSystemState(){
|
||||
if(!updates.isEmpty()){
|
||||
if(updates.value("status").toString()!="noupdates"){
|
||||
int tmp = 2;
|
||||
if(updates.value("status").toString()=="rebootrequired"){
|
||||
if(updates.value("status").toString()=="rebootrequired"){
|
||||
tmp = 9; //user input required
|
||||
//Check if the auto_update_reboot flag is set, and reboot as needed
|
||||
QJsonObject upset = sysadm::Update::readSettings();
|
||||
|
||||
@@ -18,7 +18,7 @@ void LogManager::checkLogDir(){
|
||||
QDir dir(logd);
|
||||
dir.mkpath(logd);
|
||||
}
|
||||
int daysold = CONFIG->value("prune_log_days_old",90).toInt(); //90 days by default
|
||||
int daysold = CONFIG->value("prune_log_days_old",30).toInt(); //90 days by default
|
||||
if(daysold>0){
|
||||
LogManager::pruneLogs(QDate::currentDate().addDays(0-daysold));
|
||||
}
|
||||
@@ -35,7 +35,7 @@ void LogManager::pruneLogs(QDate olderthan){
|
||||
for(int i=0; i<files.length(); i++){
|
||||
QDate fdate = QDate::fromString( files[i].section(".log",0,0).section("-",-3,-1), Qt::ISODate);
|
||||
//qDebug() << "Check File Date:" << fdate << olderthan;
|
||||
if( fdate < olderthan && fdate.isValid()){
|
||||
if( fdate < olderthan && fdate.isValid()){
|
||||
dir.remove(files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user