Arduino Tutorials
Here’s a great site with PLENTY of Arduino examples and tutorials: Arduino Tutorials « t r o n i x s t u f f.
Vim: How To Fold Functions
The is really a tip on how to fold any code block including functions. Navigate your cursor somewhere inside of the code block you want to fold, make sure you are in command/normal mode (press escape if you need to) then type zfa}
To save your folds between vim sessions you need to issue the command :mkview otherwise when you close vim your folds will be lost (your folds, not your code). To make life easier on you, you can have your folds automatically saved for you by adding this to your .vimrc file
au BufWinLeave * mkview
au BufWinEnter * silent loadview
Source: Refreshingly Blue » Blog Archive » Vim: How To Fold Functions.
Finding Zero Graph Hosts in Cacti
Sometimes when we do all this nice trimming of graphs/etc we trim a host down to having NO graphs at all. these need to be looked at (either remove the host or add some interfaces to be graphed).
Here’s some SQL that will give a list of hosts that don’t have any graphs:
Console Size
Sometimes you just need to work in console … no fancy graphics/etc. Here’s where VGA modes for PC computers comes in. AKA screen resolution
Grab Excel WorkSheet Names Into 1 Sheet
Here’s a nice macro that will combine all your worksheet names into a new sheet.
Some more good excel tips here too plus a cool util called RDBMerge!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | Sub ListSheetNames() Dim NumSheets NumSheets = Sheets.Count Application.DisplayAlerts = False Dim i For i = 1 To NumSheets + 1 If ActiveSheet.Name = "SheetNames" Then Sheets("SheetNames").Select ActiveWindow.SelectedSheets.Delete Exit Sub End If Next i Application.DisplayAlerts = True Sheets.Add ActiveSheet.Name = "SheetNames" Sheets("SheetNames").Move after:=Sheets(NumSheets + 1) 'MsgBox (NumSheets) For i = 1 To NumSheets Range("A" & i) = Sheets(i).Name Next i End Sub |
Project HiJack
Hijacking power and bandwidth from the mobile phone’s audio interface.
Creating a cubic-inch peripheral sensor ecosystem for the mobile phone.
Removing Stale RRD Files
I’ve found that when dealing with rrdfiles, they can show the wrong lastmodified time. This means if I go with the usual: delete all files that haven’t been modified within say 2 days, I could be deleting some GOOD rrd files…
Here’s my solution. Use rrdtool lastupdated to spit out epoch time of last updated and anything that’s older than 2 days we’ll delete:
1 2 3 4 5 6 7 8 9 10 11 12 | for myfile in *.rrd do #rrdtool lastupdate $myfile | tail -1 | awk -F: '{if ($1 < systime()-172800) print strftime("%c",$1)}'; RETURN=`rrdtool lastupdate $myfile | tail -1 | awk -F: '{if ($1 < systime()-172800) print 0}'` if [ "$RETURN" == 0 ]; then echo "Deleting $myfile" # uncomment to really remove file #/bin/rm -f $myfile else echo "Skipping File $myfile" fi done |
Installing Your Own Perl Modules
Sometimes you need to install Perl Modules in your OWN (non root) directory. Found a great writeup on how to do this:
% perl5 Makefile.PL PREFIX=/usr/home/USERNAME/usr/local
% make
% make test
% make install
% make clean
And then in your perl code you would use this near the top:
use lib qw(/usr/home/USERNAME/usr/local/lib/perl5);
There’s another writeup on using CPAN that didn’t work as well for me:
$ mkdir ~/.cpan
$ mkdir ~/.cpan/CPAN
$ cd ~/.cpan/CPAN
$ cp /usr/lib/perl5/5.8.4/CPAN/Config.pm MyConfig.pm
$ perl -pi -e's!/root/\.cpan!$ENV{HOME}/.cpan!' MyConfig.pm
$ perl -pi -e'/makepl_arg/ && s!\]! PREFIX=$ENV{HOME}]!' MyConfig.pm
$ echo "export PERL5LIB=${HOME}/lib/perl5/site_perl/5.8.4/i686-linux:${HOME}/lib/perl5/site_perl/5.8.4" >> ~/.bash_profile
$ . ~/.bash_profile
$ perl -MCPAN -e shell
cpan> install HTML::Template
Wget NASA Photos
Here’s a great wget trick to download all the Photos of the Day from NASA. There’s some great switches in there I never new existed.
wget -r -l2 -t1 -nd -N -np -w2 -A.jpg -erobots=off http://apod.nasa.gov/apod/archivepix.html
(source lifehacker)
Adding Batch Hosts To op5 (Nagios) from CSV
Even with the lovely GUI that op5 comes with, sometimes you need to enter in a large set of hosts into the system. op5 gives you the ability to use the GUI as well as the historical nagios (hosts.cfg) files.
I wanted a way to not only create a hosts file but include some other items as well like the parent of the device, hostgroups and image to use. The input file should be in csv (comma separated format).
So I grabbed some old code on the net that and edited to fit my needs. There are 3 parts
- mk_hosts.sh
- hosts.skel
- inputfile.csv
mk_hosts.sh:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #!/bin/sh # mk_hosts.sh # convert csv input file into hosts.cfg file=$1 cat $file |while read line; do echo "${line}" NAME=`echo ${line}|cut -d, -f1` ADDRESS=`echo ${line}|cut -d, -f2` IMAGE=`echo ${line}|cut -d, -f3` PARENTS=`echo ${line}|cut -d, -f4` # Since hostgroups may contain spaces let's put at end and grab everything from field 5 on HOSTGROUPS=`echo ${line}|cut -d, -f5- | sed -s 's/"//g'` cat hosts.skel | sed -e "s/TEMP_NAME/$NAME/" -e "s/TEMP_IP/$ADDRESS/" -e "s/TEMP_HOSTGROUPS/$HOSTGROUPS/" -e "s/TEMP_IMG/$IMAGE/" -e "s/TEMP_PARENTS/$PARENTS/" >>hosts.cfg done |
hosts.skel:
1 2 3 4 5 6 7 8 9 10 | define host{ use default-host-template host_name TEMP_NAME alias TEMP_NAME address TEMP_IP hostgroups TEMP_HOSTGROUPS icon_image TEMP_IMG statusmap_image TEMP_IMG parents TEMP_PARENTS } |
inputfile.csv
1 2 3 4 | oracle-prod1,172.2.6.32,redhat.png,ny-router-1,"All Servers, NY DataCenter, Everything, Prod Servers, Linux Servers" oracle-prod2,172.2.6.33,redhat.png,ny-router-1,"All Servers, NY DataCenter, Everything, Prod Servers, Linux Servers" oracle-prod3,172.2.6.34,redhat.png,ny-router-1,"All Servers, NY DataCenter, Everything, Prod Servers, Linux Servers" win-exchange,172.4.6.32,windows.png,ny-router-1,"All Servers, NY DataCenter, Everything, Prod Servers, Window Servers" |
Your CSV file should use the following columns:
Name, IP, Image_Name, Parent_Name, HostGroup(s)
Once you have done this simply run the command (outside of your etc dir):
1 | ./mk_hosts.sh inputfile.csv |
Now look at the newly created file hosts.cfg
If everything looks good, simply cat >> this onto the end of the hosts.cfg file. Within op5, goto config and it will notice you have a NEWER config. Click save and all is well. If not, go back and fix the errors.
BTW: You might want to create a backup within op5 before doing this just in case you lay down some wrong hosts.
op5 Nagvis Root Node
Nagvis wants to use by default localhost for it’s root within the auto map.
Go into the file “/opt/monitor/op5/nagvis/etc/nagvis.ini.php” and edit the line with the name of your op5 host
defaultroot=”myprod-op5″
Finding Large Emails in Gmail via FindBigMail
Found a great site “http://www.findbigmail.com” that sorts your largest emails in a separate folder to explore and delete. This is a free service, all online!
Turin Netcool Lookup Table Via Ops Guide
Wrote a script to pull in the (highest) default values for all traps found within the Node Operations and Maintenance Guide
Stepping Through Traces in an Eagle Board
Found this great trick (script) on this board: http://www.element-14.com/community/message/13435





