A cautionary tale of Git and Virtualbox

I have been trying to keep the code chops sharp since work doesn’t require it very often anymore, usually by working on polishing up projects I’ve started in the past but let fall by the wayside.  Last night was a bugfix session on imgur2pdf which I have been neglecting for a while now and specifically working on the resizing logic which was hosed up and created some ugly PDFs.  All told I think I spent about two and a half hours working on the code testing it over and over with galleries to make sure sizes were right and it made changes as appropriate to large dimension images.  Once I got things right to where I wanted them I pushed my commit up to the repo and took a break for a while, grabbing some tea and having a look at why the virtualbox VM I was working on wasn’t letting me copy/paste between it and my parent OS.

Some quick poking around and I realized I hadn’t installed the Guest Additions software so I loaded that up and rebooted the VM only to be graced with a solid black screen that was unresponsive. I rebuild the VM since it was mostly empty and try it a second time and the exact same thing happens when rebooting after installing.  Asked around on IRC and a buddy pointed out to me that this is kind of a known issue and there is a potential fix out for it, so I guess I know what I am doing with my evening tonight.

Thinking about this today made me realize that the old way of doing code would have probably cost me several hours of work and resulted in a great deal of profanity had I wiped out everything.  So let this be a lesson to anybody just getting started with Git, commit/push often as it beats the alternative of losing hours of work

Log parsing for cell phone records

Update

So I totally screwed up the code previously, it didnt have any logic to look at only the target phone number so it was just running calculations on the entire log.  Also tossed in some avg calculations for number of calls and time per day for the hell of it.


So I was curious how much time I spend on the phone to certain people, so I decided to write some quick python to figure this out.

 

This is pretty straight forward, change the value for target_number to whatever number in the logs you want to look for then let it rip like so

low tech Salt deployment

So I have been tearing down and rebuilding a lot of crap in the lab lately (kubernetes clusters, ELK stack, etc) and I have been constantly having to re-add salt to the VMs because salt-cloud doesnt yet play nice with Xen.  After about the 3rd time of doing this I got tired of manually installing epel-release, salt-minion and then changing the config so I wrote perhaps the worst script ever to remotely do all that work for me and possibly be used later when I finally get salt-cloud working with Xen.

Granted this relies upon me still manually doing ssh-copy-id so I don’t have to keep typing in passwords thats a lot fewer commands, maybe if I get the time I will add in some logic to then auto-accept the key in salt so that I don’t have to manually do that either.

Strange behavior from Postman

I was working through changing my Saltstack configuration to work with LibreNMS and was working through adding devices via the API as opposed to using auto discovery and realized that basically the same query in curl works fine, but when I tried it with Postman it doesn’t work and acts like I never passed some of the values, observe!

as opposed to when done in curl

The only possible thing I can figure that is going since this is such an absurdly simple API query is that Postman does some kind of magic thats not plainly visible that changes how the data is received by the API.  This is moderately troubling because it gets me wondering what else they are doing with data and if there is some kind underhanded snooping going on, not that I’m working on anything too terribly sensitive other than helping myself become more lazy in the lab.  If I was tossing in a pile of headers I could see where the room for mistakes exists but with only three key/value pairs passed in data and the X-Auth-Token passed in headers I can’t really see any possible place I have messed up but sure enough we get the error about not specifying the version of SNMP for the add device call, so something definitely is hosed up somewhere.

SNMP, Remotely!

So I have been building up a bit of a Windows environment in the lab (a DC, two clients and a sql server so far) and I wanted to push out SNMP to the environment because thats how I monitor things in the lab. Unfortunately I have seen absolutely no reliable way to do so with Group Policy, so in comes the glory that has become PowerShell lately. First we need to figure out which servers we are going to target, so lets whip up servers.txt with the shortnames and make a note of its path. Once we have that list we whip up a quick little loop that works on each line of the servers.txt file to make things happen.

Of course if you only need to do a single server for a one-off reason you could just run Invoke-Command manually but where is the fun in that when we can push to every single system in a hurry AND kick off the gpupdate which will pull down the settings to enable SNMP across the lab.

Comic Scrape

So last night I decided I wanted to archive some web comics I used to read religiously in a format that I could later manipulate into an easy to read format so I can catch up on a few years of missed material without clicking Next a ton of times, thus was born cscrape!

It spits out the images and an accompanying XML file in the comics/ directory so that later I can write something else to process them into an easy to digest format to view say on a tablet or mobile phone for comfortable reading while kicked back in my recliner. Unfortunately for right now its fairly specific to a certain comic however I hope to be able make the code a bit more flexible in the future to allow working with any comic and perhaps roll in the functionality to process the scraped data into easy to read formats.

A horrible way to generate IP addresses

Sometimes I find myself doing the dumbest things ever, like needing a list of ip addresses for a tool that doesn’t accept CIDR notation for target addresses. The tool is unimportant other than it being poorly designed and inefficient as hell, what is important however is that I slapped together a set of 3 loops in a bash script to use the seq tool to generate a massive number of ip addresses. Its really slow actually, so slow that it generates like 250k every 5 seconds which really isnt that much for a simple task like this, I think my prime number code is quicker and its doing actual math. Anyway if someone happens to want this for some god-awful purpose have at it, its terrible and I should probably feel terrible for writing something this ugly

scripting: system-help

We have this handy script at work that pulls all kinds of useful details from a system and saves us a ton of time checking by hand, so I took a stab at making my own version for generic use. Its not very good at all but it kinda works and probably could be expanded upon to do something actually useful.

Repo on Github

Pure Win – Monitoring Comcast’s Failures

So this is the greatest thing I have read in ages; for those too lazy to click a person having lots of problems with Comcast took it upon themselves to create a python script that ran a speed test and if certain conditions were met would send a tweet to Comcast complaining about not getting what they paid for.  Unfortunately there are lots of people getting paid to fellate Comcast and they flocked to the r/technology thread on Reddit to remind OP that he should be grateful for paying a pile of cash for “up to 150 Mbit” like he is somehow blessed to have the absolute worst company in the US as his ISP.  Naturally I grabbed the code and set it up on my development box to run every 15 minutes so hopefully in like a week or so I can generate a fancy graph to see just how bad Comcast is boning me on my already high monthly bill.

Troubleshooting Script

I have been planning to try to convince a friend to take up Linux in place of her aging Windows 8.1 system since its been officially put out to pasture by Microsoft so I started thinking about supporting said system since my friend is not exactly a Linux guru.  This of course lead me to think about a very handy script I use at work that does a whole bunch of things like check database settings, look for necessary running processes and look at system loads of our software to determine if there are any easy fixes before getting into logs and headaches.  Naturally I cannot share this script because its work related (and I didn’t write it either) but it made me decide to make a version of my own that I can show off.  Currently the script resembles a rather ugly gnome of some type in that it is short and VERY ugly but I figured I would toss it out so I can test a few other things like my nifty social share buttons that are about as basic as you can get without setting foot inside a HS Chemistry classroom.

Github/Gist

The long term goal for this script is to make it collect a whole load of system data, run some basic checks like pinging Google, and probably a few other things like making sure vital things like crontab haven’t been somehow deleted.  Probably will also make it verify that my ssh key is still active within the system so that if I have to I can remote into said system and might consider some sort of reverse ssh invocation as well if I really want to get fancy with the script.  If it saves me even 10 minutes when trying to fix the system that I haven’t even setup yet then my past hour or so messing with it and remembering all the things I’ve forgotten about scripting in the past few months was well worth it, plus it gets me back to actually posting something here for a change.