bash -c 'exec -a ProcessName sleep 1000000' &
Linux administration , Unix administration , Vmware Vsphere administration , Oracle DBA ,apache, backup, dhcp, dns, kvm, xen, kernel, ldap, kvm, monitoring, ticketing, networking, Mail servers, SAN,troubleshooting
Labels
- Amanda (2)
- Ansible (2)
- Answer these Questions (2)
- antivirus (2)
- apache (3)
- Bash (16)
- Chef (3)
- Citrix (2)
- clusters (2)
- Concept (22)
- DatabaseAdminstration (11)
- DevOps (1)
- dhcp (2)
- Downloads (3)
- ELK (1)
- ELK stack (1)
- encryption (1)
- Free trainings (1)
- Frequently Used Commands (46)
- FTP (1)
- git (1)
- gpg (2)
- Hardware (1)
- httpd (2)
- Interview Questions (53)
- iptables (1)
- IT NEWS (3)
- java (1)
- kibana (2)
- knife (1)
- KVM (2)
- linux (17)
- Linux installations (22)
- Linux Jobs (4)
- Linux Links (2)
- logstash (1)
- Mac (1)
- MediaWiki (1)
- MySql (2)
- Nagios (2)
- Networking (3)
- open Nebula (5)
- Open Source tools (12)
- OpenNMS (1)
- openSSL (1)
- Oracle on Linux (5)
- Performance Monitoring (1)
- php (1)
- postfix (1)
- postgres (1)
- postgres-XL (1)
- Product Reviews (1)
- Python (2)
- rssh (1)
- Samba (2)
- Scripting (16)
- security (4)
- selinux (1)
- Server (1)
- SFTP (1)
- Social Awareness (1)
- Solaris (1)
- SSL (1)
- svn (1)
- TCP/IP (1)
- Technology (1)
- Tips and Tricks (32)
- Training and materials (8)
- Troubleshooting (6)
- Ubuntu (18)
- unix (1)
- virtualization (17)
- Vmware (25)
- Vyatta (1)
- windows7 (1)
- xml (1)
nagios https proxy monitoring plugin or Bash website monitoring script
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No arguments supplied"
fi
if [ $# -eq 1 ]
then
output=`curl -x 10.11.10.10:3128 -L $1 -m 10 -o /dev/null || echo "Website_down"`
if [ "$output" == "Website_down" ] ; then
echo "Website is down CRITICAL "
exit 2
else
echo "Website_up $1 OK"
exit 0
fi
fi
if [ $# -eq 0 ]
then
echo "No arguments supplied"
fi
if [ $# -eq 1 ]
then
output=`curl -x 10.11.10.10:3128 -L $1 -m 10 -o /dev/null || echo "Website_down"`
if [ "$output" == "Website_down" ] ; then
echo "Website is down CRITICAL "
exit 2
else
echo "Website_up $1 OK"
exit 0
fi
fi
Adding client certificate file using chef data bags
Below is just an example
logstash_cert_secret = Chef::EncryptedDataBagItem.load_secret("/etc/chef/secrets/logstash_client_key")
logstash_certs = Chef::EncryptedDataBagItem.load("certs", "logstash_client", logstash_cert_secret)
directory "/etc/pki/tls/certs/" do
action :create
mode "0755"
owner "root"
group "root"
end
file "/etc/pki/tls/certs/logstash_client.crt" do
action :create
mode "0644"
owner "root"
group "root"
content logstash_certs["crt"].join("")
end
Search and replace in all files in a current directory
grep -rl 'pc961' ./|xargs sed -i 's/pc961/pc/g'
Ansible define a basic windows hosts
[windows]
10.10.10.120
[windows:vars]
ansible_connection=winrm
ansible_ssh_user=Administrator
ansible_ssh_pass=AdminPa$$
Three basic Git commands
1) git add -A
git add -A is equivalent to git add .; git add -u.
git add . ( This will add all files but does not remove files )
git add -u ( This will add only changes but will not add any new files created )
So we use
git add -A ( this will take care of both the commands )
2) git commit -m “Commit changes text ex: I have added new function xyz to the file
3) git push origin
example of branch name : develop
Another 3 frequently used commands include :
git pull
git status
git merge origin/Branchname
Installing configuring Ansible and deploying haproxy playbook
Basic installation
sudo yum install ansible (or) sudo pip install ansible
Configuring your hosts file with inventory
cat /etc/ansible/hosts[haproxy]10.0.184.12[all_servers:vars]ansible_connection=sshansible_user=rootansible_ssh_private_key_file=/Users/home/yoursshkey.pemI have only one server in my inventory where i will be setting up an haproxy For easy management we will be writing common variables under [all_servers:vars]When we run ansible play books hosts will be picked from the above inventory file
Example : hosts: haproxy ( this will run on all servers under haproxy )
Now test servers doing a ping ( ping in ansible will connect to the server using ssh )
ansible haproxy -m ping10.0.184.12 | SUCCESS => {"changed": false,"ping": "pong"}Then Download ready made packages from ansible galaxyhttps://galaxy.ansible.com/devops/haproxy/Also download dependencies that will configure EPEL repositorieshttps://galaxy.ansible.com/sfromm/epel/Then create a common playbook for both the roles main.yml- hosts: haproxyroles:- { role: devops.epel }- hosts: haproxyroles:- role: devops.haproxyhaproxy_stats:name: 'global_monitor'ip: "{{ ansible_default_ipv4.address }}"port: '38888'stats:enabled: Truehide_version: trueuri: /slb_stats_urlrealm: Welcome\ to\ slb\ monitorauth: admin:adminrefresh: 2shaproxy_frontends:- name: 'fe-testsite'ip: '{{ ansible_default_ipv4.address }}'port: '80'maxconn: '1000'default_backend: 'be-testsite'haproxy_backends:- name: 'be-testsite'description: 'testsite'servers:- name: 'be-testsite-01'ip: '192.168.1.100'
sh-3.2# ansible-playbook main.yml
PLAY [haproxy] *****************************************************************
TASK [setup] *******************************************************************
ok: [10.0.184.12]
TASK [devops.epel : Installs python dependencies] ******************************
changed: [10.0.184.12] => (item=[u'libselinux-python'])
TASK [devops.epel : Disable SElinux] *******************************************
changed: [10.0.184.12]
TASK [devops.epel : create EPEL yum repository] ********************************
changed: [10.0.184.12]
TASK [devops.epel : import EPEL GPG key] ***************************************
changed: [10.0.184.12]
PLAY [haproxy] *****************************************************************
TASK [setup] *******************************************************************
ok: [10.0.184.12]
TASK [devops.haproxy : Include OS-specific variables.] *************************
ok: [10.0.184.12]
TASK [devops.haproxy : Installs haproxy as well as socat for socket api.] ******
changed: [10.0.184.12] => (item=[u'haproxy', u'socat'])
TASK [devops.haproxy : Ensure HAProxy is started and enabled on boot.] *********
changed: [10.0.184.12]
TASK [devops.haproxy : Ensure chroot directory exists.] ************************
ok: [10.0.184.12]
TASK [devops.haproxy : Create directory for the frontend] **********************
changed: [10.0.184.12]
TASK [devops.haproxy : Empty the folder if not already empty] ******************
changed: [10.0.184.12]
TASK [devops.haproxy : Build up the frontends] *********************************
[DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the full variable syntax ('{{haproxy_frontends}}').
This feature will be
removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
changed: [10.0.184.12] => (item={u'ip': u'10.0.184.12', u'maxconn': u'1000', u'default_backend': u'be-testsite', u'port': u'80', u'name': u'fe-testsite'})
TASK [devops.haproxy : Create directory for the backends] **********************
changed: [10.0.184.12]
TASK [devops.haproxy : Empty the folder if not already empty] ******************
changed: [10.0.184.12]
TASK [devops.haproxy : Build up the backends] **********************************
[DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the full variable syntax ('{{haproxy_backends}}').
This feature will be
removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
changed: [10.0.184.12] => (item={u'servers': [{u'ip': u'192.168.1.100', u'name': u'be-testsite-01'}], u'description': u'testsite', u'name': u'be-testsite'})
TASK [devops.haproxy : Create directory for the listen sections] ***************
changed: [10.0.184.12]
TASK [devops.haproxy : Empty the folder if not already empty] ******************
changed: [10.0.184.12]
TASK [devops.haproxy : Build up the listen sections] ***************************
skipping: [10.0.184.12] => (item=haproxy_listen)
TASK [devops.haproxy : Create directory for the userlists] *********************
changed: [10.0.184.12]
TASK [devops.haproxy : Empty the folder if not already empty] ******************
changed: [10.0.184.12]
TASK [devops.haproxy : Build up the userlist sections] *************************
skipping: [10.0.184.12] => (item=haproxy_userlists)
TASK [devops.haproxy : Create the compiled folder] ****************************
changed: [10.0.184.12]
TASK [devops.haproxy : Empty the folder if not already empty] ******************
changed: [10.0.184.12]
TASK [devops.haproxy : Build up the global config] *****************************
changed: [10.0.184.12]
TASK [devops.haproxy : Build up the default config] ****************************
changed: [10.0.184.12]
TASK [devops.haproxy : Build up the stats config] ******************************
changed: [10.0.184.12]
TASK [devops.haproxy : Assemble the frontends configuration file] **************
changed: [10.0.184.12]
TASK [devops.haproxy : Assemble the backends configuration file] ***************
changed: [10.0.184.12]
TASK [devops.haproxy : Assemble the listen sections configuration file] ********
changed: [10.0.184.12]
TASK [devops.haproxy : Assemble the userlists sections configuration file] *****
changed: [10.0.184.12]
TASK [devops.haproxy : Assemble the final configuration file] ******************
changed: [10.0.184.12]
RUNNING HANDLER [devops.haproxy : restart haproxy] *****************************
changed: [10.0.184.12]
PLAY RECAP *********************************************************************
10.0.184.12 : ok=31 changed=27 unreachable=0 failed=0
This is just a test deployment that will forward request to background test server 192.168.1.100
Subscribe to:
Posts (Atom)