All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.collectd.protocol.StdoutDispatcher Maven / Gradle / Ivy

Go to download

The jcollectd package implements the collectd protocol in Java, making it possible for Java applications to push data into collectd over the wire.

The newest version!
/*
 * jcollectd
 * Copyright (C) 2009 Hyperic, Inc.
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; only version 2 of the License is applicable.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

package org.collectd.protocol;

import java.util.ArrayList;
import java.util.List;

import org.collectd.api.DataSource;
import org.collectd.api.Notification;
import org.collectd.api.ValueList;

/**
 * Dispatch collectd data to stdout.
 * java -classpath collectd.jar org.collectd.protocol.UdpReceiver 
 */
public class StdoutDispatcher implements Dispatcher {

    private boolean namesOnly =
        "true".equals(Network.getProperty(PropertyNames.NAMES_ONLY));

    public void dispatch(ValueList vl) {
        if (namesOnly) {
            System.out.print("plugin=" + vl.getPlugin());
            System.out.print(",pluginInstance=" + vl.getPluginInstance());
            System.out.print(",type=" + vl.getType());
            System.out.print(",typeInstance=" + vl.getTypeInstance());
            List ds = vl.getDataSource();
            if (ds == null) {
                ds = TypesDB.getInstance().getType(vl.getType());
            }
            if (ds != null) {
                List names = new ArrayList();
                for (int i=0; i" + names);
            }
            System.out.println();
        }
        else {
            System.out.println(vl);
        }
    }

    public void dispatch(Notification notification) {
        System.out.println(notification);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy