linprocfs – ain’t as easy as it sounds

I wanted to get linprocfs running on the dual opteron. I was setting up Cacti and a few of the features I am using requires access to linprocfs. First, let’s get the Linux Binary Compatibility:

# kldload linux
kldload: can't load linux: File exists

Eh? Really?

# kldstat
Id Refs Address            Size     Name
 1    4 0xffffffff80100000 9795b8   kernel
 2    1 0xffffffffbb3ca000 1402     fdescfs.ko
 3    1 0xffffffffbb3cc000 8e5      pflog.ko
 4    1 0xffffffffbb3cd000 2b914    pf.ko

Ahh, I must have it built in. Yes, I do. My kernel configuration file is:

include GENERIC

ident   OPTI
options SMP

options         IPI_PREEMPTION

options BREAK_TO_DEBUGGER
options ALT_BREAK_TO_DEBUGGER # CR ~ ^b (solaris style)

And… well, GENERIC includes linux compat:

# grep -i linux GENERIC
options         COMPAT_43               # Needed by COMPAT_LINUX32
options         COMPAT_LINUX32          # Compatible with i386 linux binaries
# Linux 32-bit ABI support

Ahh, well, that’s not the problem. Let’s try mounting…. But first add the entry to /etc/fstab:

linprocfs               /compat/linux/proc   linprocfs   rw     0       0

But first, make the directory:

mkdir -p /compat/linux/proc 
chmod -w /compat/linux/proc
mount /compat/linux/proc

Then all is well.

Now, let’s run the script:

# perl /usr/local/share/cacti/scripts/linux_memory.pl MemFree
cat: /proc/meminfo: No such file or directory

Well, that’s simple to fix (but don’t do this. see the comments):

[root@supernews:/] # ln -s /usr/compat/linux/proc /proc
[root@supernews:/] # perl /usr/local/share/cacti/scripts/linux_memory.pl MemFree
8100616[root@supernews:/] #

Now let’s see that Cacti run…

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

3 thoughts on “linprocfs – ain’t as easy as it sounds”

  1. [root@supernews:/] # ln -s /usr/compat/linux/proc /proc

    Uhh, now this is TOTALLY HARMFULL thing to do. Think about programs that expect FreeBSD style proc in /proc …

    Sounds like Cacti needs to be ported to use FreeBSD specific harvesting methods.

  2. Pav: I think this patch does the trick:

    [dan@ngaio:/usr/local/share/cacti/scripts] $ diff -ru linux_memory.pl~ linux_memory.pl
    --- linux_memory.pl~    Thu Feb 15 18:35:21 2007
    +++ linux_memory.pl     Thu Feb 15 18:35:21 2007
    @@ -1,6 +1,6 @@
     #!/usr/bin/perl
    
    -open(PROCESS, "cat /proc/meminfo | grep -w $ARGV[0] |");
    +open(PROCESS, "cat /compat/linux/proc/meminfo | grep -w $ARGV[0] |");
     foreach () {
            if ($_ =~ /($ARGV[0].*\s)(.*[0-9])( kB)/) {
                    print $2;
    [dan@ngaio:/usr/local/share/cacti/scripts] $
    

Leave a Comment

Scroll to Top