String[] words = getRemainingWords();
if (words.length < 3) {
throw new RrdException("Insufficent number of parameters for rrdupdate command");
}
String path = words[1];
RrdDb rrdDb = getRrdDbReference(path);
try {
if (dsNames != null) {
// template specified, check datasource names
for (String dsName : dsNames) {
if (!rrdDb.containsDs(dsName)) {
throw new RrdException("Invalid datasource name: " + dsName);
}
}
}
// parse update strings
long timestamp = -1;
for (int i = 2; i < words.length; i++) {
String[] tokens = new ColonSplitter(words[i]).split();
if (dsNames != null && dsNames.length + 1 != tokens.length) {
throw new RrdException("Template requires " + dsNames.length + " values, " +
(tokens.length - 1) + " value(s) found in: " + words[i]);
}
int dsCount = rrdDb.getHeader().getDsCount();
if (dsNames == null && dsCount + 1 != tokens.length) {
throw new RrdException("Expected " + dsCount + " values, " +
(tokens.length - 1) + " value(s) found in: " + words[i]);
}
timestamp = Util.getTimestamp(tokens[0]);
Sample sample = rrdDb.createSample(timestamp);
for (int j = 1; j < tokens.length; j++) {
if (dsNames == null) {
sample.setValue(j - 1, parseDouble(tokens[j]));
}
else {