LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 08-17-2008, 07:20 AM   #1
ohcarol
Member
 
Registered: Dec 2004
Location: Nepal
Posts: 86

Rep: Reputation: 15
Net-Snmp perl scripts failed to open file


Hi,

I am trying to monitor my software RAID1 using snmpd exten command
below is my snmpd.conf file
extend raid-md0 /usr/local/bin/nagios-linux-swraid.pl --device=md0
================
root@localhost]snmpwalk -v2c -c public 127.0.0.1 NET-SNMP-EXTEND-MIB::nsExtendOutputFull

NET-SNMP-EXTEND-MIB::nsExtendOutputFull."raid-md0" = STRING: Can't open /proc/mdstat : Permission denied at /usr/local/bin/nagios-linux-swraid.pl line 56.
=======================
IT gives me permission denied opening file. File permission is r--r--r.
Attached sample scripts:
#!/usr/bin/env perl

# Get status of Linux software RAID for SNMP / Nagios
# Author: Michal Ludvig <michal@logix.cz>
# http://www.logix.cz/michal/devel/nagios
#
# Simple parser for /proc/mdstat that outputs status of all
# or some RAID devices. Possible results are OK and CRITICAL.
# It could eventually be extended to output WARNING result in
# case the array is being rebuilt or if there are still some
# spares remaining, but for now leave it as it is.
#
# To run the script remotely via SNMP daemon (net-snmp) add the
# following line to /etc/snmpd.conf:
#
# extend raid-md0 /root/parse-mdstat.pl --device=md0
#
# The script result will be available e.g. with command:
#
# snmpwalk -v2c -c public localhost .1.3.6.1.4.1.8072.1.3.2

use strict;
use Getopt::Long;

# Sample /proc/mdstat output:
#
# Personalities : [raid1] [raid5]
# md0 : active (read-only) raid1 sdc1[1]
# 2096384 blocks [2/1] [_U]
#
# md1 : active raid5 sdb3[2] sdb4[3] sdb2[4](F) sdb1[0] sdb5[5](S)
# 995712 blocks level 5, 64k chunk, algorithm 2 [3/2] [U_U]
# [=================>...] recovery = 86.0% (429796/497856) finish=0.0min speed=23877K/sec
#
# unused devices: <none>

my $file = "/proc/mdstat";
my $device = "all";

# Get command line options.
GetOptions ('file=s' => \$file,
'device=s' => \$device,
'help' => sub { &usage() } );

## Strip leading "/dev/" from --device in case it has been given
$device =~ s/^\/dev\///;

## Return codes for Nagios
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);

## This is a global return value - set to the worst result we get overall
my $retval = 0;

my (%active_devs, %failed_devs, %spare_devs);

open FILE, "< $file" or die "Can't open $file : $!";

while (<FILE>) {
next if ! /^(md\d+)+\s*:/;
next if $device ne "all" and $device ne $1;
my $dev = $1;
====================REST is scraped================
 
Old 08-17-2008, 07:32 AM   #2
RaelOM
Member
 
Registered: Dec 2004
Posts: 110

Rep: Reputation: 16
What is the perms on /proc?
 
Old 08-17-2008, 07:48 AM   #3
ohcarol
Member
 
Registered: Dec 2004
Location: Nepal
Posts: 86

Original Poster
Rep: Reputation: 15
This is permission of proc

dr-xr-xr-x 97 root root 0 Aug 12 14:37 proc
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to configure ucd-snmp and net-snmp? Tazzmanian Linux - Networking 1 05-27-2005 08:09 AM
NET-SNMP vs UCD-SNMP nitind Red Hat 1 05-20-2005 06:08 AM
net-snmp : perl(tk) shivaligupta Linux - Software 0 02-03-2005 11:18 AM
perl, Net::Ftp, and Novell file modification time neo77777 Programming 0 01-30-2003 09:41 PM
snmp (ucd-snmp, net-snmp) markus1982 Linux - Software 1 11-21-2002 10:45 AM


All times are GMT -5. The time now is 09:07 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration