Altered version of the sys-mon-set widgets with more padding
- Link to original version: http://tracesof.net/uebersicht-widgets/#sys-mon-set
This commit is contained in:
5
README.md
Normal file
5
README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Credits
|
||||
|
||||
Authors of the various widgets include:
|
||||
|
||||
George Irwin, mfam, Aliceljm, Johan Bleuzen, Spencer Oberstadt, Felix Hageloh
|
||||
27
battery.widget/index.coffee
Normal file
27
battery.widget/index.coffee
Normal file
@@ -0,0 +1,27 @@
|
||||
command: "pmset -g batt | grep -o '[0-9]*%'"
|
||||
|
||||
refreshFrequency: 60000
|
||||
|
||||
style: """
|
||||
bottom: 135px
|
||||
left: 10px
|
||||
color: #ccc
|
||||
font-family: Helvetica Neue
|
||||
|
||||
div
|
||||
display: block
|
||||
text-shadow: 0 0 1px rgba(#000, 0.5)
|
||||
font-size: 24px
|
||||
font-weight: 100
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
render: -> """
|
||||
<div class='battery'></div>
|
||||
"""
|
||||
|
||||
update: (output, domEl) ->
|
||||
$(domEl).find('.battery').html(output)
|
||||
|
||||
47
mini-top-mem.widget/index.coffee
Normal file
47
mini-top-mem.widget/index.coffee
Normal file
@@ -0,0 +1,47 @@
|
||||
command: "ps axo \"rss,pid,ucomm\" | sort -nr | head -n3 | awk '{printf \"%8.0f,%s,%s\\n\", $1/1024, $3, $2}'"
|
||||
|
||||
refreshFrequency: 5000
|
||||
|
||||
style: """
|
||||
bottom: 10px
|
||||
left: 590px
|
||||
color: #ccc
|
||||
font-family: Helvetica Neue
|
||||
|
||||
table
|
||||
border-collapse: collapse
|
||||
table-layout: fixed
|
||||
margin-bottom: 4px
|
||||
|
||||
td
|
||||
font-size: 10px
|
||||
font-weight: normal
|
||||
width: 80px
|
||||
max-width: 80px
|
||||
overflow: ellipsis
|
||||
text-shadow: 0 0 1px rgba(#000, 0.5)
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
render: ->
|
||||
"""
|
||||
<table>
|
||||
<tr id="row-1"></tr>
|
||||
<tr id="row-2"></tr>
|
||||
<tr id="row-3"></tr>
|
||||
</table>
|
||||
"""
|
||||
|
||||
update: (output, domEl) ->
|
||||
processes = output.split('\n')
|
||||
table = $(domEl).find('table')
|
||||
|
||||
renderProcess = (mem, name) ->
|
||||
"<td>#{name}</td><td>#{mem} MB</td>"
|
||||
|
||||
for process, i in processes
|
||||
args = process.split(',')
|
||||
table.find("#row-#{i+1}").html renderProcess(args...)
|
||||
|
||||
54
netstat.widget/index.coffee
Normal file
54
netstat.widget/index.coffee
Normal file
@@ -0,0 +1,54 @@
|
||||
command: "sys-mon-set.widget/netstat.widget/scripts/netst"
|
||||
|
||||
refreshFrequency: 1000
|
||||
|
||||
style: """
|
||||
bottom: 180px
|
||||
left: 15px
|
||||
color: #ccc
|
||||
font-family: Helvetica Neue
|
||||
|
||||
div
|
||||
display: block
|
||||
text-shadow: 0 0 1px rgba(#000, 0.5)
|
||||
font-size: 16px
|
||||
font-weight: 100
|
||||
|
||||
p
|
||||
margin: 5px 0 0 0
|
||||
|
||||
p > span
|
||||
font-weight: normal
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
render: -> """
|
||||
<div class='netstat'>
|
||||
<p>In: <span id="in"></span></p>
|
||||
<p>Out: <span id="out"></span></p>
|
||||
</div>
|
||||
"""
|
||||
|
||||
|
||||
update: (output, domEl) ->
|
||||
bytesToSize = (bytes) ->
|
||||
return "0 Byte" if parseInt(bytes) is 0
|
||||
k = 1024
|
||||
sizes = [
|
||||
"b/s"
|
||||
"kb/s"
|
||||
"mb/s"
|
||||
"gb/s"
|
||||
"gb/s"
|
||||
"pb/s"
|
||||
"eb/s"
|
||||
"zb/s"
|
||||
"yb/s"
|
||||
]
|
||||
i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
(bytes / Math.pow(k, i)).toPrecision(3) + " " + sizes[i]
|
||||
values = output.split(' ')
|
||||
$(domEl).find('#in').text(bytesToSize(values[0]))
|
||||
$(domEl).find('#out').text(bytesToSize(values[1]))
|
||||
BIN
netstat.widget/scripts/netst
Executable file
BIN
netstat.widget/scripts/netst
Executable file
Binary file not shown.
166
netstat.widget/scripts/netst.c
Normal file
166
netstat.widget/scripts/netst.c
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Print interface statistics in bytes per second
|
||||
*
|
||||
* Parameters:
|
||||
* -t # Time interval to compute, default 2 seconds
|
||||
* -i <ifname> Interface name, defaults to 'en0'
|
||||
* -s Print raw stats
|
||||
*
|
||||
* Output: Two numbers separated by a space. First value is input bytes per
|
||||
* second. Second value is output bytes per second
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_mib.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_var.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static u_int64_t opackets = 0;
|
||||
static u_int64_t ipackets = 0;
|
||||
static u_int64_t obytes = 0;
|
||||
static u_int64_t ibytes = 0;
|
||||
static int raw_stats = 0;
|
||||
|
||||
int
|
||||
get_stats(char *interface)
|
||||
{
|
||||
int ret = 0;
|
||||
char name [32];
|
||||
int mib [6];
|
||||
char *buf = NULL, *lim, *next;
|
||||
size_t len;
|
||||
struct if_msghdr *ifm;
|
||||
unsigned int ifindex = 0;
|
||||
|
||||
if (interface != 0)
|
||||
ifindex = if_nametoindex(interface);
|
||||
|
||||
mib[0] = CTL_NET;
|
||||
mib[1] = PF_ROUTE;
|
||||
mib[2] = 0;
|
||||
mib[3] = 0;
|
||||
mib[4] = NET_RT_IFLIST2;
|
||||
mib[5] = 0;
|
||||
|
||||
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0)
|
||||
return ret;
|
||||
if ((buf = malloc(len)) == NULL) {
|
||||
printf("malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
|
||||
if (buf)
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
lim = buf + len;
|
||||
for (next = buf; next < lim;) {
|
||||
ifm = (struct if_msghdr *)next;
|
||||
next += ifm->ifm_msglen;
|
||||
|
||||
if (ifm->ifm_type == RTM_IFINFO2) {
|
||||
struct if_msghdr2 *if2m = (struct if_msghdr2 *)ifm;
|
||||
struct sockaddr_dl *sdl = (struct sockaddr_dl *)(if2m + 1);
|
||||
|
||||
strncpy(name, sdl->sdl_data, sdl->sdl_nlen);
|
||||
name[sdl->sdl_nlen] = 0;
|
||||
if (interface != 0 && if2m->ifm_index != ifindex)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Get the interface stats. These may get overriden
|
||||
* below on a per-interface basis.
|
||||
*/
|
||||
opackets = if2m->ifm_data.ifi_opackets;
|
||||
ipackets = if2m->ifm_data.ifi_ipackets;
|
||||
obytes = if2m->ifm_data.ifi_obytes;
|
||||
ibytes = if2m->ifm_data.ifi_ibytes;
|
||||
if (ret == 0) {
|
||||
ret = 1;
|
||||
if (raw_stats) {
|
||||
printf("%5s %10s %14s ",
|
||||
"Name", "Ipkts", "IBytes");
|
||||
printf("%10s %14s\n", "Opkts", "Obytes");
|
||||
}
|
||||
}
|
||||
if (raw_stats) {
|
||||
printf("%-5s %10llu ", name, ipackets);
|
||||
printf("%14llu ", ibytes);
|
||||
printf("%10llu ", opackets);
|
||||
printf("%14llu\n", obytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
printf("arguments:\n\t-t #\t\tTime interval to compute, default 2 seconds\n");
|
||||
printf("\t-i <ifname>\tInterface name, defaults to 'en0'\n");
|
||||
printf("\t-s\t\tPrint raw stats\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *ifname = "en0";
|
||||
int r;
|
||||
int sleeptime = 2;
|
||||
|
||||
int bflag , ch, fd;
|
||||
|
||||
bflag = 0;
|
||||
while ((ch = getopt(argc, argv, "st:i:")) != -1) {
|
||||
switch (ch) {
|
||||
case 't':
|
||||
sleeptime = atoi(optarg);
|
||||
if (sleeptime < 1) {
|
||||
sleeptime = 1;
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
case 's':
|
||||
raw_stats = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
r = get_stats(ifname);
|
||||
if (r) {
|
||||
u_int64_t ib = ibytes;
|
||||
u_int64_t ob = obytes;
|
||||
u_int64_t diffo, diffi;
|
||||
|
||||
sleep(sleeptime);
|
||||
get_stats(ifname);
|
||||
diffo = (obytes - ob) / (u_int64_t) sleeptime;
|
||||
diffi = (ibytes - ib) / (u_int64_t) sleeptime;
|
||||
printf("%llu %llu\n", diffi, diffo);
|
||||
} else {
|
||||
printf("No interface %s\n", ifname);
|
||||
}
|
||||
}
|
||||
26
public_ip.widget/index.coffee
Normal file
26
public_ip.widget/index.coffee
Normal file
@@ -0,0 +1,26 @@
|
||||
command: "curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'"
|
||||
|
||||
refreshFrequency: 43200000
|
||||
|
||||
style: """
|
||||
bottom: 135px
|
||||
left: 90px
|
||||
color: #ccc
|
||||
font-family: Helvetica Neue
|
||||
|
||||
div
|
||||
display: block
|
||||
text-shadow: 0 0 1px rgba(#000, 0.5)
|
||||
font-size: 24px
|
||||
font-weight: 100
|
||||
|
||||
"""
|
||||
|
||||
|
||||
render: -> """
|
||||
<div class='ip_address'></div>
|
||||
"""
|
||||
|
||||
update: (output, domEl) ->
|
||||
$(domEl).find('.ip_address').html(output)
|
||||
|
||||
23
simple-clock.widget/index.coffee
Normal file
23
simple-clock.widget/index.coffee
Normal file
@@ -0,0 +1,23 @@
|
||||
format = '%d %a %H:%M'
|
||||
|
||||
command: "date +\"#{format}\""
|
||||
|
||||
# the refresh frequency in milliseconds
|
||||
refreshFrequency: 30000
|
||||
|
||||
render: (output) -> """
|
||||
<h1>#{output}</h1>
|
||||
"""
|
||||
|
||||
style: """
|
||||
color: #eee
|
||||
font-family: Helvetica Neue
|
||||
left: 10px
|
||||
bottom: 50px
|
||||
|
||||
h1
|
||||
font-size: 5em
|
||||
font-weight: 100
|
||||
margin: 0
|
||||
padding: 0
|
||||
"""
|
||||
69
top-cpu.widget/index.coffee
Normal file
69
top-cpu.widget/index.coffee
Normal file
@@ -0,0 +1,69 @@
|
||||
command: "ps axro \"pid, %cpu, ucomm\" | awk 'FNR>1' | head -n 3 | awk '{ printf \"%5.1f%%,%s,%s\\n\", $2, $3, $1}'"
|
||||
|
||||
refreshFrequency: 2000
|
||||
|
||||
style: """
|
||||
bottom: 10px
|
||||
left: 10px
|
||||
color: #ccc
|
||||
font-family: Helvetica Neue
|
||||
|
||||
table
|
||||
border-collapse: collapse
|
||||
table-layout: fixed
|
||||
|
||||
td
|
||||
font-size: 24px
|
||||
font-weight: 100
|
||||
width: 100px
|
||||
max-width: 100px
|
||||
overflow: ellipsis
|
||||
text-shadow: 0 0 1px rgba(#000, 0.5)
|
||||
|
||||
.wrapper
|
||||
padding: 4px 6px 4px 6px
|
||||
position: relative
|
||||
|
||||
p
|
||||
padding: 0
|
||||
margin: 0
|
||||
font-size: 11px
|
||||
font-weight: normal
|
||||
max-width: 100%
|
||||
color: #ddd
|
||||
text-overflow: ellipsis
|
||||
text-shadow: none
|
||||
|
||||
.pid
|
||||
position: absolute
|
||||
top: 2px
|
||||
right: 2px
|
||||
font-size: 10px
|
||||
font-weight: normal
|
||||
|
||||
"""
|
||||
|
||||
|
||||
render: -> """
|
||||
<table>
|
||||
<tr>
|
||||
<td class='col1'></td>
|
||||
<td class='col2'></td>
|
||||
<td class='col3'></td>
|
||||
</tr>
|
||||
</table>
|
||||
"""
|
||||
|
||||
update: (output, domEl) ->
|
||||
processes = output.split('\n')
|
||||
table = $(domEl).find('table')
|
||||
|
||||
renderProcess = (cpu, name, id) ->
|
||||
"<div class='wrapper'>" +
|
||||
"#{cpu}<p>#{name}</p>" +
|
||||
"</div>"
|
||||
|
||||
for process, i in processes
|
||||
args = process.split(',')
|
||||
table.find(".col#{i+1}").html renderProcess(args...)
|
||||
|
||||
74
total-mem.widget/index.coffee
Normal file
74
total-mem.widget/index.coffee
Normal file
@@ -0,0 +1,74 @@
|
||||
# vm_stat returns pages (4096 bytes on mac). 256 pages per MB.
|
||||
# To convert pages to GB: no. of pages / 256 / 1024
|
||||
|
||||
command: "vm_stat | awk 'NR==2 {print \"Free,\"($3 / 256) / 1024} NR==3 {print \"Active,\"($3 / 256) / 1024} NR==4 {print \"Inactive,\"($3 / 256) / 1024} NR==7 {print \"Wired,\"($4 / 256) / 1024}'"
|
||||
|
||||
refreshFrequency: 1000
|
||||
|
||||
style: """
|
||||
bottom: 10px
|
||||
left: 310px
|
||||
color: #bbb
|
||||
font-family: Helvetica Neue
|
||||
|
||||
table
|
||||
border-collapse: collapse
|
||||
table-layout: fixed
|
||||
|
||||
td
|
||||
font-size: 24px
|
||||
font-weight: 100
|
||||
width: 70px
|
||||
max-width: 70px
|
||||
overflow: hidden
|
||||
text-shadow: 0 0 1px rgba(#000, 0.5)
|
||||
|
||||
.wrapper
|
||||
padding: 4px 6px 4px 6px
|
||||
position: relative
|
||||
|
||||
|
||||
p
|
||||
padding: 0
|
||||
margin: 0
|
||||
font-size: 11px
|
||||
font-weight: normal
|
||||
max-width: 100%
|
||||
color: #ddd
|
||||
text-overflow: ellipsis
|
||||
|
||||
.pid
|
||||
position: absolute
|
||||
top: 2px
|
||||
right: 2px
|
||||
font-size: 10px
|
||||
font-weight: normal
|
||||
|
||||
"""
|
||||
|
||||
|
||||
render: ->
|
||||
"""
|
||||
<table>
|
||||
<tr>
|
||||
<td class='col1'></td>
|
||||
<td class='col2'></td>
|
||||
<td class='col3'></td>
|
||||
<td class='col4'></td>
|
||||
</tr>
|
||||
</table>
|
||||
"""
|
||||
|
||||
update: (output, domEl) ->
|
||||
processes = output.split('\n')
|
||||
table = $(domEl).find('table')
|
||||
|
||||
renderProcess = (type, mem) ->
|
||||
"<div class='wrapper'>" +
|
||||
"#{Math.round(mem * 100) / 100}<p>#{type}</p>" +
|
||||
"</div>"
|
||||
|
||||
for process, i in processes
|
||||
args = process.split(',')
|
||||
table.find(".col#{i+1}").html renderProcess(args...)
|
||||
|
||||
Reference in New Issue
Block a user