/** * Check that FS path is the same as the last time. */ int CheckLastFS( ) { int rc; lmgr_t lmgr; char value[1024]; rc = ListMgr_InitAccess( &lmgr ); if ( rc ) { DisplayLog( LVL_CRIT, "CheckFS", "Error %d connecting to database", rc ); return rc; } rc = ListMgr_GetVar( &lmgr, FS_PATH_VAR, value ); if ( rc == DB_SUCCESS ) { if ( strcmp( value, global_config.fs_path ) ) { DisplayLog( LVL_CRIT, "CheckFS", "Filesystem %s does not correspond to database content (%s)", global_config.fs_path, value ); DisplayLog( LVL_CRIT, "CheckFS", "Drop the database and restart the daemon." ); rc = -1; } else { DisplayLog( LVL_DEBUG, "CheckFS", "%s matches database content.", global_config.fs_path ); rc = 0; } } else if ( rc == DB_NOT_EXISTS ) { DisplayLog( LVL_FULL, "CheckFS", FS_PATH_VAR "='%s'.", global_config.fs_path ); rc = ListMgr_SetVar( &lmgr, FS_PATH_VAR, global_config.fs_path ); if ( rc ) DisplayLog( LVL_CRIT, "CheckFS", "Error %d setting variable 'FS_path'", rc ); } else { DisplayLog( LVL_CRIT, "CheckFS", "Error %d retrieving variable 'FS_path'", rc ); } ListMgr_CloseAccess( &lmgr ); return rc; }
/** Store FS Scan into database */ int FSScan_StoreStats( lmgr_t * lmgr ) { int rc; robinhood_fsscan_stat_t stats; char tmp_buff[256]; if ( ( rc = Robinhood_StatsScan( &stats ) ) ) return rc; /* store the number of scanning threads */ sprintf( tmp_buff, "%i", fs_scan_config.nb_threads_scan ); ListMgr_SetVar( lmgr, LAST_SCAN_NB_THREADS, tmp_buff ); if ( stats.scan_running ) { if ( stats.last_action > 0 ) { sprintf( tmp_buff, "%lu", ( unsigned long ) stats.last_action ); ListMgr_SetVar( lmgr, LAST_SCAN_LAST_ACTION_TIME, tmp_buff); } if ( stats.scanned_entries ) { sprintf(tmp_buff, "%u", stats.scanned_entries); ListMgr_SetVar( lmgr, LAST_SCAN_ENTRIES_SCANNED, tmp_buff); sprintf(tmp_buff, "%u", stats.error_count); ListMgr_SetVar( lmgr, LAST_SCAN_ERRORS, tmp_buff); sprintf(tmp_buff, "%.2f", stats.avg_ms_per_entry); ListMgr_SetVar( lmgr, LAST_SCAN_AVGMSPE, tmp_buff); sprintf(tmp_buff, "%.2f", stats.curr_ms_per_entry); ListMgr_SetVar( lmgr, LAST_SCAN_CURMSPE, tmp_buff); } } sprintf(tmp_buff, "%u", stats.nb_hang); ListMgr_SetVar( lmgr, LAST_SCAN_TIMEOUTS, tmp_buff); return 0; }