Keep watch over your server system with Webmin

Log Files, System Monitoring, and Automatic Jobs

Even with logfiles, Webmin clearly distinguishes between its own stuff and the operating system in which it runs. The Webmin | Webmin Actions Log window is a search interface for Webmin's internal log. Use it whenever you need to figure out exactly what you did in all of Webmin or just in some of its modules.

Rotation of system logfiles – and definition of post-rotation commands for each of them – has its own panel in the System section. Monitoring system performance is split between Networking | Bandwidth Monitoring and Others | System and Server Status. In the latter window, you can activate tens of system monitors, and you can set how often they should run and to which email address they should send updates and warnings.

Speaking of automated actions, the most useful part of Webmin might be its interface to set up and control cron jobs – that is, automatic execution of specific commands or scripts at regular intervals. From the visual point of view, the form in System | Scheduled Cron Jobs might be outdated, but it makes it very, very easy to create cron jobs that run only when you want. You can even specify a non-recurring range of dates in which each job should be executed and define which users can have their own cron jobs.

Firewall and Servers

The most critical part of the Networking section is probably the configuration of your firewall. By default, Webmin includes two modules for firewall configuration, called FirewallD and Linux Firewall. Which one is more appropriate depends on which distribution you are running. Luckily, Webmin is smart enough to advise you, in most cases, which you should use.

Out of the box, Webmin knows how to configure the servers corresponding to the essential services of any Linux system: remote access via SSH; websites with Apache; databases with MySQL; and email with Postfix, Procmail, and SpamAssassin. Many more servers, from DNS to DHCP, have separate modules that you can activate with a few clicks.

On one hand, this part of Webmin is the least useful: This is not Webmin's fault, it's just the nature of the beast. Regardless of which flavor of Linux you use, any configuration interface for services like running websites or email can only do so much for its users. Webmin has many practical forms that help a lot – and save lots of time – to set each variable of those servers; however, it's still up to you to know what those variables mean.

Beyond the GUI: Advanced Webmin Usage

No software interface is really useful if you cannot customize at least part of it to your specific needs or occasionally do something that is not specifically listed in its menus. Webmin provides several functions that make these things possible even without hacking its source code.

To execute a command that you would otherwise have to enter at a shell prompt, click on Others | Command Shell and type the command. To do serious terminal work, choose Others | Text Login (Figure 4). This option opens a terminal inside your browser in which you can run all the commands and scripts you want inside a secure SSH session. If there's a command that you want to assign to a clickable button for frequent use, add it in the Others | Custom Commands page shown in Figures 5 and 6.

Figure 4: A built-in Ajax terminal gives you a command prompt right inside your browser.
Figure 5: You can add buttons as you please, attaching them to your custom scripts, controlling which parameters they have, and defining how they display their output.
Figure 6: The Back up budget files button created with the form in Figure 5 will stay, by default, in the Custom Commands window.

These features alone make Webmin flexible enough for most users, but there is more: If you want to save even more time, you can write Perl scripts that will use Webmin on your behalf, using the XML Remote Procedure Call protocol. To understand how this trick works, look at Listing 1, which shows the essential parts of one of the sample scripts provided by the Webmin developers [5]. This script connects to your Webmin with the credentials in the single line of a file called url.txt (line 1), which has the following format:

Listing 1

Using Webmin from a Perl Script

 

https://USERNAME:PASSWORD@yourserver.com:10000/xmlrpc.cgi

Lines 2 to 6 create an object that connects to the specified Webmin instance. Using the cron::list_cron_jobs method, lines 7 to 10 check whether a cron job that executes the command echo foo as user root already exists. If yes, it is deleted (remember, this is just an example). Otherwise (lines 17 to 25), the server object is told to connect to Webmin again to create the cron job with the specified parameters. Of course, in real life, the user and command terms specified in the script would be parameters passed to the script.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News