Friday, 31 March 2017

Linux Server Admin : Bash Kill Processes By Common Name

On my Linux server I've recently wanted to go through and kill a bunch of application instances in one go, this is a server where students have been connecting and running carious programs under python, therefore I want to remove from my processes anything called "python".

We can see these in our bash shell with the command:

sudo ps -aux | grep python

To remove all these programs I create the following bash shell script:

k = 0
for i in $(ps -aux | grep python)
  k=`expr $k + 1`
  kill -9 $i  
logger -s "Closed $k Python Instances"

Notice k=`exp... this is NOT a single quote (apostrophe) it is the "smart quote" on a UK English keyboard this is the key to the left of the number 1.  It is used to substitute the command into place, so the value counted in K becomes the result of the expression "$k + 1", i.e. K+1.  More about Command Substitution in Bash here.

The call to logger -s places the message both on screen and in syslog for me to review later.

This simply loops through all the applications resident and kills them off, I've saved this as a "sh" file, added executable rights with "sudo chmod +x ./" and I created this to run as a cron job everyday at 3am (a pretty safe time, unless I have some students burning the candle at both ends).

That's everything about the bash script, for those of you wondering about the students, they're those folks following my learning examples from my book, which you can buy here.

Thursday, 30 March 2017

People : Some Life Advice (Reading)

My grandfather was quite a serious fellow, an absolutely lovely fellow, he was a (or even "the") chief quarter master for the Royal Mail in Nottinghamshire before he retired.  However, a mere five years, after he retired he had a diagnosis of lung cancer and was dead shortly thereafter.  The first major figure in my life to pass away.

I was eighteen, had just started university, and being honest with myself it affected me deeply, both personally, mentally and spiritually.  Personally as my mother then assumed she was the helmsman of the family, never have I seen the monkey leading the organ grinder more ineffectually.  Then mentally, he was gone, the one great intellectual figure in my life was gone.

His intellectual influence was deeper on me today than perhaps I ever realised, I remember when I was around three or four he showed me how to write the figure 8.  I distinctly remember his being behind me, his affirmative arms either side of me as he intoned an 8 before me, and I copied.  There was always paper to doodle on and pens in a draw, they were the main "play thing" of a wet or dank day, of which there are many in Britain.

He taught me to pronounce things, and to this day I can slap on a lovely accented English, very polite, which he taught me; and which my wife adores when I use it within a telephone conversation.  It empowers me to escape my strong, rough, Nottingham accent whenever I wish, both are part of me, one through nature the other nurture.

I also remember his buying books, or handing me books, the first I remember were the complete Encyclopedia Britannica, a lovely red leather bound set; which must have cost a fortune in the early 1980's; I'd sit and paw over these pages for hours, years later I remember some kid at school going on about French writers, I instantly named Victor Hugo... Thanks to those hours spent with my nose in a book.  Kids today can look things up instantly with the internet, but watch out for the kid who avidly reads anything, they might just be expressing their interests early.

Another day he handed me a huge book, it was a cheat book, with every answer to most all the crossword questions of the day, he was teaching me a lesson... You could sit and think about the intricate layout of the crossword, how things meet, depart and conjoin.  However, you could also just get the bloody answer.  This has become a massive power for me, I feel enabled, even if I don't know anything about a topic, or it's currently not on my mental radar, it is but a quick read away.

I know this, I'm sure reading this, you know it too.  However, how many people out there look at someone judge them and then think they can't do the same as them?  I'd suggest a lot of them do... When really they might just need to read the right book, or take the right advice, don't close yourself off from these people, embrace them, help them, let them help you too.

Wednesday, 29 March 2017

Development : People Error 404 (Scrum)

I talked last week about my implementing three new cards for my Scrum meetings, I'm thinking about another card... a "Person 404 Error"... When I find an empty chair, post scrum, when I expect people to be working feverishly or at least planning their tasks for the day, but instead I find them drinking a coffee in a corridor, eating an apple staring at a wall, or just bemoaning they've been up since 8, I am going to assign them a 404 card.

My reason being, the developers I'm talking about, do not have a fixed start time, they can start anytime they like, so long as they're at the scrum, the scrum is 10 to 15 minutes, and then they have to get on with their task.  Coffee collecting, and apple eating, and especially bemoaning, is not allowed after the scrum for at least an hour, results, progress and some personal planning are required of them.

So, if you're a developer who wants to do the scrum then vanish... 404 you're not found... I'll be watching... And waiting.... And I'll make sure your 404 card is in your least favourite colour!...

That means Pink for you SB!... PINK!.... You have been warned.

Monday, 27 March 2017

People : British Baby Boomer Bullshit

I'm going to talk about someone I know, whom I have known all my life, they consider themselves to have been brought up without the advantages of a modern childhood (my birth in the late 1970's and childhood in the 1980's being considered modern to their birth in the mid-1950's).

They once spoke to me about my having advantages they don't... That I could get work, when they couldn't (at least not at the time - the 1990's) and I admit that with the closure of the coal industry, the privitazation of Rail and Telecomms many "normal" routes of general employment of the British worker of yester-year were curtailed; though not closed off; in the 1990's.

But, I was still a kid, I didn't go to university until 1996, and I officially didn't graduate (despite working in the IT industry from 1998) until 2000.

All the time I struggled to keep myself in work, and have been now gainfully employed fulltime since 1998, no mean feat between Brexit today and the dot com bubble burst at the time of my graduation.

So, what was this persons point?... Well, their point was "We kids of the Baby Boom, were only had to replace the war dead, our parents had no interest in us".

They repeated this mantra in several slight variations for many years, and it always struck me as odd, even as a kid.  Because I had read the history of the second world war, and here in Britain we can only count about 350,000 service personnel killed (328,600 according to wikipedia) and there were only 67,100 civilian dead, a total less than half a million people.  Tragic, but nowhere near enough to warrant a ten year population boom from 1945 to 1955 of around 800,000 births per year.

A birth trend which went on for a peak of over 1 million live births in 1963.

That's millions more people, which this one person justified their upbringing as warranted for the loss of less than half a million lives in a war?  A war which predates them by a decade?

Strange thinking... And only now, in the internet age can one really turn around and challenge such strange miss-conceptions, no you didn't have a poor childhood, we're on the cusp of living our days where the current generations are for the first time earning less per capita than the previous, that is only now, nearing seventy years since your birth, that's generations before now which have enjoyed living well.

Brexit brings uncertainty, our special relationship with the USA; ironically fostered during the Second World War; is one life-line we have, but the youth of today can't point to the Falklands conflict or the First Gulf War and complain that their birth was accelerated by a necessity to respawn the population after a devastation.

Such devastation of the population has not happened since the First World War and the following Spanish Flu epidemic.

Could it happen again?  Perhaps... Will I be contributing children to repopulate?  No.  And will I cry that today we have iPads whilst when I was born we didn't even have an Apple 2?... No, of course I won't.

Sunday, 26 March 2017

People : Again Who is Robert Yates?

I asked before who Robert Yates was, because I don't know, I still don't know... He's linking to my blog in some way, but I don't know who he is... And now, rather puzzlingly the post I made asking who he was, it keeps coming up as one of my top 10 viewed daily posts... 100+ people a day want to know like me, who Robert Yates is?

Someone suggested to me that this was a little like the character Robert Paulson in Fight Club... He had no name until named...

Friday, 24 March 2017

Development : New to the Scrum?

I have evolved my Scrum meeting technique, during the scrums I host I always go around the circle, only the person directed by me (when I am the scrum master) may talk and they talk until completion and pass onto the next person.

However, there has been a drop out between the person talking and those in the room with feedback, I had asked anyone with feedback to hold it, but I have made an exception in the form of a series of coloured laminate cards.

The cards are "HELP", "INFO", "SUGGESTION".  When the person speaking is saying they have something blocking them, and someone else has done that work before and can help, that person picked up the HELP card.  I know to note down they are going to then help that person directly after the scrum breaks up.

If the person knows of a solution or has information to help unblock the speaker they pick up the "INFO" card, and I know to note down they will pass that on, as an email or conversation between them after the meeting.

The last card is that the sort of know the problem, sort of have some information, but it's only a suggestion, this might be to do things a different way, leverage a different technology, basically to suggest a new path... They pick up the card, and there is only one, and after ALL speakers are complete then I hand them back the floor and they can discuss their ideas, often times as the scrum master I can leave this conversation for five or ten minutes to gestate of its own and lead to HELP or INFO coming about, but I've also found it to be an excellent ice breaker for those new to a team or project.

They have a documented, easy to access, way into bringing their skills to the forum, all whilst being protected from being pressured into behaving or proving themselves.

So far this has been a great success, unfortunately it has not yet percolated up the chain to stop bespoke hardware solutions being pushed.

Friday, 17 March 2017

Development : Managers Trust your Developers

I have been so busy, I'm deep in the middle of a new system development with work, but as a personal side line I'm also completely re-engineering a different system, you know when you've worked on something or in a field as long as I have it becomes second nature to want to do things your own way... So I've been doing just that.

I picked a coding standard & style, I've stuck to it, I've pulled in SDL and Boost, it's all C++ and it's around 100x faster than the original system and amazingly more simple to access.

The problem, the boss doesn't want it, he doesn't trust it.  More importantly he doesn't trust me.

My previous boss has seen the system he's gobsmacked, his opinion was that it was exactly what was needed four or five years ago, and to have done it alone with no support in parallel with my real daily work just blew him away.

So what was my current bosses argument?  Well, it's one I can't counter, his point is that the current system I want to replace has been out on the market with real customers for years, nearly twelve years in fact, and I ported it to cover five different platforms.  He's right, it is, it has been, and it will be again, but that doesn't make the system any good.  All it lets a manager in his position do is quantify the risk versus reward, and I can not argue or knock him for that.

However, what I can knock is when you have an employee, like myself, who lives and breaths this technology, who writes books and blogs on the topic, and they've worked for you for 14 years... They're investment in the product is vastly more than the product risk for taking up the new system, especially when the new system would only go to trusted customers for trials, it would not immediately go out to the full estate of customers.  You reduce that risk you've presented drastically, there is less risk, but the reward for introducing that new system is vast, acceptance of it is equally as likely as giving customers the original old system in a new skin.

They are 100% compatible by the way, content for one works on content for the other, they work in the same sequence and order, they are the same except the underlying code is vastly better in one and a squelchy pile of over cooked spaghetti in the other...

So, to managers out there, the world over, yes evaluate your risks, but your developers are a huge component of that risk, if you have a good one, trust them when they do 40+ days of leg work on something, they're not doing it just for their own sake, they're doing it because of a driving need.

Wednesday, 8 March 2017

Development : Visual Studio Giving False Reports of Missing Symbols

I have just run across an issue which has me slightly baffled... Sending the build down to my automated server and it started coming back as failed, panic ensued, so that I started to then do builds on my local Visual Studio instance... (which is VS2013). 

Now, this code is perfectly working, has been fine, released and tested for... Since about 2011.

This is how the error shows up...

Taking a closer look...

We can see there are suddenly a bunch of unresolved externals, specifically the definitions of a bunch of functions.

There is NOTHING wrong with this code, indeed, the work around to get a build to complete is to comment out any one of these functions....

Rebuild, and it now fails on that specifically missing function body.

Finally, re-enable the code and do a further rebuild... and everything completes perfectly...

Consulting the internet about this one, as everyone here has drawn a blank, and one person suggests that this is a miss-match between the Byte set setting of the project (Multi-byte) and any libraries being Unicode.  However, I have no third party libraries... The mystery only deepens.

A full fresh check out of the code, still fails, a full clean fails, a rebuild fails, rebooting the machine has failed.  None of the fixes has made a difference, and more problematic is that the failure happens sporadically.