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

Curl within a salt-state

So I have been looking all over for how to make this happen and finally figured it out, preserving it for anybody else who wants to kick off a curl in a salt state to say add something into monitoring or begin another process via an API call

Right now this is just using testing data from my lab, but as long as you enclose all the salient data in ‘ or ” it should be fine

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.

Nginx permalinks and search fixed!

So I realized the other day I couldn’t have nice permalinks for some reason so I set out to try to figure out why and/or fix it as it had all worked fine before I migrated from Apache to Nginx a month or so ago.  Unfortunately it seems like there were plenty of sites talking about a fix of changing the location block around a bit, however I quickly realized that while the suggested fixes would indeed let me change to non-default permalink styles it invariably broke the ability to search the website which kind of inhibits me using it for storing thoughts and fixed and things and being able to recall them with a quick search.  Finally I stumbled across the golden bullet for this problem and I will provide it so that hopefully nobody else spends an hour and a half of their Sunday messing with this when there are QSOs to be made!

Original location block

and now the updated one

 

And with a quick restart of nginx (that took a few tries because I’m too used to systemctl over service already) and ta-da I can search again and have the fancy pants permalinks that mean search engines can better index my ramblings.  Oddly enough as I was testing this I saw a spider doing its thing while I was looking at the access logs for the server, pretty interesting that a spider would be active on a sunday at like 1145 EST.

Network Manager and OpenVPN

It blows my mind that Network Manager is still as bad as ever, I just finished up getting my new phone aimed at the home VPN when I remembered that the laptop lost all the old settings in my switch to Fedora so I figured I would give it a spin and see if somehow NM had been fixed.  A few minutes and some profanity later and it seems it STILL is unable to properly load up .ovpn profiles and parse out the various bits into the fields they need to go.  Even when I manually split up the keys and certs and all that it only worked halfway, I could connect to the VPN but was unable to browse the internet over it or even access resources local to the VPN server itself.  Fortunately the command line comes to the rescue again, all I had to do was tell openvpn itself where the config was and it did all the legwork that the abomination known as Network Manager failed to do.  For those who might care the proper way to invoke it is as follows

Now I just have to make a handy way to suppress the output, give me a status indicator and kill off the connection when I am done with it…

Successful Upgrade is Successful

I would say I can’t believe I’m typing this from a successful full upgrade from Fedora 23 to 24 but I’m not since I am at work and they frown upon me pecking away on my personal laptop, but I am still amazed that it was an absolutely painless process to upgrade from 23 to 24 with dnf.  In prior years it was almost always advisable to reinstall rather than attempt an upgrade from one major release to the next but the fine folks over at Fedora seem to have hit a home run on this one.  Sure it took a while to apply everything but the moment of truth (or reboot) came and passed and all I got was my normal login screen, no fancy explosions of failed video drivers, no corrupted profiles or missing files; it went so smooth I almost didn’t think it worked until I checked the redhat-release file and verified that it was in fact on the 24 release.

Crontab – Always Check your Environment Variables

So I have been running into this issue for like a month now where a script that I can run from the command line by hand executes fine, but when I try to run it via a crontab job it just goes absolutely pear shaped without any real explanation.  Finally I got some time at the beginning of a shift to sit with one of our senior guys to take a look at it as the script provides data the entire team uses and when it doesn’t run they get cranky.  It turns out that the environment my cron jobs run as is highly different, as indicated by the following which is obtained by adding adding a line to output env to a text file every time the crontab job ran.

Compare that against the results from env when run by hand

Notice the path statement is very sparse when cron outputs the environment variables, turns out that anemic path lacked access to fping which was integral to my script building out a list of live hosts within our lab environment. Once that was fixed the cron jobs hum along nicely and churn out an updated map of the lab every hour without me doing anything and now I know that crontabjobs run with fairly different environment variables than scripts manually ran and can cause all kinds of havoc if you don’t use full explicit path statements in your bash scripts that you plan to automate.

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.

Strange copy behavior?

So a friend hit me up today to let me know he had updated a sqlite database that we use in a project and I could go ahead and copy it over to my home directory to update things with.  Login to the box, sudo to root and cop the file with full paths and something bizarre happened, the file which he had ownership of changed over to my user level account.  Immediately he suggested that it might be the -a flag in an alias, however my alias was simply set to use -i so I deleted the file from my home directory and tried the copy again.  As far as I can tell this shouldn’t actually be happening because I didn’t specify the -a flag and the user moving the file is root, so if anything root should have ownership of the file once it hits the directory.  I doubt this is any kind of nefarious or exploitable situation but it does seem strange because I remember forgetting to chown files in the past after moving them as root and things not working until I went back and corrected the ownership of the files

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.