[Xymon] [Newbie] Smaller, lighter Xymon based program?
Hi James,
On Mon, 26 Nov 2012 18:44:48 -0800, James <kfc.android at gmail.com> wrote:
The reason why I want to modify Xymon is because I'm working on a small class project which only need a simple networking-related function (in my case: ping) with minimal size of code. [snip] My optimal goal is: to use minimal amount of code to perform a ping test, but keep the framework and style of Xymon. (Now I'm reading Xymonping.c file under /xymonnet folder)
I think those are somewhat conflicting goals; keeping a Xymon style "framework" will require more work than what is really necessary for a "small class project".
My guess is that the primary focus of your project is to show that you understand some network programming, rather than prove that you understand the details of Xymon - although I would be personally flattered if Xymon became mandatory teaching :-)
My advice to you would be:
Is it a requirement to use ping as the network test, or could you use a TCP connection as the network test ? ping is a bit complicated, because the normal network programming API's don't support it directly - you have to more or less construct the contents of each packet yourself. The socket API in Unix (or Winsock on Windows) have much better support for a normal transport-layer protocol - TCP - so that would allow you to show that you understand network programming, rather then getting bogged down with the details of ICMP packet request/response formats.
If you are allowed to use normal TCP connections for your network test, try writing some code using the Unix socket API and non-blocking sockets. I.e. you need to use the socket(), connect(), select(), read(), write() and close() API's - plus the various little details of getting all the data structures setup correctly. There must be lots of sample code for this - not least the "select_tut(2)" man-page in Linux - but for Xymon code look at lib/sendmsg.c the "sendtoxymond()" routine, or xymonnet/contest.c file "do_tcp_tests()". The first one is good to understand the basics, because it does one connection at a time; the xymonnet/contest.c code is a bit more complicated, because it juggles multiple connections at once. With TCP, you can use a connection to e.g. port 80 (web) or some other port - possibly something user-configurable on a per-host basis.
If you must use ping, then xymonping.c borrows heavily from fping, so have a look at that code as well.
Once you know how to check if you can connect/ping a host, then you can decide what the configuration file should be like, and how the test results can be reported. If you want something "xymon-like", then perhaps you can just generate a simple webpage listing the test result, so it gets updated whenever your test-program runs.
Regards, Henrik
PS: I know this does go a bit off-topic for the Xymon list, but we've all had to learn things at some point. So I'm just trying to guide the newbies in the right direction :-)
On Mon, December 3, 2012 07:18, henrik at hswn.dk wrote:
PS: I know this does go a bit off-topic for the Xymon list, but we've all had to learn things at some point. So I'm just trying to guide the newbies in the right direction :-)
It was a wonderful response. I'm proud to be associated with you, however loosely.
Hi Henrik,
Got midterms these days, so it's a little bit late to reply this post. By the way, it's my great, great honor to get your reply :P
*"My guess is that the primary focus of your project is to show that you* *understand some network programming, rather than prove that you understand the details of Xymon - although I would be personally flattered if Xymon became mandatory teaching :-)"* * * For the part regarding project goal: It is very true that the purpose of our class project is to demonstrate that we have some kind of network programming skill, but if we can demonstrate a very good understanding on Xymon will also be considered as good project. Based on my personal opinion, Xymon is capable to perform many tests and it's not just several files of code, thus, it may take me months to understand the whole thing. Hence, I was thinking about to show a good understanding regarding a part(or function) of Xymon (ping, in this case, is just my idea)
*"Is it a requirement to use ping as the network test, or could you use a TCP connection as the network test ? ping is a bit complicated, because the normal network programming API's don't support it directly - you have to more or less construct the contents of each packet yourself. The socket API in Unix (or Winsock on Windows) have much better support for a normal transport-layer protocol - TCP - so that would allow you to show that you understand network programming, rather then getting bogged down with the details of ICMP packet request/response formats."*
Since you mentioned ping test is more complicated, while TCP is easier to perform, I will definitely ask my professor on next class meeting. Since this class project is just to show we have certain network programming and we are all newbies to this field, I guess the chance to do TCP connection test is very high.
By the way, it takes time for me to digest your code-writing suggestions, but I really appreciate that suggestion because it points out a direction that I can work on. I was like a blind without your suggestion. I wonder is that okay if I send you some e-mail regarding network programming questions? I afraid the content may be too easy and not related to this mailing list.
Last but not least, as I'm working on this project, I will keep everyone whoever interested posted, who knows maybe someone will be asked to do the same/similar project like us.
Thanks again, Henrik, my classmate won't believe who I got reply from.
Best, James
2012/12/3 <henrik at hswn.dk>
Hi James,
On Mon, 26 Nov 2012 18:44:48 -0800, James <kfc.android at gmail.com> wrote:
The reason why I want to modify Xymon is because I'm working on a small class project which only need a simple networking-related function (in my case: ping) with minimal size of code. [snip] My optimal goal is: to use minimal amount of code to perform a ping test, but keep the framework and style of Xymon. (Now I'm reading Xymonping.c file under /xymonnet folder)
I think those are somewhat conflicting goals; keeping a Xymon style "framework" will require more work than what is really necessary for a "small class project".
My guess is that the primary focus of your project is to show that you understand some network programming, rather than prove that you understand the details of Xymon - although I would be personally flattered if Xymon became mandatory teaching :-)
My advice to you would be:
Is it a requirement to use ping as the network test, or could you use a TCP connection as the network test ? ping is a bit complicated, because the normal network programming API's don't support it directly - you have to more or less construct the contents of each packet yourself. The socket API in Unix (or Winsock on Windows) have much better support for a normal transport-layer protocol - TCP - so that would allow you to show that you understand network programming, rather then getting bogged down with the details of ICMP packet request/response formats.
If you are allowed to use normal TCP connections for your network test, try writing some code using the Unix socket API and non-blocking sockets. I.e. you need to use the socket(), connect(), select(), read(), write() and close() API's - plus the various little details of getting all the data structures setup correctly. There must be lots of sample code for this - not least the "select_tut(2)" man-page in Linux - but for Xymon code look at lib/sendmsg.c the "sendtoxymond()" routine, or xymonnet/contest.c file "do_tcp_tests()". The first one is good to understand the basics, because it does one connection at a time; the xymonnet/contest.c code is a bit more complicated, because it juggles multiple connections at once. With TCP, you can use a connection to e.g. port 80 (web) or some other port - possibly something user-configurable on a per-host basis.
If you must use ping, then xymonping.c borrows heavily from fping, so have a look at that code as well.
Once you know how to check if you can connect/ping a host, then you can decide what the configuration file should be like, and how the test results can be reported. If you want something "xymon-like", then perhaps you can just generate a simple webpage listing the test result, so it gets updated whenever your test-program runs.
Regards, Henrik
PS: I know this does go a bit off-topic for the Xymon list, but we've all had to learn things at some point. So I'm just trying to guide the newbies in the right direction :-)
-- Best, James
participants (3)
-
henrik@hswn.dk
-
hobbit@epperson.homelinux.net
-
kfc.android@gmail.com