...
 
Commits (40)
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
vendor
node_modules
*/linuxDash.min.js.map
temp
<br/>
<h1 align="center">
<h4 align="center">
linux-dash
</h1>
</h4>
<p align="center">
A simple, low-overhead web dashboard for Linux
<small>A simple & low-overhead web dashboard for linux systems</small>
</p>
<p align="center">
<strong>
<a href="http://linuxdash.afaqtariq.com"><i>Demo</i></a> &nbsp;|&nbsp;
<a href="#features"><i>Features</i></a> &nbsp;|&nbsp;
<a href="#installation">
<i>Installation</i></a> &nbsp;|&nbsp;
<a href="#support"><i>Support</i></a>
</strong>
<small>
<a href="http://linuxdash.afaqtariq.com">Demo</a> &nbsp;|&nbsp;
<a href="#features">Features</a> &nbsp;|&nbsp;
<a href="#installation">
Installation</a> &nbsp;|&nbsp;
<a href="#support">Support</a>
</small>
</p>
<p align="center">
<a href="https://gitter.im/afaqurk/linux-dash">
<img
src="https://badges.gitter.im/gitterHQ/gitter.png"
alt="Linux Dash Gitter chat">
<img
src="https://badges.gitter.im/gitterHQ/gitter.png"
alt="linux-dash Gitter chat">
</a>
</p>
<br/>
<p align="center">
<a href="http://linuxdash.afaqtariq.com">
<img
<img
width="80%"
alt="Linux Dash screenshot"
alt="linux-dash screenshot"
src="http://i.imgur.com/tehGyrQ.gif">
</a>
</p>
......@@ -38,82 +36,85 @@
<br/>
## Features
* A beautiful, simple web-based dashboard for monitoring a linux server
* Only ~1MB on disk! *(.git removed)*
* Live graphs, refresh-able widgets, and a growing # of supported modules
* Drop-in installation for PHP, Node.js, Python, and Go
* **Simple** --- Web-based dashboard for monitoring a linux server
* **Small** ----- Only ~500KB on disk! *(you can cut that in 1/2 by removing `.git/`)*
* **Easy** ------ Drop-in installation for PHP, Node.js, Python, and Go
* **Live** ------- Streaming graphs and refresh-able plugins
## Installation
#### Step 1: Download Linux Dash
Clone the git repo
```sh
git clone https://github.com/afaqurk/linux-dash.git
```
Or download it **[here](https://github.com/afaqurk/linux-dash/archive/master.zip)**.
## 1. clone the repo
git clone --depth 1 https://github.com/afaqurk/linux-dash.git
#### Step 2: Secure Linux Dash
## 2. go to the cloned directory
cd linux-dash/app/server
Linux Dash does not provide any security or authentication features.
## OR
**It is strongly recommended** that all Linux Dash installations be protected via a security measure of your choice.
## 1. alternatively, you can download the .zip
curl -LOk https://github.com/afaqurk/linux-dash/archive/master.zip && unzip master.zip
#### Step 3: Start Linux Dash
<h6 align="center">
Linux Dash can be run in: <u>Node.js</u>, PHP, Go, or Python.
<br/>
<sub>
* Node.js is the recommended platform since it has native support for websockets and fast I/O.
</sub>
</h6>
## 2. navigate to downloaded & unzipped dir
cd linux-dash-master/app/server
First, navigate to the `linux-dash` folder you downloaded or cloned.
```
Then, refer to the section for your preferred platform:
Pick the platform to run linux-dash on:
##### Node.js
* [Node.js](#nodejs) (recommended)
* [Go](#go)
* [Python](#python)
* [PHP](#php)
* C++ (_coming soon_)
Install NPM dependencies
```
npm install
```
<br/>
#### Node.js
```sh
## install dependencies
npm install --production
## start linux-dash (on port 80 by default)
node index.js
Start Linux Dash
```
node server/
<br/>
#### Go
```sh
## start the server (on port 80 by default)
go run index.go
```
Default port for Linux Dash is 80. You may change this in [server/index.js on line 9](https://github.com/afaqurk/linux-dash/blob/master/server/index.js#L9)
To build a binary, run `go build && ./server -h`. See [@tehbilly](https://github.com/sergeifilippov)'s notes [here](https://github.com/afaqurk/linux-dash/pull/281) for binary usage options
<br/>
#### Python
```sh
# Start the server (on port 80 by default).
python index.py
```
<br/>
##### PHP
#### PHP
(TODO: Update PHP instructions with snippets for nginx & apache configs)
1. Make sure you have the `exec`, `shell_exec`, and `escapeshellarg` functions enabled
2. Restart your web server (Apache, nginx, etc.)
2. Point your web server to `app/` directory under `linux-dash`
2. Restart your web server (Apache, nginx, etc.)
- For PHP + Apache setup follow the [Digital Ocean tutorial](https://www.digitalocean.com/community/tutorials/how-to-install-linux-dash-on-ubuntu-14-04).
- For help with nginx setup, see [this gist](https://gist.github.com/sergeifilippov/8909839) by [@sergeifilippov](https://github.com/sergeifilippov).
<br/>
##### Go
Go to the `linux-dash/server` folder and run
```
go run index.go
```
## Support
To build a binary, run `go build && ./server -h`. See [@tehbilly](https://github.com/sergeifilippov)'s notes [here](https://github.com/afaqurk/linux-dash/pull/281) for binary usage options
For general help, please use the [Gitter chat room](https://gitter.im/afaqurk/linux-dash).
##### Python
Run `./python-server.py` will run a server on port 80.
## Security
## Support
**It is strongly recommended** that all linux-dash installations be protected via a security measure of your choice.
For help with general setup and configuration issues please use the [Linux Dash Gitter chat room](https://gitter.im/afaqurk/linux-dash).
The following distributions are supported:
* Arch
* Debian 6,7
* Ubuntu 11.04+
* Linux Mint 16+
* CentOS 5, 6
* openSUSE
linux-dash does not provide any security or authentication features.
......@@ -2,45 +2,30 @@
<html lang="en" ng-app="linuxDash">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>linux-dash : Server Monitoring Web Dashboard</title>
<title>Linux Dash : Simple, beautiful server monitoring web dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Monitor your Linux server through a simple web dashboard. Open source and free!">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link href='//fonts.googleapis.com/css?family=Merriweather:300italic,300|Open+Sans:400,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/themes.css">
<link rel="stylesheet" type="text/css" href="css/animate.css">
<link href='linuxDash.min.css' rel='stylesheet' type='text/css'>
<!-- Angular Libs -->
<script src="js/angular.min.js" type="text/javascript"></script>
<script src="js/angular-route.js" type="text/javascript"></script>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="hero">
<div id="hero">
<h4 class="title">Linux Dash</h4>
<small>A simple linux dashboard</small>
<theme-switcher></theme-switcher>
<nav-bar></nav-bar>
</div>
<!-- Templates Get Rendered Here -->
<div
id="plugins"
class="animated fadeInDown"
ng-view>
</div>
<div id="plugins" ng-view></div>
<!-- Javascript-->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/linuxDash.js" type="text/javascript"></script>
<script src="js/modules.js" type="text/javascript"></script>
<script src="js/smoothie.min.js" type="text/javascript"></script>
<script src="linuxDash.min.js" type="text/javascript"></script>
</body>
</html>
#hero .title,*{letter-spacing:.1rem}#hero .title,#hero nav-bar{display:block;text-align:center}#hero .title,#hero nav-bar,#plugins,.plugin,.plugin .top-bar,.spinner{text-align:center}*{font-family:Merriweather,Arial,sans-serif}html{margin-top:0;padding-top:0;border-top:1px solid #4F8EF7;background-color:rgba(0,0,0,.02);-webkit-transition:all 1s ease;-moz-transition:all 1s ease;-ms-transition:all 1s ease;-o-transition:all 1s ease;transition:all 1s ease}body{padding:0}#hero .title{color:#222;font-size:30px;font-weight:300;height:32px;line-height:52.5px;margin-bottom:20px;margin-top:0}#hero nav-bar ul li a,.plugin .top-bar,table th{font-weight:600;text-transform:uppercase}.plugin ::-webkit-scrollbar{width:8px;height:8px}.plugin ::-webkit-scrollbar-track{background:#eee;border:thin solid #d3d3d3;box-shadow:0 0 3px #dfdfdf inset}.plugin ::-webkit-scrollbar-thumb{background:#999;border:thin solid gray;border-radius:0}table td,table th{border-bottom:1px solid #f1f1f1}.plugin ::-webkit-scrollbar-thumb:hover{background:#7d7d7d}.centered{margin:0 auto}#hero nav-bar ul{margin:0;padding:0;list-style-type:none;display:inline}#hero nav-bar ul li a{font-size:11px;letter-spacing:.2rem;margin-right:35px;text-decoration:none;line-height:2.3rem;color:#222;display:inline}#hero nav-bar ul li a:hover,#hero nav-bar ul li.active a{color:#1EAEDB}#hero nav-bar ul li{margin-left:20px;display:inline}.plugin,.progress-bar,.qs,.spinner>div{display:inline-block}@media (min-width:1080px){#plugins{float:none;margin:0 auto;clear:both}}@media (max-width:1079px){#plugins{float:none;margin:0 auto;clear:both}}#plugins{padding:0 20px 20px;margin-top:0;border:1px}.plugin{vertical-align:text-top;width:400px;padding:0;background-color:#FFF;color:#000;border-radius:2px;box-shadow:0 5px 10px rgba(0,0,0,.53),0 3px 10px rgba(0,0,0,.16);margin:20px auto 50px 20px;max-height:400px;overflow:hidden}@media (max-width:768px){.plugin{max-width:80%;float:none;margin:0 auto 10px}.plugin-body{max-height:400px}}.plugin .top-bar{height:25px;max-width:100%;padding:20px;letter-spacing:.1rem;line-height:1.3rem;font-size:11px;color:#009587}.plugin .no-padding{padding:0}.plugin-body{height:400px;font-size:12px;padding:10px;line-height:30px;overflow:auto;border-top:1px solid #ececec}.plugin last-update{font-size:11px;float:left}no-data{font-style:italic}refresh-btn button{background-color:#009587;border:0;float:right;font-size:15px;color:#fff;border-radius:50%;width:30px;height:30px;padding:5px;-webkit-transition:all .5s ease;-moz-transition:all .5s ease;-ms-transition:all .5s ease;-o-transition:all .5s ease;transition:all .5s ease}.spinner,table,table td{font-size:10px}refresh-btn button:hover{background-color:#ffeb3b;color:#000}refresh-btn button:active{background-color:#0f9d58}.spinner{margin:100px auto;width:50px;height:30px}.spinner>div{background-color:#009587;height:100%;width:6px;-webkit-animation:stretchdelay 1.2s infinite ease-in-out;animation:stretchdelay 1.2s infinite ease-in-out}.spinner .rect2{-webkit-animation-delay:-1.1s;animation-delay:-1.1s}.spinner .rect3{-webkit-animation-delay:-1s;animation-delay:-1s}.spinner .rect4{-webkit-animation-delay:-.9s;animation-delay:-.9s}.spinner .rect5{-webkit-animation-delay:-.8s;animation-delay:-.8s}@-webkit-keyframes stretchdelay{0%,100%,40%{-webkit-transform:scaleY(.4)}20%{-webkit-transform:scaleY(1)}}@keyframes stretchdelay{0%,100%,40%{transform:scaleY(.4);-webkit-transform:scaleY(.4)}20%{transform:scaleY(1);-webkit-transform:scaleY(1)}}table{width:100%;margin:0;border-collapse:collapse;text-align:left;table-layout:fixed}table td,table th{padding:2px;max-width:250px;word-wrap:break-word}table td{font-family:Arial,sans-serif;color:rgba(0,0,0,.65)}table tbody tr:hover td{background-color:#fafafa}table.metrics-table{text-align:center}canvas{float:none;margin:0 auto;width:100%;max-width:100%}.progress-bar{background-color:#eec;border-radius:10px;padding:0;clear:both;overflow:hidden;white-space:nowrap}.progress-bar>div{background-color:#1EAEDB;width:0;height:5px;border-radius:5px}.table-data-plugin .filter-container{padding-bottom:0;margin:0}.table-data-plugin .filter,.table-data-plugin .filter:active,.table-data-plugin .filter:focus{height:20px;padding:5px;border:none;outline-color:transparent;background:0 0;width:100%;margin:0;text-align:center;font-size:15px}.table-data-plugin .filter:focus{border-bottom:1px solid #ff5722}.table-data-plugin thead tr th a,.table-data-plugin thead tr th a:visited{color:#000;text-decoration:none}.table-data-plugin .column-sort-caret{font-size:10px;color:#1EAEDB}.qs{cursor:default;position:relative}.qs .popover{text-transform:none;background-color:rgba(0,0,0,.85);border-radius:5px;bottom:42px;box-shadow:0 0 5px rgba(0,0,0,.4);color:#fff;display:none;font-size:12px;font-family:Helvetica,sans-serif;padding:7px 10px;position:absolute;width:200px;z-index:4}.qs .popover:before{border-top:7px solid rgba(0,0,0,.85);border-right:7px solid transparent;border-left:7px solid transparent;bottom:-7px;content:'';display:block;left:50%;margin-left:-7px;position:absolute}.qs:hover .popover{display:block;-webkit-animation:fade-in .3s linear 1,move-up .3s linear 1;-moz-animation:fade-in .3s linear 1,move-up .3s linear 1;-ms-animation:fade-in .3s linear 1,move-up .3s linear 1}@-webkit-keyframes fade-in{from{opacity:0}to{opacity:1}}@-moz-keyframes fade-in{from{opacity:0}to{opacity:1}}@-ms-keyframes fade-in{from{opacity:0}to{opacity:1}}@-webkit-keyframes move-up{from{bottom:30px}to{bottom:42px}}@-moz-keyframes move-up{from{bottom:30px}to{bottom:42px}}@-ms-keyframes move-up{from{bottom:30px}to{bottom:42px}}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,13 +7,11 @@ import (
"net/http"
"os"
"os/exec"
"path/filepath"
)
var (
listenAddress = flag.String("listen", "0.0.0.0:80", "Where the server listens for connections. [interface]:port")
staticPath = flag.String("static", "../", "Location of static files.")
scriptPath = flag.String("scripts", "./modules/shell_files", "Location of shell scripts used to gather stats.")
)
func init() {
......@@ -24,19 +22,18 @@ func main() {
http.Handle("/", http.FileServer(http.Dir(*staticPath)))
http.HandleFunc("/server/", func(w http.ResponseWriter, r *http.Request) {
module := r.URL.Query().Get("module")
script := filepath.Join(*scriptPath, module+".sh")
if module == "" {
http.Error(w, "No module specified, or requested module doesn't exist.", 406)
return
}
// Execute the command
cmd := exec.Command(script)
cmd := exec.Command("./linux_json_api.sh", module)
var output bytes.Buffer
cmd.Stdout = &output
err := cmd.Run()
if err != nil {
fmt.Printf("Error executing '%s': %s\n\tScript output: %s\n", script, err.Error(), output.String())
fmt.Printf("Error executing '%s': %s\n\tScript output: %s\n", module, err.Error(), output.String())
http.Error(w, "Unable to execute module.", http.StatusInternalServerError)
return
}
......
......@@ -28,7 +28,7 @@ wsServer = new ws({
});
function getShellFilePath(moduleName) {
return __dirname + '/modules/shell_files/' + moduleName + '.sh';
return __dirname + '/linux_json_api.sh';
}
function shellPathAndModuleNameAreValid(shellFilePath, moduleName) {
......@@ -47,7 +47,7 @@ function shellPathAndModuleNameAreValid(shellFilePath, moduleName) {
wsServer.on('request', function(request) {
var wsClient = request.accept('linux-dash', request.origin);
var wsClient = request.accept('', request.origin);
wsClient.on('message', function(wsReq) {
......@@ -58,7 +58,7 @@ wsServer.on('request', function(request) {
return;
}
var command = spawn(shellFile, [ wsReq.color || '' ]);
var command = spawn(shellFile, [ moduleName, wsReq.color || '' ]);
var output = [];
command.stdout.on('data', function(chunk) {
......
......@@ -2,7 +2,7 @@
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
$modules_dir = dirname(__FILE__) . '/modules/shell_files/';
$shell_file = dirname(__FILE__) . '/linux_json_api.sh';
$module = escapeshellcmd($_GET['module']);
echo shell_exec( $modules_dir . $module . '.sh' );
echo shell_exec( $shell_file . " " . $module );
......@@ -5,8 +5,8 @@ from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer, test as _test
import subprocess
from SocketServer import ThreadingMixIn
modulesSubPath = '/server/modules/shell_files/'
serverPath = os.path.dirname(os.path.realpath(__file__))
modulesSubPath = '/server/linux_json_api.sh'
appRootPath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
pass
......@@ -19,16 +19,16 @@ class MainHandler(BaseHTTPRequestHandler):
if self.path.startswith("/server/"):
module = self.path.split('=')[1]
output = subprocess.Popen(
serverPath + modulesSubPath + module + '.sh',
appRootPath + modulesSubPath + " " + module,
shell = True,
stdout = subprocess.PIPE)
data = output.communicate()[0]
else:
if self.path == '/':
self.path = 'index.html'
f = open(os.path.dirname(os.path.realpath(__file__)) + os.sep + self.path)
f = open(appRootPath + os.sep + self.path)
data = f.read()
if self.path.startswith('/css/'):
if self.path.startswith('/main.css'):
contentType = 'text/css'
f.close()
self.send_response(200)
......@@ -40,6 +40,6 @@ class MainHandler(BaseHTTPRequestHandler):
self.send_error(404, 'File Not Found: %s' % self.path)
if __name__ == '__main__':
server = ThreadedHTTPServer(('0.0.0.0', 8081), MainHandler)
server = ThreadedHTTPServer(('0.0.0.0', 80), MainHandler)
print 'Starting server, use <Ctrl-C> to stop'
server.serve_forever()
This diff is collapsed.
{
"name": "afaqurk/linux-dash",
"description": "A drop-in, low-overhead monitoring web dashboard for a linux machine.",
"license": "MIT",
"version": "1.2.0",
"keywords": ["linux", "dashboard", "linux-dash", "server dashboard"],
"authors": [
{
"name": "Afaq Tariq",
"email": "afaq05@gmail.com"
}
],
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0"
},
"support": {
"issues": "https://github.com/afaqurk/linux-dash/issues?state=open",
"forum": "https://gitter.im/afaqurk/linux-dash",
"source": "https://github.com/afaqurk/linux-dash"
}
}
This diff is collapsed.
/**************************************
Theme: linux-dash beta
**************************************/
html.old {
background: #F9F6F1;
}
html.old body {
margin: 0;
}
html.old body * {
font-family: "Open Sans";
letter-spacing: 0;
}
html.old body .hero {
background: #00BA8B;
color: #ffffff;
padding: 0;
}
html.old body .hero h4 {
color: #ffffff;
display: inline-block;
font-size: 20px;
font-weight: 600;
height: 40px;
line-height: 35px;
margin: 0;
vertical-align: middle;
}
html.old body .hero small {
letter-spacing: 0.1rem;
line-height: 40px;
margin-left: 20px;
opacity: 0.9;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}
html.old body .hero #theme-switcher {
right: -315px;
}
html.old body .hero #theme-switcher.open {
right: 0;
}
html.old body .hero nav-bar {
background: #ffffff;
border-bottom: 1px solid #d6d6d6;
color: #333333;
}
html.old body .hero nav-bar br {
display: none;
}
html.old body .hero nav-bar ul {
display: inline-block;
}
html.old body .hero nav-bar ul li {
display: inline-block;
margin: 0;
}
html.old body .hero nav-bar ul li:not(:first-child) {
border-left: 1px solid #e6e6e6;
}
html.old body .hero nav-bar ul li a {
color: #B2AFAA;
display: block;
font-size: 12px;
font-weight: bold;
line-height: 30px;
margin: 0;
padding: 0 15px;
text-transform: capitalize;
}
html.old body .hero nav-bar ul li:hover a {
color: #888888;
}
html.old body #plugins {
display: flex;
flex-flow: row wrap;
justify-content: center;
}
html.old body .plugin {
border: 1px solid #d5d5d5;
border-radius: 0 0 5px 5px;
box-shadow: none;
margin: 10px;
}
html.old body .plugin .top-bar {
background: transparent linear-gradient(to bottom, #f9f6f1 0%, #f2efea 100%) repeat scroll 0px 0px;
border-bottom: 1px solid #d6d6d6;
color: #525252;
font-size: 14px;
font-weight: bold;
height: 40px;
line-height: 40px;
padding: 0 0 0 15px;
position: relative;
text-align: left;
text-transform: none;
}
html.old body .plugin .top-bar last-update {
float: right;
margin: 0 10px;
opacity: 0.8;
}
html.old body .plugin .top-bar refresh-btn {
float: right;
}
html.old body .plugin .top-bar refresh-btn button {
background: #ffffff;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.1) inset, 0px 1px 2px rgba(0, 0, 0, 0.1);
color: #555555;
cursor: pointer;
box-shadow: none;
display: inline-block;
float: none;
font-size: 14px;
height: auto;
margin: 0 -5px 0 10px;
padding: 0 4px;
width: auto;
}
html.old body .plugin .top-bar refresh-btn button:hover {
background: #e6e6e6;
}
html.old body .plugin .plugin-body {
border: none;
height: auto;
line-height: normal;
max-height: 300px;
padding: 0;
}
html.old body .plugin .plugin-body table {
border-collapse: separate;
border-spacing: 0;
font-size: 12px;
min-width: 300px;
}
html.old body .plugin .plugin-body table tr:not(:first-child) th {
border-top: 1px solid #dddddd;
}
html.old body .plugin .plugin-body table td,
html.old body .plugin .plugin-body table th {
border-bottom: none;
padding: 4px 5px;
}
html.old body .plugin .plugin-body table td:not(:first-child),
html.old body .plugin .plugin-body table th:not(:first-child) {
border-left: 1px solid #dddddd;
}
html.old body .plugin .plugin-body table th:not(.filter-container) {
background: transparent -moz-linear-gradient(center top, #fafafa 0%, #e9e9e9 100%) repeat scroll 0% 0%;
text-transform: uppercase;
}
html.old body .plugin .plugin-body table th.filter-container .filter {
border-bottom: none;
font-size: 12px;
height: auto;
padding: 2px;
}
html.old body .plugin .plugin-body table th.filter-container .filter::before {
content: 'Search >';
opacity: 0.5;
position: absolute;
left: 0;
}
html.old body .plugin .plugin-body table td {
border-top: 1px solid #dddddd;
}
html.old body .plugin canvas {
width: 100%;
}
@import "theme-old.css";
/**************************************
Theme: Winter
**************************************/
html.winter {
background: url(../img/themes/contemporary_china_2.png) ;
}
html.winter .hero nav-bar ul li.active a,
html.winter .hero nav-bar ul li a:hover {
color: #23568f;
}
html.winter .plugin {
background-color: rgba(255, 255, 255, 0.60);
}
html.winter .plugin .top-bar {
color: #012e40;
}
html.winter .plugin refresh-btn button {
background-color: #4c6c73;
}
table th {
color: #012e40;
}
/**************************************
Theme: Summer
**************************************/
html.summer {
clear: both;
background: url(../img/themes/congruent_pentagon.png);
}
html.summer .hero nav-bar ul li.active a,
html.summer .hero nav-bar ul li a:hover {
color: #D84315;
}
html.summer .plugin{
background-color: rgba(255, 255, 255, 0.8);
}
html.summer .plugin .top-bar {
color: #BF360C;
}
html.summer .plugin refresh-btn button {
background-color: #BF360C;
}
/**************************************
Theme: Spring
**************************************/
html.spring {
clear: both;
background: url(../img/themes/food.png);
}
html.spring .hero nav-bar ul li.active a,
html.spring .hero nav-bar ul li a:hover {
color: #E65100;
}
html.spring .plugin {
background-color: rgba(255,255,255,0.95);
}
html.spring .plugin .top-bar {
color: #FF6D00;
}
html.spring .plugin refresh-btn button {
background-color: #E65100;
}
/**************************************
Theme: Fall
**************************************/
html.fall {
background: url(../img/themes/skulls.png);
}
html.fall .plugin {
background: url(../img/themes/crossword.png);
}
html.fall .hero nav-bar ul li.active a,
html.fall .hero nav-bar ul li a:hover,
html.fall .plugin .top-bar {
color: #F09819;
}
html.fall .plugin refresh-btn button {
background-color: #FF512F;
}
<!DOCTYPE html>
<html lang="en" ng-app="linuxDash">
<head>
<title>linux-dash : Server Monitoring Web Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Monitor your Linux server through a simple web dashboard. Open source and free!">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link href='//fonts.googleapis.com/css?family=Merriweather:300italic,300|Open+Sans:400,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/themes.css">
<link rel="stylesheet" type="text/css" href="css/animate.css">
<!-- Angular Libs -->
<script src="js/angular.min.js" type="text/javascript"></script>
<script src="js/angular-route.js" type="text/javascript"></script>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<a href="https://github.com/afaqurk/linux-dash">
<img
style="position: absolute; top: 0; left: 0; border: 0; z-index:10;"
src="https://camo.githubusercontent.com/567c3a48d796e2fc06ea80409cc9dd82bf714434/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_darkblue_121621.png">
</a>
<div class="hero">
<h4 class="title">Linux Dash</h4>
<small>A simple linux dashboard</small>
<theme-switcher></theme-switcher>
<nav-bar></nav-bar>
</div>
<!-- Templates Get Rendered Here -->
<div
id="plugins"
class="animated fadeInDown"
ng-view>
</div>
<!-- Javascript-->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/linuxDash.js" type="text/javascript"></script>
<script src="js/modules.js" type="text/javascript"></script>
<script src="js/smoothie.min.js" type="text/javascript"></script>
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-44168418-2', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
var g = require('gulp')
var concat = require('gulp-concat')
var uglify = require('gulp-uglify')
var cssmin = require('gulp-cssmin')
var gutil = require('gulp-util')
var ngAnnotate = require('gulp-ng-annotate')
var templateCache = require('gulp-angular-templatecache')
g.task('template-cache', function () {
return g.src('src/**/*.html')
.pipe(templateCache('templates.js', {
module: 'linuxDash',
standAlone: false,
root: 'src/'
}))
.pipe(g.dest('temp/'))
})
g.task('generate-js-dist', ['template-cache'], function () {
return g.src([
'node_modules/angular/angular.min.js',
'node_modules/angular-route/angular-route.min.js',
'node_modules/smoothie/smoothie.js',
'src/js/**/*.js',
'temp/templates.js'
])
.pipe(concat('linuxDash.min.js'))
.pipe(ngAnnotate())
.pipe(uglify())
.on('error', gutil.log)
.pipe(g.dest('app/'))
})
g.task('generate-css-dist', function () {
return g.src([ 'src/main.css' ])
.pipe(cssmin())
.pipe(concat('linuxDash.min.css'))
.pipe(g.dest('app/'))
})
g.task('build', [
'generate-js-dist',
'generate-css-dist'
])
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
(function(e){function n(e){this.options=t.extend({},n.defaultOptions,e);this.clear()}function r(e){this.options=t.extend({},r.defaultChartOptions,e);this.seriesSet=[];this.currentValueRange=1;this.currentVisMinValue=0;this.lastRenderTimeMillis=0}var t={extend:function(){arguments[0]=arguments[0]||{};for(var e=1;e<arguments.length;e++){for(var n in arguments[e]){if(arguments[e].hasOwnProperty(n)){if(typeof arguments[e][n]==="object"){if(arguments[e][n]instanceof Array){arguments[0][n]=arguments[e][n]}else{arguments[0][n]=t.extend(arguments[0][n],arguments[e][n])}}else{arguments[0][n]=arguments[e][n]}}}}return arguments[0]}};n.defaultOptions={resetBoundsInterval:3e3,resetBounds:true};n.prototype.clear=function(){this.data=[];this.maxValue=Number.NaN;this.minValue=Number.NaN};n.prototype.resetBounds=function(){if(this.data.length){this.maxValue=this.data[0][1];this.minValue=this.data[0][1];for(var e=1;e<this.data.length;e++){var t=this.data[e][1];if(t>this.maxValue){this.maxValue=t}if(t<this.minValue){this.minValue=t}}}else{this.maxValue=Number.NaN;this.minValue=Number.NaN}};n.prototype.append=function(e,t,n){var r=this.data.length-1;while(r>=0&&this.data[r][0]>e){r--}if(r===-1){this.data.splice(0,0,[e,t])}else if(this.data.length>0&&this.data[r][0]===e){if(n){this.data[r][1]+=t;t=this.data[r][1]}else{this.data[r][1]=t}}else if(r<this.data.length-1){this.data.splice(r+1,0,[e,t])}else{this.data.push([e,t])}this.maxValue=isNaN(this.maxValue)?t:Math.max(this.maxValue,t);this.minValue=isNaN(this.minValue)?t:Math.min(this.minValue,t)};n.prototype.dropOldData=function(e,t){var n=0;while(this.data.length-n>=t&&this.data[n+1][0]<e){n++}if(n!==0){this.data.splice(0,n)}};r.defaultChartOptions={millisPerPixel:20,enableDpiScaling:true,yMinFormatter:function(e,t){return parseFloat(e).toFixed(t)},yMaxFormatter:function(e,t){return parseFloat(e).toFixed(t)},maxValueScale:1,minValueScale:1,interpolation:"bezier",scaleSmoothing:.125,maxDataSetLength:2,grid:{fillStyle:"#000000",strokeStyle:"#777777",lineWidth:1,sharpLines:false,millisPerLine:1e3,verticalSections:2,borderVisible:true},labels:{fillStyle:"#ffffff",disabled:false,fontSize:10,fontFamily:"monospace",precision:2},horizontalLines:[]};r.AnimateCompatibility=function(){var e=function(e,t){var n=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return window.setTimeout(function(){e((new Date).getTime())},16)};return n.call(window,e,t)},t=function(e){var t=window.cancelAnimationFrame||function(e){clearTimeout(e)};return t.call(window,e)};return{requestAnimationFrame:e,cancelAnimationFrame:t}}();r.defaultSeriesPresentationOptions={lineWidth:1,strokeStyle:"#ffffff"};r.prototype.addTimeSeries=function(e,n){this.seriesSet.push({timeSeries:e,options:t.extend({},r.defaultSeriesPresentationOptions,n)});if(e.options.resetBounds&&e.options.resetBoundsInterval>0){e.resetBoundsTimerId=setInterval(function(){e.resetBounds()},e.options.resetBoundsInterval)}};r.prototype.removeTimeSeries=function(e){var t=this.seriesSet.length;for(var n=0;n<t;n++){if(this.seriesSet[n].timeSeries===e){this.seriesSet.splice(n,1);break}}if(e.resetBoundsTimerId){clearInterval(e.resetBoundsTimerId)}};r.prototype.getTimeSeriesOptions=function(e){var t=this.seriesSet.length;for(var n=0;n<t;n++){if(this.seriesSet[n].timeSeries===e){return this.seriesSet[n].options}}};r.prototype.bringToFront=function(e){var t=this.seriesSet.length;for(var n=0;n<t;n++){if(this.seriesSet[n].timeSeries===e){var r=this.seriesSet.splice(n,1);this.seriesSet.push(r[0]);break}}};r.prototype.streamTo=function(e,t){this.canvas=e;this.delay=t;this.start()};r.prototype.resize=function(){if(!this.options.enableDpiScaling||!window||window.devicePixelRatio===1)return;var e=window.devicePixelRatio;var t=parseInt(this.canvas.getAttribute("width"));var n=parseInt(this.canvas.getAttribute("height"));if(!this.originalWidth||Math.floor(this.originalWidth*e)!==t){this.originalWidth=t;this.canvas.setAttribute("width",Math.floor(t*e).toString());this.canvas.style.width=t+"px";this.canvas.getContext("2d").scale(e,e)}if(!this.originalHeight||Math.floor(this.originalHeight*e)!==n){this.originalHeight=n;this.canvas.setAttribute("height",Math.floor(n*e).toString());this.canvas.style.height=n+"px";this.canvas.getContext("2d").scale(e,e)}};r.prototype.start=function(){if(this.frame){return}var e=function(){this.frame=r.AnimateCompatibility.requestAnimationFrame(function(){this.render();e()}.bind(this))}.bind(this);e()};r.prototype.stop=function(){if(this.frame){r.AnimateCompatibility.cancelAnimationFrame(this.frame);delete this.frame}};r.prototype.updateValueRange=function(){var e=this.options,t=Number.NaN,n=Number.NaN;for(var r=0;r<this.seriesSet.length;r++){var i=this.seriesSet[r].timeSeries;if(!isNaN(i.maxValue)){t=!isNaN(t)?Math.max(t,i.maxValue):i.maxValue}if(!isNaN(i.minValue)){n=!isNaN(n)?Math.min(n,i.minValue):i.minValue}}if(e.maxValue!=null){t=e.maxValue}else{t*=e.maxValueScale}if(e.minValue!=null){n=e.minValue}else{n-=Math.abs(n*e.minValueScale-n)}if(this.options.yRangeFunction){var s=this.options.yRangeFunction({min:n,max:t});n=s.min;t=s.max}if(!isNaN(t)&&!isNaN(n)){var o=t-n;var u=o-this.currentValueRange;var a=n-this.currentVisMinValue;this.isAnimatingScale=Math.abs(u)>.1||Math.abs(a)>.1;this.currentValueRange+=e.scaleSmoothing*u;this.currentVisMinValue+=e.scaleSmoothing*a}this.valueRange={min:n,max:t}};r.prototype.render=function(e,t){var n=(new Date).getTime();if(!this.isAnimatingScale){var r=Math.min(1e3/6,this.options.millisPerPixel);if(n-this.lastRenderTimeMillis<r){return}}this.resize();this.lastRenderTimeMillis=n;e=e||this.canvas;t=t||n-(this.delay||0);t-=t%this.options.millisPerPixel;var i=e.getContext("2d"),s=this.options,o={top:0,left:0,width:e.clientWidth,height:e.clientHeight},u=t-o.width*s.millisPerPixel,a=function(e){var t=e-this.currentVisMinValue;return this.currentValueRange===0?o.height:o.height-Math.round(t/this.currentValueRange*o.height)}.bind(this),f=function(e){return Math.round(o.width-(t-e)/s.millisPerPixel)};this.updateValueRange();i.font=s.labels.fontSize+"px "+s.labels.fontFamily;i.save();i.translate(o.left,o.top);i.beginPath();i.rect(0,0,o.width,o.height);i.clip();i.save();i.fillStyle=s.grid.fillStyle;i.clearRect(0,0,o.width,o.height);i.fillRect(0,0,o.width,o.height);i.restore();i.save();i.lineWidth=s.grid.lineWidth;i.strokeStyle=s.grid.strokeStyle;if(s.grid.millisPerLine>0){i.beginPath();for(var l=t-t%s.grid.millisPerLine;l>=u;l-=s.grid.millisPerLine){var c=f(l);if(s.grid.sharpLines){c-=.5}i.moveTo(c,0);i.lineTo(c,o.height)}i.stroke();i.closePath()}for(var h=1;h<s.grid.verticalSections;h++){var p=Math.round(h*o.height/s.grid.verticalSections);if(s.grid.sharpLines){p-=.5}i.beginPath();i.moveTo(0,p);i.lineTo(o.width,p);i.stroke();i.closePath()}if(s.grid.borderVisible){i.beginPath();i.strokeRect(0,0,o.width,o.height);i.closePath()}i.restore();if(s.horizontalLines&&s.horizontalLines.length){for(var d=0;d<s.horizontalLines.length;d++){var v=s.horizontalLines[d],m=Math.round(a(v.value))-.5;i.strokeStyle=v.color||"#ffffff";i.lineWidth=v.lineWidth||1;i.beginPath();i.moveTo(0,m);i.lineTo(o.width,m);i.stroke();i.closePath()}}for(var g=0;g<this.seriesSet.length;g++){i.save();var y=this.seriesSet[g].timeSeries,b=y.data,w=this.seriesSet[g].options;y.dropOldData(u,s.maxDataSetLength);i.lineWidth=w.lineWidth;i.strokeStyle=w.strokeStyle;i.beginPath();var E=0,S=0,x=0;for(var T=0;T<b.length&&b.length!==1;T++){var N=f(b[T][0]),C=a(b[T][1]);if(T===0){E=N;i.moveTo(N,C)}else{switch(s.interpolation){case"linear":case"line":{i.lineTo(N,C);break};case"bezier":default:{i.bezierCurveTo(Math.round((S+N)/2),x,Math.round(S+N)/2,C,N,C);break};case"step":{i.lineTo(N,x);i.lineTo(N,C);break}}}S=N;x=C}if(b.length>1){if(w.fillStyle){i.lineTo(o.width+w.lineWidth+1,x);i.lineTo(o.width+w.lineWidth+1,o.height+w.lineWidth+1);i.lineTo(E,o.height+w.lineWidth);i.fillStyle=w.fillStyle;i.fill()}if(w.strokeStyle&&w.strokeStyle!=="none"){i.stroke()}i.closePath()}i.restore()}if(!s.labels.disabled&&!isNaN(this.valueRange.min)&&!isNaN(this.valueRange.max)){var k=s.yMaxFormatter(this.valueRange.max,s.labels.precision),L=s.yMinFormatter(this.valueRange.min,s.labels.precision);i.fillStyle=s.labels.fillStyle;i.fillText(k,o.width-i.measureText(k).width-2,s.labels.fontSize);i.fillText(L,o.width-i.measureText(L).width-2,o.height-2)}if(s.timestampFormatter&&s.grid.millisPerLine>0){var A=o.width-i.measureText(L).width+4;for(var l=t-t%s.grid.millisPerLine;l>=u;l-=s.grid.millisPerLine){var c=f(l);if(c<A){var O=new Date(l),M=s.timestampFormatter(O),_=i.measureText(M).width;A=c-_-2;i.fillStyle=s.labels.fillStyle;i.fillText(M,c-_,o.height-2)}}}i.restore()};r.timeFormatter=function(e){function t(e){return(e<10?"0":"")+e}return t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())};e.TimeSeries=n;e.SmoothieChart=r})(typeof exports==="undefined"?this:exports)
{
"name": "linux-dash",
"version": "1.2.0",
"version": "2.0.0",
"description": "A simple, low overhead web dashboard for linux.",
"main": "server/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"main": "app/server/index.js",
"repository": {
"type": "git",
"url": "https://github.com/afaqurk/linux-dash.git"
......@@ -25,6 +22,19 @@
"homepage": "https://github.com/afaqurk/linux-dash",
"dependencies": {
"express": "^4.11.1",
"websocket": "^1.0.22"
"websocket": "^1.0.23"
},
"devDependencies": {
"angular": "1.3.4",
"angular-route": "1.3.4",
"del": "^2.2.0",
"gulp": "^3.9.1",
"gulp-angular-templatecache": "^1.8.0",
"gulp-concat": "^2.6.0",
"gulp-cssmin": "^0.1.7",
"gulp-ng-annotate": "^2.0.0",
"gulp-uglify": "^1.5.3",
"gulp-util": "^3.0.7",
"smoothie": "^1.27.0"
}
}
This diff is collapsed.
#!/bin/bash
arpCommand=$(command -v arp)
result=$($arpCommand | awk 'BEGIN {print "["} NR>1 \
{print "{ \"address\": \"" $1 "\", " \
"\"hw_type\": \"" $2 "\", " \
"\"hw_address\": \"" $3 "\", " \
"\"flags\": \"" $4 "\", " \
"\"mask\": \"" $5 "\" }, " \
} \
END {print "]"}' \
| /bin/sed 'N;$s/},/}/;P;D')
if [ -z "$result" ]; then echo {}
else echo $result
fi
\ No newline at end of file
#!/bin/bash
/bin/cat /proc/net/dev \
| awk 'BEGIN {print "["} NR>2 {print "{ \"interface\": \"" $1 "\"," \
" \"tx\": " $2 "," \
" \"rx\": " $10 " }," } END {print "]"}' \
| /bin/sed 'N;$s/,\n/\n/;P;D'
#!/bin/bash
result=$(whereis php node mysql mongo vim python ruby java apache2 nginx openssl vsftpd make \
| awk -F: '{if(length($2)==0) { installed="false"; } else { installed="true"; } \
print \
"{ \
\"binary\": \""$1"\", \
\"location\": \""$2"\", \
\"installed\": "installed" \
},"}')
echo "[" ${result%?} "]"
\ No newline at end of file
#!/bin/bash
result=$(/usr/bin/lscpu \
| /usr/bin/awk -F: '{print "\""$1"\": \""$2"\"," } '\
)
echo "{" ${result%?} "}"
\ No newline at end of file
#!/bin/bash
result=$(/bin/ps axo pid,user,pcpu,rss,vsz,comm --sort -pcpu,-rss,-vsz \
| head -n 15 \
| /usr/bin/awk 'BEGIN{OFS=":"} NR>1 {print "{ \"pid\": " $1 \
", \"user\": \"" $2 "\"" \
", \"cpu%\": " $3 \
", \"rss\": " $4 \
", \"vsz\": " $5 \
", \"cmd\": \"" $6 "\"" "},"\
}')
echo "[" ${result%?} "]"
\ No newline at end of file
#!/bin/bash
if [ `which sensors` ]; then
returnString=`sensors`
#amd
if [[ "${returnString/"k10"}" != "${returnString}" ]] ; then
echo ${returnString##*k10} | cut -d ' ' -f 6 | cut -c 2- | cut -c 1-4
#intel
elif [[ "${returnString/"core"}" != "${returnString}" ]] ; then
fromcore=${returnString##*"coretemp"}
echo ${fromcore##*Physical} | cut -d ' ' -f 3 | cut -c 2-5
fi
else
echo "[]"
fi
#!/bin/bash
# by Paul Colby (http://colby.id.au), no rights reserved ;)
PREV_TOTAL=0
PREV_IDLE=0
iteration=0
while [[ iteration -lt 2 ]]; do
# Get the total CPU statistics, discarding the 'cpu ' prefix.
CPU=(`sed -n 's/^cpu\s//p' /proc/stat`)
IDLE=${CPU[3]} # Just the idle CPU time.
# Calculate the total CPU time.
TOTAL=0
for VALUE in "${CPU[@]}"; do
let "TOTAL=$TOTAL+$VALUE"
done
# Calculate the CPU usage since we last checked.
let "DIFF_IDLE=$IDLE-$PREV_IDLE"
let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
#echo -en "\rCPU: $DIFF_USAGE% \b\b"
# Remember the total and idle CPU times for the next check.
PREV_TOTAL="$TOTAL"
PREV_IDLE="$IDLE"
# Wait before checking again.
sleep 1
iteration="$iteration+1"
done
echo -en "$DIFF_USAGE"
#!/bin/bash
grepCmd=$(which grep)
cronLog='/var/log/syslog'
numberOfLines='50'
# Month, Day, Time, Hostname, tag, user,
result=$($grepCmd -m$numberOfLines CRON $cronLog \
| awk '{ s = ""; for (i = 6; i <= NF; i++) s = s $i " "; \
print "{\"time\" : \"" $1" "$2" "$3 "\"," \
"\"user\" : \"" $6 "\"," \
"\"message\" : \"" $5" "gensub("\"", "\\\\\"", "g", s) "\"" \
"},"
}'
)
echo [${result%?}]
#!/bin/bash
awkCmd=`which awk`
catCmd=`which cat`
grepCmd=`which grep`
memInfoFile="/proc/meminfo"
# References:
# Calculations: http://zcentric.com/2012/05/29/mapping-procmeminfo-to-output-of-free-command/
# Fields: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
memInfo=`$catCmd $memInfoFile | $grepCmd 'MemTotal\|MemFree\|Buffers\|Cached'`
echo $memInfo | $awkCmd '{print "{ \"total\": " ($2/1024) ", \"used\": " ( ($2-($5+$8+$11))/1024 ) ", \"free\": " (($5+$8+$11)/1024) " }" }'
#!/bin/bash
result=$(/bin/df -Ph | awk 'NR>1 {print "{\"file_system\": \"" $1 "\", \"size\": \"" $2 "\", \"used\": \"" $3 "\", \"avail\": \"" $4 "\", \"used%\": \"" $5 "\", \"mounted\": \"" $6 "\"},"}')
echo [ ${result%?} ]
\ No newline at end of file
#!/bin/bash
result=""
containers="$(docker ps | awk '{if(NR>1) print $NF}')"
for i in $containers; do
result="$result $(/usr/bin/docker top $i axo pid,user,pcpu,pmem,comm --sort -pcpu,-pmem \
| head -n 15 \
| /usr/bin/awk -v cnt="$i" 'BEGIN{OFS=":"} NR>1 {print "{ \"cname\": \"" cnt \
"\", \"pid\": " $1 \
", \"user\": \"" $2 "\"" \
", \"cpu%\": " $3 \
", \"mem%\": " $4 \
", \"cmd\": \"" $5 "\"" "},"\
}')"
done
echo "[" ${result%?} "]"
#!/bin/bash
files=(/sys/class/net/*)
pos=$(( ${#files[*]} - 1 ))
last=${files[$pos]}
json_output="{"
for interface in "${files[@]}"
do
basename=$(basename "$interface")
# find the number of bytes transfered for this interface
in1=$(cat /sys/class/net/"$basename"/statistics/rx_bytes)
# wait a second
sleep 1
# check same interface again
in2=$(cat /sys/class/net/"$basename"/statistics/rx_bytes)
# get the difference (transfer rate)
in_bytes=$((in2 - in1))
# convert transfer rate to KB
in_kbytes=$((in_bytes / 1024))
# convert transfer rate to KB
json_output="$json_output \"$basename\": $in_kbytes"
# if it is not the last line
if [[ ! $interface == $last ]]
then
# add a comma to the line (JSON formatting)
json_output="$json_output,"
fi
done
# close the JSON object & print to screen
echo "$json_output}"
#!/bin/bash
function displaytime {
local T=$1
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
[[ $D > 0 ]] && printf '%d days ' $D
[[ $H > 0 ]] && printf '%d hours ' $H
[[ $M > 0 ]] && printf '%d minutes ' $M
[[ $D > 0 || $H > 0 || $M > 0 ]] && printf 'and '
printf '%d seconds\n' $S
}
lsbRelease=$(/usr/bin/lsb_release -ds | sed -e 's/^"//' -e 's/"$//')
uname=$(/bin/uname -r | sed -e 's/^"//' -e 's/"$//')
os=`echo $lsbRelease $uname`
hostname=$(/bin/hostname)
uptime_seconds=$(/bin/cat /proc/uptime | awk '{print $1}')
server_time=$(date)
echo { \
\"OS\": \"$os\", \
\"Hostname\": \"$hostname\", \
\"Uptime\": \" $(displaytime ${uptime_seconds%.*}) \", \
\"Server Time\": \"$server_time\" \
}
#!/bin/bash
SCRIPTPATH=`dirname $(readlink -f $0)`
SPEED_TEST_SCRIPT=$SCRIPTPATH"/../python_files/speedtest_cli.py"
$SPEED_TEST_SCRIPT \
| grep 'Upload\|Download' \
| awk 'BEGIN {print "{"} {print "\"" $1 "\": \"" $2 " " $3 "\"," } END {print "}"}' \
| /bin/sed 'N;$s/",/"/;P;D'
\ No newline at end of file
#!/bin/bash
result=$(/bin/cat /proc/diskstats | /usr/bin/awk \
'{ if($4==0 && $8==0 && $12==0 && $13==0) next } \
{print "{ \"device\": \"" $3 "\", \"reads\": \""$4"\", \"writes\": \"" $8 "\", \"in_progress\": \"" $12 "\", \"time_in_io\": \"" $13 "\"},"}'
)
echo [ ${result%?} ]
\ No newline at end of file
#!/bin/bash
awkCmd=`which awk`
grepCmd=`which grep`
sedCmd=`which sed`
ifconfigCmd=`which ifconfig`
trCmd=`which tr`
digCmd=`which dig`
externalIp=`$digCmd +short myip.opendns.com @resolver1.opendns.com`
echo -n "["
for item in $($ifconfigCmd | $grepCmd -oP "^[a-zA-Z0-9:]*(?=:)")
do
echo -n "{\"interface\" : \""$item"\", \"ip\" : \"$( $ifconfigCmd $item | $grepCmd "inet" | $awkCmd '{match($0,"inet (addr:)?([0-9.]*)",a)}END{ if (NR != 0){print a[2]; exit}{print "none"}}')\"}, "
done
echo "{ \"interface\": \"external\", \"ip\": \"$externalIp\" } ]"
#!/bin/bash
grepCmd=`which grep`
awkCmd=`which awk`
catCmd=`which cat`
numberOfCores=$($grepCmd -c 'processor' /proc/cpuinfo)
if [ $numberOfCores -eq 0 ]; then
numberOfCores=1
fi
result=$($catCmd /proc/loadavg | $awkCmd '{print "{ \"1_min_avg\": " ($1*100)/'$numberOfCores' ", \"5_min_avg\": " ($2*100)/'