Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


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

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


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

NET-SNMP-EXTEND-MIB::nsExtendOutputFull."raid-md0" = STRING: Can't open /proc/mdstat : Permission denied at /usr/local/bin/ 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 <>
# 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/ --device=md0
# The script result will be available e.g. with command:
# snmpwalk -v2c -c public localhost .

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

## 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, 08:32 AM   #2
Registered: Dec 2004
Posts: 110

Rep: Reputation: 16
What is the perms on /proc?
Old 08-17-2008, 08:48 AM   #3
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


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 09:09 AM
NET-SNMP vs UCD-SNMP nitind Red Hat 1 05-20-2005 07:08 AM
net-snmp : perl(tk) shivaligupta Linux - Software 0 02-03-2005 12:18 PM
perl, Net::Ftp, and Novell file modification time neo77777 Programming 0 01-30-2003 10:41 PM
snmp (ucd-snmp, net-snmp) markus1982 Linux - Software 1 11-21-2002 11:45 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:57 PM.

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