Tool to handle the errors in the error log file - perl

We are developing a script in perl which when gives the url and the webserver to hit. It hits the url given in the webserver and gives the html content of the page.
For example :
perl scribehtml.pl --server servername --port portnumber --url /home/firstpage/index.php
This returns the entire html code of the page.
Now we are grepping the errors from the html code and write in a text file. Say when we see a text like 'Internal server error' we will put the entire html code into the text file.
There by we are going to have a error.txt where all the errors for different urls will be stored when we execute the script.
Now my Questions are :
How to make the error.txt into some log file say error.log and what are things i need to do to make a proper structure log file.
Is there any tool in which if we specify the log file it will parse the error in it and display the count of occurrence of each error in the log file in the dashboard.
As for us now I m storing the list of around 500 urls in a text file and parsing the it one by one and executing so there by i am getting error for the urls which are failing and I m writing those errors in the text file error.txt

Ideally you can make your own subroutine to store the logs in to the .log file.
The default structure for the log file is as following:
[Timestamp]:Error/Warning/Info: String to define the issue
You can format the lines using printf.

Related

ffmpeg concat command not reading input file correctly

I am trying to concatenate two video files using ffmpeg, and I am receiving an error.
ffmpeg -f concat -safe 0 -i list.txt -c copy concat.mp4
And the error output I receive is....
[concat # 0x7ff922000000] Line 1: unknown keyword '43.mp4'
list.txt: Invalid data found when processing input
It looks like that the file names in the list have to be specially formatted to look like:
file '/path/to/file1.wav'
with a word file included. I spent a lot of time trying to guess why ffmpeg encountered an error trying to read the file names. It didn't matter if they were in the list or in the command line. So only after I utilized a command
for f in *.wav; do echo "file '$f'" >> mylist.txt; done
to make list from ffmpeg's manual I had success. The only difference was an additional word file.
Here you can read it yourself: https://trac.ffmpeg.org/wiki/Concatenate#demuxer

Aborting wget on file found (Windows)

I am trying to use wget for Windows (on Windows 7) to find and download a file that I don't know the full name of (I have a partial name, and I know the form of the unknown part of the name). I am using an input file with a list of the possible file names, and I want to abort wget when the file is found (the rest of the possibilities will give 404 errors). How can I cause wget to abort automatically when that one file is found?

wget read input from standard input

From the wget man page
§ 2.4 Logging and Input File Options
‘-i file’
‘--input-file=file’
Read urls from a local or external file. If ‘-’ is specified as file, urls
are read from the standard input. (Use ‘./-’ to read from a file literally
named ‘-’.)
If this function is used, no urls need be present on the command line. If
there are urls both on the command line and in an input file, those on the
command lines will be the first ones to be retrieved. If ‘--force-html’ is
not specified, then file should consist of a series of URLs, one per line.
I tried doing
wget -i - www.google.com
It downloaded a file index.html, but then it hangs. Even after I pressed
"Enter" several times, it still hangs. Why?
Because you have not closed your 'file' wget continues waiting for you to type more into stdin. To terminate, press ctrl + d [EOF terminator]

Unsure of how to proceed with creating ec2-consisten-snapshot

I was just put on a task to try and debug and figure out why our ec2-consistent-snapshot script isn't working.
Our lead programmer followed this blog post.
We have a .sh script that we'd like to take the snapshot and it looks like this:
#!/bin/sh
/opt/aws/bin/ec2-consistent-snapshot --aws-access-key-id MYACCESSKEY --aws-secret-access-key MYSECRETKEY --freeze-filesystem /vol --mysql --mysql-host localhost --mysql-socket /var/lib/mysql/mysql.sock --mysql-username USERNAME --mysql-password PASSWORD --description "Demo MySQL data volume: $(date +%c)" vol-MYVOL
If I run this by doing sudo ./snapshot_script.sh I get a single error:
ec2-consistent-snapshot: ERROR: create_snapshot: File does not exist: at /usr/share/perl5/vendor_perl/Net/Amazon/EC2.pm line 232
I of course followed this error and line 232 in EC2.pm is this:
my $ref = $xs->XMLin($xml);
I have 0 perl experience and I don't know what this could be doing.
Any help would be wonderful.
The Net::Amazon::EC2 that I'm looking at on CPAN has that line at 252, not 232 so perhaps you are not on the latest version. Looking above that line, the program has attempted to do a "query to sign" using lots of the security parms. I suspect there is a problem with the authentication keys you are using. There is a debug flag, you might want to turn that on to generate more messages.
If you go to this page, you will see that XMLin() is a function of XML::Simple, and it takes a file as an argument. So, $xml is presumably a variable that contains an xml file name. That file does not exist.
The next step would be to trace the error back into the source code of ec2-consistent-snapshot, in order to see how it is calling XML::Simple and where the bad value gets passed in.

Perl script not sending mail and not unlink - ing

I have some scripts that I didn't write... they search a Squid log database and then create a spreadsheet and email it and then delete the .pid and .xls files it created.
The scripts were using NTLM for one of it's variables (request_user)... I changed it to a manually entered text field.
I don't know perl and the scripts are not working.
The .pid and .xls are getting created but nothing gets emailed and the files don't get deleted (unlink)
Here is are the links to the request and generate files
http://www.the-greenes.net/spreadsheet_request-test.txt
http://www.the-greenes.net/spreadsheet_gen.txt
Can anyone help a limited guy with very limited perl skills?
Thanks
In the spreadsheet_gen script you have this line to setup address to smtp server:
my $mail_server=`10.0.1.98`;
Using backticks make it run command named 10.0.1.98 and assign its output into $mail_server variable. This is most likely wrong, try to replace backticks with regular apostrophes to create string:
my $mail_server = '10.0.1.98';
Can you see any error in your error.log? If $message->send ... fails, it dies with error message and nothing gets sent nor unlinked.