mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
20141021-1 选题
This commit is contained in:
parent
a65a83e210
commit
15aa35f5bd
50
sources/share/20141021 Nifty Free Image Viewers.md
Normal file
50
sources/share/20141021 Nifty Free Image Viewers.md
Normal file
@ -0,0 +1,50 @@
|
||||
Nifty Free Image Viewers
|
||||
================================================================================
|
||||
One of my favorite adages is "A picture is worth a thousand words". It refers to the notion that a still image can convey a complex idea. Images can portray a lot of information quickly and more efficiently than text. They capture memories, and never let you forget something you want to remember, and refresh it in your memory.
|
||||
|
||||
Images are part of every day internet usage, and are particularly important for social media engagement. A good image viewer is an essential part of any operating system.
|
||||
|
||||
Linux offers a vast collection of open source small utilities that perform functions ranging from the obvious to the bizarre. It is the quality and selection of these tools that help Linux stand out as a productive environment. This is particularly true when it comes to image viewers. There are so many image viewers that are available for Linux that it can make selection difficult.
|
||||
|
||||
An image viewer that is not included in this roundup but is worth a mention is Fragment Image Viewer. It is released under a proprietary license (yes, I know!), and would not install on Ubuntu. But it certainly looks interesting! One for the future, particularly if the developers release it under an open source license.
|
||||
|
||||
Now, let's explore the 13 image viewers at hand. With one exception, each of them is released under an open source license. As there is a lot of information to detail, I have departed from a roundup on a single page, but instead have devoted a page for each image viewer, with a full description of the software, an in-depth analysis of its features, a screenshot of the software in action, together with links to relevant resources and reviews.
|
||||
|
||||
### Image Viewers ###
|
||||
|
||||
- [**Eye of Gnome**][1] -- Fast and functional image viewer
|
||||
- [**gThumb**][2] -- Advanced image viewer and browser
|
||||
- [**Shotwell**][3] -- Image organizer designed to provide personal photo management
|
||||
- [**Gwenview**][4] -- Simple image viewer for KDE 4
|
||||
- [**Imgv**][5] -- Powerful image viewer
|
||||
- [**feh**][6] -- Fast and light Imlib2-based image viewer
|
||||
- [**nomacs**][7] -- Handles most image formats including RAW images
|
||||
- [**Geeqie**][8] -- Lightweight Gtk+ based image viewer
|
||||
- [**qiv**][9] -- Very small and pretty fast open source gdk/imlib image viewer
|
||||
- [**PhotoQT**][10] -- Good looking, highly configurable, yet easy to use and fast
|
||||
- [**Viewnior**][11] -- Designed with usability in mind
|
||||
- [**Cornice**][12] -- Designed to be a free replacement of ACDSee
|
||||
- [**XnViewMP**][13] -- Graphic viewer, browser, converter (proprietary)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxlinks.com/article/20141018070111434/ImageViewers.html
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:https://projects.gnome.org/eog/
|
||||
[2]:https://wiki.gnome.org/Apps/gthumb
|
||||
[3]:https://wiki.gnome.org/Apps/Shotwell/
|
||||
[4]:http://gwenview.sourceforge.net/
|
||||
[5]:http://imgv.sourceforge.net/
|
||||
[6]:http://feh.finalrewind.org/
|
||||
[7]:http://www.nomacs.org/
|
||||
[8]:http://geeqie.sourceforge.net/
|
||||
[9]:http://spiegl.de/qiv/
|
||||
[10]:http://photoqt.org/
|
||||
[11]:http://siyanpanayotov.com/project/viewnior/
|
||||
[12]:http://wxglade.sourceforge.net/extra/cornice.html
|
||||
[13]:http://www.xnview.com/en/
|
@ -0,0 +1,157 @@
|
||||
How to create and use Python CGI scripts
|
||||
================================================================================
|
||||
Have you ever wanted to create a webpage or process user input from a web-based form using Python? These tasks can be accomplished through the use of Python CGI (Common Gateway Interface) scripts with an Apache web server. CGI scripts are called by a web server when a user requests a particular URL or interacts with the webpage (such as clicking a "Submit" button). After the CGI script is called and finishes executing, the output is used by the web server to create a webpage displayed to the user.
|
||||
|
||||
### Configuring the Apache web server to run CGI scripts ###
|
||||
|
||||
In this tutorial we assume that an Apache web server is already set up and running. This tutorial uses an Apache web server (version 2.2.15 on CentOS release 6.5) that is hosted at the localhost (127.0.0.1) and is listening on port 80, as specified by the following Apache directives:
|
||||
|
||||
ServerName 127.0.0.1:80
|
||||
Listen 80
|
||||
|
||||
HTML files used in the upcoming examples are located in /var/www/html on the web server. This is specified via the DocumentRoot directive (specifies the directory that webpages are located in):
|
||||
|
||||
DocumentRoot "/var/www/html"
|
||||
|
||||
Consider a request for the URL: http://localhost/page1.html
|
||||
|
||||
This will return the contents of the following file on the web server:
|
||||
|
||||
/var/www/html/page1.html
|
||||
|
||||
To enable use of CGI scripts, we must specify where CGI scripts are located on the web server. To do this, we use the ScriptAlias directive:
|
||||
|
||||
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
|
||||
|
||||
The above directive indicates that CGI scripts are contained in the /var/www/cgi-bin directory on the web server and that inclusion of /cgi-bin/ in the requested URL will search this directory for the CGI script of interest.
|
||||
|
||||
We must also explicitly permit the execution of CGI scripts in the /var/www/cgi-bin directory and specify the file extensions of CGI scripts. To do this, we use the following directives:
|
||||
|
||||
<Directory "/var/www/cgi-bin">
|
||||
Options +ExecCGI
|
||||
AddHandler cgi-script .py
|
||||
</Directory>
|
||||
|
||||
Consider a request for the URL: http://localhost/cgi-bin/myscript-1.py
|
||||
|
||||
This will call the following script on the web server:
|
||||
|
||||
/var/www/cgi-bin/myscript-1.py
|
||||
|
||||
### Creating a CGI script ###
|
||||
|
||||
Before creating a Python CGI script, you will need to confirm that you have Python installed (this is generally installed by default, however the installed version may vary). Scripts in this tutorial are created using Python version 2.6.6. You can check your version of Python from the command line by entering either of the following commands (the -V and --version options display the version of Python that is installed):
|
||||
|
||||
$ python -V
|
||||
$ python --version
|
||||
|
||||
If your Python CGI script will be used to process user-entered data (from a web-based input form), then you will need to import the Python cgi module. This module provides functionality for accessing data that users have entered into web-based input forms. You can import this module via the following statement in your script:
|
||||
|
||||
import cgi
|
||||
|
||||
You must also change the execute permissions for the Python CGI script so that it can be called by the web server. Add execute permissions for others via the following command:
|
||||
|
||||
# chmod o+x myscript-1.py
|
||||
|
||||
### Python CGI Examples ###
|
||||
|
||||
Two scenarios involving Python CGI scripts will be considered in this tutorial:
|
||||
|
||||
- Create a webpage using a Python script
|
||||
- Read and display user-entered data and display results in a webpage
|
||||
|
||||
Note that the Python cgi module is required for Scenario 2 because this involves accessing user-entered data from web-based input forms.
|
||||
|
||||
### Example 1: Create a webpage using a Python script ###
|
||||
|
||||
For this scenario, we will start by creating a webpage /var/www/html/page1.html with a single submit button:
|
||||
|
||||
<html>
|
||||
<h1>Test Page 1</h1>
|
||||
<form name="input" action="/cgi-bin/myscript-1.py" method="get">
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
</html>
|
||||
|
||||
When the "Submit" button is clicked, the /var/www/cgi-bin/myscript-1.py script is called (specified by the action parameter). A "GET" request is specified by setting the method parameter equal to "get". This requests that the web server return the specified webpage. An image of /var/www/html/page1.html as viewed from within a web browser is shown below:
|
||||
|
||||
![](https://farm4.staticflickr.com/3933/14932853623_eff2df3260_z.jpg)
|
||||
|
||||
The contents of /var/www/cgi-bin/myscript-1.py are:
|
||||
|
||||
#!/usr/bin/python
|
||||
print "Content-Type: text/html"
|
||||
print ""
|
||||
print "<html>"
|
||||
print "<h2>CGI Script Output</h2>"
|
||||
print "<p>This page was generated by a Python CGI script.</p>"
|
||||
print "</html>"
|
||||
|
||||
The first statement indicates that this is a Python script to be run with the /usr/bin/python command. The print "Content-Type: text/html" statement is required so that the web server knows what type of output it is receiving from the CGI script. The remaining statements are used to print the text of the webpage in HTML format.
|
||||
|
||||
When the "Submit" button is clicked in the above webpage, the following webpage is returned:
|
||||
|
||||
![](https://farm4.staticflickr.com/3933/15553035025_d70be04470_z.jpg)
|
||||
|
||||
The take-home point with this example is that you have the freedom to decide what information is returned by the CGI script. This could include the contents of log files, a list of users currently logged on, or today's date. The possibilities are endless given that you have the entire Python library at your disposal.
|
||||
|
||||
### Example 2: Read and display user-entered data and display results in a webpage ###
|
||||
|
||||
For this scenario, we will start by creating a webpage /var/www/html/page2.html with three input fields and a submit button:
|
||||
|
||||
<html>
|
||||
<h1>Test Page 2</h1>
|
||||
<form name="input" action="/cgi-bin/myscript-2.py" method="get">
|
||||
First Name: <input type="text" name="firstName"><br>
|
||||
Last Name: <input type="text" name="lastName"><br>
|
||||
Position: <input type="text" name="position"><br>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
</html>
|
||||
|
||||
When the "Submit" button is clicked, the /var/www/cgi-bin/myscript-2.py script is called (specified by the action parameter). An image of /var/www/html/page2.html as viewed from within a web browser is shown below (note that the three input fields have already been filled in):
|
||||
|
||||
![](https://farm4.staticflickr.com/3935/14932853603_ffc3bd330e_z.jpg)
|
||||
|
||||
The contents of /var/www/cgi-bin/myscript-2.py are:
|
||||
|
||||
#!/usr/bin/python
|
||||
import cgi
|
||||
form = cgi.FieldStorage()
|
||||
print "Content-Type: text/html"
|
||||
print ""
|
||||
print "<html>"
|
||||
print "<h2>CGI Script Output</h2>"
|
||||
print "<p>"
|
||||
print "The user entered data are:<br>"
|
||||
print "<b>First Name:</b> " + form["firstName"].value + "<br>"
|
||||
print "<b>Last Name:</b> " + form["lastName"].value + "<br>"
|
||||
print "<b>Position:</b> " + form["position"].value + "<br>"
|
||||
print "</p>"
|
||||
print "</html>"
|
||||
|
||||
As mentioned previously, the import cgi statement is needed to enable functionality for accessing user-entered data from web-based input forms. The web-based input form is encapsulated in the form object, which is a cgi.FieldStorage object. Once again, the "Content-Type: text/html" line is required so that the web server knows what type of output it is receiving from the CGI script. The data entered by the user are accessed in the statements that contain form["firstName"].value, form["lastName"].value, and form["position"].value. The names in the square brackets correspond to the values of the name parameters defined in the text input fields in **/var/www/html/page2.html**.
|
||||
|
||||
When the "Submit" button is clicked in the above webpage, the following webpage is returned:
|
||||
|
||||
![](https://farm4.staticflickr.com/3949/15367402150_946474dbb0_z.jpg)
|
||||
|
||||
The take-home point with this example is that you can easily read and display user-entered data from web-based input forms. In addition to processing data as strings, you can also use Python to convert user-entered data to numbers that can be used in numerical calculations.
|
||||
|
||||
### Summary ###
|
||||
|
||||
This tutorial demonstrates how Python CGI scripts are useful for creating webpages and for processing user-entered data from web-based input forms. More information about Apache CGI scripts can be found [here][1] and more information about the Python cgi module can be found [here][2].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/create-use-python-cgi-scripts.html
|
||||
|
||||
作者:[Joshua Reed][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/joshua
|
||||
[1]:http://httpd.apache.org/docs/2.2/howto/cgi.html
|
||||
[2]:https://docs.python.org/2/library/cgi.html#module-cgi
|
@ -0,0 +1,132 @@
|
||||
How to monitor a log file on Linux with logwatch
|
||||
================================================================================
|
||||
Linux operating system and many applications create special files commonly referred to as "logs" to record their operational events. These system logs or application-specific log files are an essential tool when it comes to understanding and troubleshooting the behavior of the operating system and third-party applications. However, log files are not precisely what you would call "light" or "easy" reading, and analyzing raw log files by hand is often time-consuming and tedious. For that reason, any utility that can convert raw log files into a more user-friendly log digest is a great boon for sysadmins.
|
||||
|
||||
[logwatch][1] is an open-source log parser and analyzer written in Perl, which can parse and convert raw log files into a structured format, making a customizable report based on your use cases and requirements. In logwatch, the focus is on producing more easily consumable log summary, not on real-time log processing and monitoring. As such, logwatch is typically invoked as an automated cron task with desired time and frequency, or manually from the command line whenever log processing is needed. Once a log report is generated, logwatch can email the report to you, save it to a file, or display it on the screen.
|
||||
|
||||
A logwatch report is fully customizable in terms of verbosity and processing coverage. The log processing engine of logwatch is extensible, in a sense that if you want to enable logwatch for a new application, you can write a log processing script (in Perl) for the application's log file, and plug it under logwatch.
|
||||
|
||||
One downside of logwatch is that it does not include in its report detailed timestamp information available in original log files. You will only know that a particular event was logged in a requested range of time, and you will have to access original log files to get exact timing information.
|
||||
|
||||
### Installing Logwatch ###
|
||||
|
||||
On Debian and derivatives:
|
||||
|
||||
# aptitude install logwatch
|
||||
|
||||
On Red Hat-based distributions:
|
||||
|
||||
# yum install logwatch
|
||||
|
||||
### Configuring Logwatch ###
|
||||
|
||||
During installation, the main configuration file (logwatch.conf) is placed in /etc/logwatch/conf. Configuration options defined in this file override system-wide settings defined in /usr/share/logwatch/default.conf/logwatch.conf.
|
||||
|
||||
If logwatch is launched from the command line without any arguments, the custom options defined in /etc/logwatch/conf/logwatch.conf will be used. However, if any command-line arguments are specified with logwatch command, those arguments in turn override any default/custom settings in /etc/logwatch/conf/logwatch.conf.
|
||||
|
||||
In this article, we will customize several default settings of logwatch by editing /etc/logwatch/conf/logwatch.conf file.
|
||||
|
||||
Detail = <Low, Med, High, or a number>
|
||||
|
||||
"Detail" directive controls the verbosity of a logwatch report. It can be a positive integer, or High, Med, Low, which correspond to 10, 5, and 0, respectively.
|
||||
|
||||
MailTo = youremailaddress@yourdomain.com
|
||||
|
||||
"MailTo" directive is used if you want to have a logwatch report emailed to you. To send a logwatch report to multiple recipients, you can specify their email addresses separated with a space. To be able to use this directive, however, you will need to configure a local mail transfer agent (MTA) such as sendmail or Postfix on the server where logwatch is running.
|
||||
|
||||
Range = <Yesterday|Today|All>
|
||||
|
||||
"Range" directive specifies the time duration of a logwatch report. Common values for this directive are Yesterday, Today or All. When "Range = All" is used, "Archive = yes" directive is also needed, so that all archived versions of a given log file (e.g., /var/log/maillog, /var/log/maillog.X, or /var/log/maillog.X.gz) are processed.
|
||||
|
||||
Besides such common range values, you can also use more complex range options such as the following.
|
||||
|
||||
- Range = "2 hours ago for that hour"
|
||||
- Range = "-5 days"
|
||||
- Range = "between -7 days and -3 days"
|
||||
- Range = "since September 15, 2014"
|
||||
- Range = "first Friday in October"
|
||||
- Range = "2014/10/15 12:50:15 for that second"
|
||||
|
||||
To be able to use such free-form range examples, you need to install Date::Manip Perl module from CPAN. Refer to [this post][2] for CPAN module installation instructions.
|
||||
|
||||
Service = <service-name-1>
|
||||
Service = <service-name-2>
|
||||
. . .
|
||||
|
||||
"Service" option specifies one or more services to monitor using logwath. All available services are listed in /usr/share/logwatch/scripts/services, which cover essential system services (e.g., pam, secure, iptables, syslogd), as well as popular application services such as sudo, sshd, http, fail2ban, samba. If you want to add a new service to the list, you will have to write a corresponding log processing Perl script, and place it in this directory.
|
||||
|
||||
If this option is used to select specific services, you need to comment out the line "Service = All" in /usr/share/logwatch/default.conf/logwatch.conf.
|
||||
|
||||
![](https://farm6.staticflickr.com/5612/14948933564_94cbc5353c_z.jpg)
|
||||
|
||||
Format = <text|html>
|
||||
|
||||
"Format" directive specifies the format (e.g., text or HTML) of a logwatch report.
|
||||
|
||||
Output = <file|mail|stdout>
|
||||
|
||||
"Output" directive indicates where a logwatch report should be sent. It can be saved to a file (file), emailed (mail), or shown to screen (stdout).
|
||||
|
||||
### Analyzing Log Files with Logwatch ###
|
||||
|
||||
To understand how to analyze log files using logwatch, consider the following logwatch.conf example:
|
||||
|
||||
Detail = High
|
||||
MailTo = youremailaddress@yourdomain.com
|
||||
Range = Today
|
||||
Service = http
|
||||
Service = postfix
|
||||
Service = zz-disk_space
|
||||
Format = html
|
||||
Output = mail
|
||||
|
||||
Under these settings, logwatch will process log files generated by three services (http, postfix and zz-disk_space) today, produce an HTML report with high verbosity, and email it to you.
|
||||
|
||||
If you do not want to customize /etc/logwatch/conf/logwatch.conf, you can leave the default configuration file unchanged, and instead run logwatch from the command line as follows. It will achieve the same outcome.
|
||||
|
||||
# logwatch --detail 10 --mailto youremailaddress@yourdomain.com --range today --service http --service postfix --service zz-disk_space --format html --output mail
|
||||
|
||||
The emailed report looks like the following.
|
||||
|
||||
![](https://farm6.staticflickr.com/5611/15383540608_57dc37e3d6_z.jpg)
|
||||
|
||||
The email header includes links to navigate the report sections, one per each selected service, and also "Back to top" links.
|
||||
|
||||
You will want to use the email report option when the list of recipients is small. Otherwise, you can have logwatch save a generated HTML report within a network share that can be accessed by all the individuals who need to see the report. To do so, make the following modifications in our previous example:
|
||||
|
||||
Detail = High
|
||||
Range = Today
|
||||
Service = http
|
||||
Service = postfix
|
||||
Service = zz-disk_space
|
||||
Format = html
|
||||
Output = file
|
||||
Filename = /var/www/html/logs/dev1.html
|
||||
|
||||
Equivalently, run logwatch from the command line as follows.
|
||||
|
||||
# logwatch --detail 10 --range today --service http --service postfix --service zz-disk_space --format html --output file --filename /var/www/html/logs/dev1.html
|
||||
|
||||
Finally, let's configure logwatch to be executed by cron on your desired schedules. The following example will run a logwatch cron job every business day at 12:15 pm:
|
||||
|
||||
# crontab -e
|
||||
|
||||
----------
|
||||
|
||||
15 12 * * 1,2,3,4,5 /sbin/logwatch
|
||||
|
||||
Hope this helps. Feel free to comment to share your own tips and ideas with the community!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/monitor-log-file-linux-logwatch.html
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/gabriel
|
||||
[1]:http://sourceforge.net/projects/logwatch/
|
||||
[2]:http://xmodulo.com/how-to-install-perl-modules-from-cpan.html
|
Loading…
Reference in New Issue
Block a user