- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
TRWTF is the poorly written and ambiguous story. The needlessly-vague-in-a-misbegotten-attempt-to-sound-cool-and-laid-back phrase "querying a column in some database table" is a lousy choice of wording since that "some" elides the one vital piece of information that would let us understand the entire article.
Admin
If, after 15 years using unix, you feel that these privileges are of use to anyone, then some time spent on the basics would be well spent.
Admin
Not to mention that it doesn't even need to use the database because it already knows if the mainframe is on or not as a result of the check.
Admin
Ask Rumen if the mainframe is on.
Admin
HA HA HA! Good one Paula!
The WTF with the code is every time it runs it adds a new column called MainframeOn to that datbase table. Eventually it should error out once it reaches the maximum number of columns per table.
Captcha: Let Go My Ego???
Admin
The additional minor-WTFs are the repeated posts insisting that ping.exe on Windows is setuid root, or the Windows equivalent. There isn't a Windows equivalent for a start, and for a finish ping.exe is a normal binary.
None of this setuid fruityness kthxbaibbqroflcopter!
tm
Admin
So why can't they just rely on a TCP connection attempt to check if it's online? If it connects, then it's online. If it timeouts then it's offline.
Admin
Admin
using exceptions to handle your expected-case scenarios is not the right way; (only a little bit) better to try to retrieve the value, and on exception, add the column.
Admin
Admin
No it doesn't - it's "Expection Handling" - if you try to add a column that already exists, there will be an exception thrown. Since the developers obviously knew this was a possibility, they should have checked for existence of the column, rather than just trying to add it every time. Or better yet, assume that the schema is correct and keep DDL where it belongs.
The second bit of code is less of a WTF, but still a little off, because the database response doesn't necessarily indicate that the mainframe is running - unless the database runs on the mainframe and it's the only service you care about, in which case there is a much better way of checking to see if the database is responding.
The overall WTF, for me anyway, is that there is specific code to check if vital services are running, and it's part of the user login for a client application. I've seen this done in rare cases, but usually, you just have the client application do whatever it is going to do, and you handle the errors when they happen, rather than checking to see if any errors might happen and then doing what you are going to do sometime later. The problem is that maybe the mainframe is running just fine when the user logs in, and then some time later, the mainframe is not running when the client attempts something, but the lazy programmer doesn't handle the error correctly, because hey, they already checked to see if the mainframe is on.
So IMO, the proper way to code this would have been to just have the client application attempt a login, and if an exception is thrown such as "mainframe could not be reached" then you handle the error at that point.
Admin
That's like buttering butter.
Admin
Why even bother checking if the mainframe is on?
If it's not on, the user probably can't access the website.
That's like using JavaScript to detect JavaScript, or making an EXE that only checks to see if you're running Windows.
Admin
I see the WTF: ExecuteNonQuery. "ALTER TABLE [Mainframe] ADD MainframeOn Bit" sure looks like a query to me; it should be passed to ExecuteQuery!
Admin
No, it's not a query. It does not return data. Look up "query" in a dictionary...
Admin
Oh, those mainframes that use regular 13-amp sockets?
Yeah, you get a lot of those around. I think Dell make a few of those.
On a slightly more sensible note, SunCluster's HA-Oracle agent connects to the database and gets some status data from the database to check that the database is online. That is all after checking that the machine responds to pings, is talking over the private interconnect, has access to the storage, and so on, but to be fully confident that the service is actually usable (as opposed to hung-but-answering-ping-requests) it will query the database instance.
Other SunCluster agents do do similar tests - again, phased to allow for the range between "the other server disappeared totally" (take control immediately to avoid data corruption) down to "the other server seems fine, but let's check what the users would see" (allow the other node to die or come back online before taking more drastic action).
VCS can do similar things; actually, it's the norm for resilient systems - it is a requirement.
Not everything is Microsoft...
Admin
Admin
Admin
Don't knock buttered butter. It's delicious. I want to stuff nob after nob of delicious buttered butter into my festering gob, as tears of joy roll down my cheeks.
Admin
The cleaning crew is not supposed to come near your mainframe.
In general, "mainframe" relates to IBM System Z nowadays. If you own such a box, you pay massive amounts of money just to ensure that systems are online. 24x7x365.
So, when your IT department is charged tons of money every month for your mainframe ... these folks will make sure that noone comes near their sacred box.
Admin
Why should an "asset management application" check whether the mainframe is on? Just use whatever resources you need to use when you need them; if such resources are unavailable, act accordingly, but a previous check is unneeded.
Admin
Nice theory... I know a bank where a "IBM System Z" was unplugged by a technician to replace a broken bulb; a real situation, not a theory.
Admin
Admin
(One day downtime every four years, you'll note.)
Admin
Admin
Heh. My bank had its datacentre go down when you turned on the lights.
AS400s don't like power faults at all, and we found the System Z is much less tolerant than the windows boxes to momentary interruptions. Longer version : Emergency power cutout breaker located in false wall by door had wire work loose over time, vibration from pushing the adjacent light switches firmly was enough to make the wire jump & cut the power briefly.
Admin
Only 3-nines reliability then
Admin
or do I mean 5?
Admin
Isn't it a 49.1346154 year contract ?
Admin
Admin
Hahahahaha!!! You read this site as much and for at least as long as me!!!
Wow! Big Captcha! ullamcorper???
Admin
What, nobody mentioned 'int32 is_computer_on()'?!?
Surely there's a ASP.NET, VB.NET, or PHP equivalent.
Admin
Admin
Admin
I think you might just be a dirty mac user
Admin
Nevertheless, I can't see a good reason (as long as you're co-located) not to ban ICMP via a firewall. It's too high-level to be safe, and too low-level to be useful.
Needle nardle noo!
Admin
What happens if MainframeOn = 0 ?
Admin
The funny part is that I have just tested this after about 2 minutes of reading some recordset docs.
If rs.State = 0 Then \tMsgBox "Something must be wrong." EndIf
If you ping, you are checking if the MAINFRAME is UP! Which is the goal. If you want to check of the DB on the mainframe is running as service (use your service manager status output). If you want to see if the Mainframe is up, the DB service is running AND that the DB is functioning, check the DB State.
THAT is the WTF. I don't see why this isn't obvious for people.
Admin
Likewise, it would be wise for you to spend some time with the basics of reading comprehension. I did not say "anyone". I challenge you to pinpoint where I said or implied "anyone" (or at least a piece of text that I wrote that can be construed as such under the widest of interpretations.)
Let's go back to the opening salvo by dpm (or you if you happen to be dpm's sock puppet which in the land of the interweebz it's all too common.)
Every application runs under a user (nobody, root, a domain/app-specific user.) For nobody and root, we don't need to discuss anything further. For domain-specific users, you assign them to a given group with certain privileges, including if you wish, the ability to execute certain functions that are otherwise privileged.
And in cases where (using PING or whatever ICMP functionality you want to) something is strictly off-limits to anyone but root (due to x/y process in place), you can still have a process running as root under control (.ie. a chroot jail) performing the function in question, and writing its output to an IPC/temp file/whatever-messaging-mechanism to be read on the other end by the application in question running under the domain-specific user with restricted access.
Restrictions would also happen at the firewall level .ie. not allowing ICMP packets traveling except to certain locations (.ie. from the app host to the mainframe to be poked for liveness.)
You might want to spout about spending time with the basics, but it seems that you have lost the basics yourself, not to mention that you fail at reading comprehension.
In summary:
Anyone who thinks otherwise is either a sysadmin control freak living in a dark, secluded sysadmin cave with little exposure to the realities of application development/support or someone enamored with a book on ICMP (theory, but no practice.)
You make it sound as if we are trying to mix oil and water (OMG! user can haz! ICMP, impozzibel division by 0!!(eleven)- we are not. There is nothing intrinsic/built-in that stops a non-root user from doing so, which is how your first post reads - whether that's what you meant or whether that's how it got written by poor communication skills, I don't know.
If you still think I'm claiming anyone should have these privileges (so that you can have an argument to point a finger at), please do so.
I'm not one to judge your lifestyle, so long as you don't complain when you get splinters from screwing that strawman of yours.
Admin
Exaaaactly! That's how it's done first and foremost, not by setting up all potentially risky funcs exclusively to root.
Admin
The mark of a true gourmand! You win.
Admin
Mmmmmm....that's my lunch. Buttered butter, with a marble-rye-on-toasted-whole-wheat sandwich on the side.
Admin
jasmine2501: My bad. You're right trying to add a column that already exists would throw and exception.
Admin
what the hell is this?? database runs on mainframe. if mainframe up db up. is db up? select 1 from dual;
-- 1
it's up.....
done. DDL? convolutions? madness! KISS....
Admin
errr...
nooooo......
what happens if the mainframe is in a maintenance state, only accessible by the console op or at a run level where ping will wok but users cannot login?
I think it is about context - is the mainframe from the viewpoint of users who want to use the system
Admin
A good word for 'ping'. I use ping from my notebook computer in Thailand; I ping my server in Singapore. The IP address is in /etc/hosts; no need for DNS. What does this tell me? It tells me that I can get to the Internet. My router is working, my ADSL is working, the ISP's network is working, and the national gateway to the global Internet is working. This is valuable information. If necessary I can 'ping yahoo.com' to see whether DNS is working.
Admin
In most places, if the mainframe is down, making sure that some program works ok in that situation is a very minimal problem.
But, even if you need to check for write access there is no justification for altering a table instead of inserting a row somewhere :-). Maybe there was a good reason to do it like that... We'll never know...
Admin
OK I know nobody is reading this because I'm two days late to the party, but I just wanted to tell the silent uncaring world that "Is the Mainframe On" was published on the same day that we finally shut our last mainframe down forever. (sniff)
"Those who do not understand the mainframe are condemned to reinvent it, poorly." -- with apologies to Henry Spencer
Admin
As opposed to sending "I'm down!" whenever it crashed?
Admin