| Author |
Message |
caker
Joined: 15 Apr 2003
Posts: 2404
Location: Galloway, NJ
|
| Posted: Wed Mar 16, 2005 1:05 pm Post subject: HTTP-Retrievable Linode Stats (in XML) |
|
|
By request of satyap, I've extended the bw-xml script to include more data.
Code: http://www.linode.com/members/bw/?user=[linodeUsername]
http://www.linode.com/members/info/?user=[linodeUsername]
Since this is XML, the old /bw/ URL returns the identical data.
The http request must come from one of the IPs of [linodeUsername]. There is no access control other than this. If that's an issue, let me know.
Example Output:
Code: <?xml version="1.0" encoding="ISO-8859-1" ?>
<linData>
<host>
<host>host41.linode.com</host>
<hostLoad>low</hostLoad>
<pendingJobs>0</pendingJobs>
</host>
<upSince>2005-03-16 11:49:34</upSince>
<cpuConsumption>0.01</cpuConsumption>
<bwdata>
<year>2005</year>
<month>3</month>
<max_avail>39728447488</max_avail>
<rx_bytes>4692233</rx_bytes>
<tx_bytes>2963967</tx_bytes>
<total_bytes>7656200</total_bytes>
</bwdata>
</linData>
Enjoy!
-Chris |
|
| Back to top |
|
warewolf
Joined: 30 Apr 2005
Posts: 20
|
| Posted: Tue Jan 23, 2007 2:24 pm Post subject: |
|
|
| ^bump^ only because this was mentioned on linode IRC and I had *no* clue it existed. |
|
| Back to top |
|
efudd
Joined: 27 Oct 2003
Posts: 17
|
| Posted: Tue Jan 23, 2007 11:46 pm Post subject: |
|
|
Then I guess I'll remind folk about this:
http://forever.broked.net/~jason/bw.pl.txt
It's what I had in mind when I (others?) asked caker for bandwidth utilization figures via XML. I just did a quick update to fix a couple of bugs, change requested URL to /info from /bw and parse/print out parent host/load figures.
Original post on this is located at:
http://www.linode.com/forums/viewtopic.php?t=776
-jbl |
|
| Back to top |
|
smiffy
Joined: 23 Jan 2007
Posts: 66
Location: 80 miles from Adelaide, Australia
|
| Posted: Wed Jan 24, 2007 1:08 am Post subject: |
|
|
How about an alternative, losing the user=, running it through https, with basic authentication, and picking the user name up from there.
The idea being that I can pick it up from my local machines rather than having to have the extra hop of going through my Linode. |
|
| Back to top |
|
smiffy
Joined: 23 Jan 2007
Posts: 66
Location: 80 miles from Adelaide, Australia
|
| Posted: Tue Jan 30, 2007 8:09 pm Post subject: |
|
|
Just looking at the output - should host be nested in host?
Also, thinking to the future when we can have more than one Linode per account, maybe it should be something like:
Code:
<linData>
<linode id='my-linode-id'>
<host>
<hostname>host65536.linode.com</hostname>
<hostLoad>meltdown</hostLoad>
<pendingJobs>0</pendingJobs>
</host>
...blah...
...blah...
...blah...
</linode>
<linode id='my-other-linode'>
....
</linode>
</linData>
Having the <linode/> element here and now would help with amalgamating data from several hosts.
I am going to get the data from each host, then fire them back to my office server, which will aggregate, store and alert me about anything nasty that might be going on. |
|
| Back to top |
|
rick111
Joined: 28 Nov 2007
Posts: 5
|
| Posted: Mon Dec 24, 2007 10:07 am Post subject: |
|
|
what do you guys use this for? I've got it ouputting the data to stats.php but not really finding it useful?
Cheers lads
have a good one |
|
| Back to top |
|
sweh
Joined: 13 Apr 2004
Posts: 245
|
| Posted: Mon Dec 24, 2007 11:12 am Post subject: |
|
|
rick111 wrote: what do you guys use this for? I've got it ouputting the data to stats.php but not really finding it useful?
Cheers lads
have a good one
All I really care about is network usage; don't want to go over! So for me the following in cron.daily is sufficient
Code: #!/bin/bash
# Your linode user name
USER=xxxx
# Where to report mail
EMAIL=yyyy
URL="http://www.linode.com/members/bw/?user=$USER"
data=$(lynx --dump $URL)
year=${data#*\<year\>} ; year=${year%%\<*}
month=${data#*\<month\>} ; month=${month%%\<*}
max=${data#*\<max_avail\>} ; max=${max%%\<*}
tx=${data#*\<tx_bytes\>}; tx=${tx%%\<*}
rx=${data#*\<rx_bytes\>}; rx=${rx%%\<*}
total=${data#*\<total_bytes\>}; total=${total%%\<*}
let pct=100*total/max
let tx=tx/1048576
let rx=rx/1048576
let total=total/1048576
let max=max/1048576
{
echo Report for $year/$month
echo Transmitted: $tx Mbytes
echo Received: $rx Mbytes
echo Total: $total Mbytes
echo
echo Allowance: $max Mbytes
echo Used: ${pct}%
} | /bin/mail -s "Linode bandwidth report" $EMAIL
|
|
| Back to top |
|
rick111
Joined: 28 Nov 2007
Posts: 5
|
| Posted: Tue Dec 25, 2007 7:14 am Post subject: |
|
|
| thanks man |
|
| Back to top |
|
Smark
Joined: 11 Apr 2007
Posts: 24
|
| Posted: Sat Dec 06, 2008 1:56 pm Post subject: |
|
|
Hey guys,
I had played with this script at points in the past (6+ months ago) and used the URL format:
Code: http://www.linode.com/members/bw/?user=[linodeUsername]
http://www.linode.com/members/info/?user=[linodeUsername]
I recently decided to try playing with the XML script (mostly to make a gadget for my iGoogle Homepage) and found that I kept get access denied errors when trying to view it from a Linode IP.
After some poking around and with some help in the IRC channel, we figured out that you now need to use your Linode ID. This can be found on the Console tab of the Dashboard for the Linode you need information for. It will be in the format of:
Code: ssh linode#####@locationXXX.linode.com
Your Linode ID is the "linode#####" part. For instance say you are on linode12345, you would put the following as your bandwidth URL:
Code: http://www.linode.com/members/bw/?user=linode12345
http://www.linode.com/members/info/?user=linode12345
I suspect this was changed when Linode announced support for multiple Linodes on one account.
Thanks,
Smark |
|
| Back to top |
|
| |