Saturday, February 10, 2018

How to test if your zabbix server receive data from zabbix client or not?



you have installed zabbix agent on your server. Process zabbix client is up and running but does zabbix server start to receive data from it?

Simplest way to this is to connect to your zabbix server and initiate zabbix_get command! With this command can get to see data from zabbix client.

 zabbix_get - Zabbix get utility.

Syntax:

ram@zabbixserver:~$  zabbix_get -s IP_ZABBIX_CLIENT -k ZABBIX_ITEM


Where  -s, --host <host name or IP>
              Specify host name or IP address of a host.

             -k, --key <item key>
              Specify key of item to retrieve value for.

Test the connection between zabbix_server to client.

ram@zabbixserver:~$ zabbix_get -s 192.168.101.26 -k agent.ping
1

If u get output 1 means connection is ok and data is received from 192.168.101.26

ram@zabbixserver:~$ zabbix_get -s 192.168.101.26 -k agent.ping

zabbix_get [31561]: Get value error: cannot connect to [[192.168.101.26 ]:10050]: [111] Connection refused

server 192.168.101.26 but zabbix agent is not installed, not running or firewall is blocking or network problem !!

How to check agent version from zabbix server ?

Using zabbix_get command u can easily get agent version.


ram@zabbixserver:~$zabbix_get -s 192.168.101.26 -k agent.version
3.0.6

Get any information from client host without login to host server using zabbix_get command for example load average.

ram@zabbixserver:~$zabbix_get -s 192.168.101.26 -k "system.cpu.load[all,avg5]"
0.410000


Thursday, January 11, 2018

how long server has been up in linux using uptime command ?

Linux Server Uptime Command To Find Out How Long The System Has Been Running


Both Linux and Unix-like systems comes with various command to find out server uptime command. Under Linux file /proc/uptime has uptime information and file /var/run/utmp has information about who is currently logged on. However, information from /proc or utmp file is not directly readable by humans so you need to use the uptime command.
uptime - Tell how long the system has been running.

UNIX / Linux uptime command

Open a command-line terminal and then type the following commands:
#uptime
Sample outputs:
uptime
 12:04:44 up 8 days, 19:42,  3 users,  load average: 1.56, 2.56, 1.96
Note: The uptime command gives a one line display of the following information.
1). The current time
2). How long the system has been running
3). How many users are currently logged on
4). The system load averages for the past 1, 5, and 15 minutes

See uptime in pretty format pass the -p option to the uptime command

#uptime -p
Sample outputs:
uptime -p
up 1 week, 1 day, 19 hours, 47 minutes

See uptime in system up since, in yyyy-mm-dd MM:HH:SS format pass the -s option to the uptime command

#uptime -s
uptime -s
2017-12-27 16:22:09

How to Disable Ctrl-Alt-Delete in Ubuntu ?

Having a physical access to the keyboard can simply use the Ctrl+Alt+Delete key combination to reboot the server without having to logged on, But we can prevent the use of this key combination on a production server for an accidental reboots.
To disable the reboot action taken by pressing the Ctrl+Alt+Delete key combination,
Comment out the following line in the file /etc/init/control-alt-delete.conf
$ sudo vi /etc/init/control-alt-delete.conf
Or
$sudo gedit /etc/init/control-alt-delete.conf
Find line that read as follows:
exec shutdown -r now “Control-Alt-Delete pressed”
delete configuration line or comment out line by prefixing # symbol
#exec shutdown -r now "Control-Alt-Delete pressed"
Save and close the file.
But In 16.04
In the systemd world, Ctrl+Alt+Delete is handled by ctrl-alt-del.target
ctrl-alt-del.target systemd starts this target whenever Control+Alt+Del is pressed on the console. Usually, this should be aliased (symlinked) to reboot.target.

Disable Ctrl+Alt+Delete using following command

$systemctl mask ctrl-alt-del.target
$systemctl daemon-reload

Thursday, January 4, 2018

How to Find All Failed SSH login Attempts in Linux ?

Each attempt to login to SSH server is tracked and recorded into a log file by the rsyslog daemon in Linux. The most basic mechanism to list all failed SSH logins attempts in Linux is a combination of displaying and filtering the log files.
The most simple command to list all failed SSH logins is the one shown below.
#grep "Failed password" /var/log/auth.log
Sample output.
grep "Failed password" /var/log/auth.log
Sep 26 09:49:11 linuxforfreshers.com sshd[32138]: Failed password for ravi from 192.168.101.26 port 33325 ssh2
Oct  2 23:04:25 linuxforfreshers.com sshd[25028]: Failed password for root from 192.168.101.211 port 55800 ssh2
In order to display extra information about the failed SSH logins, issue the command as shown in the below example.
#egrep "Failed|Failure" /var/log/auth.log
In CentOS or RHEL, the failed SSH sessions are recorded in /var/log/secure file. Issue the above command against this log file to identify failed SSH logins.
#egrep "Failed|Failure" /var/log/secure
Sample output
Dec 29 16:11:01 localhost sshd[32526]: Failed password for root from 192.168.101.111 port 31729 ssh2
Dec 29 16:11:04 localhost sshd[32526]: Failed password for root from 58.218.198.264 port 31729 ssh2

Saturday, November 18, 2017

how to install and configure aws cli on linux ?

AWS Command Line Interface (CLI). Depending on your operating system ways are different for installation. I will show you installation of AWS CLI on Ubuntu and CentOS Linux OS.

Install AWS Command Line Interface ( CLI)
 Install AWS CLI in Ubuntu Linux
Pip is recommended method of installing AWS CLI on Linux which is python based tool helps in install, upgrade, and remove Python packages.
– Install python-pip package using apt-get
[root@linuxforfreshers~] apt-get install python-pip

Install AWS CLI using pip command

[root@linuxforfreshers~] pip install awscli

– Configure AWS CLI

You can configure it using “aws configure” command.

While configuring, it will ask you for the several information like AWS Access Key ID, AWS Secret Access Key, Default region name, Default output format. You need to provide that information. In my case below is the Access Key and Secret Access Key.

AWS Access Key = AKIAJRSF3SHFXWALVL2A
AWS Secret Access Key = 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

Let’s configure it using command.

[root@linuxforfreshers~] aws configure
AWS Access Key ID [None]: AKIAJRSF3SHFXWALVL2A
AWS Secret Access Key [None]: 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
Default region name [None]: us-east-1
Default output format [None]:
[root@linuxforfreshers~]

Once configuration complete, It will create .aws folder in user’s home directory. Below is the content of .aws directory.
[root@linuxforfreshers~] ls .aws/
Config Credentials

[root@linuxforfreshers~] cat .aws/config
[default]
region = us-east-1
[root@linuxforfreshers~] cat .aws/credentials
[default]
aws_access_key_id = AKIAJRSF3SHFXWALVL2A
aws_secret_access_key = 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

[root@linuxforfreshers~]

 – Now Test if AWS CLI is installed correctly or not.

[root@linuxforfreshers~] aws help

If you are given wrong access_key u will get following error.

An error occurred (InvalidAccessKeyId) when calling the ListBuckets operation: The AWS Access Key Id you provided does not exist in our records.

– Check Version of AWS CLI.

[root@linuxforfreshers]aws --version
aws-cli/1.11.129 Python/2.7.6 Linux/4.4.0-59-generic botocore/1.5.92

Install AWS CLI in CentOS Linux

– Check if python is installed in your system or not. If not install it using below command.

[root@linuxforfreshers~]# yum -y install python

– Install Pip on Linux.
Download the installation script.
[root@linuxforfreshers~]# curl -O https://bootstrap.pypa.io/get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time        Time  Current
                                    Dload  Upload   Total   Spent    Left  Speed
100 1388k  100 1388k    0       0   205k      0  0:00:06  0:00:06 --:--:--  265k
[root@linuxforfreshers~]#


Run the script with Python.

[root@linuxforfreshers~]# python get-pip.py
  Downloading pip-7.0.3-py2.py3-none-any.whl (1.1MB)
    100% |████████████████████████████████| 1.1MB 155kB/s
Collecting wheel
  Downloading wheel-0.24.0-py2.py3-none-any.whl (63kB)
    100% |████████████████████████████████| 65kB 252kB/s
Collecting argparse (from wheel)
  Downloading argparse-1.3.0-py2.py3-none-any.whl
Installing collected packages: pip, argparse, wheel
Successfully installed argparse-1.3.0 pip-7.0.3 wheel-0.24.0
[root@linuxforfreshers~]#



– Now install AWS command line using pip.

[root@linuxforfreshers~]# pip install awscli

– Let’s configure AWS CLI.

[root@linuxforfreshers~] aws configure
AWS Access Key ID [None]: AKIAJRSF3SHFXWALVL2A
AWS Secret Access Key [None]: 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
Default region name [None]: us-east-1
Default output format [None]:
[root@linuxforfreshers~]


– Verify either file and folder is created.



[root@linuxforfreshers~] ls .aws/
Config Credentials

[root@linuxforfreshers~] cat .aws/config
[default]
region = us-east-1
[root@linuxforfreshers~] cat .aws/credentials
[default]
aws_access_key_id = AKIAJRSF3SHFXWALVL2A
aws_secret_access_key = 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
[root@linuxforfreshers~]

Installation is complete now and you can start using aws cli.