Getting System Information from Linux
November 10, 2008 on 3:37 pm | In Programming | By QBasicer | 2 CommentsMost of the information I gather for my Linux version of my uptime program comes from procfs.
/proc/sys/kernel/hostname
Provides me the one word hostname of this kernel. I’m planning on switching this and /proc/version to a uname() syscall (see man 3 uname) to provide better compatibility on systems without /proc.
/proc/uptime
Provides me the raw number of seconds (including factional) since the computer booted, as well as the total number of seconds this computer has been idle (the second bit I discard)
/proc/loadavg
Provides me with the three load averages
/proc/version
Provides me with a long kernel version, which is different than the one supplied by uname -a.
/proc/meminfo
I get all of my memory information from here, but I don’t use all of the information available to me. Most of it is pretty useless, but I do get:
- Total Memory
- Buffered Memory
- Cached Memory
- Free Memory
- Total Swap
- Free Swap
I get ‘memory used’ from the formula: “int memused = memtotal - cached - buffers - memfree;”
Managing Computer Health in Multiple Places
October 31, 2008 on 10:27 am | In Programming | By QBasicer | 2 CommentsI have a few computers under my control. Unfortunately, not all of them are in the same room. Actually, most are spread all around the country. I have essentially two computers under my direct control, with a few others that I tend to use.
It becomes very important when you start needing these computers to do tasks, such as serve up websites, provide SSH servers, or other such services. Unfortunately, power interruptions, and crashes do happen. A lot of times, if a server goes down, you need to wait until you can get somebody to physically press the button if it’s remote, or provide some details on network access (did just the network go down, or did the actual computer go down, or both). Collecting information about a server after it has gone down is a trivial task, just look through the logs. The big crunch here is, what about real-time outage information? Having a server “ping” a webpage every 5 minutes, uploading the latest load average, memory information, disk usage, uptime, and system log information should provide adequate information to provide a decent report on system health.
Over the weekend, I want to see if I can write some code and set up a little site where I can monitor all my computers, and maybe even try and send commands to them (security and authentication being somewhat of a problem here).
Update: I started work on this on the weekend, and I already have it working. Visit data.vectec.net/uptime for live uptime information for three of my Linux computers (Mac OSX coming soon I hope).
Poor Man’s Build Farm
May 12, 2008 on 12:01 pm | In Programming | By QBasicer | No CommentsBuild farms are kinda cool, I deal with one at work. Unfortunately, it’s large, complicated, and very task specific. I did a quick google search, and didn’t find much in alternatives. I’d really like a system which:
- Has an HTTP interface for submitting jobs, getting results, etc
- Allows for any project to be built providing it has a makefile
- Automatic and dynamic resource management
- Relatively simple in implementation usage
The resource management is probably the most curious. Say I’m at a lab computer at school, and I want to use that as a build machine, I would like to be able to run a daemon, which given the right server address and password, will become avilable in the build menu when you submit a job.
There are security problems though. How do you prevent unauthorized users from submitting malicous code? You really can’t, unless you have trusted users. Big companies like SourceForge can afford to create build farms, and probably run the compile in a chrooted environment, but if the disk gets hosed, so what? Just reimage the disk and you’re good to go. Obviously with such distributed systems that really is more of a peer system, that isn’t possible. For example, my own personal laptop could become a build machine.
Of course, ultimately the other option is tarballing the source and emailing it around and getting people to test it on their machines, but that might not that be that easy.
Just a thought.
Fibbing Around
April 24, 2008 on 10:45 pm | In Personal, Programming | By QBasicer | No CommentsMy officemate Alexei and I were wondering a bit on how fast Fibonacci in assembly would be, so I wrote a quick little linear fib application in Linux.
08048074 <_start>: 8048074: 31 c0 xor %eax,%eax 8048076: bb 01 00 00 00 mov $0x1,%ebx 804807b: ba 01 00 00 00 mov $0x1,%edx 08048080 <_calc>: 8048080: 31 c9 xor %ecx,%ecx 8048082: 01 c1 add %eax,%ecx 8048084: 01 d9 add %ebx,%ecx 8048086: 89 d8 mov %ebx,%eax 8048088: 89 cb mov %ecx,%ebx 804808a: 42 inc %edx 804808b: 83 fa 2e cmp $0x2e,%edx 804808e: 75 f0 jne 8048080 <_calc> 8048090: 89 cb mov %ecx,%ebx 8048092: b8 01 00 00 00 mov $0x1,%eax 8048097: cd 80 int $0x80
Runs pretty quick, but I’m not sure how good it would be, as it’s only using 32 bits, so it can only calculate fib(46) and lower, and doesn’t even output (that’s a bit trickier).
Smallest Hello World
April 23, 2008 on 10:04 am | In Personal, Programming | By QBasicer | No CommentsIn what turned out to be an assembly vs Java comparison of hello world, I’ve managed to get a hello world app down to a lean 380 bytes. objdump -d:
hello.bin: file format elf32-i386 Disassembly of section .text: 08048094 <.text>: 8048094: ba 0c 00 00 00 mov $0xc,%edx 8048099: b9 b8 90 04 08 mov $0x80490b8,%ecx 804809e: bb 01 00 00 00 mov $0x1,%ebx 80480a3: b8 04 00 00 00 mov $0x4,%eax 80480a8: cd 80 int $0x80 80480aa: bb 00 00 00 00 mov $0x0,%ebx 80480af: b8 01 00 00 00 mov $0x1,%eax 80480b4: cd 80 int $0x80
Can you do better? This hello world does not link to any outside libs like stdlib, and only uses kernel system calls. We were able to get a java 6 compiled class to 517 bytes, but I’m not sure if I could make it smaller (Java bytecode maybe?)
Edit: I found a page on creating really small ELF executables for linux. They don’t say hello world, but it could be easily modified if you knew how to translate AT&T to Intel. I really can’t remember, or have the ambition to do so, so I’ll just link
Application Development Preferences
April 15, 2008 on 1:27 pm | In Programming | By QBasicer | 3 CommentsYou’re going to be writing an app. The biggest question is what language will you use?
For some people, it’s a nobrainer, it’s either Java, C++, or other language. What would you use? Usually it has to depend on what the app is for. Lets just say a simple chat client that’s cross platform.
That narrows down the playing field to a few choices:
Java:
- SWT
- AWT
- Swing
CLR (C#, VB, etc):
- Winforms
C/C++
- wxWidgets (GTK)
- Qt
Which would you use, and why? Personally, I like the C/C++ route. I’ve delt with both wxWidgets and Qt, and find both offerings pretty nice. I really like how Qt works over wx, but that’s just personal preference.
Java is getting better these days, but I feel that application start time is still a big issue, as well as memory usage, although these are supposedly getting better. The other issue with Java is that it usually requires people to go and download a JRE before usage, while if you static compile the C/C++ libs, you don’t usually need any extra dependencies (or even just package the dll’s/so’s along with the main executable).
So what about you, oh general audience, what would you choose, and why?
Dump the GC
March 27, 2008 on 10:39 am | In Personal, Programming | By QBasicer | 4 CommentsIronically, what some say that the Java Garbage Collector is one of the best features of the language. For some people, yes, but as a C/C++ programmer, I’m more accustomed to managing my own memory. In fact, I think it’s almost insulting to have to rely on the virtual machine’s ability to guess when I’m done with an object. I’d personally really like to see the ability to switch the gc into manual mode, where there is no automatic collection of garbage, and you must specifically call a delete command.
And don’t give me any nonsense on nulling objects. Really. I currently am using a library that when I null the only pointer to it, it persists in memory. There’s nothing I can do about the 700 megs of memory it takes up while loaded. I can see that in an attempt to be smart, it’s stupid. Save me the clock cycles, and just let me do it myself. Please.
Ease Of Access
March 19, 2008 on 9:56 am | In Programming, ZDLSharp | By QBasicer | 1 CommentA few modifications I’m making to the interface of qZDL should greatly improve the usability. I’m switching from mainly dialog based down to mainly tab based. Instead of going to ZDL -> Options, there is now a settings tab along the top, that is ALMOST identical to the options dialog of ZDLSharp. The only change I’m making is I’m moving out the update log to it’s own update tab.
People that previously found ZDLSharp too cramped will rejoyce in that now that everything is resizable. You can, in fact, have a full screen ZDL if you chose. Of course, I need add functionality to remember the size last used, although this is trivial. The actual sizing information will be stored globally, and not locally. I’ll use the local operating system’s built preferencing system (using Qt, of course).
I also plan on enhancing the update system, although not right away. It’s pretty stupid, and I’d like to see changelog viewing from inside the app itself. Also, ‘Remind me later’, and ‘ignore this release’, and both of those functions require me to rewrite the php update script (not a big deal).
That’s pretty much most of the planned changes in a nutshell. The new INI backend will IMHO, be one of the most welcome features.
Missing Feature?
March 15, 2008 on 5:48 pm | In Programming, ZDLSharp | By QBasicer | 2 CommentsFor as long as there’s been an update checker in ZDLSharp, I’ve included ZDLSharp in the User-Agent field of the HTTP requests. With this, I also send out the OS type and verson, so I can easily target specific operating systems better. Come to find out, Qt has no easy to way to get some of that information, such as windows major, minor, release, and build IDs. The QSysInfo class isn’t much help either, it just provides a variable that maps to some constant, which is NOT fun at all. Also, that works for Windows and Mac only, so I have no idea what else is going on. I’d have to check: Win32, WinNT, WinCE, Mac, and then deduce that it’s Linux. Not particularly the best way to do it. I may have to try and write my own cross platform versioning stuff, because this is just unreal, and a complete oversight in my books.
References:
http://lists.trolltech.com/qt-interest/2003-06/msg01237.html
http://lists.trolltech.com/qt-interest/2005-09/msg00741.html
ZDL, on a Mac?!
March 10, 2008 on 8:52 am | In Programming, ZDLSharp | By QBasicer | 1 CommentAfter 10 hours of compiling Qt, qZDL compiled cleanly inside Tiger. First I’d like to note that I previously hadn’t been targeting the Mac audience at all. Now that I’m using Qt, I can safely do so, and make some interface changes to better suit their needs. Right now it’s lifted directly from Win32/Linux, but there’s a lot of changes that need to be made first. Here’s a screenshot:
![]()
Powered by WordPress with Pool theme design by Borja Fernandez. I rewrote the CSS because I'm cool like that.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^
