|
| 1 | +On NagiosServer: |
| 2 | + |
| 3 | + 1 yum install httpd php gcc glibc glibc-comman gd gd-devel make net-snmp unzip -y |
| 4 | + 3 wget https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.3.2/nagios-4.3.2.tar.gz |
| 5 | + 4 wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz |
| 6 | + 5 tar -zxvf nagios-4.3.2.tar.gz |
| 7 | + 6 tar -zxpvf nagios-plugins-2.2.1.tar.gz |
| 8 | + 7 useradd nagios |
| 9 | + 8 passwd nagios |
| 10 | + 9 groupadd nagcmd |
| 11 | + 10 usermod -G nagcmd nagios |
| 12 | + 11 usermod -G nagcmd apache |
| 13 | + 12 cd nagios-4.3.2 |
| 14 | + 13 ./configure --with-command-group=nagcmd |
| 15 | + 14 make all |
| 16 | + 15 make install |
| 17 | + 16 make install-init |
| 18 | + 17 make install-commandmode |
| 19 | + 18 make install-config |
| 20 | + 19 make install-webconf |
| 21 | + 20 htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin |
| 22 | + //21 vi /usr/local/nagios/etc/objects/contacts.cfg |
| 23 | + 22 systemctl restart httpd |
| 24 | + 23 cd .. |
| 25 | + 24 cd nagios-plugins-2.2.1/ |
| 26 | + 25 ./configure --with-nagios-user=nagios --with-nagios-group=nagios |
| 27 | + 26 make |
| 28 | + 27 make install |
| 29 | + 28 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg |
| 30 | + 29 systemctl enable nagios |
| 31 | + 30 systemctl start nagios |
| 32 | + 31 systemctl restart httpd |
| 33 | + systemctl restart nagios |
| 34 | +open the browser http://ip address/nagios |
| 35 | +uid:nagiosadmin(set in the previous steps) |
| 36 | +pwd: |
| 37 | + |
| 38 | +On Nagios Host (linux): |
| 39 | + 7 rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm |
| 40 | + 8 yum install nrpe nagios-plugins-all -y |
| 41 | + 9 vim /etc/nagios/nrpe.cfg |
| 42 | +In this file, |
| 43 | +uncomment server address, |
| 44 | +and remove the value for current server adress |
| 45 | +and add the private ip of you nagios server as |
| 46 | +Server address=172.31.40.7 |
| 47 | + |
| 48 | +add private ip of nagios server under |
| 49 | + |
| 50 | +allowed_hosts=172.31.40.7 |
| 51 | + |
| 52 | + |
| 53 | + 10 systemctl enable nrpe |
| 54 | + 11 systemctl start nrpe |
| 55 | + |
| 56 | +Go to nagios server |
| 57 | + |
| 58 | +In nigios.cfg |
| 59 | + |
| 60 | +# vim nagios.cfg |
| 61 | +uncomment this dire : /usr/local/nagios/etc/servers |
| 62 | + |
| 63 | +etc] # mkdir servers |
| 64 | +] # cd servers/ |
| 65 | +# ls |
| 66 | +# cp /usr/local/nagios/etc/objects/localhost.cfg ip-172-31-22-220.us-east-2.compute.internal.cfg |
| 67 | + |
| 68 | +copy the localhost.cfg file from objects directory and create file with name as |
| 69 | +privatehostanameofNagiosHost.cfg |
| 70 | + |
| 71 | +# ls |
| 72 | + |
| 73 | +privatehostanameofNagiosHost.cfg file will be there. copy it |
| 74 | + |
| 75 | +# vim privatehostanameofNagiosHost.cfg |
| 76 | + |
| 77 | +Inside this file make follwoing chnages: |
| 78 | +Under |
| 79 | +define host{ |
| 80 | + |
| 81 | +add host_name= privatehostname of nagioshost |
| 82 | +alias = privatehostname of nagioshost |
| 83 | +address = private ip of host |
| 84 | +} |
| 85 | + |
| 86 | +under chnage linuxservers to linux server |
| 87 | + |
| 88 | +define hostgroup{ |
| 89 | + |
| 90 | +hostgroup_name= linuxserver |
| 91 | +alias = linux server |
| 92 | +memeber = privatehostname of nagioshost |
| 93 | +} |
| 94 | + |
| 95 | +in all services definitions change |
| 96 | +host_name= privatehostname of nagioshost |
| 97 | +} |
| 98 | + |
| 99 | +:wq! |
| 100 | + |
| 101 | +# now restart nagios |
| 102 | + |
| 103 | +systemctl restart nagios |
| 104 | + |
| 105 | +go to web view of nagios and see new linux machine is added. |
| 106 | + |
| 107 | +This is how you can monitor a windows and linux machine |
| 108 | + |
| 109 | +Go to HOST machine |
| 110 | + |
| 111 | +********************************* |
| 112 | + |
| 113 | + |
| 114 | +Install docker |
| 115 | + |
| 116 | +# yum install docker -y |
| 117 | + |
| 118 | +# systemctl start docker |
| 119 | + |
| 120 | +# docker run -itd -P nginx |
| 121 | + |
| 122 | +# docker ps |
| 123 | + |
| 124 | +note the port number |
| 125 | + |
| 126 | +go to browser |
| 127 | + |
| 128 | +public ip of host :portnumber |
| 129 | + |
| 130 | +container created and app running |
| 131 | + |
| 132 | +Now let us monitor this app using nagios |
| 133 | + |
| 134 | +Go to Nagios SERVER |
| 135 | + |
| 136 | +******************* |
| 137 | + |
| 138 | +Go to following location: |
| 139 | + |
| 140 | +servers] # cd.. |
| 141 | +objects] # cd.. |
| 142 | +etc] # cd .. |
| 143 | +nagios] # ls |
| 144 | + |
| 145 | +# cd libexec |
| 146 | + |
| 147 | +# ls |
| 148 | + |
| 149 | +You will see all the default plugins running |
| 150 | + |
| 151 | +to monitor an application. use the plugin ./check_http |
| 152 | + |
| 153 | +# ./check_http -I 18.222.209.193 -p 32768 |
| 154 | + |
| 155 | +# ./check_http -v // give all options to use with this plugin |
| 156 | + |
| 157 | +# ./check_tcp -H 172.31.44.151 -v -p 8888 -N http://3.21.41.81:8888/addressbook/ |
| 158 | + |
| 159 | +// adress book |
| 160 | + |
| 161 | +http://3.21.41.81:8888/addressbook/ |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | +************************************ |
| 166 | + |
| 167 | +WINDOWS MACHINE SETUP |
| 168 | + |
| 169 | +*********************************** |
| 170 | + |
| 171 | +After installation |
| 172 | + |
| 173 | +go to |
| 174 | +cd /usr/local/nagios |
| 175 | +ls |
| 176 | +cd etc |
| 177 | +ls |
| 178 | + |
| 179 | +You will see file nagios.cfg |
| 180 | + |
| 181 | +# vim nagios.cfg |
| 182 | + |
| 183 | +Uncomment this line: |
| 184 | + |
| 185 | +# Definitions for monitoring a Windows machine |
| 186 | +cfg_file=/usr/local/nagios/etc/objects/windows.cfg |
| 187 | + |
| 188 | +Now go to objects directory |
| 189 | + |
| 190 | +# cd objects/ |
| 191 | +ls |
| 192 | +vim windows.cfg |
| 193 | + |
| 194 | +go to cmd prompt |
| 195 | +ipconfig |
| 196 | + |
| 197 | + IPv4 Address. . . . . . . . . . . : 192.168.1.4 |
| 198 | + |
| 199 | +C:\Users\vishal mittal>hostname |
| 200 | +LAPTOP-N0G0NBDP |
| 201 | + |
| 202 | + |
| 203 | +In the windows.cfg file change |
| 204 | + |
| 205 | +address = 192.168.1.4 |
| 206 | + |
| 207 | +host_name = LAPTOP-N0G0NBDP |
| 208 | + |
| 209 | + |
| 210 | +save the file |
| 211 | + |
| 212 | +# systemctl restart nagios |
| 213 | +systemctl restart httpd |
| 214 | + systemctl restart nagios |
| 215 | + |
| 216 | +go to web :http://3.139.73.88/nagios/ |
| 217 | + |
| 218 | +hosts |
| 219 | +laptop will be available for monitoring |
| 220 | + |
| 221 | + |
0 commit comments