Tuesday, March 21, 2017

OMG tmux how have I ever lived without you!

How the **** I have I never heard of/used "tmux" on a Linux box?  I mean seriously, they had me at Control + B --> D.  For those like me who had never heard of "tmux" it is a NECESSITY if you ever run any long running (or even short running) scripts that require you to be connected to a SSH session.

Let's pretend that you are upgrading a very important application on your server and this upgrade script does thousands of instructions and database queries etc etc.  Now let's pretend that you are 4 hours in and all of a sudden a squirrel nibbles the fiber optic cable connecting you to the interwebs (yes, this happened).  All of a sudden all of the processes that are running have been terminated because your SSH session was disconnected.  Now you have to pray that it either finished, somehow is still running, and didn't corrupt itself and you have to roll back to a snapshot (you did make a snapshot before you started right?).

Now let's pretend you knew about "tmux" and let's run though this situation again.  You first SSH into your server and then you immediately issue the command:
tmux
Now you get a nifty colored bar at the bottom of your SSH screen.  Mine is green, but it will probably depend on your terminal settings.  You seem to get a standard prompt like you had before.  That green bar is the only thing that really lets you know you are in tmux.  Now you issue your script commands.  4 hours in the rascally squirrel gets his teeth into your cables.  After flipping out and finally realizing what happened you then proceed to go to your mom's house for some nice good old fashioned cable internet and cookies.

From there you connect to your server (VPN + SSH) and then you issue the command (as the SAME user that you ran tmux from before):
tmux attach

Now you are brought right back where you were!!! HAPPINESS!!!

Useless example:
$ tmux
Now in tmux:
$ nano hello.txt
If you purposely want to disconnect hold down the CONTROL key and press "b" then press "d" to "detach"
Close your SSH connection completely or go to another computer and connect to your server.  Now as the same user type:
$ tmux attach
Violoa! you now are editing hello.txt!
To exit from tmux you can just type "exit" at the prompt.  Here is a nifty site dedicated to more tmux use cases like splitting screens etc: https://danielmiessler.com/study/tmux/

Happy tmux-ing!

Tuesday, March 07, 2017

Why I Hate/Love Free Support - I'm looking at you Piwik!

Who doesn't like free? Of course as the age old adage goes, you get what you pay for and Piwik is no different. Piwik is an analytical platform for log analysis and real time (semi) user tracking via web service calls. All in all the product is decent. We are running a local version of their software and performing log analysis only.

We (meaning me) ran into problems during a few different stages of implementation. I posted 3 different times to their forum with only crickets as a response. One topic was viewed 138 times and the others around 50ish. Not a lot, but hey someone's looking. There weren't even any responses from that one jerk who says, "I have no idea, man" or the other jerk that says "just RTFM" or the jerk that says "I'm not going to do your schoolwork for you" or the last jerk that is obviously from the java forums who says "if you are too stupid to figure it out I can't help you" (you know who you are!). 

There is one guy, Matthieu Aubry (the creator of Piwik) who does make great efforts to answer questions, but he appears to be just one guy (or ARE YOU?!?!?!). I do not fault him in any way and as a developer who also supports users I understand the lack of time he has to do both.

Piwik does have paid support contracts that will solve the world's problems, but it is rather expensive. For the little guy you are SOL. Piwik has a stackoverflow section, but that too is sparsely answered. In the end, I spent way too many hours troubleshooting and trying to figure things out, but hey you get what you pay for.