LiquidObject

Bulk disabling modules in LibreNMS

So I was in the process of adding in a large quantity of devices into LibreNMS but noticed a few days later the discovery and polling times were getting longer. Not really to be unexpected as there was more devices but some devices took an abnormally amount of time to finish the SNMP scans. Below is an example how to bulk disable attributes under LibreNMS (likely to work on Observium as well).

Outside of globally disabling different modules we will need to talk directly to the MySQL database in order to accomplish what we are looking for.

In the below example I’m looking at disabling the discover_arp-table on all Windows hosts.

select device_id,hostname from devices where OS = 'windows';

Then copy and paste the results into your favorite editor (I generally use excel for data like this).

="insert into devices_attribs (device_id,attrib_type,attrib_value) values ("""&A2&""",""discover_arp-table"",""0"");"

In the above the “A” column contains all the device_id’s I wish to adjust.

This will generate MySQL insert statements like the below

insert into devices_attribs (device_id,attrib_type,attrib_value) values ("4","discover_arp-table","0");

At this point all you need to do is run the generated MySQL statements against the LibreNMS database to disable the given module in bulk.

, ,
October 27, 2014 at 12:06 pm Comments (0)

Ubuntu – Clearing up the /boot volume

For years Ubuntu has had the ability to automatically patch the system via crontab, however as kernel updates are applied old revisions are never purged (in the event there is an issue). However, if you have a smaller drive for your install say as a Virtual Machine the /boot volume can be sized pretty small. Eventually you’ll start to see upon login a message warning you the partition is over 80% full, in this case we need to go back and purge some old kernels.

Lets check to see how bad it currently is?

df -h /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       228M   190M  38M  83% /boot

So lets obtain our currently running build information

sudo uname -r

Now, lets take a look at what is currently installed.

sudo dpkg -l linux-image-\* | grep ^ii

Which returned for me returned

ii  linux-image-3.5.0-23-generic           3.5.0-23.35   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-3.5.0-36-generic           3.5.0-36.57   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-3.5.0-37-generic           3.5.0-37.58   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-3.5.0-39-generic           3.5.0-39.60   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-3.5.0-40-generic           3.5.0-40.62   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-3.5.0-44-generic           3.5.0-44.67   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-3.5.0-45-generic           3.5.0-45.68   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-3.5.0-46-generic           3.5.0-46.70   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-3.5.0-47-generic           3.5.0-47.71   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-extra-3.5.0-23-generic     3.5.0-23.35   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-extra-3.5.0-36-generic     3.5.0-36.57   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-extra-3.5.0-37-generic     3.5.0-37.58   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-extra-3.5.0-39-generic     3.5.0-39.60   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-extra-3.5.0-40-generic     3.5.0-40.62   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP  
ii  linux-image-extra-3.5.0-44-generic     3.5.0-44.67   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-extra-3.5.0-45-generic     3.5.0-45.68   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-extra-3.5.0-46-generic     3.5.0-46.70   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-extra-3.5.0-47-generic     3.5.0-47.71   amd64     Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-generic                    3.5.0.47.63   amd64     Generic Linux kernel image

At this point everything has been stable for a few weeks, so I will purge anything below 3.5.0-47.

sudo apt-get purge linux-image linux-image-3.5.0-23 linux-image-3.5.0-36 linux-image-3.5.0-37 linux-image-3.5.0-39 linux-image-3.5.0-40 linux-image-3.5.0-44 linux-image-3.5.0-45 linux-image-3.5.0-46

After everything was removed, lets check again to see where we sit.

df -h /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       228M   29M  188M  14% /boot

In the end we ended up clearing up 69% of the /boot partition.

,
March 21, 2014 at 8:24 am Comments (0)