메인 콘텐츠로 건너뛰기
블로그 Linode (주) HTTP 검색 가능한 Linode 통계(XML)

HTTP 검색 가능한 리노드 통계(XML)

satyap의 요청에 의해, 나는 [url=https://www.linode.com/포럼/뷰토픽.php?t=776]bw-xml 스크립트 [/url]을 확장하여 더 많은 데이터를 포함했습니다.

【코드】https://www.linode.com/members/bw/?user=【리노드사용자네임】
https://www.linode.com/members/info/?user=[리노드사용자네임][/코드]
이것은 XML이므로 이전 /bw / URL은 동일한 데이터를 반환합니다.

http 요청은 [linodeUsername]의 IP 중 하나에서 가져와야 합니다. 이것 이외에는 액세스 제어가 없습니다. 이것이 문제라면 알려주세요.

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>[/code]

즐길!
-Chris

댓글 (7)

  1. Author Photo

    ^bump^ only because this was mentioned on linode IRC and I had *no* clue it existed.

  2. Author Photo

    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:

    https://www.linode.com/forums/viewtopic.php?t=776

    -jbl

  3. Author Photo

    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.

  4. Author Photo

    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>
    [/code]

    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.

  5. Author Photo

    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

  6. Author Photo

    [quote:83000eaf58=”rick111″]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[/quote]

    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
    [/code]

  7. Author Photo

댓글 남기기

이메일 주소는 게시되지 않습니다. 필수 필드가 표시됩니다 *