Thursday, August 23, 2018

Monitoring Audit Log Linux File Access, File Open , Changes and Data Modifications

Monitoring Audit Log Linux File Access, File Open, 
Changes and Data Modifications

Step -1

Create an audit policy watch rule.

[root@muthayammal ssh]# auditctl -w /etc/passwd -p war -k password-file

Step -2

finding audit log linux file open / file open detect  and modification / changes.

[root@muthayammal ssh]# ausearch -f /etc/passwd -i
----
time->Thu Aug 23 14:55:36 2018
type=PROCTITLE msg=audit(1535016336.242:81887): proctitle=67726570002D2D636F6C6F723D6175746F00736F6D657468696E67002F6574632F706173737764
type=PATH msg=audit(1535016336.242:81887): item=0 name="/etc/passwd" inode=134980183 dev=fd:01 mode=0100644 ouid=0 ogid=0 rdev=00:00 objtype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0type=CWD msg=audit(1535016336.242:81887):  cwd="/etc/ssh"type=SYSCALL msg=audit(1535016336.242:81887): arch=c000003e syscall=257 success=yes exit=3 a0=ffffffffffffff9c a1=7ffd11eb181d a2=0 a3=0 items=1 ppid=14653 pid=15174 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=4275 comm="grep" exe="/usr/bin/grep" key="password-file

Step -3

List running audit policy.

[root@muthayammal etc]# auditctl -l
-w /etc/passwd -p rwa -k password-file

Step -4

Delete Audit policy using below command.

[root@muthayammal etc]# auditctl -D -k password-file
No rules

Saturday, August 11, 2018

Centos (Linux) adding multiple IP addresses and adding NIC Routing

Centos (Linux) adding multiple IP addresses and adding NIC Routing


Step-1:-

NIC Interfaces config are as follow :

root#cd /etc/sysconfig/network-scripts

ETH0 :  (ifcfg-ens160)

TYPE="Ethernet"
NAME="ens160"
UUID="21a11fc4-899c-4d3c-bf55-82cb2b5b64ab"
ONBOOT="yes"
HWADDR="90:0C:29:fg:2B:44"
IPADDR=192.168.100.211
NETMASK=255.255.255.0
GATEWAY=192.168.100.1


ETH1 : (ifcfg-ens192)

TYPE="Ethernet"
IPADDR=103.58.120.120
NETMASK=255.255.255.240
GATEWAY=103.58.120.113
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
DNS1=103.58.200.2
DNS2=8.8.8.8
NAME="ens192"
ONBOOT="yes"
HWADDR="00:0c:29:ed:2b:11"
PEERDNS="yes"
PEERROUTES="yes"

Step-2:-

Add default External Geway address (Optional).

[root@localhost sysconfig]# cat /etc/sysconfig/network
GATEWAY=103.58.120.113

Step-3:-

Create Shell scripts adding both IP address gateway for simultaneous access.

root#vi /root/network.sh

#!/bin/sh

ip rule add from 103.58.120.112/28 pref 200 lookup 201
ip route add default via 103.58.120.113 dev ens192 table 201

ip rule add from 192.168.100.0/24 pref 200 lookup 202
ip route add default via 192.168.100.1 dev ens160 table 202

ip route flush cache

Reference Note:-

103.58.120.112/28 - Subnet
103.58.120.113 - Gateway

192.168.100.0/24 - Subnet
192.168.100.1 - Gateway

Step-4:-

Provide execute permission shell scripts.

root#chmod 755 /root/network.sh
root#chmod +x /root/network.sh

Step-5:-

Add shell script file path into init.d network file for auto adds the default gateway. if any node restart.

root#vi /etc/init.d/network

#! /bin/bash
#
# network       Bring up/down networking
#
# chkconfig: 2345 10 90
# description: Activates/Deactivates all network interfaces configured to \
#              start at boot time.
#
### BEGIN INIT INFO
# Provides: $network
# Should-Start: iptables ip6tables NetworkManager-wait-online NetworkManager
# Short-Description: Bring up/down networking
# Description: Bring up/down networking
### END INIT INFO

./root/network.sh

Step-6:-

Perform the restart command.

root#reboot

After successful Reboot the Linux system. It will accessible both IP address segments.

Reference other sites - https://serverfault.com/questions/567249/centos-multiple-nics-routing-issue

Friday, June 29, 2018

Nagios do2db-3x: mysql_error: 'Incorrect key file for table

Nagios do2db-3x: mysql_error: 'Incorrect key file for table

Nagios Error Code:-

Jun 23 16:15:40 eznag ndo2db-3x: mysql_error: 'Incorrect key file for table './nagios/nagios_timedevents.MYI'; try to repair it'
Jun 23 16:15:40 eznag ndo2db-3x: Error: mysql_query() failed for 'DELETE FROM nagios_timedeventqueue WHERE instance_id='1' AND scheduled_time<FROM_UNIXTIME(1529750740)'
Jun 23 16:15:40 eznag ndo2db-3x: mysql_error: 'Incorrect key file for table './nagios/nagios_timedeventqueue.MYI'; try to repair it'
Jun 23 16:15:40 eznag ndo2db-3x: Error: mysql_query() failed for 'INSERT INTO nagios_hostchecks SET instance_id='1', host_object_id='406', check_type='0', is_raw_check='0', current_check_attempt='1', max_check_attempts='10', state='0', state_type='1', start_time=FROM_UNIXTIME(1529750740), start_time_usec='126616', end_time=FROM_UNIXTIME(0), end_time_usec='0', timeout='30', early_timeout='0', execution_time='0.000000', latency='0.126000', return_code='0', output='', long_output='', perfdata='', command_object_id='1', command_args='', command_line='/usr/local/nagios/libexec/check_ping -H 192\.168\.10\.3 -w 3000\.0,80% -c 5000\.0,100% -p 5' ON DUPLICATE KEY UPDATE instance_id='1', host_object_id='406', check_type='0', is_raw_check='0', current_check_attempt='1', max_check_attempts='10', state='0', state_type='1', start_time=FROM_UNIXTIME(1529750740), start_time_usec='126616', end_time=FROM_UNIXTIME(0), end_time_usec='0', timeout='30', early_timeout='0', execution_time='0.000000', latency='0.126000', return_code='0', output='', long_output='', perfdata='''
Jun 23 16:15:40 eznag ndo2db-3x: mysql_error: 'Incorrect key file for table './nagios/nagios_hostchecks.MYI'; try to repair it'

Resolution:-

Run below Mysql Linux command on Nagios Linux node.

[root@eznag log]#mysqlcheck --user=nagios --password=nagios --repair --all-databases
[root@eznag log]#myisamchk --safe-recover /var/lib/mysql/*/*.MYI

Recover DB safer mode. You can see logs all status "OK".

[root@eznag log]# mysqlcheck -u nagios -p nagios
Enter password:
nagios.nagios_acknowledgements                     OK
nagios.nagios_commands                             OK
nagios.nagios_commenthistory                       OK
nagios.nagios_comments                             OK
nagios.nagios_configfiles                          OK
nagios.nagios_configfilevariables                  OK
nagios.nagios_conninfo                             OK
nagios.nagios_contact_addresses                    OK
nagios.nagios_contact_notificationcommands         OK
nagios.nagios_contactgroup_members                 OK
nagios.nagios_contactgroups                        OK
nagios.nagios_contactnotificationmethods           OK
nagios.nagios_contactnotifications                 OK
nagios.nagios_contacts                             OK
nagios.nagios_contactstatus                        OK
nagios.nagios_customvariables                      OK
nagios.nagios_customvariablestatus                 OK
nagios.nagios_dbversion                            OK
nagios.nagios_downtimehistory                      OK
nagios.nagios_eventhandlers                        OK
nagios.nagios_externalcommands                     OK
nagios.nagios_flappinghistory                      OK
nagios.nagios_host_contactgroups                   OK
nagios.nagios_host_contacts                        OK
nagios.nagios_host_parenthosts                     OK
nagios.nagios_hostchecks                           OK
nagios.nagios_hostdependencies                     OK
nagios.nagios_hostescalation_contactgroups         OK
nagios.nagios_hostescalation_contacts              OK
nagios.nagios_hostescalations                      OK
nagios.nagios_hostgroup_members                    OK
nagios.nagios_hostgroups                           OK
nagios.nagios_hosts                                OK
nagios.nagios_hoststatus                           OK
nagios.nagios_instances                            OK
nagios.nagios_logentries                           OK
nagios.nagios_notifications                        OK
nagios.nagios_objects                              OK
nagios.nagios_processevents                        OK
nagios.nagios_programstatus                        OK
nagios.nagios_runtimevariables                     OK
nagios.nagios_scheduleddowntime                    OK
nagios.nagios_service_contactgroups                OK
nagios.nagios_service_contacts                     OK
nagios.nagios_servicechecks                        OK
nagios.nagios_servicedependencies                  OK
nagios.nagios_serviceescalation_contactgroups      OK
nagios.nagios_serviceescalation_contacts           OK
nagios.nagios_serviceescalations                   OK
nagios.nagios_servicegroup_members                 OK
nagios.nagios_servicegroups                        OK
nagios.nagios_services                             OK
nagios.nagios_servicestatus                        OK
nagios.nagios_statehistory                         OK
nagios.nagios_systemcommands                       OK
nagios.nagios_timedeventqueue                      OK
nagios.nagios_timedevents                          OK
nagios.nagios_timeperiod_timeranges                OK
nagios.nagios_timeperiods                          OK
nagios.snmptt                                      OK
nagios.snmptt_archive                              OK
nagios.snmptt_unknown                              OK
[root@eznag log]#

Nagios ndomod Still unable to connect to data sink Error

Nagios ndomod Still unable to connect to data sink Error


Nagios Error Code:-

[root@eznag log]# tail -f messages
Jun 17 03:51:44 eznag nagios: ndomod: Still unable to connect to data sink.  3585388 items lost, 5000 queued items to flush.
Jun 17 03:52:00 eznag nagios: ndomod: Still unable to connect to data sink.  3585561 items lost, 5000 queued items to flush.
Jun 17 03:52:16 eznag nagios: ndomod: Still unable to connect to data sink.  3585774 items lost, 5000 queued items to flush.
Jun 17 03:52:32 eznag nagios: ndomod: Still unable to connect to data sink.  3585877 items lost, 5000 queued items to flush.
Jun 17 03:52:48 eznag nagios: ndomod: Still unable to connect to data sink.  3585970 items lost, 5000 queued items to flush.

Resolution:-

Run below Linux commands.

[root@eznag log]#service nagios stop

Delete the sock file.
[root@eznag log]#rm /usr/local/nagios/var/ndo.sock

[root@eznag log]#service nagios start

Check logs, It will stop "Still unable to connect to data sink" error logs.

[root@eznag log]# tail -f messages
Jun 23 16:31:43 eznag nagios: ndomod: Successfully connected to data sink.  8 queued items to flush.
Jun 23 16:31:43 eznag nagios: ndomod: Successfully flushed 8 queued items to data sink.
Jun 23 16:31:43 eznag nagios: Event broker module '/usr/local/nagios/bin/ndomod-3x.o' initialized successfully.
Jun 23 16:31:43 eznag nagios: npcdmod: Copyright (c) 2008-2009 Hendrik Baecker (andurin@process-zero.de) - http://www.pnp4nagios.org
Jun 23 16:31:43 eznag nagios: npcdmod: /usr/local/nagios/etc/npcd.cfg initialized
Jun 23 16:31:43 eznag nagios: npcdmod: spool_dir = '/usr/local/nagios/var/spool/'.
Jun 23 16:31:43 eznag nagios: npcdmod: perfdata file '/usr/local/nagios/var/perfdata.dump'.
Jun 23 16:31:43 eznag nagios: npcdmod: Ready to run to have some fun!
Jun 23 16:31:43 eznag nagios: Event broker module '/usr/local/nagios/lib/npcdmod.o' initialized successfully.
Jun 23 16:31:43 eznag nagios: Finished daemonizing... (New PID=10457)

Monday, February 19, 2018

Gitlab Automation Project Showcase

My GitLab Projects Showcase 🚀 Welcome to my portfolio of GitLab projects. Each repository reflects my journey as an engineer, focusing...