186 | | You can now click ''Finish install''. |
| 186 | |
| 187 | You can now click ''''Finish install''''. |
| 188 | |
| 189 | == Configuring LibreNMS == |
| 190 | |
| 191 | === Setting the SNMP community === |
| 192 | |
| 193 | Let's change the SNMP community that LibreNMS will try when discovering and adding new devices. |
| 194 | |
| 195 | First edit the file /opt/librenms/config.php, |
| 196 | {{{ |
| 197 | # vi /opt/librenms/config.php |
| 198 | }}} |
| 199 | |
| 200 | and find the line: |
| 201 | {{{ |
| 202 | $config['snmp']['community'] = array("public"); |
| 203 | }}} |
| 204 | |
| 205 | And change it to: |
| 206 | {{{ |
| 207 | $config['snmp']['community'] = array("<class password>"); |
| 208 | }}} |
| 209 | |
| 210 | === Allowed Subnets === |
| 211 | |
| 212 | Tell LibreNMS which subnets it's allowed to scan automatically |
| 213 | |
| 214 | By default, LibreNMS will try ask for the list of “neighbors” that network devices "see" on the network. This is done using the Link Layer Discovery Protocol (LLDP) or Cisco's CDP (Cisco Discovery Protocol). |
| 215 | |
| 216 | But to be on the safe side, and not scan networks outside your organization, LibreNMS needs to be told which subnets it's allowed to scan for new devices. |
| 217 | |
| 218 | Still in the file /opt/librenms/config.php, find the line: |
| 219 | {{{ |
| 220 | #$config['nets'][] = "10.0.0.0/8"; |
| 221 | }}} |
| 222 | |
| 223 | And replace this with the following to scan our specific subnets in use by our network and the workshop infrastructure. |
| 224 | {{{ |
| 225 | $config['nets'][] = "192.248.6.0/24"; |
| 226 | }}} |
| 227 | |
| 228 | === Avoid Duplicate devices === |
| 229 | |
| 230 | We need to make one more change... |
| 231 | |
| 232 | Tell LibreNMS not to add duplicate devices |
| 233 | |
| 234 | To avoid making duplicate devices, add the following line at the bottom of the config.php file: |
| 235 | {{{ |
| 236 | $config['allow_duplicate_sysName'] = false; |
| 237 | }}} |
| 238 | |
| 239 | === Discovery Method === |
| 240 | |
| 241 | Finaly we have to define the discovery method. Here we will use ARP to discover devices. to do that add the following line |
| 242 | {{{ |
| 243 | $config['discovery_modules']['discovery-arp'] = 1; |
| 244 | }}} |
| 245 | |
| 246 | After you've added the above setting, save the file and exit - we’re nearly done! |
| 247 | |
| 248 | |
| 249 | === Add a host === |
| 250 | |
| 251 | Let's add localhost (i.e.: YOUR virtual server), using the following commands. you can do this from the Web interface: |
| 252 | {{{ |
| 253 | # cd /opt/librenms |
| 254 | # php addhost.php localhost <class password> v2c |
| 255 | }}} |
| 256 | |
| 257 | You should see: |
| 258 | {{{ |
| 259 | Added device localhost (1) |
| 260 | }}} |
| 261 | |
| 262 | Notice we explicitly tell LibreNMS which SNMP community to use. We also assume it's SNMP v2c. If you're using v3, there are additional steps which aren't provided here. |
| 263 | |
| 264 | === Final Configuration === |
| 265 | |
| 266 | Discover and Poll newly added hosts |
| 267 | |
| 268 | LibreNMS first “discovers” each host that has been added. This means that it methodically examines each host you added and figures out what it should monitor. The discover.php script does not automatically scan your network to find new devices. To run this script do: |
| 269 | {{{ |
| 270 | # cd /opt/librenms |
| 271 | # sudo -u librenms php discovery.php -h all |
| 272 | }}} |
| 273 | |
| 274 | NOTE: This could take some time. If you try to add devices that do not yet have an snmp service configured, then the discovery script takes a while to time out. |
| 275 | |
| 276 | Once this has finished you can now "poll" the hosts. This means LibreNMS now knows what it wishes to monitor for each host, but it has yet to populate its database with initial values for each item. To do this we do: |
| 277 | |
| 278 | {{{ |
| 279 | # sudo -u librenms php poller.php -h all |
| 280 | }}} |
| 281 | |
| 282 | As you can see the poller.php script does quite a bit with just a few devices. When we add it to a cronjob below this helps explain why LibreNMS is a resource intensive tool. |
| 283 | |
| 284 | === Create cronjob === |
| 285 | |
| 286 | Create the cronjob which will run periodic tasks required by LibreNMS: |
| 287 | {{{ |
| 288 | # cd /opt/librenms |
| 289 | # cp librenms.nonroot.cron /etc/cron.d/librenms |
| 290 | }}} |
| 291 | |
| 292 | One last thing: edit the file /etc/cron.d/librenms ... |
| 293 | {{{ |
| 294 | # editor /etc/cron.d/librenms |
| 295 | }}} |
| 296 | |
| 297 | ...and find the line: |
| 298 | {{{ |
| 299 | */5 * * * * librenms /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16 |
| 300 | }}} |
| 301 | |
| 302 | And change the ''16'' at the end to ''4'' (we have a single processor, and 4 threads is plenty) |
| 303 | {{{ |
| 304 | */5 * * * * librenms /opt/librenms/cronic /opt/librenms/poller-wrapper.py 4 |
| 305 | }}} |
| 306 | |
| 307 | Save, and exit. |
| 308 | |