Using C Language in monitoring
“C Programming language” (or simply C Language) is the title of the book published in 1978 by Brian W. Kernighan and Dennis M. Ritchie, where they introduced the idea of presenting an example program called “Hello world !” And that is today a common model in almost every tutorial for programming, regardless of the language used.
Perhaps from there comes the idea of C language omnipresence. The book presented many paradigms, or at least several writing styles that we still use today. But C Language also has a dark past that will surprise you.
Legend: “C Programming Language https://commons.wikimedia.org/wiki/File:The_C_Programming_Language_logo.svg”
BASIC language and the ABC of programming
I learned BASIC Language from Thomas E. Kurtz and John G. Kemeny through a book. When computers finally came into our daily lives (long story), what I had at hand was the Microsoft Quick Basic® (not to be confused with Microsoft QBasic®, that one came much later) and I used for a little while Microsoft GW-BASIC®. In 1990, we learned in college about the ANSI C specification, which had come out the previous year, but there, in engineering degrees, we were so into Pascal Language for pragmatic reasons. Shortly thereafter, we moved to Microsoft Visual Basic® to then reach a turning point in proprietary programming: Microsoft Visual Studio 97®, the first office suite with several languages, including Java and C++ (yes, from this last one Rust Language was “born” in 2010, with which the popular Mozilla Firefox® browser is compiled).
Up until that point, C Language had grown enough to evolve, but where does it really come from? Although there was never an “A Language” as such, what did exist was the “Basic Combined Programming Language” or BCPL ( O Intermediate Language included) which later transformed into B Language, but both were not enough for the new hardware (I may be simplifying this too much, and historians may start chasing me with torches and sickles). It turns out that, in 1969, they invented the PDP-7 computer, with which Unix® was born the following year. The next computer was the PDP-11, with which they could execute C Language to rewrite Unix®, and that is how the legend was born in 1972.
What the programmers realized was that C Language could be implemented in many different hardwares. The task was not, nor it is easy, in fact, it is still a burdensome task. But if you want something very well structured and well founded, C Language is what you’re looking for.
But be careful, C Language is so far, or rather abstracted from hardware, that there may be serious problems later. It makes you come a lot closer to the hardware, so much that it makes you understand more and more about different electronic components. That is the good thing about it and it can be of help in the monitoring field, especially in the industry area.
Hardware, software and C Language
C Language has a problem very similar to what we reported in a previous article about hardware: a serious issue related to access to memory (Random Access Memory or RAM). If you have an assigned memory range, say from 100 to 200, if you perform a cycle up to 201, you will suffer major inconveniences. So, they make programs that delve beyond what they are supposed to on purpose, and C Language allows it. Another problem is variable initialization. It is assigned a place in memory, but the value that was in that sector is not “deleted.” Look at the quotation marks: you must type in the initial value you need in each variable: if it is numerical, zero (usually), but if it is a date, there you may have problems.
This leads to another problem: handling variables that handle different types of data, for example “adding” a date with a text string. The fourth main problem is to release some variable and then re-access it: there is no warning or error warning, if you are lucky enough and the operating system doesn’t use that memory sector where your variable is, you won’t even notice it, but at some point your algorithm will fail.
Although C++ comes from C Language, I should make clear that the first one is object oriented and the second is structured programming oriented. Therefore, it is useful for our purpose of building small scripts for monitoring. Although it would take a whole article to describe both programming models, I can tell you that C++ includes structured programming but uses objects to take advantage of the most advanced hardware we currently have, especially that with multiple cores.
Not everything is lost
Do you remember that we mentioned Pascal language and its use in engineering? Well, this language does not allow operations between different types of variables. In addition, its math oriented syntax makes it useful for that field. However, it also suffers from what has been said about the exceptions of C Language.
Nowadays, there are modern and safe languages such as Rust (inspired on C++) and even Swift Language (inspired on Rust itself with Haskell, Ruby, Python and C#) that get rid of all these “inconveniences” from memory management. But the hundreds of millions of code lines made in C Language (see Linux kernel project, for example) would make it necessary to create another language specifically for migration. Therefore, nowadays, people work on a progressive change basis, which is better: slow but sure.
For these reasons, we include C in our list of the most used languages and whenever you have to monitor at some high point, you may use it confidently, although the work will be hard (they say that with C Language you have to reinvent the wheel, but I say we can even make octagonal wheels if we need them to be that way).
We provide lots of flexibility in terms of languages: for example, when creating a remote inventory module, you may either use C++ or even Java. The key is that, regardless of the language used, it returns a value with a specific format. Even our agents are created with C++ and Perl!
If you are interested in knowing better the scope of Pandora FMS, we encourage you to click on this link.
In case of having more than 100 devices to monitor, you may contact our Pandora FMS team through the following form.
Also, remember that if your monitoring needs are more limited, you have at your disposal the OpenSource version of Pandora FMS. Find out more here.
Traductora a francés e inglés. Me encantan las lenguas. Amante de la ropa oversize, la tarta de queso y el chocolate caliente en invierno. Me gusta leer, escuchar música, viajar y explorar cosas nuevas. Mi frase más temida por aquellos que me conocen es “he estado pensando…”
Translator into French and English. I love languages. Lover of oversized clothes, cheesecake and hot chocolate in winter. I like reading, listening to music, travelling and exploring new things. My most feared phrase by those who know me is “I’ve been thinking…”