my $data_source = 'something'; my $username = 'user'; my $password = 'password'; $dbh = DBI->connect($data_source, $username, $password, { RaiseError => 1, AutoCommit => 1, }); my $sql_select = " SELECT volumeletter, peernodes FROM VolData ORDER BY volumeid "; my $sql_update = " UPDATE VolData SET volstatus = ? WHERE volumeletter = ? "; my %NUM_2_VOLSTATUS = ( 0 => 'Not Mirrored', 1 => 'Mirroring', 2 => 'Resync', 3 => 'Broken', 4 => 'Paused', 5 => 'Resync Pending', ); my $sth = $dbh->prepare($sql_select); my $sth_update = $dbh->prepare($sql_update); $sth->execute(); # Iterate over configured volumes and update status, rrd data and graphs while ( my ($vol, $peernodes) = $sth->fetchrow_array() ) { # Populate a hash with current volume data my %voldata = getVolumeData($vol, $peernodes); my $vol_current_state = $NUM_2_VOLSTATUS{$voldata{'MirrorState'}} || 'Unknown'; print "COLLECTOR: Setting volume $vol to state $vol_current_state\n"; $sth_update->execute($vol_current_state, $vol); } $sth_update->finish; $sth->finish; $dbh->disconnect;