FreeBSD Monitoring

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
bb
Posts: 8
Joined: Sun Feb 10, 2002 7:00 pm
Location: USA

Post by bb »

Check this:
http://www.raxnet.net/board/viewtopic.p ... &forum=1&7

Look at the bottom it tells how to get meminfo working. Some of the other scripts are fixed by just looking at them and changing the paths.

I would be nice to fix all the scripts and get them to rax as a bsd download.
User avatar
digger
Posts: 23
Joined: Tue Mar 05, 2002 7:00 pm
Location: Ft. Thomas, KY
Contact:

Post by digger »

Out of curiosity, why have you left Solaris for FreeBSD o nthis one? I am evaluating Cacti on a Linux box ( and yes even it needs some of the sripts re-written) but I may end up implimenting this on Solaris. Have you come accross issues with this and Solaris and/ or HP-UX?
frnht451

alternative way to get meminfo

Post by frnht451 »

Just installed Cacti,

-----------------------------------------------------
#!/usr/bin/perl

@top = `top`;

$line = 3;
$line = 4 if ($ARGV[0] =~ s/Swap//);

$top[$line] =~ /(\d+)\w $ARGV[0]/;

print $1;
------------------------------------------------------

seems to work ok for the meminfo, need to change the 'grep' params in cacti config.

Could probably do it better but I didn't redirect std err in the cron job so it was emailing me every 5 minutes :)
Chainey

Post by Chainey »

Seems ping needs -c arg before IP address in BSD.. swap the args in the code or the config.. to swap in the code (which seems to be the logical 0,1 progression)

<cacti>/scripts/ping.pl

------------------------------------------------------
#!/usr/bin/perl

if ($ARGV[0]=="x") {
$db = ":0";
$ARGV[0] = 2;
}

$response = `ping -c $ARGV[0] $ARGV[1] |grep round-trip| awk '\{print \$4 \}' | aw
k -F / '\{print \$1 \}' | grep -v "Warning"`;
chomp $response;
$response = $response;
print "$response$db";
------------------------------------------------------

Had to change the webhits access log path in the DB as well. There is a default value in webhits.pl if eq "", which you can change as well.

HTH :)

-=Chainey
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

Oooh very nice scripts being accumulated here. I will have to include them in a future cacti release along with the other scripts I have been receiving lately (thanks!). Anyone have a shell account on a BSD/Solaris box I borrow to test these out? Thanks for all of the help.

-Ian
ross
Posts: 16
Joined: Sun Mar 17, 2002 7:00 pm

Post by ross »

here is my FreeBSD script i wrote. It does req Linux emulation. (Just install the linux_base, i beleave linux_base-7.1_2 is the latest. Then just add "linprocfs /compat/linux/proc linprocfs rw 0 0" to your /etc/fstab file)

here is the script, i tried to make it editable as much as possible to work across most platforms. So it should be easy for any avg joe to set up.

http://www.degodehjelperne.no/~ross/fbsd-stats.txt




Yo rex shoot me a mail at evilk@ozline.net and i'll give yea an account on my box.

ross
gwynnebaer
Posts: 35
Joined: Sat Apr 13, 2002 5:16 pm
Location: Santa Barbara, CA

Post by gwynnebaer »

raX wrote:Oooh very nice scripts being accumulated here. I will have to include them in a future cacti release along with the other scripts I have been receiving lately (thanks!).
-Ian
Here's a few more:

my rewrite of loadavg.pl (only need the one script, not _multi also), and all perl except for uptime call...)

Code: Select all

#!/usr/bin/perl

# get load uptimes for 1;5;15 min
# usage: loadavg.pl 1|5|15|all|debug
chomp($uptime = qx(uptime));
$uptime_raw = $uptime;
$uptime =~ s/.*:\s+|,//g;
@uptime = split(/\s+/,$uptime);

for ($ARGV[0]) {
        /^1$/ && print $uptime[0];
        /^5/ && print $uptime[1];
        /^15/ && print $uptime[2];
        /all/ && print $uptime;
        /debug/ && do { print "UPTIME: $uptime_raw\n",
                              "5MIN:    $uptime[0]\n",
                              "15MIN:   $uptime[1]\n",
                              "30MIN:   $uptime[2]\n"; };
}

exit 0;
my all-perl rendition of webhits.pl:

Code: Select all

#!/usr/bin/perl

# reads in apache (or any) logfile and returns either 0 or number of lines
$lines = 0;

unless ($ARGV[0]) {
        $log_path = '/var/log/httpd/access_log';
} else {
        $log_path = $ARGV[0];
}


if (-r $log_path) {
        open(LOG_PATH,$log_path);
        while (<LOG_PATH>) {
                $lines++;
        }
        close(LOG_PATH);
}

print $lines;
my 99.9% perl version of proc.pl:

Code: Select all

#!/usr/bin/perl

# returns number of open processes from 'ps' output

open(PROCS,'/bin/ps ax |');
while (<PROCS>) {
        $procs++;
}
close(PROCS);

$procs--;

print $procs;
my all-perl FreeBSD/Linux compliant memfree.pl:

Code: Select all

#!/usr/bin/perl

if (-r '/proc/meminfo') {
    $procfile = '/proc/meminfo';
} elsif (-r '/compat/linux/proc/meminfo') {
    # FreeBSD Linux emulation
    $procfile = '/compat/linux/proc/meminfo';
} else {
    # this only works for Linux or FreeBSD (with linux emulation)
    exit(1);
}

open(PROCFILE,$procfile);
while (<PROCFILE>) {
    chomp();
    if (/^$ARGV[0]/) {
        s/^$ARGV[0]:?\s+(\d+).*/$1/g;
        print;
        last;
    }
}
close(PROCINFO);

I'll have more soon. Just returning some of the love...

-gwynnebaer
raX
Lead Developer
Posts: 2243
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

Post by raX »

Excellent! I think I am going to start collecting these on the raXnet page as I get them. I am starting to accumulate quite a few. Thanks everyone for the help!

-Ian
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests