• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Moving ntopng DB to non-default directory

Scheduled Pinned Locked Moved Traffic Monitoring
4 Posts 2 Posters 559 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M
    mdp716
    last edited by Jan 12, 2023, 2:26 PM

    Date: January 12, 2023
    ntopng version: ntopng Community v.5.0.220112 rev.0 (FreeBSD 12.3)
    pfsense version: Community Edition 2.6.0-RELEASE (amd64)

    Disclaimer: I am very much a n00b when it comes to both pfsense and ntopng so forgive any dumb moves I suggest if there are better ways to do it.

    I'm posting this in the hopes that others who come after me might not find themselves deep in the same rabbit hole I did when searching for information on how to relocate the db files for ntopng on their pfsense device.

    So here are the boiled down steps I took to relocate the DB files with more details to follow the basic steps:

    1. Follow standard steps to install and configure ntopng from the pfsense Package Manager.
    2. Verify that the installation is working. I would suggest rebooting the pfsense device prior to this step so that you know the configuration, etc. survives a reboot.
    3. Go to the ntopng settings page and uncheck the "Enable ntopng" checkbox and click SAVE.
    4. The default directory for the db files on the version I have is /var/db/ntopng/ - move that 'notopng' directory to your new location, in my case that was /data/db/ntopng/
    5. Backup the file /usr/local/pkg/ntopng.inc
    6. Edit the the file /usr/local/pkg/ntopng.inc by replacing all instances of '/var/db/ntopng' with your new path and then save the file.
    7. Restart ntopng, verify that it is working, verify that there are no new files in the old directory path, and verify that the time stamp on some of the files in the new directory path have been updated to ensure that the new directory path is being used.

    Things I learned as a relative newbie to Freebsd/pfsense/ntopng:

    First I decided I needed to have a different db path for ntopng than the default because I did not want to have massive read/write operations being done on my system drive and as well, that drive was limited as to how much space it had so I bought a 1GB SSD drive and added it to my pfsense device for the sole primary purpose of relocating the ntopng db files to it.

    You will need to have SSH access to do the above steps and in my case I thought I was being smart by creating a new pfsense user as an administrator and then disabling the default 'Admin' account. After some frustrations I realized that even though the new administrator account was in the administrators group, it does not have all of the rights that the default Admin account has so I had to re-enable the default admin account to do these steps or, I learned, I could have installed another package 'sudo', to accomplish the steps with my new account. Wanting to avoid making too many changes to my pfsense device on my path toward moving the db files, I re-enabled the Admin account instead of installing yet another package for the time being.

    Next, there are a number of pages I found that discusses moving the db files for ntopng and they involved doing non-standard things that would have to be redone if pfsense is updated or worse, such as some GUI actions not working as expected after the modifications were made. Plus many of these articles referenced directory paths to certain files and in my installation few of those paths were correct.

    In my quest to find a solution I came across the ntopng.inc file referenced above and since I was familiar with php I realized that this was a php include file which was invoked as a result of actions taken on the ntopng settings GUI page such has clearing out the db files or starting/stopping ntopng so I figured that editing this file might work as the solution to my objective of relocating the db files.

    Sadly, only one of the pages I found related to relocating the db files even referenced this file and in that case it wasn't for the purpose of relocating the db files but rather to get an out of band version of ntopng to function in the 'community' mode and I believe that even in that case the path to the file referenced in that article is not where I found it in my installation.

    At this point I do not know if my changes will survive a pfsense update process. However, even if it does not, the fix is simple as all I would need to do is re-edit the ntopng.inc file that may replace the one I had previously edited.

    Hopefully I have saved some who follows me some time by providing this information.

    K 1 Reply Last reply Jan 13, 2023, 7:34 PM Reply Quote 0
    • K
      keyser Rebel Alliance @mdp716
      last edited by keyser Jan 13, 2023, 7:35 PM Jan 13, 2023, 7:34 PM

      @mdp716 Thanks for posting. I’m guessing the article you referenced regarding getting the lastest NtopNG on pfsense, is mine.
      Your post is good stuff those wanting to relocate the DB. But be advised, it will not survive either a pfSense update or a NtopNG package update, as both of those actions restores the NtopNG package to it’s default installed settings (with your UI settings from the config file applied).

      So if you do update NtopNG or pfSense, you need to reapply your fix - but this time don’t move the /var/db/ntopng folder. Just delete it, and edit the ntopng.inc file to reference your previously used /data/db/ntopng folder (thus restoring the data).

      On another note: I have seen that NtopNG on pfsense should become much more stable if you start using InfluxDB instead of RDD redis as a database. I have no experience with that just yet, but it’s an interesting observation.

      Love the no fuss of using the official appliances :-)

      M 1 Reply Last reply Jan 13, 2023, 8:03 PM Reply Quote 0
      • M
        mdp716 @keyser
        last edited by mdp716 Jan 13, 2023, 8:06 PM Jan 13, 2023, 8:03 PM

        @keyser

        Correct, your well documented post was one of the ones I referred to. I found several and one appeared to be basically a rip of yours. The most frustrating thing is knowing precisely what someone's post was referring to, which flavor of the ntopng (community or not) and in a few cases they were blog or other types of posts which had no dates that would suggest when they were written nor references to which version of what - both being important as products evolve over time, file locations change, etc.

        But anyway, yes I suspected that my solution would not survive an update as it makes sense that the ntopng.inc file would get overwritten with the update as it may have changes done to it with the update - but re-editing the replacement is a fairly simple thing to do and it would presumably be the only required step unless a new DB schema is introduced. I'd also imagine that deleting the var/db/ntopng/ folder wouldn't necessarily be required except for purists who hate leaving unused artifacts laying around.

        I've not seen anything about the difference between the databases yet, but then again I have not looked either since I am literally still at less than 100 hours into using ntopng. But if you do happen to make the switch, I'd love to hear about it.

        Since the above I ran into a situation where click on an I.P. address resulted in a page saying I wasn't supposed to be there - guessing that is one of the buggy things you referred to. I found another post that indicated that clicking on the Developer menu option and then "Reload Pug-ins" cures that and it did, in fact, cure the problem - for how long who knows.

        Right now I am trying to figure out how to get reporting on something rather specific. I rent rooms out to tenants and I have a finite amount of data allotted to me by Cox (pronounced "/sək/" as in "Sucks") and get charged for each additional block of 50GB or portion thereof so I want to be able to identify how much data each tenant is using. But I will make a separate post about that.

        Thanks for your reply though.

        K 1 Reply Last reply Jan 13, 2023, 9:52 PM Reply Quote 0
        • K
          keyser Rebel Alliance @mdp716
          last edited by keyser Jan 13, 2023, 9:55 PM Jan 13, 2023, 9:52 PM

          @mdp716 Thanks. On your last investigation note:

          A few pointers:
          An easy way to do it would be to install one of the data summary packages in pfSense like “Bandwidthd”. There are others but I don’t know if they do it by hosts. They do by interface - if your tenants are on seperate VLANs

          The slightly more blinky way of doing it would be to leverage the data from nTopNG and visualize it in Grafana. NtopNG has created a plugin for Grafana so you can query the data pr. Host or interface directly and both visualize and do math operations on (like summaries based om dates and what not).

          Love the no fuss of using the official appliances :-)

          1 Reply Last reply Reply Quote 1
          4 out of 4
          • First post
            4/4
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
            This community forum collects and processes your personal information.
            consent.not_received