LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Closed Thread
 
Search this Thread
Old 08-10-2010, 03:38 AM   #1
koshihaku
Member
 
Registered: Aug 2010
Posts: 50

Rep: Reputation: 0
Use of uninitialized value in pattern match (m//)


> I am running the following code and receiving the warning :
>
> Use of uninitialized value in pattern match (m//) at processMonitor.pl line 38
>
>
> processMonitor.pl:







#!/usr/bin/perl -w
#
#name: processMonitor.pl
#written by trizsolo
#usage: ./processMonitor.pl args args args
#you can add as many processes as needed for args
#or use the defaults... syslogd is always checked
#----------------------------
my $user='root';
my $host=`hostname`;
chomp($host);
my $date=`date`;
chomp($date);
my $logfile="$host" . '.log';
our @proc_list=@ARGV;
# Default list of processes
if(@proc_list==0){ # check for arguments
@proc_list=('inetd', 'sendmail', 'chkMounts.pl');
}
push(@proc_list, 'syslogd'); # add syslogd to check

# ---------- open logfile and determine Operating System --------------
open(LOG, ">>$logfile") or die "Can't open $logfile to write: $!";
print LOG "Searching for: @proc_list on $date!\n";
chomp($os=`uname -r`);
print LOG "OS on this server is $os\n";
close(LOG);

# ---------------- call "ps" & analyse output --------------------
foreach my $process (@proc_list) {
$event_count{$process} = 0;
}
open(PS, "/bin/ps auwx |") or die "Can't run ps: __FILE__ $!";
$/="\n"; # record seperator
while(
) {
foreach my $process(@proc_list) {
if($_ =~(m/$process/i)) {
$event_count{$process}++;
}
}
}
close(PS);
open(LOG,">>$logfile") or die "Cannot open $logfile: $!";
# Add line to log to nagios if needed
foreach $process(@proc_list) {
if($event_count{$process} ==0) {
print LOG "Process $process is NOT running!\n";
system("/bin/logger -p warn Process: $process is NOT running!\n")
== 0 or die "Cannot complete cmd: $! : $?";
}else{
print LOG "Process $process occurred $event_count{$process} times!\n";
}
}
close(LOG);
exit 0;
#EOF




please help
 
Old 08-10-2010, 03:53 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Hello,

Please stick to one thread per problem/question. Double posting will not help you any faster but on the other hand will confuse you a lot more. Stick to your first thread discussing the same problem/question, where users have already posted and keep the conversation in one place please.

Kind regards,

Eric
 
Old 08-10-2010, 02:07 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


http://www.linuxquestions.org/questi...6/#post4061545
 
  


Closed Thread


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
Match pattern and replace sol_nov Programming 7 11-30-2009 09:23 PM
[SOLVED] Adding (not replacing) a pattern match with a similar pattern? b-bri Linux - Newbie 2 08-31-2009 01:36 AM
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 07:17 AM
pattern match : korn shell tostay2003 Programming 1 12-31-2008 01:08 PM
perl pattern match question lluciano Programming 4 02-28-2006 06:59 AM


All times are GMT -5. The time now is 05:47 PM.

Main Menu
Advertisement
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