pblock_analytics_report(Slapi_PBlock *pb)
{
    /* Some parts of DS re-use or double free pblocks >.< */
    if (pb->analytics_init != ANALYTICS_MAGIC) {
        return;
    }
    /* Write the report to disk. */
    /* Take the write lock. */
    PR_Lock(pblock_analytics_lock);

    FILE *fp = NULL;
    fp = fopen("/tmp/pblock_stats.csv", "a");
    if (fp == NULL) {
        int errsv = errno;
        printf("%d\n", errsv);
        abort();
    }
    /* Map over the hashmap */
    PL_HashTableEnumerateEntries(pb->analytics, pblock_analytics_report_entry, fp);
    /* Printf the new line */
    fprintf(fp, "\n");
    fclose(fp);
    /* Unlock */
    PR_Unlock(pblock_analytics_lock);
}
pblock_analytics_report(Slapi_PBlock *pb)
{
     
    if (pb->analytics_init != ANALYTICS_MAGIC) {
        return;
    }
     
     
    PR_Lock(pblock_analytics_lock);

    FILE *fp = NULL;
    fp = fopen("/tmp/pblock_stats.csv", "a");
    if (fp == NULL) {
        int errsv = errno;
        printf("%d\n", errsv);
        abort();
    }
     
    PL_HashTableEnumerateEntries(pb->analytics, pblock_analytics_report_entry, fp);
     
    fprintf(fp, "\n");
    fclose(fp);
     
    PR_Unlock(pblock_analytics_lock);
}