Does anyone know how to create a bash or perl script that will capture and send server stats to another server via wget or something. Server stats like free cpu % idle, 1,5,15 min load average, memory free, memory free + memory buffers, swap used, swap used %, network traffic in + out, total swap used, hard disk use %.
Then send it to something like IP/something.php?mem=1234&cpu=5678 etc. Ive been searching the net trying to find anything that could start be out with this but no luck. If anyone could help me that would be great. Thanks
Thats basically what I want yah. I plan to have multiple servers which will all call home and give stats. However I need the stats in raw number form as well because I want them to load balance via DNS round robin to change as server load levels get too high in some places. Not sure if this can do that.
I'll give you an idea to run with, which would include having the stats in raw number form, and let you figure out how to do the rrdns (I'm not very well versed in that):
create your rrd dbs here, such as loadavg.rrd, mem.rrd, etc
server to obtain stats from
code a script that obtains local values (mem usage, load averages, etc) and
places them inside a directory accessible from the main server (such as via wget, or using IO::Socket with perl)
back on the main server
write a script that obtains the values from the server collecting the stats, updates the rrd dbs, then generates the graphs.
You could also somehow use the stats (collected on the main server from the others) to do the rrdns.
rrdtool isn't complex, but it will take a bit of reading to learn how it works (creating the dbs, updating the dbs, then graphing the dbs). Once you get past that, it's really great to work with.
Basically you'll want to learn the following functions from rrdtool:
You know, actually, if you don't even need the graphs, this would be much simpler. Just write something that obtains the values from the local server (say, perl reading from /proc/loadavg and writing the output to a file), places them into a web accessible directory, and have another server wget that file, and perform the rrdns functions based on that. Are you more looking for scripts that obtain the values? If so, you can find some in HotSaNIC, or Cacti to base your scripts on.