Created
April 25, 2011 17:02
-
-
Save booyaa/940828 to your computer and use it in GitHub Desktop.
sysinfo2pachube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unix sysinfo 2 pachube eeml | |
# mark sta. ana (booyaa.org) | |
# assumptions: this script is running on a vps guest on openvz | |
# user connected | |
users=`w | head -1 | awk '{print $6}'` | |
# get home volume max storage capacity and current usage | |
homeFree=`df -m | grep '/dev/simfs' | awk '{print $4}'` | |
homeMax=`df -m | grep '/dev/simfs' | awk '{print $2}'` | |
# get number of hits made against feedburner feed | |
feedHits=`curl -s https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=booyaa | grep 'hits=' | sed -e 's/.* hits="\(.*\)" .* reach=.*$/\1/'` | |
# average load time | |
loadAvg=`uptime | cut -d, -f6` | |
# count http, mail and misc processes as well as memory usage | |
httpProcs=`ps aux | grep http | wc -l` | |
httpMem=`ps aux | grep http | awk ' { s += $5; } END { print s}'` | |
mailProcs=`ps aux | grep -E '(smtp|anvil|amavisd|imap|dovecot|spamd|qmgr|postfix)' | wc -l` | |
mailMem=`ps aux | grep -E '(smtp|anvil|amavisd|imap|dovecot|spamd|qmgr|postfix)' | awk ' { s += $5; } END { print s}'` | |
miscProcs=`ps aux | grep -vE '(httpd|smtp|anvil|amavisd|imap|dovecot|spamd|qmgr|postfix)' | wc -l` | |
miscMem=`ps aux | grep -vE '(httpd|smtp|anvil|amavisd|imap|dovecot|spamd|qmgr|postfix)' | awk ' { s += $5; } END { print s}'` | |
# memory available | |
memFree=`free -m | grep Mem | awk '{print $4}'` | |
cat<<EEML | |
<?xml version="1.0" encoding="UTF-8"?> | |
<eeml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.eeml.org/xsd/005" version="5" xsi:schemaLocation="http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd"> | |
<environment> | |
<title>booyaa dot sysinfo</title> | |
<description>system info about booyaa dot org</description> | |
<website>http://booyaa.org/projects/pachube/</website> | |
<data id="0"> | |
<tag>users</tag> | |
<tag>logins</tag> | |
<value minValue="0" maxValue="15">$users</value> | |
<unit type="contextDependentUnits">loginsPerQuarterHour</unit> | |
</data> | |
<data id="1"> | |
<tag>storage</tag> | |
<tag>diskSpace</tag> | |
<value minValue="0" maxValue="$homeMax">$homeFree</value> | |
<unit symbol="MB">Megabyte</unit> | |
</data> | |
<data id="2"> | |
<tag>feed</tag> | |
<tag>hits</tag> | |
<tag>rss</tag> | |
<value>$feedHits</value> | |
<unit type="contextDependentUnits">hitsPerQuarterHour</unit> | |
</data> | |
<data id="3"> | |
<tag>load</tag> | |
<tag>average</tag> | |
<value minValue="0" maxValue="10">$loadAvg</value> | |
<unit type="contextDependentUnits">systemLoadPerQuarterHour</unit> | |
</data> | |
<data id="4"> | |
<tag>http</tag> | |
<tag>processes</tag> | |
<value minValue="0">$httpProcs</value> | |
<unit type="contextDependentUnits">systemLoadPerQuarterHour</unit> | |
</data> | |
<data id="5"> | |
<tag>http</tag> | |
<tag>memory</tag> | |
<value minValue="0">$httpMem</value> | |
<unit symbol="KB">Kilobyte</unit> | |
</data> | |
<data id="6"> | |
<tag>mail</tag> | |
<tag>processes</tag> | |
<value minValue="0">$mailProcs</value> | |
<unit type="contextDependentUnits">systemLoadPerQuarterHour</unit> | |
</data> | |
<data id="7"> | |
<tag>mail</tag> | |
<tag>memory</tag> | |
<value minValue="0">$mailMem</value> | |
<unit symbol="KB">Kilobyte</unit> | |
</data> | |
<data id="8"> | |
<tag>misc</tag> | |
<tag>processes</tag> | |
<value minValue="0">$miscProcs</value> | |
<unit type="contextDependentUnits">systemLoadPerQuarterHour</unit> | |
</data> | |
<data id="9"> | |
<tag>misc</tag> | |
<tag>memory</tag> | |
<value minValue="0">$miscMem</value> | |
<unit symbol="KB">Kilobyte</unit> | |
</data> | |
<data id="10"> | |
<tag>memory</tag> | |
<value minValue="0">$memFree</value> | |
<unit symbol="MB">Megabyte</unit> | |
</data> | |
</environment> | |
</eeml> | |
EEML | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment