mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Merge branch 'master' of github.com:pcbsd/sysadm
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include <sysadm-lifepreserver.h>
|
||||
#include <sysadm-network.h>
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
@@ -47,6 +48,12 @@ int main( int argc, char ** argv )
|
||||
qDebug() << " - Static Gateway:" << set.staticGateway;
|
||||
qDebug() << " - Allow Secure Wifi:" << set.wifisecurity;
|
||||
}
|
||||
|
||||
// LP tests
|
||||
qDebug() << "Life-Preserver::listCron()";
|
||||
QList<QStringList> cronSnaps = sysadm::LifePreserver::listCron();
|
||||
for ( int i = 0; i < cronSnaps.size(); i++)
|
||||
qDebug() << cronSnaps.at(i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,12 @@ VERSION = 1.0.0
|
||||
|
||||
HEADERS += sysadm-global.h \
|
||||
sysadm-general.h \
|
||||
sysadm-lifepreserver.h \
|
||||
sysadm-network.h
|
||||
|
||||
|
||||
SOURCES += sysadm-general.cpp \
|
||||
sysadm-lifepreserver.cpp \
|
||||
sysadm-network.cpp \
|
||||
NetDevice.cpp
|
||||
|
||||
|
||||
46
src/library/sysadm-lifepreserver.cpp
Normal file
46
src/library/sysadm-lifepreserver.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
//===========================================
|
||||
// PC-BSD source code
|
||||
// Copyright (c) 2015, PC-BSD Software/iXsystems
|
||||
// Available under the 3-clause BSD license
|
||||
// See the LICENSE file for full details
|
||||
//===========================================
|
||||
#include "sysadm-general.h"
|
||||
#include "sysadm-lifepreserver.h"
|
||||
//PLEASE: Keep the functions in the same order as listed in pcbsd-general.h
|
||||
|
||||
#include "sysadm-global.h"
|
||||
|
||||
using namespace sysadm;
|
||||
|
||||
// Build list of scheduled cron snapshot jobs
|
||||
QList<QStringList> LifePreserver::listCron() {
|
||||
QStringList output = General::RunCommand("lpreserver listcron").split("\n");
|
||||
QList<QStringList> snaps;
|
||||
QStringList snapitems;
|
||||
|
||||
// Parse the output
|
||||
bool inSection = false;
|
||||
for ( int i = 0; i < output.size(); i++)
|
||||
{
|
||||
if ( output.at(i).indexOf("-----------------") != -1 ) {
|
||||
inSection = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!inSection)
|
||||
continue;
|
||||
|
||||
if ( output.at(i).isEmpty() || output.at(i).indexOf("-----------------") != -1 )
|
||||
break;
|
||||
|
||||
// Save this cron job
|
||||
snapitems.clear();
|
||||
snapitems << output.at(i).section("-", 0, 0).simplified();
|
||||
snapitems << output.at(i).section("-", 1, 1).simplified();
|
||||
snapitems << output.at(i).section("-", 2, 2).simplified().replace("total: ", "");
|
||||
|
||||
snaps << snapitems;
|
||||
}
|
||||
|
||||
return snaps;
|
||||
}
|
||||
22
src/library/sysadm-lifepreserver.h
Normal file
22
src/library/sysadm-lifepreserver.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//===========================================
|
||||
// PC-BSD source code
|
||||
// Copyright (c) 2015, PC-BSD Software/iXsystems
|
||||
// Available under the 3-clause BSD license
|
||||
// See the LICENSE file for full details
|
||||
//===========================================
|
||||
#ifndef __PCBSD_LIB_UTILS_LIFEPRESERVER_H
|
||||
#define __PCBSD_LIB_UTILS_LIFEPRESERVER_H
|
||||
|
||||
#include "sysadm-global.h"
|
||||
|
||||
namespace sysadm{
|
||||
|
||||
class LifePreserver{
|
||||
public:
|
||||
// List schedule snapshots
|
||||
static QList<QStringList> listCron();
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user