How to get Load AVG for remote server on loop

Baby Tux

This handy script will allow you to get the current Load Average (loadavg) for a remote server over SSH. It will stream the result set back to you, which you can then pipe into a file if you need to.

This would be handy for monitoring the load of a server while stress testing, for example.

ssh example.com 'while true; do L=$(awk '\''{ print $1 }'\''  /proc/loadavg); D=$(date +%H:%M:%S); echo -e "$D\t$L"; sleep 1; done'

One point of note is the escaping single quote technique. This is based on the suggestion on Muffin Research on how to escape single quotes within single quotes.

As the result is tab-separated, it would be very easy to get the data into a spreadsheet and generate a graph of it.

Comment Icon

0 Comments

There are no comments yet. Why not be the first?

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <img> <p>
  • You can use BBCode tags in the text. URLs will automatically be converted to links.
  • You can enable syntax highlighting of source code with the following tags: <code>, <pre>, <bash>, <css>, <html>, <js>, <jquery>, <mysql>, <php>. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.