Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Load averages of *nix server running dashing.

Setup

Put the loadavg1min.rb to jobs/loadavg1min.rb.

Add the code from loadavg1min.erb to the desired dashboard.

Preview

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="loadavg1min" data-view="Graph" data-title="Server load" style="background-color:#47bbb3;" data-moreinfo="1 min intervals" ></div>
</li>
# Populate the graph with 0.00 results
points = []
(1..10).each do |i|
points << { x: i, y: 0 }
end
last_x = points.last[:x]
SCHEDULER.every '1m' do
points.shift
last_x += 1
uptime = %x('uptime')
points << { x: last_x, y: uptime[-17..-14].to_f }
send_event('loadavg1min', points: points)
end
@foreverforced

This comment has been minimized.

Copy link

commented Mar 22, 2013

Like this widget, but found that it causes defunct processes to be spawned every minute when it runs. Not sure why. Running this on: FreeBSD 9.1 in a jail that is created just for Dashing.

@gregology

This comment has been minimized.

Copy link
Owner Author

commented Apr 16, 2013

Ok, I'm no longer using IO.popen to prevent the zombies

@aislanluiz

This comment has been minimized.

Copy link

commented Mar 9, 2015

Someone knows how to get info of another machines?

@elfinith

This comment has been minimized.

Copy link

commented Mar 30, 2015

Maybe try to get load info by running script like this (on remote machine, using cron):

X=$(uptime | cut -c46-49)
LOAD='{ "auth_token": "YOUR_AUTH_TOKEN", "value" : '$X' }'
curl -d "${LOAD}" \http://dashing_url:3030/widgets/widget_name

@lucymhdavies

This comment has been minimized.

Copy link

commented Aug 13, 2016

I used the following to get this to work on both OS X and Linux:

  uptime = %x('uptime').gsub(/.*: /, '\1').gsub(/,/, '\1')
  points << { x: last_x, y: uptime[0..3].to_f }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.