- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl script to monitor a running log for a partic...
Operating System - HP-UX
1758020
Members
2239
Online
108866
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 10:02 AM
тАО01-22-2003 10:02 AM
In perl or Shell script, how would I do this.
Everytime a page is sent out to a customer, the following last 2 lines (see below) are printed in the page log after the text message,if the page was successful.How do I monitor the log so that "Page Sent" line should always be followed by "Request Successful" line. If the line that contains "Page Sent" is followed by anything else then send mail to admin@abc.com with subject "PAGING ERROR". I guess I would run the script as:
tail -f page.log | monitor.pl &
page.log
------------cut-----------------
"Customer having problems with workstation"
Page Sent
Request Successful
------------cut-----------------
Everytime a page is sent out to a customer, the following last 2 lines (see below) are printed in the page log after the text message,if the page was successful.How do I monitor the log so that "Page Sent" line should always be followed by "Request Successful" line. If the line that contains "Page Sent" is followed by anything else then send mail to admin@abc.com with subject "PAGING ERROR". I guess I would run the script as:
tail -f page.log | monitor.pl &
page.log
------------cut-----------------
"Customer having problems with workstation"
Page Sent
Request Successful
------------cut-----------------
good judgement comes from experience and experience comes from bad judgement.
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 11:24 AM
тАО01-22-2003 11:24 AM
SolutionHow do you prevent multiple simultaneous pages from wacking the log?
OF COURSE It makes more sense to change the program that is paging to "email" paging errors.
try this as a start
#!/opt/perl/bin/perl
#
$pagesent = 0;
while (<>) {
chop;
if ( ($pagesent) && (! m/^Request Successful/) ) {
printf("Error Error, panic\n");
}
$pagesent=0;
if (m/^Page Sent/) {
$pagesent=1;
}
}
live free or die
harry
Live Free or Die
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 02:15 PM
тАО01-22-2003 02:15 PM
Re: Perl script to monitor a running log for a particular message
Thanks a bunch Harry. That works great. A little twist now. How would you change the script so that only email me if the log does NOT have the following 2 lines in succession.
----cut----
Page Sent
Request Successful
-----cut----
What happens is, many times we see the line
"Page Sent" in the log but a blank line followed by it. (That tells us the page did not go).
If "Page Sent" line is followed by a line anything other than "^Request ", I need to get emailed. Otherwise, do not do anything.
Right now, I have modified your script to email me only if
----cut----
Page Sent
Request Successful
-----cut----
appear right after another. Right ? How would you reverse the logic.
---------------------cut-------------
#!/usr/bin/perl
#
$pagesent = 0;
while (<>) {
chop;
if ( ($pagesent=0) && (! m/^Request/) ) {
printf("Error Error, panic\n");
}
$pagesent=0;
if (m/^Page Sent/) {
$pagesent=1;
open MAILER, "|mailx -s 'PAGE ERROR' sam_p\@dom.com";
print MAILER "ERROR IN PAGE"
close MAILER;
}
}
-------------cut----------------------
----cut----
Page Sent
Request Successful
-----cut----
What happens is, many times we see the line
"Page Sent" in the log but a blank line followed by it. (That tells us the page did not go).
If "Page Sent" line is followed by a line anything other than "^Request ", I need to get emailed. Otherwise, do not do anything.
Right now, I have modified your script to email me only if
----cut----
Page Sent
Request Successful
-----cut----
appear right after another. Right ? How would you reverse the logic.
---------------------cut-------------
#!/usr/bin/perl
#
$pagesent = 0;
while (<>) {
chop;
if ( ($pagesent=0) && (! m/^Request/) ) {
printf("Error Error, panic\n");
}
$pagesent=0;
if (m/^Page Sent/) {
$pagesent=1;
open MAILER, "|mailx -s 'PAGE ERROR' sam_p\@dom.com";
print MAILER "ERROR IN PAGE"
close MAILER;
}
}
-------------cut----------------------
good judgement comes from experience and experience comes from bad judgement.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP