Latest Event Updates

Monitor GlusterFS using nagios plugin

Posted on Updated on

Here I am discussing about how to monitor Glusterfs using nagios plugin. You can download the plugin from the below link :

http://exchange.nagios.org/directory/Plugins/System-Metrics/File-System/GlusterFS-checks/details

I assume you have already installed nagios packages (we are using nrpe for monitoring glusterfs). I have another post discussing how to configure glusterfs for files replication here :

http://gopukrish.wordpress.com/glusterfs/

Briefly, the concept is as follows :

 Download the script to the gluster node and make sure that it gives the exact output while executing. Once confirmed, add it as an argument to nrpe and call from the nagios server. If you are able to get the exact results, add it in the nagios configuration file of the gluster node you would like to monitor.

So here we start the processes :

First confirm from gluster nodes that scripts executes fine and gives the exact results :
/usr/lib/nagios/plugins/check_glusterfs.sh -v datavol -n 2

If you get any errors, do the following 2 steps in the gluster node (nagios client)

1. install package bc (eg : apt-get install bc)
2. set necessary permissions for the nrpe user :
To find out the nrpe user, check in configuration file nrpe.cfg(gluster node). In my case, it was ‘nagios‘(change nagios with ‘nrpe’,if the user is ‘nrpe’ ). So give proper permission

vi /etc/sudoers.d/nrpe

Defaults:nrpe !requiretty
nagios ALL=(root) NOPASSWD:/usr/sbin/gluster volume status [[\:graph\:]]* detail,/usr/sbin/gluster volume heal [[\:graph\:]]* info

If you haven’t added these permissions, you may get the below error :
no bricks found

The same you can test from the gluster server as below :

root@www:/usr/local/nagios/etc/objects# /usr/local/nagios/libexec/check_nrpe -H my_server -c check_glusterfs
CRITICAL: no bricks found

once the permission is added correctly:

root@www:/usr/local/nagios/etc/objects# /usr/local/nagios/libexec/check_nrpe -H my_server -c check_glusterfs
OK: 2 bricks; free space 26GB

nrpe gives us the exact output while running from the nagios server. So we can safely add it in the  configuration file

In nagios server :

my_server.cfg :

define service {
check_command check_nrpe!check_glusterfs
service_description Gluster Server Health Check
host_name my_server
use generic-service
}

change my_server with your server node or its ip address

If you hadn’t added the required permission for nrpe, you may get the below error :

gluster_critical

Note that in some version of nrpe, you might need to add “check_nrpe_1arg!check_glusterfs” instead of “check_nrpe!check_glusterfs” as the check_command

Edit the commands.cfg and define the below commands for nrpe unless you have a separate config file for nrpe. In my case it was in /etc/nagios-plugins/config/check_nrpe.cfg
If you dont have any, you can add nrpe definition in commands.cfg as below :

commands.cfg :

define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ $ARG2$
}

In client :

vi /etc/nagios/nrpe.cfg

<pre>command[check_glusterfs]=/usr/lib/nagios/plugins/check_glusterfs.sh -v datavol -n 2</pre>

This means, whenever the nagios server check the service using ‘check_nrpe!check_glusterfs’, the check_glusterfs.sh will run and give the output back to the nagios server.

Once you have set everything correctly, you can see the status as ‘ok ‘

gluster_ok

I know this is little bit confused and not organised. I just posted it for a quick reference of my colleagues. I shall organize it well later. For the mean time if you have any doubt, please let me know…. Thanks :)

check the srv record from Linux machine (sip or exchange autodiscover)

Posted on Updated on

You can use any of the below 2 methods to find out the srv records :
1. Using dig

root@test:~# dig _autodiscover._tcp.mydomain.com srv

(check for the answer section similar to below )

;; ANSWER SECTION:
_autodiscover._tcp.mydomain.com. 29 IN SRV     10 10 443 autodiscover.mydomain1.com.

2. Using nslookup

root@test:~# nslookup (press ENTER)
> set type=srv (press ENTER)
> _autodiscover._tcp.mydomain.com (press ENTER)

(See the output similar to below )


Non-authoritative answer:
_autodiscover._tcp.mydomain.com        service = 10 10 443 autodiscover.mydomain1.com.

Authoritative answers can be found from:
autodiscover.mydomain.com   internet address = 1.2.3.4(IP)

Change the current document root to a new directory inside the current one using .htaccess

Posted on

The scenario is as follows. Client is having a website mydomain.com which is the primary domain of the cpanel account. Now the user want to redirect all the traffic coming to the current document root (/home/username/public_html) to the new_folder created (/home/username/public_html/new_folder/) for the site. Create a .htaccess file in /home/username/public_html with the below contents :

RewriteEngine on

# Change mydomain.com to be your primary main domain.
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$

# Change 'new_folder' to be the folder you want to redirect request to.
RewriteCond %{REQUEST_URI} !^/new_folder/

# Don't change this line.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d

# Change 'new_folder' to be the folder you want to use for your primary domain.
RewriteRule ^(.*)$ /new_folder/$1

# Change mydomain.com to be your primary domain again.
# Change 'new_folder' to be the folder you will use for your primary domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$
RewriteRule ^(/)?$ new_folder/index.php [L]

It is always recommended to change the document root directly in apache or from WHM rather than using this temporary solution. Still worth to know. :)

Run asterisk commands without entering into the CLI

Posted on

We can run the asterisk commands by entering into the CLI as below :

asterisk -vvvr

you can run the same commands without entering into the CLI as below :

[root@NOCMEConnect ~]# asterisk -rx "sip show peers"
Name/username              Host            Dyn Nat ACL Port     Status
6123                       192.168.22.73    D   N   A  5060     OK (13 ms)
6124                       192.168.22.67    D   N   A  5060     OK (16 ms)
6125                       192.168.22.35    D   N   A  5060     OK (16 ms)

Enjoy :)

MySQLZRM extract the backup to mysql

Posted on

1. locate the backup using the below command :

mysql-zrm-reporter --show restore-info --where backup-set=myhostserver1.com

where ‘myhostserver1.com’ is my host configured for backup
2. Extract the backup to the location /backup/sql/myhostserver1.com/20140604050029/ using the command below :

mysql-zrm-extract-backup --source-directory /backup/sql/myhostserver1.com/20140604050029/ --tmpdir /temporary_location/ 

Enjoy :)

MySQLZRM extract the backup to mysql

Posted on

1. locate the backup using the below command :

mysql-zrm-reporter --show restore-info --where backup-set=myhostserver1.com

where ‘myhostserver1.com’ is my host configured for backup
2. Extract the backup to the location /backup/sql/myhostserver1.com/20140604050029/ using the command below :

mysql-zrm-extract-backup --source-directory /backup/sql/myhostserver1.com/20140604050029/ --tmpdir /temporary_location/ 

Enjoy :)

MySQLZRM extract the backup to mysql

Posted on

1. locate the backup using the below command :

mysql-zrm-reporter --show restore-info --where backup-set=myhostserver1.com

where ‘myhostserver1.com’ is my host configured for backup
2. Extract the backup to the location /backup/sql/myhostserver1.com/20140604050029/ using the command below :

mysql-zrm-extract-backup --source-directory /backup/sql/myhostserver1.com/20140604050029/ --tmpdir /temporary_location/ 

Enjoy :)