September 24, 2009
admin
0 comments
keywords:
| Python |
Looks like I'll be learning yet another language. It seems to be good at parsing java created XML
I tried to make a mental list of how many languages (programming) I had worked with, but I don't have enough fingers and toes.
|
| |
|
July 11, 2009
Meuon
0 comments
keywords:
| APC 10KVA UPS monitoring via SNMP |
First you have to find the right MIB for your ups. This one is a "Smart-UPS RT 10000 XL" from APC. The real trick is using the right mib file with the -m "./mibfile.mib" command line syntax. The quotes make a lot of difference. The same trick works for snmpwalk and other snmp utilities. I'm running a much fancier version of what I have below in a production setting, but this is a good starting place and has the essentials working.
Sure beats serial cables and Java runtimes for the "official APC method" and you can run this on multiple servers, each with their own decision tree and set of commands. ie: Keep the mission critical stuff up the longest, drop the junk you don't need quickly and make that UPS last longer.
#!/usr/bin/perl #This is as simple of an APC power monitor as I could make. #Should be run as a cron job every 5 minutes or less. replace 192.168.192.4 with the IP of your UPS.
$shutdownthreshhold = 20 ; open(IN,"/usr/bin/snmpget -v1 -c public -m "/home/juice/apc/powernet395.mib" 192.168.192.4 PowerNet-MIB::upsAdvBatteryCapacity.0 |") ; while(<IN>) { @d = split(/ /) ; $capacity = $d[3] * 1 ; } ; open(IN,"/usr/bin/snmpget -v1 -c public -m "/home/juice/apc/powernet395.mib" 192.168.192.4 PowerNet-MIB::upsBasicOutputStatus.0 |") ; while(<IN>) { @d = split(/ /) ; $status = $d[3] ; chop($status) ; } ; open(OUT,">/tmp/powercheck") ; print OUT "Battery Capacity: $capacity percent Battery Status: $status Shutdown at $shutdownthreshhold" ; close(OUT) ;
if($status eq 'onBattery(3)') { if($capacity < $shutdownthreshhold) { print "SHUTDOWN " ; system("/sbin/shutdown -P now") ; #standard Linux shutdown, -P is power off } ;
} ;
|
| |
|
July 10, 2009
admin
0 comments
keywords:
| Back to Perl: simplecsv2xml |
i used to use Perl a lot, but I got rusty. Today I needed to convert a bunch of typical CSV files into "XML" Quick and Dirty, simple flat files.
It's a sad world when a professional $150+/hr developer only knows how to read XML. My guess is they code in Java or Dot.Not. Heck, Maybe MS-Visual Basic.
Mine is not to wonder why... mine is just to do or die. I went looking for what I wanted.. most of the solutions were just too complex, so I started from scratch and ened up with a simple Perl script to convert CSV to XML.. Why perl? Fast and easy parser of STDIN/STDOUT. This is NOT what is used in the final project, but it is something that works and many people (and sometimes me) just need a quick CSV to XML conversion.
Usage: simplecsv2xml.pl <infile >outfile
#!/usr/bin/perl # Mikes Uber Simple CSV to XML Parser use Text::CSV; $csv = Text::CSV->new(); $i = 0 ; print "<?xml version="1.0" encoding="UTF-8"?>
" ; print "<document>
" ; while(<STDIN>) { $status = $csv->parse($_); # parse a CSV string into fields if($i < 1) { @key = $csv->fields() ; # get the parsed fields # assumes the first line is the key/field names } else { @data = $csv->fields(); # get the parsed fields } ; #now make it XML-ish. if($i > 0) { $r = 0 ; print '<row>' ; foreach(@data) { if($key[$r] ne '') { print '<'. $key[$r] . '>' . $_ . '</' . $key[$r] . '>' ; } ; $r++ ; } ; print '</row>' ."
" ; } ; $i++ ; } ; print "</document>
" ;
|
|
| |
|
April 18, 2009
Meuon
1 comment
keywords: UtiliFlex Juice GPL PrePaid Electricity
| Proud Papa Again |

Every once in a while you get to build something you are really proud of. The "UtiliFlex Juice PrePaid/Pay-As-You-Go Electricity/Utility platform" has become such a beast.
I'm standing next to a complete working system, including an awesome firewall, 2 Asterisk based IVR servers, SMS/text Gateways, and an Intel Modular Server. It's about to be shipped to Guyana Power and Light in South America and will help run a significant percentage of the utility. the screen shows only one of the compute modules, with 8 CPU's, 32gb of ram.. etc..
It will allow people in that country to do something they haven't been doing much of: Buy electricity. In their context, prepaid is an enabler. It allows people to purchase electricity as they need it and as they can afford it, without a penalty for getting disconnected because they can't afford the bill that came too late for them to do anything about.
There are some people that deserve some serious credit for helping me get Juice to this level of system:
Joe Gordon. My cohort in UtiliFlex, owner of UtiliSol He's been a pleasure to work with and develop Juice with. His vision, drive, insight, intelligence, tolerence and ethics are without peer.
Lucius Hilley, Programmer. The kind that does hex/ascii/cipher math in his head whle coding in 3 or 6 languages at once while putting up with a lot of schtuff from me.
Isaac Ingram, Programmer. While we aren't using much of his excellent mapserver/event-outage management code in this system, a little of his soul permeates.
Dave Brockman, SysAdmin. Helped me configure and setup the Intel Modular Server in record time, without laughing too much.
Catherine Colby, Tim Galbreth and Rob Shaw, UtiliFlex Sales and Project team. Lots of interface, code and functionality improvements and quality control, as well as a significant part of the documentation.
Oh, and Ben, Judy, Mark and the team at MicroTronics for being a great supplier of high end hardware.
Side note: Isaac did the original GeekLabs logo's back in 1998. I think I've grown to look more like my cartoon self over time.. |
| |
|
September 06, 2008
meuon
0 comments
keywords: PHP Data Visualization
| Low Tech Data Display. |
There is a lot of push towards incredibly powerful web toolkits. Very complex javascript, lots of embedded flash. But that requires powerful client computers, and all that JavaScript/ActionScript has fits crossing domains, for good reasons. So you have to go back to old school. Enter PHP and GDlib creating graphics on the fly at the web server. Geeky kWh Gauge example in PHP will create (given some assumptions) nice looking graphs as an image and will try to resize itself and the data nicely based on parameters given.
It's useful for embedding data displays low tech browsers as well as things like Chumby's, Google Electricity/kWh Gadgets and other widgets where everything but images seem to be cached, relayed, or protected from embedding data from other sources. The best part is the looks you get when showing to "Web 2.0 kids" who can't conceive of doing it without an IDE, JavaScript/ActionScript and possibly a fat embed/object download.. |
| |
|
|
| |