Configure mail (sendmail) on Linux (RHEL)

Mission: Configure sendmail to be able to send mails to a smtp relay.

– Edit /etc/mail/sendmail.cf or /etc/sendmail.cf , it depends on your operating system.
Edit as:

# “Smart” relay host (may be null)
DS<mailserver_hostname>

Then restart sendmail.

Advertisements
Configure mail (sendmail) on Linux (RHEL)

Scan to email with Sharp AR-208D

Issues: I had a CE-03 error after scanning. Looking at the /var/log/maillog on my postfix server I saw a timeout exceeded error.
To be more specific, the error in the maillog file was:

postfix/smtpd[21913]: > unknown[10.3.10.109]: 421 myserver.mydomain.com 
Error: timeout exceeded
postfix/smtpd[21913]: timeout after EHLO from unknown[10.3.10.109]

Solution:
I changed the value of smtpd_timeout in /etc/postfix/main.cf:

smtpd_timeout = 35s

It was only 15s before.
And to apply the modification:

/etc/init.d/postfix reload

Then it worked, I received my scan by email but I didn’t realized right away because the e-mail arrived with a wrong timestamp.
So I set the scanner clock and everything went fine :-)

Comments in French, Portuguese, Spanish, Italian or Romanian are also welcomed.

Scan to email with Sharp AR-208D

Cluster monitoring with Nagios

Mission: We have a cluster of 2 devices. From the Nagios server network, we can’t ping both devices at the same time. It will be possible to ping one device for a while and impossible to ping the other one until the contrary happens.
An alert will appear in Nagios if one of the device becomes unreachable but it’s going to be a false alarm as the other device is reachable and the cluster healthy…
We want an alarm only if both devices are unreachable.

Solution:
To do this I used a Nagios plugins called check_multiaddr.
I found it there: http://exchange.nagios.org/directory/Plugins/Others/check_multiaddr/details

How I deployed it:
– I uploaded the file check_multiaddr.pl to my Nagios server
– I copied it into my nagios plugins directory (/usr/lib/nagios/plugins/)
– I made it executable:

#chmod +x check_multiaddr.pl

– I tested the script:
I want to test the ping service (Example with options already set: check_ping -H $HOSTADDRESS$ -w 800.0,20% -c 999.0,60% -p 5)
My devices IP addresses are 10.2.0.2 and 10.2.0.4
So, here is the command I executed:

#./check_multiaddr.pl /usr/lib/nagios/plugins/check_ping -H 10.2.0.2,10.2.0
.4 -w 800.0,20% -c 999.0,60% -p 5

– I got a timeout error:

Timeout detected (9s - you can edit its duration in ./check_multiaddr.pl).

– I edited the check_multiaddr.pl file and changed the TIMEOUT value from 9 to 15 seconds:

my $TIMEOUT = 20;

– I executed the same command and this time it worked:

10.2.0.2: PING OK - Packet loss = 0%, RTA = 0.97 ms|rta=0.970000ms;800.000000;999.000000;0.000000 pl=0%;20;60;0

– Now I had to change the Nagios configuration. I added a new host to represent my cluster. And I typed the 2 IP addresses separated by a comma (where I usually enter 1 IP address)
– I also created 2 new commands based on my existing commands: one to check if the host is alive and the standard ping service.
So, a command which was before: $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 1
became: $USER1$/check_multiaddr.pl $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 1
– And of course I assigned this commands to the new host check command and to the ping service for this host.
– Then I reloaded Nagios to make it apply the new configuration
– At first I got timeout errors (again?):

(Host Check Timed Out)

But this time it wasn’t because of the script setting. I had to change the Host Check Timeout in Nagios main configuration file. I changed the value to 15 (it was set to 10). If you’re using Centreon to set the Nagios configuration, the parameter is in Nagios -> nagios.cfg > Logs Options
– I reloaded again and it worked :-)

Again, don’t hesitate to write your questions/comments in French, Portuguese, Italian, Spanish or Romanian.

Cluster monitoring with Nagios

Dates in a Talend job

Mission: A friend sent me an email today. His question:

I have 2 incoming flows

Datebeg: DD/MM/YYYY format
Hourbeg: in minutes (example: 540 = 9h00)

How do I do to get this output: YYYYMMDDHHMMSS?

My answer:

I would do that:

First, add the minutes (Hourbeg) to the date (Datebeg):
TalendDate.addDate(row1.Datebeg, row1.Hourbeg, “mm”) 
The Datebeg type is Date.
The Hourbeg type is Integer.

Then, format the date :
TalendDate.formatDate(“yyyyMMddHHmmss”,Var.date2) 
Var.date2 is the output of TalendDate.addDate. Its type is Date. The output is gonna be a String.

Questions in French, Portuguese, Italian, Spanish, Romanian are welcomed.

Dates in a Talend job

Discussion avec un Cisco en telnet

Mission: chitchat with a Cisco through telnet. This is my old cheatsheet… in French.

telnet port 23

#enable
Rq : “en” suffit à la place de “enable”
=> taper mot de passe
#show run
Pour montrer la config existante
#conf t
Pour modifier la config
#?
Le ? permet de lister les possibilités de commandes
#wr mem
Pour enregistrer

exemple (après un conf t) :
#ip route 172.16.92.0 255.255.248.0 172.16.12.100

You can write your comments in English, French, Portuguese, Spanish, Italian or Romanian!

Discussion avec un Cisco en telnet

Add an user access to Nagios web interface

Mission: Give access to the Nagios web interface.

First, create a new user.
On the Nagios server:

# htpasswd /etc/nagios3/htpasswd.users newusername

htpasswd.users might be located somewhere else (you can use the locate command to find it) and you might also use htpasswd2 instead of htpasswd.

– I’m not sure it’s necessary but I did it:

/etc/init.d/apache2 reload

Then you have 2 options:

  • Option #1: you allow your user to view only specific hosts. In this case, if you enabled external commands in the Nagios configuration, your user will also be allowed to execute commands through the Nagios interface.
  • Option #2: you allow your user to view all hosts. In this case you can unauthorized the execution of external commands for this user.

You can find explanations in the official documentation : http://nagios.sourceforge.net/docs/3_0/cgiauth.html

Implementation of the Option #1:
– Create a contact user with the same username than the one you used in the htpasswd command
– Add the contact for each Host you want him to access (don’t need to add the contact at the service level, if it is a contact for a host, he can also view all the services associated to this host)
– Reload Nagios

Implementation of the Option #2:
– Modify the cgi.cfg file to give the user (use the same name as the one you used in the htpasswd command) the rights of :

  • System/Process Information Access
  • Global Host Information Access
  • Global Service Information Access

– Reload Nagios

References:
http://nagios.sourceforge.net/docs/3_0/cgiauth.html
http://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-another-user-for-nagios-web-interface-607353/
http://linuxsysadminblog.com/2009/05/setup-nagios-user-to-view-specific-host-and-services/

Loved this article? Send Ethereum to this address: 0x9b09d5b83395FE4F43e4746a8c44E8d8491799A3

Add an user access to Nagios web interface

Add disk space on a VM

Mission: Add disk space (10GB) to a VM (vSphere5) running one of the last versions of CentOS.
This will actually consist of extending the LVM logical volume.

– Couple of checks before starting:

# lvdisplay
--- Logical volume ---
LV Name                /dev/vg_myserver/lv_root
VG Name                vg_myserver
LV UUID                WhZDxf-IHgn-jM82-HfOQ-jbJc-
MtcL-ogyARd
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                15.54 GiB
Current LE             3978
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:0

--- Logical volume ---
LV Name                /dev/vg_myserver/lv_swap
VG Name                vg_myserver
LV UUID                gEzSPv-GyuX-34Ld-usrx-1Nks-Apcw-0OFfeT
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                3.97 GiB
Current LE             1016
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:1

# lvm vgdisplay
--- Volume group ---
VG Name               vg_myserver
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  3
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               19.51 GiB
PE Size               4.00 MiB
Total PE              4994
Alloc PE / Size       4994 / 19.51 GiB
Free  PE / Size       0 / 0
VG UUID               KJaWtf-ig6Y-9pAi-L2iw-3kl4-Jx1W-cFocjr

Good, we actually have logical volumes :-)

– I also checked that the last backup of this VM was successful before to start.

– Add disk space to the VM
You can extend the size of your virtual disk or create a new disk (I actually created a new disk: I couldn’t increase the size of my disk. I stopped the VM and still couldn’t increase the size of the disk, I thought it was because of the provisioning type but it was actually because I had created a snapshot. You can’t increase a disk size if there is any snapshot… I know it, now…)

– Now, you can take a snapshot of the VM in case it would go bad and you would need to go back and need the delta between the last backup and now.

– Then I checked I could see the new disk in the server. I supposed that my new disk would appear as /dev/sdb. So to be sure I used fdisk:

#fdisk /dev/sdb

I didn’t get any error message (good sign)
then I typed p to display the partitions (no partition)
I’m sure there is another way to do… but that the way I did it :-)

– Add a physical volume for use by LVM

# lvm pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created

– Add the physical volume to the volume group

# lvm vgextend vg_myserver /dev/sdb
Volume group "vg_myserver" successfully extended

I knew the name of my volume group from the command lvm vgdisplay I executed before

– We check:

# lvm vgdisplay
--- Volume group ---
VG Name               vg_myserver
System ID
Format                lvm2
Metadata Areas        2
Metadata Sequence No  4
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                2
Act PV                2
VG Size               29.50 GiB
PE Size               4.00 MiB
Total PE              7553
Alloc PE / Size       4994 / 19.51 GiB
Free  PE / Size       2559 / 10.00 GiB
VG UUID               KJaWtf-ig6Y-9pAi-L2iw-3kl4-
Jx1W-cFocjr

I can know see the available space :-)

– I check the size of my actual volume to know what would be the total size (actually I already had the information when I typed lvdisplay but anyway…)

# lvm lvdisplay /dev/vg_myserver/lv_root
--- Logical volume ---
LV Name                /dev/vg_myserver/lv_root
VG Name                vg_myserver
LV UUID                WhZDxf-IHgn-jM82-HfOQ-jbJc-
MtcL-ogyARd
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                15.54 GiB
Current LE             3978
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:0

– I make a hard calculation…. 3978+2559= 6537

– I extend the volume using this value:

# lvm lvresize -l 6537 /dev/vg_myserver/lv_root
Extending logical volume lv_root to 25.54 GiB
Logical volume lv_root successfully resized

– I resize the filesystem:

# resize2fs /dev/vg_myserver/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_myserver/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_myserver/lv_root to 6693888 (4k) blocks.
The filesystem on /dev/vg_myserver/lv_root is now 6693888 blocks long.

– Last check:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_biofloat-lv_
root
26G   13G   12G  51% /

It worked :-)

– Don’t forget to delete the snapshot ones you are sure everything is OK.
I had an instant of doubt after clicking on  “Delete” but no worries: If “You are here” is after your snapshot, the “Delete” action will commit the snapshot data to the parent and delete the snapshot.

References: http://wiki.centos.org/TipsAndTricks/ExpandLV

If you any question/comment, don’t hesitate to write in another language if you prefer. I should be able to answer in French, Portuguese, Spanish, Italian or Romanian.

Add disk space on a VM