int main(int argc, char **argv) { int i; int val, longindex; int only_print = 0; int compare = 0; numthreads = 1; do { val = getopt_long(argc, argv, "t:pc", options, &longindex); switch (val) { case 't': numthreads = atoi(optarg); break; case 'p': only_print = 1; break; case 'c': compare = 1; break; } } while (val != EOF); if (optind >= argc) { printf("No tablebase specified.\n"); exit(0); } if (numthreads < 1) numthreads = 1; else if (numthreads > MAX_THREADS) numthreads = MAX_THREADS; total_work = (numthreads == 1) ? 1 : 100 + 10 * numthreads; init_threads(0); if (!compare) { if (!only_print) for (i = optind; i < argc; i++) verify_checksum(argv[i]); else for (i = optind; i < argc; i++) { char sum[40]; printf("%s: ", argv[i]); print_checksum(argv[i], sum); puts(sum); } } else { for (i = optind; i < argc; i++) compare_checksums(argv[i]); } return 0; }
/****************************************************************************** * * * Function: main_nodewatcher_loop * * * * Purpose: periodically calculates checks sum of config data * * * * Parameters: * * * * Return value: * * * * Author: Alexei Vladishev * * * * Comments: never returns * * * ******************************************************************************/ int main_nodewatcher_loop() { int start, end; int lastrun = 0; zabbix_log( LOG_LEVEL_DEBUG, "In main_nodeupdater_loop()"); for(;;) { start = time(NULL); zbx_setproctitle("connecting to the database"); zabbix_log( LOG_LEVEL_DEBUG, "Starting sync with nodes"); DBconnect(ZBX_DB_CONNECT_NORMAL); #if 0 if(lastrun + 120 < start) { DBbegin(); calculate_checksums(); compare_checksums(); update_checksums(); /* Send configuration changes to required nodes */ main_nodesender(); DBcommit(); lastrun = start; } #endif /* Send new events to master node */ main_eventsender(); /* Send new history data to master node */ main_historysender(); DBclose(); end = time(NULL); if(end-start<10) { zbx_setproctitle("sender [sleeping for %d seconds]", 10-(end-start)); zabbix_log( LOG_LEVEL_DEBUG, "Sleeping %d seconds", 10-(end-start)); sleep(10-(end-start)); } } }
int main(int argc, char ** argv) { uint32_t blockno; if (argc != 3) { fprintf(stderr, "About: check linux_bd writes\n"); fprintf(stderr, "Usage: %s <linux_bd_writes> <disk_image>\n", argv[0]); exit(1); } load_log(argv[1]); compare_checksums(argv[2]); for (blockno = 0; blockno < MAXBLOCKNO; blockno++) { struct linux_bd_write * last_write = &writes.writes[blocks[blockno].last_write]; uint32_t index; int32_t blockwriteno = 0; int checksum_match = 0; int issue_mismatch = 0; if (!blocks[blockno].nwrites) continue; if (blocks[blockno].read_checksum == last_write->checksum) continue; printf("block %u differs. written %u times. %d writes inflight. checksums: 0x%x (kfstitchd), 0x%x (read).\n", blockno, blocks[blockno].nwrites, last_write->ninflight, last_write->checksum, blocks[blockno].read_checksum); printf("block %u previous write checksum matches: ", blockno); for (index = 0; index < MAXWRITES; index++) { struct linux_bd_write * write = &writes.writes[index]; if (write->blockno != blockno) continue; blockwriteno++; if (blocks[blockno].read_checksum == write->checksum) { checksum_match = 1; printf("%d ", blockwriteno); } if (blockwriteno == blocks[blockno].nwrites) break; } if (checksum_match) printf("of its %u writes", blocks[blockno].nwrites); else printf("none"); printf("\n"); printf("block %u issue->complete ordering differences: ", blockno); for (index = 0; index < writes.next; index++) if (writes.writes[index].blockno == blockno) if (index != writes.writes[index].completed) { issue_mismatch = 1; printf("%u->%u ", index, writes.writes[index].completed); } if (issue_mismatch) printf("of %u total writes", writes.next); else printf("none"); printf("\n"); } return 0; }