Script for a quick assessment of the state of Linux systems
The responsibility of the system administrator is to monitor the load of the system, the users, create a backup copy and blah blah blah. For the most repetitive tasks, there are various scenarios that allow you to keep your fingers on your hands and make constantly repeating tasks easier. Here is a script that does not seek to automate the tasks of a typical system administrator, but it can be useful for those beginners who want to get some of the necessary information about their system, network, users, load, RAM, owners, internal and external IP, etc.
The script does not have any malicious content and can be run using regular user accounts. In fact, it is recommended to run the script from under a user with limited rights and not a super-user.
You can freely use, modify, distribute the following code fragments. The script is optimized as much as possible to display only the necessary data and access only the necessary directories - nothing more.
All you need is working Linux.
In this case, the script is compatible with all standard Linux distributions. In addition, it does not require root permission to execute. But when installing from a non-root user account, you will need to enter the root password.
For installation and use, no additional packages are required that are not listed in this post. There is no need to have superuser privileges to run. The code was released under Apache License 2.0 and this means that you can edit, modify and redistribute it.
To install the script, use the
We get the following:
They downloaded the file without problems, now you need to set the appropriate resolution.
Set permissions.
It is highly recommended that you install the script as a limited user, and not as a superuser. In this case, there will be a password request and it will be necessary to install the components in certain places.
To install the script
We get such a password request:
Enter the root password. If everything goes well, you will receive a message about the successful installation.
A safer option would be to add the user to sudoers. In such cases, the installation command will look as follows.
After installation, you can run the script by calling a command
As soon as the command is completed, you get various information about the system:
You can check the installed version of the script using
Get this kind of result:
This is a ready-made solution out of the box that does not require special skills or knowledge on working with SSH. This solution is clearly not the best for experienced administrators, but it is perfect for beginners who are just starting to learn how to work with the server. If you know more optimal scripts for a quick assessment of the state of Linux systems that do not require over-knowledge and will be more useful, express your opinion and leave recommendations in the comments. I, like other readers, will be happy to see the opinions of professional administrators working with Linux systems. Everyone will be able to emphasize something for themselves.
UPD
At installation it is better to use sudo, from the point of view of safety.
The script does not have any malicious content and can be run using regular user accounts. In fact, it is recommended to run the script from under a user with limited rights and not a super-user.
You can freely use, modify, distribute the following code fragments. The script is optimized as much as possible to display only the necessary data and access only the necessary directories - nothing more.
Minimum System Requirements
All you need is working Linux.
Compatibility
In this case, the script is compatible with all standard Linux distributions. In addition, it does not require root permission to execute. But when installing from a non-root user account, you will need to enter the root password.
Security
For installation and use, no additional packages are required that are not listed in this post. There is no need to have superuser privileges to run. The code was released under Apache License 2.0 and this means that you can edit, modify and redistribute it.
Script installation
To install the script, use the
wget
command to download the script tecmint_monitor.sh
. You will also need to make it executable by setting the appropriate permissions.$ wget http://tecmint.com/wp-content/scripts/tecmint_monitor.sh
We get the following:
[test@localhost ~]$ wget http://tecmint.com/wp-content/scripts/tecmint_monitor.sh
--2015-12-22 13:52:21-- http://tecmint.com/wp-content/scripts/tecmint_monitor.sh
Resolving tecmint.com... 212.71.234.61
Connecting to tecmint.com|212.71.234.61|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.tecmint.com/wp-content/scripts/tecmint_monitor.sh [following]
--2015-12-22 13:52:21-- http://www.tecmint.com/wp-content/scripts/tecmint_monitor.sh
Resolving www.tecmint.com... 212.71.234.61
Reusing existing connection to tecmint.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 4015 (3.9K) [application/x-sh]
Saving to: `tecmint_monitor.sh'
100%[=============================================>] 4,015 --.-K/s in 0s
2015-12-22 13:52:21 (290 MB/s) - `tecmint_monitor.sh' saved [4015/4015]
[test@localhost ~]$
They downloaded the file without problems, now you need to set the appropriate resolution.
Set permissions.
# chmod 755 tecmint_monitor.sh
It is highly recommended that you install the script as a limited user, and not as a superuser. In this case, there will be a password request and it will be necessary to install the components in certain places.
To install the script
tecmint_monitor.sh
, use -i, as shown below.$ ./tecmint_monitor.sh -i
We get such a password request:
[test@localhost ~]$ ./tecmint_monitor.sh -i
./tecmint_monitor.sh: line 30: /tmp/scriptname: Permission denied
Password:
Enter the root password. If everything goes well, you will receive a message about the successful installation.
Congratulations! Script Installed, now run monitor Command
[test@localhost ~]$
A safer option would be to add the user to sudoers. In such cases, the installation command will look as follows.
$ $ sudo ./tecmint_monitor.sh -i
After installation, you can run the script by calling a command
monitor
from under any user.$ monitor
As soon as the command is completed, you get various information about the system:
- Internet connection
- OS type
- OS Name
- OS version
- Architecture
- Kernel version
- Host name
- Internal IP
- External IP
- Server Name
- Authorized Users
- RAM used
- Used by SWAP
- How much disk space is used
- System uptime
You can check the installed version of the script using
monitor -v
.$ monitor -v
Get this kind of result:
tecmint_monitor version 0.1
Designed by Tecmint.com
Released Under Apache 2.0 License
[test@localhost ~]$
Conclusion
This is a ready-made solution out of the box that does not require special skills or knowledge on working with SSH. This solution is clearly not the best for experienced administrators, but it is perfect for beginners who are just starting to learn how to work with the server. If you know more optimal scripts for a quick assessment of the state of Linux systems that do not require over-knowledge and will be more useful, express your opinion and leave recommendations in the comments. I, like other readers, will be happy to see the opinions of professional administrators working with Linux systems. Everyone will be able to emphasize something for themselves.
UPD
At installation it is better to use sudo, from the point of view of safety.
Adding a user to sudoers
Add user to wheel group
Adding user test to group wheel
edit sudoers file
uncomment the line, or add our user according to the syntax
Now, from under the user, you can use sudo.
$ gpasswd -a username wheel
Adding user test to group wheel
edit sudoers file
$ visudo
$$ Allows people in group wheel to run all commands
$ %wheel ALL=(ALL) ALL
uncomment the line, or add our user according to the syntax
$ username ALL=(ALL) ALL
Now, from under the user, you can use sudo.
Only registered users can participate in the survey. Please come in.
Do you use scripts to evaluate server status?
- 18.8% Yes, every day. 51
- 51.4% Very rarely. 139
- 29.6% No, I do not have a server. 80