-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82adea4
commit 3ccd381
Showing
5 changed files
with
321 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "mainwindow.h" | ||
#include <QApplication> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QApplication a(argc, argv); | ||
MainWindow w; | ||
w.show(); | ||
|
||
return a.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#include "mainwindow.h" | ||
#include "ui_mainwindow.h" | ||
#include <QProcess> | ||
#include <QString> | ||
#include <QDebug> | ||
#include <QTimer> | ||
|
||
MainWindow::MainWindow(QWidget *parent) : | ||
QMainWindow(parent), | ||
ui(new Ui::MainWindow) | ||
{ | ||
ui->setupUi(this); | ||
QTimer *timer; | ||
timer = new QTimer(this); | ||
connect(timer, SIGNAL(timeout()), | ||
this, SLOT(StatusUpdate())); | ||
timer->start(10000); | ||
StatusUpdate(); | ||
} | ||
MainWindow::~MainWindow() | ||
{ | ||
delete ui; | ||
} | ||
void MainWindow::StatusUpdate(){ | ||
pid_t apache = system("pidof -s apache2"); | ||
pid_t mysqld = system("pidof -s mysqld"); | ||
pid_t ftp = system("pidof -s filezilla"); | ||
if(apache != 256) | ||
ui->label_8->setText("Running"); | ||
else | ||
ui->label_8->setText("Not Running"); | ||
if(mysqld != 256) | ||
ui->label_5->setText("Running"); | ||
else | ||
ui->label_5->setText("Not Running"); | ||
if(ftp != 256) | ||
ui->label_7->setText("Running"); | ||
else | ||
ui->label_7->setText("Not Running"); | ||
} | ||
|
||
void MainWindow::bash(QString command) | ||
{ | ||
QProcess *p = new QProcess( this ); | ||
|
||
if (p) | ||
{ | ||
p->setEnvironment( QProcess::systemEnvironment() ); | ||
p->setProcessChannelMode( QProcess::MergedChannels ); | ||
|
||
p->start( command ); | ||
p->waitForStarted(); | ||
|
||
connect( p, SIGNAL(readyReadStandardOutput()), this, SLOT(ReadOut()) ); | ||
connect( p, SIGNAL(readyReadStandardError()), this, SLOT(ReadErr()) ); | ||
} | ||
|
||
} | ||
|
||
void MainWindow::ReadOut(){ | ||
QProcess *p = dynamic_cast<QProcess *>( sender() ); | ||
|
||
if (p){ | ||
ui->textBrowser->append( p->readAllStandardOutput() ); | ||
} | ||
} | ||
void MainWindow::ReadErr(){ | ||
QProcess *p = dynamic_cast<QProcess *>( sender() ); | ||
|
||
if (p){ | ||
ui->textBrowser->append( p->readAllStandardError() ); | ||
} | ||
} | ||
|
||
void MainWindow::on_apache_clicked() | ||
{ | ||
bash("service apache2 restart"); | ||
} | ||
|
||
void MainWindow::on_mysql_clicked() | ||
{ | ||
bash("service mysql restart"); | ||
} | ||
|
||
void MainWindow::on_ftp_clicked() | ||
{ | ||
bash("service filezilla restart"); | ||
} | ||
|
||
void MainWindow::on_startall_clicked() | ||
{ | ||
bash("service apache2 restart"); | ||
bash("service mysql restart"); | ||
bash("service filezilla restart"); | ||
|
||
} | ||
|
||
void MainWindow::on_stopall_clicked() | ||
{ | ||
bash("service apache2 stop"); | ||
bash("service mysql stop"); | ||
bash("service filezilla stop"); | ||
} | ||
|
||
void MainWindow::on_refreshall_clicked() | ||
{ | ||
StatusUpdate(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef MAINWINDOW_H | ||
#define MAINWINDOW_H | ||
|
||
#include <QMainWindow> | ||
|
||
namespace Ui { | ||
class MainWindow; | ||
} | ||
|
||
class MainWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit MainWindow(QWidget *parent = 0); | ||
~MainWindow(); | ||
|
||
private slots: | ||
void on_apache_clicked(); | ||
void on_mysql_clicked(); | ||
void on_ftp_clicked(); | ||
void bash(QString command); | ||
void ReadOut(); | ||
void ReadErr(); | ||
void on_refreshall_clicked(); | ||
void StatusUpdate(); | ||
void on_startall_clicked(); | ||
void on_stopall_clicked(); | ||
|
||
private: | ||
Ui::MainWindow *ui; | ||
}; | ||
|
||
#endif // MAINWINDOW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MainWindow</class> | ||
<widget class="QWidget" name="MainWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>431</width> | ||
<height>440</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Server Manager</string> | ||
</property> | ||
<widget class="QTextBrowser" name="textBrowser"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>20</x> | ||
<y>260</y> | ||
<width>391</width> | ||
<height>161</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
<widget class="QWidget" name="layoutWidget"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>20</x> | ||
<y>10</y> | ||
<width>391</width> | ||
<height>241</height> | ||
</rect> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
<item> | ||
<widget class="QPushButton" name="startall"> | ||
<property name="text"> | ||
<string>Start All</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="stopall"> | ||
<property name="text"> | ||
<string>Stop All</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="0" column="0"> | ||
<widget class="QLabel" name="label_3"> | ||
<property name="text"> | ||
<string>Services</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="0"> | ||
<widget class="QLabel" name="label_4"> | ||
<property name="text"> | ||
<string>MySQL</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="2"> | ||
<widget class="QPushButton" name="mysql"> | ||
<property name="text"> | ||
<string>Restart</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="2"> | ||
<widget class="QPushButton" name="apache"> | ||
<property name="text"> | ||
<string>Restart</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="1"> | ||
<widget class="QLabel" name="label_5"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="1"> | ||
<widget class="QLabel" name="label_7"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="2"> | ||
<widget class="QPushButton" name="ftp"> | ||
<property name="text"> | ||
<string>Restart</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QLabel" name="label_6"> | ||
<property name="text"> | ||
<string>Apache</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="1"> | ||
<widget class="QLabel" name="label_8"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="0"> | ||
<widget class="QLabel" name="label_9"> | ||
<property name="text"> | ||
<string>FTP</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="2"> | ||
<widget class="QPushButton" name="refreshall"> | ||
<property name="text"> | ||
<string>Refresh Status</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="1"> | ||
<widget class="QLabel" name="label_10"> | ||
<property name="text"> | ||
<string>Status</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
<layoutdefault spacing="6" margin="11"/> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#------------------------------------------------- | ||
# | ||
# Project created by QtCreator 2020-08-01T22:02:13 | ||
# | ||
#------------------------------------------------- | ||
|
||
QT += core gui | ||
|
||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||
|
||
TARGET = ServerManager | ||
TEMPLATE = app | ||
|
||
|
||
SOURCES += main.cpp\ | ||
mainwindow.cpp | ||
|
||
HEADERS += mainwindow.h | ||
|
||
FORMS += mainwindow.ui |