Skip to content

Commit

Permalink
Version 1.0.3
Browse files Browse the repository at this point in the history
Misc UI fixes, tweaks.
Now including snapshot URL with alert hook data.
  • Loading branch information
jhuckaby committed Apr 22, 2019
1 parent c8e8ebd commit 63b3d2a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 23 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,8 @@ When an alert fires (and when it clears), you can configure a "web hook" to be s
"action": "alert_new",
"hostname": "dev001.local",
"group": "main",
"url": "http://localhost:5511/#Server?hostname=dev001.local",
"live_url": "http://localhost:5511/#Server?hostname=dev001.local",
"snapshot_url": "http://localhost:5511/#Snapshot?id=dev001.local/832434",
"alert": {
"date": 1555377004,
"exp": "11.34 >= 9",
Expand Down Expand Up @@ -691,7 +692,8 @@ Here are descriptions of all the properties in the JSON web hook data:
| `action` | This denotes the event, will be `alert_new` when an alert triggers, and `alert_cleared` when an alert clears. |
| `hostname` | The server hostname where the alert event took place. |
| `group` | The Group ID which the server is assigned to (see [Groups](#groups)). |
| `url` | A fully-qualified URL to the server detail page, showing the latest real-time metrics. |
| `live_url` | A fully-qualified URL to the live server view page, showing the latest real-time metrics. |
| `snapshot_url` | A fully-qualified URL to the snapshot page, showing detailed server information recorded at the time of the alert. |
| `alert` | An object containing internal metadata about the alert event. |
| `alert/date` | The exact date/time when the alert triggered, expressed in Epoch seconds. |
| `alert/exp` | The alert expression, with all macros substituted with actual values. |
Expand Down
11 changes: 11 additions & 0 deletions htdocs/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,17 @@ fieldset.overview_group > legend {

/* Snapshot Tab */

.snap_info_column {
max-width: 180px;
}

.snap_info_column > .info_value {
height: 14px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.inline_table_scrollarea {
position: relative;
max-height: 75vh;
Expand Down
30 changes: 15 additions & 15 deletions htdocs/js/pages/Snapshot.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,6 @@ Class.subclass( Page.Base, "Page.Snapshot", {

// column 2
html += '<div class="snap_info_column">';
var nice_cores = 'n/a';
if (metadata.data.cpu && metadata.data.cpu.cores) {
if (metadata.data.cpu.physicalCores && (metadata.data.cpu.physicalCores != metadata.data.cpu.cores)) {
nice_cores = metadata.data.cpu.physicalCores + " physical, " +
metadata.data.cpu.cores + " virtual";
}
else {
nice_cores = metadata.data.cpu.cores;
}
}
html += '<div class="info_label">CPU Cores</div>';
html += '<div class="info_value">' + nice_cores + '</div>';

var nice_cpu_model = 'n/a';
if (metadata.data.cpu && metadata.data.cpu.manufacturer) {
nice_cpu_model = metadata.data.cpu.manufacturer;
Expand All @@ -262,6 +249,19 @@ Class.subclass( Page.Base, "Page.Snapshot", {
html += '<div class="info_label">CPU Clock</div>';
html += '<div class="info_value">' + nice_clock_speed + '</div>';

var nice_cores = 'n/a';
if (metadata.data.cpu && metadata.data.cpu.cores) {
if (metadata.data.cpu.physicalCores && (metadata.data.cpu.physicalCores != metadata.data.cpu.cores)) {
nice_cores = metadata.data.cpu.physicalCores + " physical, " +
metadata.data.cpu.cores + " virtual";
}
else {
nice_cores = metadata.data.cpu.cores;
}
}
html += '<div class="info_label">CPU Cores</div>';
html += '<div class="info_value">' + nice_cores + '</div>';

var nice_load = metadata.data.load.map( function(num) { return short_float_str(num); } ).join(', ');
html += '<div class="info_label">CPU Load Averages</div>';
html += '<div class="info_value">' + nice_load + '</div>';
Expand Down Expand Up @@ -364,8 +364,8 @@ Class.subclass( Page.Base, "Page.Snapshot", {
item.parentPid,
item.user,
short_float(item.pcpu) + '%',
get_text_from_bytes( (item.mem_rss || 0) * 1024 ),
get_text_from_seconds( item.age || 0, false, true ),
'<div style="white-space:nowrap;">' + get_text_from_bytes( (item.mem_rss || 0) * 1024 ) + '</div>',
'<div style="white-space:nowrap;">' + get_text_from_seconds( item.age || 0, false, true ) + '</div>',
'<span style="font-family:monospace; white-space:normal; word-break:break-word;">' + item.command + '</span>'
];
});
Expand Down
7 changes: 4 additions & 3 deletions lib/api/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ module.exports = Class.create({
}

// construct URLs to views of server
args.self_url = this.server.config.get('base_app_url') + '/#Server?hostname=' + args.params.hostname;
args.live_url = args.self_url = this.server.config.get('base_app_url') + '/#Server?hostname=' + args.params.hostname;
args.snapshot_url = this.server.config.get('base_app_url') + '/#Snapshot?id=' + args.params.hostname + '/' + time_code;

// alert or group may override e-mail address
Expand Down Expand Up @@ -744,10 +744,11 @@ module.exports = Class.create({
alert: args.alert,
hostname: args.params.hostname,
group: args.params.group,
url: args.self_url
live_url: args.live_url,
snapshot_url: args.snapshot_url
};
if (args.template == 'alert_new') {
hook_args.text = args.config.client.name + " Alert: " + args.nice_hostname + ": " + args.def.title + ": " + args.alert.message + " - ([View Details](" + args.self_url + "))";
hook_args.text = args.config.client.name + " Alert: " + args.nice_hostname + ": " + args.def.title + ": " + args.alert.message + " - ([View Details](" + args.live_url + "))";
}
else if (args.template == 'alert_cleared') {
hook_args.text = args.config.client.name + " Alert Cleared: " + args.nice_hostname + ": " + args.def.title;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "performa",
"version": "1.0.2",
"version": "1.0.3",
"description": "A multi-server monitoring system with a web based UI.",
"author": "Joseph Huckaby <[email protected]>",
"homepage": "https://github.com/jhuckaby/performa",
Expand Down
2 changes: 1 addition & 1 deletion sample_conf/emails/alert_cleared.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Snapshot Detail View:
[/snapshot_url]

Live Server View:
[/self_url]
[/live_url]

Regards,
The Performa Team
2 changes: 1 addition & 1 deletion sample_conf/emails/alert_new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Snapshot Detail View:
[/snapshot_url]

Live Server View:
[/self_url]
[/live_url]

Alert Notes:
[/nice_notes]
Expand Down

0 comments on commit 63b3d2a

Please sign in to comment.