Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
application/config/supervisor.php
composer.phar
composer.lock
/vendor
.idea
supervisord-monitor.iml
*.db
33 changes: 18 additions & 15 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,38 @@

## Install

1.Clone supervisord-monitor to your vhost/webroot:
```
1. Clone supervisord-monitor to your vhost/webroot:

```bash
git clone https://github.com/mlazarov/supervisord-monitor.git
```

2.Copy application/config/supervisor.php.example to application/config/supervisor.php
```
cp supervisord-monitor/application/config/supervisor.php.example supervisord-monitor/application/config/supervisor.php
2. Construct sqlite DB

```bash
cd supervisord-monitor
sqlite3 sqlite.db < sqlite.sql
```

3.Enable/Uncomment inet_http_server (found in supervisord.conf) for all your supervisord servers.
3. Configure your web server to point one of your vhosts to 'public_html' directory.

4. Open web browser and enter your vhost url.

5. Enable/Uncomment inet_http_server (found in supervisord.conf) for all your supervisord servers.

Do not forget to restart supervisord service after changing supervisord.conf

```ini
[inet_http_server]
port=*:9001
username="yourusername"
password="yourpass"
```
Do not forget to restart supervisord service after changing supervisord.conf

4.Edit supervisord-monitor configuration file and add all your supervisord servers
```
vim application/config/supervisor.php
```

5.Configure your web server to point one of your vhosts to 'public_html' directory.
6.Open web browser and enter your vhost url.

6. Add your supervisord servers by using "Add" button.

## Redmine integration

1.Open configuration file:
```
vim application/config/supervisor.php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@
// Show hostname after server name
$config['show_host'] = false;

$config['supervisor_servers'] = array(
'server01' => array(
'url' => 'http://server01.app/RPC2',
'port' => '9001',
'username' => 'yourusername',
'password' => 'yourpass'
),
'server02' => array(
'url' => 'http://server02.app/RPC2',
'port' => '9001'
),
'server03' => array(
'url' => 'http://server03.app/RPC2',
'port' => '9001'
),
);
$config['sqlite_db_path'] = '../sqlite.db';
$config['sqlite_db_table'] = 'servers';

$servers = array();
$sqlite_db = new PDO('sqlite:' . $config['sqlite_db_path']);
foreach ($sqlite_db->query('select * from ' . $config['sqlite_db_table']) as $server) {
$servers[$server['name']] = array(
'url' => 'http://' . $server['ip'] . '/RPC2',
'port' => $server['port'],
'username' => $server['username'],
'password' => $server['password']
);
}
$config['supervisor_servers'] = $servers;

// Set timeout connecting to remote supervisord RPC2 interface
$config['timeout'] = 3;
Expand All @@ -38,5 +36,3 @@

// Default Redmine assigne ID
$config['redmine_assigne_id'] = '69';


23 changes: 23 additions & 0 deletions application/controllers/control.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,27 @@ function Clear($server,$worker){
$this->_request($server,'clearProcessLogs',array($worker));
Redirect('/');
}
function AddServer() {
try {
$name = $_POST['name'];
$ip = $_POST['ip'];
$port = $_POST['port'];
$username = $_POST['username'];
$password = $_POST['password'];
$sqlite_db = new PDO('sqlite:' . $this->config->item('sqlite_db_path'));
$sqlite_db->exec("insert into " . $this->config->item('sqlite_db_table') . " values ('$name', '$ip', '$port', '$username', '$password')");
Redirect('/');
} catch (Exception $e) {
echo json_encode("add server error");
}
}
function DelServer($server) {
try {
$sqlite_db = new PDO('sqlite:' . $this->config->item('sqlite_db_path'));
$sqlite_db->exec("delete from " . $this->config->item('sqlite_db_table') . " where name='$server'");
Redirect('/');
} catch (Exception $e) {
echo json_encode("delete server error");
}
}
}
34 changes: 32 additions & 2 deletions application/views/welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
;?></a></li>
<li><a href="<?php echo site_url();?>">Refresh <b id="refresh">(<?php echo $this->config->item('refresh');?>)</b> &nbsp;</a></li>
<li><a href="mailto:[email protected]">Contact</a></li>
<li id="add-server"><a>Add</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
Expand All @@ -46,6 +47,19 @@


<div class="container">

<form id="add-server-form" method="post" hidden="true">
<div class="modal-body">
<input type="text" name="name" placeholder="server_name" value="localhost"/>
<input type="text" name="ip" placeholder="ip" value="127.0.0.1"/>
<input type="text" name="port" placeholder="port" value="9001"/>
<input type="text" name="username" placeholder="username" value="admin"/>
<input type="text" name="password" placeholder="password" value="admin"/>
</div>
<div class="modal-footer">
<input type="submit" value="SUBMIT" class="btn" />
</div>
</form>

<?php
if($muted){
Expand All @@ -70,6 +84,7 @@
<table class="table table-bordered table-condensed table-striped">
<tr><th colspan="4">
<a href="<?php echo $ui_url; ?>"><?php echo $name; ?></a> <?php if($this->config->item('show_host')){ ?><i><?php echo $parsed_url['host']; ?></i><?php } ?>
<a id="del-server" class="icon-trash icon-red" style="color:red" title="Delete server" href="<?php echo site_url('/control/delserver/'.$name); ?>"></a>
<?php
if(isset($cfg[$name]['username'])){echo '<i class="icon-lock icon-green" style="color:blue" title="Authenticated server connection"></i>';}
echo '&nbsp;<i>'.$version[$name].'</i>';
Expand Down Expand Up @@ -212,16 +227,31 @@ function startTimer(){
function timer(){
$refresh--;
$('#refresh').html('('+$refresh+')');
if($refresh<=0){
if($refresh<=0 && !$('#add-server-form').is(':visible')){
stopTimer();
location.href="<?php echo site_url() ?>";
}

}
function nl2br (str, is_xhtml) {
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br ' + '/>' : '<br>';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}
$(function(){
$('#add-server').on('click', function(e) {
$('#add-server-form').toggle();
});
$('#add-server-form').on('submit', function(e){
e.preventDefault();
$.ajax({
type: 'POST',
url: '/control/addserver',
data: $('#add-server-form').serialize(),
success: function(data){
location.href="<?php echo site_url() ?>";
}
});
});
});
</script>

</body>
Expand Down
6 changes: 6 additions & 0 deletions sqlite.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
create table servers (name TEXT PRIMARY KEY NOT NULL, ip TEXT NOT NULL, port TEXT NOT NULL, username TEXT NOT NULL, password TEXT NOT NULL);
/*
insert into servers (name, ip, port, username, password) values ('server01', 'server01.app', 9001, 'yourusername', 'yourpass');
insert into servers (name, ip, port, username, password) values ('server02', 'server02.app', 9001, '', '');
insert into servers (name, ip, port, username, password) values ('server03', 'server03.app', 9001, '', '');
*/