1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-11-25 19:47:02 +00:00

Merge pull request #164 from Flameeyes/master

SNMP & JMX plugins improvements
This commit is contained in:
Steve Schnepp 2012-08-10 04:12:11 -07:00
commit 27e4cf0fe3
49 changed files with 682 additions and 1164 deletions

View file

@ -1,8 +0,0 @@
.DS_Store
.classpath
.project
.fatjar
target
eclipse
old
bin

View file

@ -1,79 +0,0 @@
# jmx2munin
The [jmx2munin](http://github.com/tcurdt/jmx2munin) project exposes JMX MBean attributes to [Munin](http://munin-monitoring.org/).
Some of it's features:
* strictly complies to the plugin format
* exposes composite types like Lists, Maps, Set as useful as possible
* String values can be mapped to numbers
# How to use
This is what the Munin script will call. So you should test this first. Of course with your parameters. This example expose all Cassandra information to Munin.
java -jar jmx2munin.jar \
-url service:jmx:rmi:///jndi/rmi://localhost:8080/jmxrmi \
-query "org.apache.cassandra.*:*"
The "url" parameters specifies the JMX URL, the query selects the MBeans (and optionally also the attributes) to expose.
java -jar jmx2munin.jar \
-url service:jmx:rmi:///jndi/rmi://localhost:8080/jmxrmi \
-query "org.apache.cassandra.*:*" \
-attribute org_apache_cassandra_db_storageservice_livenodes_size
The script that does the actual interaction with munin you can find in the contrib section. It's the one you should link in the your Munin plugin directory.
:/etc/munin/plugins$ ls -la cassandra_*
lrwxrwxrwx 1 root root 37 2011-04-07 19:58 cassandra_nodes_in_cluster -> /usr/share/munin/plugins/jmx2munin.sh
In the plugin conf you point to the correct configuration
[cassandra_*]
env.query org.apache.cassandra.*:*
[cassandra_nodes_in_cluster]
env.config cassandra/nodes_in_cluster
A possible configuration could look like this
graph_title Number of Nodes in Cluster
graph_vlabel org_apache_cassandra_db_storageservice_livenodes_size
org_apache_cassandra_db_storageservice_livenodes_size.label number of nodes
The script will extract the attributes from the config and caches the JMX results to reduce the load when showing many values.
# More advanced
Sometimes it can be useful to track String values by mapping them into an enum as they really describe states. To find this possible candidates you can call:
java -jar jmx2munin.jar \
-url service:jmx:rmi:///jndi/rmi://localhost:8080/jmxrmi \
-query "org.apache.cassandra.*:*" \
list
It should output a list of possible candidates. This can now be turned into a enum configuration file:
[org.apache.cassandra.db.StorageService:OperationMode]
0 = ^Normal
1 = ^Client
2 = ^Joining
3 = ^Bootstrapping
4 = ^Leaving
5 = ^Decommissioned
6 = ^Starting drain
7 = ^Node is drained
Which you then can provide:
java -jar jmx2munin.jar \
-url service:jmx:rmi:///jndi/rmi://localhost:8080/jmxrmi \
-query "org.apache.cassandra.*:*" \
-enums /path/to/enums.cfg
Now matching values get replaced by their numerical representation. On the left needs to be a unique number on the right side is a regular expression. If a string cannot be matched according to the spec "U" for "undefined" will be returned.
# License
Licensed under the Apache License, Version 2.0 (the "License")
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

View file

@ -1,3 +0,0 @@
graph_title Number of Nodes in Cluster
graph_vlabel org_apache_cassandra_db_storageservice_livenodes_size
org_apache_cassandra_db_storageservice_livenodes_size.label number of nodes

View file

@ -1,55 +0,0 @@
#!/bin/bash
# [cassandra_nodes_in_cluster]
# env.config cassandra/nodes_in_cluster
# env.query org.apache.cassandra.*:*
if [ -z "$MUNIN_LIBDIR" ]; then
MUNIN_LIBDIR="`dirname $(dirname "$0")`"
fi
if [ -f "$MUNIN_LIBDIR/plugins/plugin.sh" ]; then
. $MUNIN_LIBDIR/plugins/plugin.sh
fi
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ -z "$url" ]; then
# this is very common so make it a default
url="service:jmx:rmi:///jndi/rmi://127.0.0.1:8080/jmxrmi"
fi
if [ -z "$config" -o -z "$query" -o -z "$url" ]; then
echo "Configuration needs attributes config, query and optinally url"
exit 1
fi
JMX2MUNIN_DIR="$MUNIN_LIBDIR/plugins"
CONFIG="$JMX2MUNIN_DIR/jmx2munin.cfg/$config"
if [ "$1" = "config" ]; then
cat "$CONFIG"
exit 0
fi
JAR="$JMX2MUNIN_DIR/jmx2munin.jar"
CACHED="/tmp/jmx2munin"
if test ! -f $CACHED || test `find "$CACHED" -mmin +2`; then
java -jar "$JAR" \
-url "$url" \
-query "$query" \
$ATTRIBUTES \
> $CACHED
echo "cached.value `date +%s`" >> $CACHED
fi
ATTRIBUTES=`awk '/\.label/ { gsub(/\.label/,""); print $1 }' $CONFIG`
for ATTRIBUTE in $ATTRIBUTES; do
grep $ATTRIBUTE $CACHED
done

View file

@ -1,121 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.vafer</groupId>
<artifactId>jmx2munin</artifactId>
<name>jmx2munin</name>
<version>1.0</version>
<description>
Munin plugin to access JMX information
</description>
<url>http://github.com/tcurdt/jmx2munin</url>
<developers>
<developer>
<id>tcurdt</id>
<name>Torsten Curdt</name>
<email>tcurdt at vafer.org</email>
<timezone>+1</timezone>
</developer>
</developers>
<licenses>
<license>
<name>Apache License 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com:tcurdt/jmx2munin.git</connection>
<developerConnection>scm:git:git://github.com:tcurdt/jmx2munin.git</developerConnection>
<url>http://github.com/tcurdt/jmx2munin/tree/master</url>
</scm>
<dependencies>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>never</forkMode>
<includes>
<include>**/*TestCase.java</include>
</includes>
<excludes>
<exclude>**/Abstract*</exclude>
</excludes>
<testFailureIgnore>true</testFailureIgnore>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<id>create-source-jar</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<artifactSet>
<includes>
<include>com.beust:jcommander</include>
</includes>
</artifactSet>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.vafer.jmx.munin.Munin</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,77 +0,0 @@
package org.vafer.jmx;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Pattern;
import javax.management.ObjectName;
public final class Enums {
private TreeMap<String, LinkedHashMap<Integer, Pattern>> sections = new TreeMap<String, LinkedHashMap<Integer, Pattern>>();
public boolean load(String filePath) throws IOException {
BufferedReader input = null;
LinkedHashMap<Integer, Pattern> section = new LinkedHashMap<Integer, Pattern>();
try {
input = new BufferedReader(new InputStreamReader(new FileInputStream(filePath)));
String line;
int linenr = 0;
while((line = input.readLine()) != null) {
linenr += 1;
line = line.trim();
if (line.startsWith("#")) {
continue;
}
if (line.startsWith("[") && line.endsWith("]")) {
// new section
String id = line.substring(1, line.length() - 1);
section = new LinkedHashMap<Integer, Pattern>();
sections.put(id, section);
} else {
String[] pair = line.split("=");
if (pair.length == 2) {
Integer number = Integer.parseInt(pair[0].trim());
Pattern pattern = Pattern.compile(pair[1].trim());
if (section.put(number, pattern) != null) {
System.err.println("Line " + linenr + ": previous definitions of " + number);
}
}
}
}
} finally {
if (input != null) {
input.close();
}
}
return false;
}
public static String id(ObjectName beanName, String attributeName) {
StringBuilder sb = new StringBuilder();
sb.append(beanName.getDomain());
sb.append('.');
sb.append(beanName.getKeyProperty("type"));
sb.append(':');
sb.append(attributeName);
return sb.toString();
}
public Number resolve(String id, String value) {
LinkedHashMap<Integer, Pattern> section = sections.get(id);
if (section == null) {
return null;
}
for(Map.Entry<Integer, Pattern> entry : section.entrySet()) {
if (entry.getValue().matcher(value).matches()) {
return entry.getKey();
}
}
return null;
}
}

View file

@ -1,9 +0,0 @@
package org.vafer.jmx;
import javax.management.ObjectName;
public interface Filter {
public boolean include(ObjectName bean, String attribute);
}

View file

@ -1,26 +0,0 @@
package org.vafer.jmx;
import java.util.HashSet;
import java.util.Set;
import javax.management.ObjectName;
public final class ListOutput implements Output {
private final Set<String> seen = new HashSet<String>();
public void output(ObjectName beanName, String attributeName, Object value) {
Value.flatten(beanName, attributeName, value, new Value.Listener() {
public void value(ObjectName beanName, String attributeName, String value) {
final String id = Enums.id(beanName, attributeName);
if (!seen.contains(id)) {
System.out.println("[" + id + "]");
seen.add(id);
}
}
public void value(ObjectName beanName, String attributeName, Number value) {
}
});
}
}

View file

@ -1,10 +0,0 @@
package org.vafer.jmx;
import javax.management.ObjectName;
public final class NoFilter implements Filter {
public boolean include(ObjectName bean, String attribute) {
return true;
}
}

View file

@ -1,9 +0,0 @@
package org.vafer.jmx;
import javax.management.ObjectName;
public interface Output {
public void output(ObjectName beanName, String attributeName, Object value);
}

View file

@ -1,52 +0,0 @@
package org.vafer.jmx;
import java.io.IOException;
import java.util.Collection;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.IntrospectionException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
public final class Query {
public void run(String url, String expression, Filter filter, Output output) throws IOException, MalformedObjectNameException, InstanceNotFoundException, ReflectionException, IntrospectionException, AttributeNotFoundException, MBeanException {
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(url));
MBeanServerConnection connection = connector.getMBeanServerConnection();
final Collection<ObjectInstance> mbeans = connection.queryMBeans(new ObjectName(expression), null);
for(ObjectInstance mbean : mbeans) {
final ObjectName mbeanName = mbean.getObjectName();
final MBeanInfo mbeanInfo = connection.getMBeanInfo(mbeanName);
final MBeanAttributeInfo[] attributes = mbeanInfo.getAttributes();
for (final MBeanAttributeInfo attribute : attributes) {
if (attribute.isReadable()) {
if (filter.include(mbeanName, attribute.getName())) {
final String attributeName = attribute.getName();
try {
output.output(
mbean.getObjectName(),
attributeName,
connection.getAttribute(mbeanName, attributeName)
);
} catch(Exception e) {
// System.err.println("Failed to read " + mbeanName + "." + attributeName);
}
}
}
}
}
connector.close();
}
}

View file

@ -1,52 +0,0 @@
package org.vafer.jmx;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.management.ObjectName;
public final class Value {
public interface Listener {
public void value(ObjectName beanName, String attributeName, String value);
public void value(ObjectName beanName, String attributeName, Number value);
}
public static void flatten(ObjectName beanName, String attributeName, Object value, Listener listener) {
if (value instanceof Number) {
listener.value(beanName, attributeName, (Number) value);
} else if (value instanceof String) {
listener.value(beanName, attributeName, (String) value);
} else if (value instanceof Set) {
final Set set = (Set) value;
flatten(beanName, attributeName + ".size", set.size(), listener);
for(Object entry : set) {
flatten(beanName, attributeName + "[" + entry + "]", 1, listener);
}
} else if (value instanceof List) {
final List list = (List)value;
listener.value(beanName, attributeName + ".size", list.size());
for(int i = 0; i<list.size(); i++) {
flatten(beanName, attributeName + "[" + i + "]", list.get(i), listener);
}
} else if (value instanceof Map) {
final Map<?,?> map = (Map<?,?>) value;
listener.value(beanName, attributeName + ".size", map.size());
for(Map.Entry<?, ?> entry : map.entrySet()) {
flatten(beanName, attributeName + "[" + entry.getKey() + "]", entry.getValue(), listener);
}
} else {
// System.err.println("Failed to convert " + beanName + "." + attributeName);
}
}
}

View file

@ -1,67 +0,0 @@
package org.vafer.jmx.munin;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.vafer.jmx.Enums;
import org.vafer.jmx.Filter;
import org.vafer.jmx.ListOutput;
import org.vafer.jmx.NoFilter;
import org.vafer.jmx.Query;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
public final class Munin {
@Parameter(description = "")
private List<String> args = new ArrayList<String>();
@Parameter(names = "-url", description = "jmx url", required = true)
private String url;
@Parameter(names = "-query", description = "query expression", required = true)
private String query;
@Parameter(names = "-enums", description = "file string to enum config")
private String enumsPath;
@Parameter(names = "-attribute", description = "attributes to return")
private List<String> attributes = new ArrayList<String>();
private void run() throws Exception {
final Filter filter;
if (attributes == null || attributes.isEmpty()) {
filter = new NoFilter();
} else {
filter = new MuninAttributesFilter(attributes);
}
final Enums enums = new Enums();
if (enumsPath != null) {
enums.load(enumsPath);
}
final String cmd = args.toString().toLowerCase(Locale.US);
if ("[list]".equals(cmd)) {
new Query().run(url, query, filter, new ListOutput());
} else {
new Query().run(url, query, filter, new MuninOutput(enums));
}
}
public static void main(String[] args) throws Exception {
Munin m = new Munin();
JCommander cli = new JCommander(m);
try {
cli.parse(args);
} catch(Exception e) {
cli.usage();
System.exit(1);
}
m.run();
}
}

View file

@ -1,24 +0,0 @@
package org.vafer.jmx.munin;
import java.util.HashSet;
import java.util.List;
import javax.management.ObjectName;
import org.vafer.jmx.Filter;
public final class MuninAttributesFilter implements Filter {
private final HashSet<String> attributes = new HashSet<String>();
public MuninAttributesFilter(List<String> pAttributes) {
for (String attribute : pAttributes) {
attributes.add(attribute.trim().replaceAll("_size$", ""));
}
}
public boolean include(ObjectName bean, String attribute) {
return attributes.contains(MuninOutput.attributeName(bean, attribute));
}
}

View file

@ -1,93 +0,0 @@
package org.vafer.jmx.munin;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.Locale;
import javax.management.ObjectName;
import org.vafer.jmx.Enums;
import org.vafer.jmx.Output;
import org.vafer.jmx.Value;
public final class MuninOutput implements Output {
private final Enums enums;
public MuninOutput(Enums enums) {
this.enums = enums;
}
public static String attributeName(ObjectName bean, String attribute) {
StringBuilder sb = new StringBuilder();
sb.append(fieldname(beanString(bean)));
sb.append('_');
sb.append(fieldname(attribute));
return sb.toString().toLowerCase(Locale.US);
}
private static String fieldname(String s) {
return s.replaceAll("[^A-Za-z0-9]", "_");
}
private static String beanString(ObjectName beanName) {
StringBuilder sb = new StringBuilder();
sb.append(beanName.getDomain());
Hashtable<String, String> properties = beanName.getKeyPropertyList();
String keyspace = "keyspace";
if (properties.containsKey(keyspace)) {
sb.append('.');
sb.append(properties.get(keyspace));
properties.remove(keyspace);
}
String type = "type";
if (properties.containsKey(type)) {
sb.append('.');
sb.append(properties.get(type));
properties.remove(type);
}
ArrayList<String> keys = new ArrayList(properties.keySet());
Collections.sort(keys);
for(String key : keys) {
sb.append('.');
sb.append(properties.get(key));
}
return sb.toString();
// return beanName.getCanonicalName();
}
public void output(ObjectName beanName, String attributeName, Object value) {
Value.flatten(beanName, attributeName, value, new Value.Listener() {
public void value(ObjectName beanName, String attributeName, String value) {
final Number v = enums.resolve(Enums.id(beanName, attributeName), value);
if (v != null) {
value(beanName, attributeName, v);
} else {
value(beanName, attributeName, Double.NaN);
}
}
public void value(ObjectName beanName, String attributeName, Number value) {
final String v;
if (Double.isNaN(value.doubleValue())) {
v = "U";
} else {
final NumberFormat f = NumberFormat.getInstance();
f.setMaximumFractionDigits(2);
f.setGroupingUsed(false);
v = f.format(value);
}
System.out.println(attributeName(beanName, attributeName) + ".value " + v);
}
});
}
}

View file

@ -1,53 +0,0 @@
#!/bin/sh
#
# Plugin to monitor the CPU temperature through lm-sensors.
# v1.0 (2008-02-15) Oliver Ladner <oli@lugh.ch>
#
# Requirements:
# - A configured lm-sensors installation
# - Supported device (see http://www.lm-sensors.org/wiki/Devices)
# - grep, sed and awk
#
# Todo:
# - Ability to monitor multiple sensors like fan speeds, voltage etc.
# - Better checks (availabilty of lm-sensors, sensors itself, path names)
#
# Parameters supported:
#
# config
# autoconf
#
# Magic markers:
#%# capabilities=autoconf
DETECTED_SENSORS=`sensors -U -A | wc -l`
case $1 in
config)
cat <<'EOM'
graph_title CPU temperature
graph_vlabel CPU temperature in °C
graph_options light
graph_info This graph shows CPU temperature in °C
temp.label temp
temp.draw LINE1
graph_category sensors
temp.warning 65
temp.critical 80
EOM
exit 0;;
esac
case $1 in
autoconf)
if [ "$DETECTED_SENSORS" -eq 0 ]; then
echo "no"
exit 1
else
echo "yes"
exit 0
fi
esac
echo -n "temp.value "
sensors | grep 'CPU Temp' | sed 's/[+|°|C]//g' | awk {'print $3'}

View file

@ -1,40 +0,0 @@
#!/bin/sh
#
# Plugin to graph temperatures based on info from /sys/devices/platform/coretemp.*
#
# Parameters:
#
#
#
#%# family=auto
#%# capabilities=autoconf
if [ "$1" = "autoconf" ]; then
if [ -d /sys/devices/platform/coretemp.0 ]; then
echo yes
exit 0
else
echo "no (/sys/devices/platform/coretemp.* not there)"
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title CPU temperature'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel temp in °C'
echo 'graph_category sensors'
echo 'graph_info This graph shows temperatures based on /sys/devices/platform/coretemp.*/.'
echo cputemp.info CPU temperature.
for c in /sys/devices/platform/coretemp.*; do
core=${c#/sys/devices/platform/coretemp.}
label=`cat $c/temp1_label`
echo core${core}.label $label
done
fi
for c in /sys/devices/platform/coretemp.*; do
core=${c#/sys/devices/platform/coretemp.}
temp=$((`cat $c/temp1_input` / 1000))
echo core${core}.value $temp
done

View file

@ -1,37 +0,0 @@
#!/bin/sh
#
# Plugin to graph temperatures based on i5k_amb-isa-0000 FB-DIMM sensor
#
# Parameters:
#
#
#
#%# family=auto
#%# capabilities=autoconf
SENSORS="/usr/bin/sensors"
if [ "$1" = "autoconf" ]; then
# testing if the i5k FB-DIMM sensors are working. (0->working)
RETVAL=`$SENSORS -A i5k_amb-isa-0000|grep -q DIMM; echo $?`
if [ $RETVAL = 0 ]; then
echo yes
exit 0
else
echo "no (i5k FB-DIMM sensors not working.)"
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title FB-DIMM temperature'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel temp in °C'
echo 'graph_category sensors'
echo 'graph_info This graph shows FB-DIMM temperatures based on reports generated by intel 5000 series chipsets.'
echo fbdimmtemp.info FB-DIMM temperature.
$SENSORS -A i5k_amb-isa-0000|grep DIMM|tr -d ":+"|awk -F "." '{print $2}'|awk '{print "ch"$1"dimm"$3".label Channel "$1" DIMM "$3}'
exit 0
fi
$SENSORS -A i5k_amb-isa-0000|grep DIMM|tr -d ":+"|awk -F "." '{print $2}'|awk '{print "ch"$1"dimm"$3".value "$4}'

0
plugins/ipmi/freeipmi_ → plugins/sensors/freeipmi_ Normal file → Executable file
View file

View file

@ -1,69 +0,0 @@
#!/bin/sh
#
# k8temp
#
# Plugin to monitor the CPU temperature through lm-sensors
# on multicore AMD cpus
#
# Author: Marc Schiffbauer <marc@schiffbauer.net>
#
# Requirements:
# - A configured lm-sensors installation with k8temp kernel module
# - rewuired shell commands: sensors, grep, sed, uniq, cut
#
# Parameters supported:
#
# config
# autoconf
#
# Magic markers:
#%# capabilities=autoconf
# VERSION 1.0
case $1 in
config)
I=1
LAST_CORE=""
echo "graph_title CPU temperature"
echo "graph_vlabel temperature in °C"
echo "graph_options light"
echo "graph_info This graph shows temperature of all CPU cores in °C"
echo "graph_category sensors"
sensors -uA | grep "^Core" | while read CORE FOO TEMP REST; do
if [ "$LAST_CORE" == "$CORE" ]; then
I=$((I+1))
else
I=1
fi
LAST_CORE=$CORE
CORE_NUM=$(echo $CORE | sed 's/Core//')
echo "core${CORE_NUM}_${I}.label Core ${CORE_NUM} sensor $I"
#echo "core${CORE_NUM}_${I}.draw LINE1"
echo "core${CORE_NUM}_${I}.warning 65"
echo "core${CORE_NUM}_${I}.critical 80"
done
exit 0
;;
autoconf)
if [ "$(sensors -uA | grep "^Core" | uniq)" ]; then
echo "yes"
exit 0
else
echo "no"
exit 1
fi
esac
sensors -uA | grep "^Core" | while read CORE FOO TEMP REST; do
if [ "$LAST_CORE" == "$CORE" ]; then
I=$((I+1))
else
I=1
fi
LAST_CORE=$CORE
CORE_NUM=$(echo $CORE | sed 's/Core//')
TEMP=$(echo $TEMP | cut -d"." -f1)
echo "core${CORE_NUM}_${I}.value $TEMP"
done

0
plugins/snmp/snmp__fn/snmp__fn-cpu.png Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After

0
plugins/snmp/snmp__fn/snmp__fn-memory.png Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

0
plugins/snmp/snmp__fn/snmp__fn-sessions.png Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before After
Before After

0
plugins/snmp/snmp__fn/snmp__fn-vpnsessions.png Executable file → Normal file
View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before After
Before After

682
plugins/snmp/snmp__if_combined Executable file
View file

@ -0,0 +1,682 @@
#!/usr/bin/perl -w
# -*- perl -*-
=head1 NAME
snmp__if_combined - SNMP card plugin to monitor the network interfaces of any networked equipment.
=head1 APPLICABLE SYSTEMS
Any SNMP capable networked computer equipment. Using a command such
as "munin-node-configure --snmp switch.langfeldt.net --snmpversion 2c
--snmpcommunity public | sh -x" should auto-detect all applicable
interfaces. On a typical switch you will get one plugin pr. ethernet
port. On a router you might get one plugin per VLAN interface.
=head1 CONFIGURATION
As a rule SNMP plugins need site specific configuration. The default
configuration (shown here) will only work on insecure sites/devices:
[snmp_*]
env.version 2
env.community public
env.ifTypeOnly ethernetCsmacd
In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption). But in any
case the community string for your devices should not be "public".
Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.
The ifTypeOnly is a space separated list of media types to show. By
default the plugin shows only interfaces identified as
'ethernetCsmacd'. To see what interface types your switch, router, or
other net thing uses you can use this command:
snmpwalk -c public -v 2c switch 1.3.6.1.2.1.2.2.1.3
It may show something like this:
IF-MIB::ifType.1 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.4 = INTEGER: mplsTunnel(150)
IF-MIB::ifType.5 = INTEGER: other(1)
IF-MIB::ifType.6 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.8 = INTEGER: tunnel(131)
IF-MIB::ifType.13 = INTEGER: propVirtual(53)
IF-MIB::ifType.123 = INTEGER: l2vlan(135)
propVirtual or l2vlan is usualy used for VLAN interfaces. Tunnel
would normaly be for VPNs. A minor horde of different interface types
are supposted, please see IANAifType-MIB (on your system or find with
Google) for a full list.
=head1 INTERPRETATION
A single graph is generated with all the interfaces overlaid one over
the other: incoming traffic is received on the interface from the
connected device, outgoing is sent to it instead.
=head1 MIB INFORMATION
This plugin requires the IF-MIB the standard IETF MIB for network
interfaces.
It reports the contents of the
IF-MIB::ifHCInOctets/IF-MIB::ifHCOutOctets if available,
IF-MIB::ifInOctets/IF-MIB::ifOutOctets if not. The former are 64 bit
counters only available with SNMP 2 and later. The later are 32 bit
counters (see FEATURES below).
=head1 MAGIC MARKERS
#%# family=snmpauto
#%# capabilities=snmpconf
=head1 VERSION
$Id: snmp__if_.in 1818 2009-01-03 19:29:30Z janl $
=head1 BUGS
Should support indexing by
- ifIndex
- ifName
- ifDescr
- ifAlias
- mac-address
(and anything else MRTG can index by) in addition to OID-index as now.
Pulling in a user definable set of ifName/ifDescr/ifAlias for textual
description and even graph_title would also be nice.
IFF we get a patch to support the .oldname attribute then we may use
that to let the operator change the indexing dynamicaly without data
loss.
=head1 FEATURES
You may get strange results if you use SNMPv1, or SNMPv2 on
switches that do not support 64 bit byte counters. If the interface
traffic exceeds about 50Mbps a 32 bit byte counter will wrap around in
less than 5 minutes making the graph for the interface show random
results.
If you have a switch/device that supports 64 bit byte counters this
plugin will use them and the graph will be fine. The graph
information will inform about this. You must use SNMPv2c or SNMPv3 to
be able to use 64 bit counters - if the device supports them.
This problem is a feature of the device SNMP implementation or your
usage of it, it is nothing the plugin can fix. In the future Munin
may be able to run the plugin more often than the counter wraps
around.
=head1 AUTHOR
Copyright (C) 2012 Diego Elio Pettenò.
Original snmp__if_multi: Copyright (C) 2004-2010 Jimmy Olsen, Dagfinn
Ilmari Mannsaaker, Nicolai Langfeldt, Redpill Linpro AS and others.
Original snmp__if_ plugin: Copyright (C) 2004-2009 Jimmy Olsen, Dagfinn
Ilmari Mannsaaker.
Initial SNMPv3 support by "Confusedhacker".
Documentation, porting to Munin::Plugin::SNMP and
further grooming by Nicolai Langfeldt.
Reworked to snmp__if_multi by Nicolai Langfeldt.
Reworked to snmp__if_all by Diego Elio Pettenò.
=head1 LICENSE
GPLv2
=cut
use strict;
use Munin::Plugin;
use Munin::Plugin::SNMP;
my $response;
my $iface;
# This is the snmpwalk:
# .1.3.6.1.2.1.2.1.0 = INTEGER: 2
# .1.3.6.1.2.1.2.2.1.1.1 = INTEGER: 1
# .1.3.6.1.2.1.2.2.1.1.65539 = INTEGER: 65539
# .1.3.6.1.2.1.2.2.1.2.1 = STRING: MS TCP Loopback interface
# .1.3.6.1.2.1.2.2.1.2.65539 = STRING: Broadcom NetXtreme Gigabit Ethernet
# .1.3.6.1.2.1.2.2.1.3.1 = INTEGER: softwareLoopback(24)
# .1.3.6.1.2.1.2.2.1.3.65539 = INTEGER: ethernetCsmacd(6)
# .1.3.6.1.2.1.2.2.1.4.1 = INTEGER: 1520
# .1.3.6.1.2.1.2.2.1.4.65539 = INTEGER: 1500
# .1.3.6.1.2.1.2.2.1.5.1 = Gauge32: 10000000
# .1.3.6.1.2.1.2.2.1.5.65539 = Gauge32: 1000000000
# .1.3.6.1.2.1.2.2.1.6.1 = STRING:
# .1.3.6.1.2.1.2.2.1.6.65539 = STRING: 0:30:48:75:65:5e
# .1.3.6.1.2.1.2.2.1.7.1 = INTEGER: up(1)
# .1.3.6.1.2.1.2.2.1.7.65539 = INTEGER: up(1)
# .1.3.6.1.2.1.2.2.1.8.1 = INTEGER: up(1)
# .1.3.6.1.2.1.2.2.1.8.65539 = INTEGER: up(1)
#
# 64 bit counters:
# .1.3.6.1.2.1.31.1.1.1.6. Counter64 ifHCInOctets
# .1.3.6.1.2.1.31.1.1.1.10. Counter64 ifHCOutOctets
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
print "require 1.3.6.1.2.1.2.2.1.1.\n";
exit 0;
}
my $sysDescr = '1.3.6.1.2.1.1.1.0';
my $sysLocation = '1.3.6.1.2.1.1.6.0';
my $sysContact = '1.3.6.1.2.1.1.4.0';
my $sysName = '1.3.6.1.2.1.1.5.0';
my $ifOIDBase = "1.3.6.1.2.1.2.2.1"; # ifEntry
my $ifv2OIDBase = "1.3.6.1.2.1.31.1.1.1"; # ifXEntry
my %ifTypes = (
other => 1,
regular1822 => 2,
hdh1822 => 3,
ddnX25 => 4,
rfc877x25 => 5,
ethernetCsmacd => 6,
iso88023Csmacd => 7,
iso88024TokenBus => 8,
iso88025TokenRing => 9,
iso88026Man => 10,
starLan => 11,
proteon10Mbit => 12,
proteon80Mbit => 13,
hyperchannel => 14,
fddi => 15,
lapb => 16,
sdlc => 17,
ds1 => 18,
e1 => 19,
basicISDN => 20,
primaryISDN => 21,
propPointToPointSerial => 22,
ppp => 23,
softwareLoopback => 24,
eon => 25,
ethernet3Mbit => 26,
nsip => 27,
slip => 28,
ultra => 29,
ds3 => 30,
sip => 31,
frameRelay => 32,
rs232 => 33,
para => 34,
arcnet => 35,
arcnetPlus => 36,
atm => 37,
miox25 => 38,
sonet => 39,
x25ple => 40,
iso88022llc => 41,
localTalk => 42,
smdsDxi => 43,
frameRelayService => 44,
v35 => 45,
hssi => 46,
hippi => 47,
modem => 48,
aal5 => 49,
sonetPath => 50,
sonetVT => 51,
smdsIcip => 52,
propVirtual => 53,
propMultiplexor => 54,
ieee80212 => 55,
fibreChannel => 56,
hippiInterface => 57,
frameRelayInterconnect => 58,
aflane8023 => 59,
aflane8025 => 60,
cctEmul => 61,
fastEther => 62,
isdn => 63,
v11 => 64,
v36 => 65,
g703at64k => 66,
g703at2mb => 67,
qllc => 68,
fastEtherFX => 69,
channel => 70,
ieee80211 => 71,
ibm370parChan => 72,
escon => 73,
dlsw => 74,
isdns => 75,
isdnu => 76,
lapd => 77,
ipSwitch => 78,
rsrb => 79,
atmLogical => 80,
ds0 => 81,
ds0Bundle => 82,
bsc => 83,
async => 84,
cnr => 85,
iso88025Dtr => 86,
eplrs => 87,
arap => 88,
propCnls => 89,
hostPad => 90,
termPad => 91,
frameRelayMPI => 92,
x213 => 93,
adsl => 94,
radsl => 95,
sdsl => 96,
vdsl => 97,
iso88025CRFPInt => 98,
myrinet => 99,
voiceEM => 100,
voiceFXO => 101,
voiceFXS => 102,
voiceEncap => 103,
voiceOverIp => 104,
atmDxi => 105,
atmFuni => 106,
atmIma => 107,
pppMultilinkBundle => 108,
ipOverCdlc => 109,
ipOverClaw => 110,
stackToStack => 111,
virtualIpAddress => 112,
mpc => 113,
ipOverAtm => 114,
iso88025Fiber => 115,
tdlc => 116,
gigabitEthernet => 117,
hdlc => 118,
lapf => 119,
v37 => 120,
x25mlp => 121,
x25huntGroup => 122,
trasnpHdlc => 123,
interleave => 124,
fast => 125,
ip => 126,
docsCableMaclayer => 127,
docsCableDownstream => 128,
docsCableUpstream => 129,
a12MppSwitch => 130,
tunnel => 131,
coffee => 132,
ces => 133,
atmSubInterface => 134,
l2vlan => 135,
l3ipvlan => 136,
l3ipxvlan => 137,
digitalPowerline => 138,
mediaMailOverIp => 139,
dtm => 140,
dcn => 141,
ipForward => 142,
msdsl => 143,
ieee1394 => 144,
'if-gsn' => 145,
dvbRccMacLayer => 146,
dvbRccDownstream => 147,
dvbRccUpstream => 148,
atmVirtual => 149,
mplsTunnel => 150,
srp => 151,
voiceOverAtm => 152,
voiceOverFrameRelay => 153,
idsl => 154,
compositeLink => 155,
ss7SigLink => 156,
propWirelessP2P => 157,
frForward => 158,
rfc1483 => 159,
usb => 160,
ieee8023adLag => 161,
bgppolicyaccounting => 162,
frf16MfrBundle => 163,
h323Gatekeeper => 164,
h323Proxy => 165,
mpls => 166,
mfSigLink => 167,
hdsl2 => 168,
shdsl => 169,
ds1FDL => 170,
pos => 171,
dvbAsiIn => 172,
dvbAsiOut => 173,
plc => 174,
nfas => 175,
tr008 => 176,
gr303RDT => 177,
gr303IDT => 178,
isup => 179,
propDocsWirelessMaclayer => 180,
propDocsWirelessDownstream => 181,
propDocsWirelessUpstream => 182,
hiperlan2 => 183,
propBWAp2Mp => 184,
sonetOverheadChannel => 185,
digitalWrapperOverheadChannel => 186,
aal2 => 187,
radioMAC => 188,
atmRadio => 189,
imt => 190,
mvl => 191,
reachDSL => 192,
frDlciEndPt => 193,
atmVciEndPt => 194,
opticalChannel => 195,
opticalTransport => 196,
propAtm => 197,
voiceOverCable => 198,
infiniband => 199,
teLink => 200,
q2931 => 201,
virtualTg => 202,
sipTg => 203,
sipSig => 204,
docsCableUpstreamChannel => 205,
econet => 206,
pon155 => 207,
pon622 => 208,
bridge => 209,
linegroup => 210,
voiceEMFGD => 211,
voiceFGDEANA => 212,
voiceDID => 213,
mpegTransport => 214,
sixToFour => 215,
gtp => 216,
pdnEtherLoop1 => 217,
pdnEtherLoop2 => 218,
opticalChannelGroup => 219,
homepna => 220,
gfp => 221,
ciscoISLvlan => 222,
actelisMetaLOOP => 223,
fcipLink => 224,
rpr => 225,
qam => 226,
lmp => 227,
cblVectaStar => 228,
docsCableMCmtsDownstream => 229,
adsl2 => 230,
macSecControlledIF => 231,
macSecUncontrolledIF => 232,
aviciOpticalEther => 233,
atmbond => 234,
voiceFGDOS => 235,
mocaVersion1 => 236,
ieee80216WMAN => 237,
adsl2plus => 238,
dvbRcsMacLayer => 239,
dvbTdm => 240,
dvbRcsTdma => 241,
x86Laps => 242,
wwanPP => 243,
wwanPP2 => 244
);
my %ifTypeByNum = map { $ifTypes{$_} => $_; } keys %ifTypes;
# Needed as globals
my $snmpinfo;
my $snmpinfoX;
sub do_collect {
# Collect information from SNMP agent
my $session = Munin::Plugin::SNMP->session();
$snmpinfo = $session->get_hash(
-baseoid => $ifOIDBase,
-cols =>
{ 2 => 'ifDescr',
# Type: See above
3 => 'ifType',
4 => 'ifMtu',
5 => 'ifSpeed',
6 => 'ifMac',
7 => 'ifAdminStatus',
# Oper: 1) up 2) down 3) testing
# 4) unknown, 5) dormant 6) not present
# 7) lowerLayerDown
8 => 'ifOperStatus',
10 => 'ifInOctets',
11 => 'ifInUcastPkts',
15 => 'ifUnUnknownProtos',
16 => 'ifOutOctets',
18 => 'ifOutNUcastPkts',
});
# ifXEntry - SNMP v2 and up only - on some devices
$snmpinfoX = $session->get_hash(
-baseoid => $ifv2OIDBase,
-cols =>
{ 2 => 'ifInMulticastPkts',
3 => 'ifInBroadcastPkts',
4 => 'ifOutMulticastPkts',
5 => 'ifOutBroadcastPkts',
6 => 'ifHCInOctets',
10 => 'ifHCOutOctets',
15 => 'ifHighSpeed',
18 => 'ifAlias',
});
}
sub do_preprocess_if {
my ($mediatype, $if) = @_;
my $response = $snmpinfo->{$if}->{ifType} || 1;
if (defined($mediatype)) {
if (defined($mediatype->{$response})) {
# This is one of the interesting media types
} else {
# This media type is not interesting. Remove.
delete $snmpinfo->{$if} if exists $snmpinfo->{$if};
delete $snmpinfoX->{$if} if exists $snmpinfoX->{$if};
return;
}
}
if (defined ($response = $snmpinfo->{$if}->{ifOperStatus})) {
# 1 = up, 2 = down, 7 = lowerLayerDown
if ($response == 2 or $response == 7) {
# Fold recognized down states into one.
$response = $snmpinfo->{$if}->{ifOperStatus} = 2;
} elsif ($response != 1) {
# This interface is fishy, remove and forget.
delete $snmpinfo->{$if} if exists $snmpinfo->{$if};
delete $snmpinfoX->{$if} if exists $snmpinfoX->{$if};
return;
}
}
}
sub do_preprocess {
my $mediatypes = 'ethernetCsmacd';
if (exists( $ENV{'ifTypeOnly'} )) {
$mediatypes = $ENV{'ifTypeOnly'};
}
my @mediatypes = split(/[ ,]+/,$mediatypes);
# Hash of numerical media types the user finds interesting.
my $mediatype={};
if ($mediatypes eq 'ALL') {
$mediatype = undef;
} else {
foreach my $type (@mediatypes) {
if (exists($ifTypes{$type})) {
$mediatype->{$ifTypes{$type}} = 1;
} else {
die "Unknown media type '$type' specified in ifTypeOnly\n";
}
}
}
foreach my $if (keys %{$snmpinfo}) {
do_preprocess_if($mediatype, $if);
}
}
sub do_config_root {
my ($host, $version) = @_;
my $extrainfo="";
if (defined ($snmpinfoX->{0}->{ifHCInOctets})) {
# If we get an answer at the 64 bit OID then this switch
# supports the extended MIB
$extrainfo .= " This switch supports 64 bit byte counters and these are used by this plugin.";
} else {
# If not we only have a 32 bit counter and are lost.
$extrainfo .= " NOTE! This switch supports only 32 bit byte counters which makes the plugin unreliable and unsuitable for most 100Mb (or faster) interfaces, where bursts are expected to exceed 50Mbps. This means that for interfaces where much traffic is sent this plugin will report false thruputs and cannot be trusted.";
# unless perhaps the operator can get us snmp version 2c or 3?
$extrainfo .= " I notice that you use SNMP version 1 which does not support 64 bit quantities. You may get better results if you switch to SNMP version 2c or 3. Please refer to the plugin documentation."
if $version == 1;
}
print "graph_title $host interfaces traffic\n";
print "graph_args --base 1000\n";
print "graph_vlabel bits in (-) / out (+) per \${graph_period}\n";
print "graph_category network\n";
print "graph_info This graph shows the total traffic for $host.$extrainfo\n";
}
sub do_config_if {
my ($host,$version,$if) = @_;
my $alias = $snmpinfo->{$if}->{ifDescr} || "Interface $if";
if (! ($alias =~ /\d+/) ) {
# If there are no numbers in the $alias add the if index
$alias .=" (if $if)";
}
my $warn = undef;
my $speed = 0;
my $extrainfo = "";
if (defined ($speed = $snmpinfoX->{$if}->{ifHighSpeed}) and $speed) {
# Speed in 1,000,000 bits per second
$speed = $speed * 1000000;
$warn = $speed / 75 * 100;
my $textspeed = scaleNumber($speed,'bps','',
'The interface speed is %.1f%s%s.');
$extrainfo .= ' '.$textspeed if $textspeed;
} elsif (defined ($speed = $snmpinfo->{$if}->{ifSpeed}) and $speed) {
# Speed in bits pr. second
$warn = $speed*100/75;
my $textspeed = scaleNumber($speed,'bps','',
'The interface speed is %.1f%s%s.');
$extrainfo .= " ".$textspeed if $textspeed;
}
$response = $snmpinfo->{$if}->{ifType};
print "recv$if.label $alias\n";
print "recv$if.type DERIVE\n";
print "recv$if.graph no\n";
print "recv$if.cdef recv$if,8,*\n";
print "recv$if.max $speed\n" if $speed;
print "recv$if.min 0\n";
print "recv$if.warning ", (-$warn), "\n" if defined $warn;
print "send$if.label $alias\n";
print "send$if.type DERIVE\n";
print "send$if.negative recv$if\n";
print "send$if.cdef send$if,8,*\n";
print "send$if.max $speed\n" if $speed;
print "send$if.min 0\n";
print "send$if.warning $warn\n" if defined $warn;
}
sub do_fetch_if {
my($if) = @_;
my $status = $snmpinfo->{$if}->{ifOperStatus} || 1;
my $response;
# 1 means up
# 2 means set to down
# Everything else we ignore.
if ($status == 2) {
# Interface is down
print "recv$if.value U\n";
print "send$if.value U\n";
print "send$if.extinfo This interface is currently down.\n";
return;
}
if (defined ($response = $snmpinfoX->{$if}->{ifHCInOctets} ||
$snmpinfo->{$if}->{ifInOctets})) {
print "recv$if.value ", $response, "\n";
} else {
# No response...
print "recv$if.value U\n";
}
if (defined ($response = $snmpinfoX->{$if}->{ifHCOutOctets} ||
$snmpinfo->{$if}->{ifOutOctets})) {
print "send$if.value ", $response, "\n";
} else {
# No response...
print "send$if.value U\n";
}
}
sub do_config {
my ($host,undef,$version) = Munin::Plugin::SNMP->config_session();
print "host_name $host\n" unless $host eq 'localhost';
do_config_root($host,$version);
foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) {
do_config_if($host,$version,$if);
}
}
# ############################## MAIN ################################
do_collect;
do_preprocess;
if ($ARGV[0] and $ARGV[0] eq "config") {
do_config();
exit 0;
}
foreach my $if (sort {$a <=> $b} keys %{$snmpinfo}) {
do_fetch_if($if);
}

View file

@ -1,35 +0,0 @@
#!/bin/sh
HOST=`echo $0 | perl -pe "s/^.+snmp_hp_(.*?)_[0-9]+/\\$1/;"`
PORT=`echo $0 | perl -pe "s/^.+snmp_hp_.*?_([0-9]+)/\\$1/;"`
if [ "$1" = "autoconf" ]; then
if [ -x /usr/bin/snmpget ]; then
echo yes
exit 0
else
echo "no (/usr/bin/snmpget not found)"
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo "graph_order down up"
echo "graph_title Switch $HOST Port $PORT Traffic"
echo 'graph_args --base 1000'
echo 'graph_vlabel bits out (-) / in (+) per ${graph_period}'
echo 'graph_category Snmp'
# echo "graph_info This graph shows the traffic of the $INTERFACE network interface. Please note that the traffic is shown in bits per second, not bytes. IMPORTANT: Since the data source for this plugin use 32bit counters, this plugin is really unreliable and unsuitable for most 100Mb (or faster) interfaces, where bursts are expected to exceed 50Mbps. This means that this plugin is usuitable for most production environments. To avoid this problem, use the ip_ plugin instead."
echo 'down.label received'
echo 'down.type COUNTER'
echo 'down.graph no'
echo 'down.cdef down,8,*'
echo 'up.label bps'
echo 'up.type COUNTER'
echo 'up.negative down'
echo 'up.cdef up,8,*'
exit 0
fi;
snmpget -v1 -c public $HOST .1.3.6.1.2.1.2.2.1.10.$PORT .1.3.6.1.2.1.2.2.1.16.$PORT | sed -e 's/^.*ifIn.*Counter32:/down.value/' -e 's/^.*ifOut.*Counter32:/up.value/'

View file

@ -1,59 +0,0 @@
#!/bin/bash
HOST=${host:-"127.0.0.1"}
: << =cut
=head1 NAME
snmp_HPLJ2015 - Consumables level on HP LaserJet 2015n reported over SNMP
=head1 CONFIGURATION
HOST
=head1 AUTHOR
Oleksiy Kochkin
=head1 LICENSE
As is.
=back
=head1 MAGIC MARKERS
#%# family=contrib
#%# capabilities=autoconf
=cut
case $1 in
config)
echo "graph_title Consumables level @ $HOST"
echo 'graph_args --upper-limit 100 -l 0'
echo 'graph_vlabel %'
echo 'graph_category printers'
echo 'graph_scale no'
echo 'black.label Black toner level'
echo 'black.draw LINE2'
echo 'black.type GAUGE'
echo 'black.colour 000000'
echo 'black.warning 5:'
echo 'black.critical 1:'
echo 'black.min 0'
echo 'black.max 100'
exit 0;;
esac
BLACK_MAX_OID=".1.3.6.1.2.1.43.11.1.1.8.1.1"
BLACK_LVL_OID=".1.3.6.1.2.1.43.11.1.1.9.1.1"
BLACK_MAX=`snmpget -v 1 -c public -Ov -Oq $HOST $BLACK_MAX_OID`
BLACK_LVL=`snmpget -v 1 -c public -Ov -Oq $HOST $BLACK_LVL_OID`
BLACK_LVL_PERCENTS=$(($BLACK_LVL*100/$BLACK_MAX))
echo -n "black.value "
echo $BLACK_LVL_PERCENTS

View file

@ -1,59 +0,0 @@
#!/bin/bash
HOST=${host:-"127.0.0.1"}
: << =cut
=head1 NAME
Xerox-WC3220 - Plugin to monitor consumables level on Xerox WorkCentre 3xxx series
=head1 CONFIGURATION
HOST
=head1 AUTHOR
Oleksiy Kochkin
=head1 LICENSE
As is.
=back
=head1 MAGIC MARKERS
#%# family=contrib
#%# capabilities=autoconf
=cut
case $1 in
config)
echo "graph_title Consumables level @ $HOST"
echo 'graph_vlabel %'
echo 'graph_category printers'
echo 'graph_args --upper-limit 100 -l 0'
echo 'graph_scale no'
echo 'black.label Black toner level'
echo 'black.draw LINE2'
echo 'black.type GAUGE'
echo 'black.colour 000000'
echo 'black.warning 5:'
echo 'black.critical 1:'
echo 'black.min 0'
echo 'black.max 100'
exit 0;;
esac
BLACK_MAX_OID=".1.3.6.1.2.1.43.11.1.1.8.1.1"
BLACK_LVL_OID=".1.3.6.1.2.1.43.11.1.1.9.1.1"
BLACK_MAX=`snmpget -v 1 -c public -Ov -Oq $HOST $BLACK_MAX_OID`
BLACK_LVL=`snmpget -v 1 -c public -Ov -Oq $HOST $BLACK_LVL_OID`
BLACK_LVL_PERCENTS=$(($BLACK_LVL*100/$BLACK_MAX))
echo -n "black.value "
echo $BLACK_LVL_PERCENTS

View file

@ -1,127 +0,0 @@
#!/bin/bash
HOST=${host:-"127.0.0.1"}
: << =cut
=head1 NAME
Xerox-WC7x32-consumables - Plugin to monitor consumables level on Xerox WorkCentre 7x32 series printers
=head1 CONFIGURATION
host
=head1 AUTHOR
Oleksiy Kochkin
=head1 LICENSE
As is.
=back
=head1 MAGIC MARKERS
#%# family=contrib
#%# capabilities=autoconf
=cut
case $1 in
config)
echo "graph_title Consumables level @ $HOST"
echo 'graph_vlabel %'
echo 'graph_category printers'
echo 'graph_args --upper-limit 100 -l 0'
echo 'graph_scale no'
echo 'cyan.label Cyan toner level'
echo 'cyan.draw LINE2'
echo 'cyan.type GAUGE'
echo 'cyan.colour 1921B1'
echo 'cyan.warning 5:'
echo 'cyan.critical 1:'
echo 'cyan.min 0'
echo 'cyan.max 100'
echo 'magenta.label Magenta toner level'
echo 'magenta.draw LINE2'
echo 'magenta.type GAUGE'
echo 'magenta.colour C00086'
echo 'magenta.warning 5:'
echo 'magenta.critical 1:'
echo 'magenta.min 0'
echo 'magenta.max 100'
echo 'yellow.label Yellow toner level'
echo 'yellow.draw LINE2'
echo 'yellow.type GAUGE'
echo 'yellow.colour FECD00'
echo 'yellow.warning 5:'
echo 'yellow.critical 1:'
echo 'yellow.min 0'
echo 'yellow.max 100'
echo 'black.label Black toner level'
echo 'black.draw LINE2'
echo 'black.type GAUGE'
echo 'black.colour 000000'
echo 'black.warning 5:'
echo 'black.critical 1:'
echo 'black.min 0'
echo 'black.max 100'
echo 'drum.label Drum unit resource left'
echo 'drum.draw LINE2'
echo 'drum.type GAUGE'
echo 'drum.colour 00C12B'
echo 'drum.warning 5:'
echo 'drum.critical 1:'
echo 'drum.min 0'
echo 'drum.max 100'
exit 0;;
esac
BLACK_MAX_OID=".1.3.6.1.2.1.43.11.1.1.8.1.1"
BLACK_LVL_OID=".1.3.6.1.2.1.43.11.1.1.9.1.1"
YELLOW_MAX_OID=".1.3.6.1.2.1.43.11.1.1.8.1.2"
YELLOW_LVL_OID=".1.3.6.1.2.1.43.11.1.1.9.1.2"
MAGENTA_MAX_OID=".1.3.6.1.2.1.43.11.1.1.8.1.3"
MAGENTA_LVL_OID=".1.3.6.1.2.1.43.11.1.1.9.1.3"
CYAN_MAX_OID=".1.3.6.1.2.1.43.11.1.1.8.1.4"
CYAN_LVL_OID=".1.3.6.1.2.1.43.11.1.1.9.1.4"
DRUM_MAX_OID=".1.3.6.1.2.1.43.11.1.1.8.1.24"
DRUM_LVL_OID=".1.3.6.1.2.1.43.11.1.1.9.1.24"
BLACK_MAX=`snmpget -v 1 -c public -Ov -Oq $HOST $BLACK_MAX_OID`
BLACK_LVL=`snmpget -v 1 -c public -Ov -Oq $HOST $BLACK_LVL_OID`
BLACK_LVL_PERCENTS=$(($BLACK_LVL*100/$BLACK_MAX))
YELLOW_MAX=`snmpget -v 1 -c public -Ov -Oq $HOST $YELLOW_MAX_OID`
YELLOW_LVL=`snmpget -v 1 -c public -Ov -Oq $HOST $YELLOW_LVL_OID`
YELLOW_LVL_PERCENTS=$(($YELLOW_LVL*100/$YELLOW_MAX))
MAGENTA_MAX=`snmpget -v 1 -c public -Ov -Oq $HOST $MAGENTA_MAX_OID`
MAGENTA_LVL=`snmpget -v 1 -c public -Ov -Oq $HOST $MAGENTA_LVL_OID`
MAGENTA_LVL_PERCENTS=$(($MAGENTA_LVL*100/$MAGENTA_MAX))
CYAN_MAX=`snmpget -v 1 -c public -Ov -Oq $HOST $CYAN_MAX_OID`
CYAN_LVL=`snmpget -v 1 -c public -Ov -Oq $HOST $CYAN_LVL_OID`
CYAN_LVL_PERCENTS=$(($CYAN_LVL*100/$CYAN_MAX))
DRUM_MAX=`snmpget -v 1 -c public -Ov -Oq $HOST $DRUM_MAX_OID`
DRUM_LVL=`snmpget -v 1 -c public -Ov -Oq $HOST $DRUM_LVL_OID`
DRUM_LVL_PERCENTS=$(($DRUM_LVL*100/$DRUM_MAX))
echo -n "cyan.value "
echo $CYAN_LVL_PERCENTS
echo -n "magenta.value "
echo $MAGENTA_LVL_PERCENTS
echo -n "yellow.value "
echo $YELLOW_LVL_PERCENTS
echo -n "black.value "
echo $BLACK_LVL_PERCENTS
echo -n "drum.value "
echo $DRUM_LVL_PERCENTS