Is it possible to get a Live Inode Count?

Updating the inode count isn’t done live because it basically involves traversing your entire website to count the files and directories.

But you can do it yourself through PHP. If you create a PHP file in your htdocs directory, you can put the following contents into it:

<?php

set_time_limit(0);

$directory = new RecursiveDirectoryIterator('./');

$counters = [];

foreach ($directory as $item) {
    if (!is_dir($item)) {
        continue;
    }

    $parts = explode('/', $item);
    $basename = end($parts);

    if (strpos($basename, '.') === 0) {
        continue;
    }

    $itemIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($item));
    $counters[(string) $item] = iterator_count($itemIterator);
}

arsort($counters);

foreach ($counters as $path => $count) {
    echo $path.': '.$count.'<br/>'.PHP_EOL;
}

echo "Total: ".array_sum($counters);

If you then trigger this script from the browser, it will tell you the inode count of the folder right now.

Due to security restrictions on free hosting, you can only do this per website folder, not for the entire account. But it may give you some indication.

7 Likes