mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	hopefully doesn't break anything Mostly issues with snmp oids and options containing spaces. Try to remove all of those. DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926` After you are done testing, you can remove the changes with `./scripts/github-remove`. If there are schema changes, you can ask on discord how to revert.
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
use LibreNMS\RRD\RrdDefinition;
 | 
						|
 | 
						|
$name = 'freeswitch';
 | 
						|
$app_id = $app['app_id'];
 | 
						|
if (!empty($agent_data[$name])) {
 | 
						|
    $rawdata = $agent_data[$name];
 | 
						|
} else {
 | 
						|
    $options = '-Oqv';
 | 
						|
    $oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.10.102.114.101.101.115.119.105.116.99.104';
 | 
						|
    $rawdata = snmp_walk($device, $oid, $options);
 | 
						|
    $rawdata  = str_replace("<<<freeswitch>>>\n", '', $rawdata);
 | 
						|
}
 | 
						|
# Format Data
 | 
						|
$lines = explode("\n", $rawdata);
 | 
						|
$freeswitch = array();
 | 
						|
foreach ($lines as $line) {
 | 
						|
    list($var,$value) = explode('=', $line);
 | 
						|
    $freeswitch[$var] = $value;
 | 
						|
}
 | 
						|
# Freeswitch stats
 | 
						|
$rrd_name =  array('app', $name, 'stats', $app_id);
 | 
						|
$rrd_def = RrdDefinition::make()
 | 
						|
    ->addDataset('calls', 'GAUGE', 0, 10000)
 | 
						|
    ->addDataset('channels', 'GAUGE', 0, 10000)
 | 
						|
    ->addDataset('peak', 'GAUGE', 0, 10000)
 | 
						|
    ->addDataset('in_failed', 'COUNTER', 0, 4294967295)
 | 
						|
    ->addDataset('in_okay', 'COUNTER', 0, 4294967295)
 | 
						|
    ->addDataset('out_failed', 'COUNTER', 0, 4294967295)
 | 
						|
    ->addDataset('out_okay', 'COUNTER', 0, 4294967295);
 | 
						|
$fields = array(
 | 
						|
    'calls' => $freeswitch['Calls'],
 | 
						|
    'channels' => $freeswitch['Channels'],
 | 
						|
    'peak' => $freeswitch['Peak'],
 | 
						|
    'in_failed' => $freeswitch['InFailed'],
 | 
						|
    'in_okay' => $freeswitch['InTotal'] - $freeswitch['InFailed'],
 | 
						|
    'out_failed' => $freeswitch['OutFailed'],
 | 
						|
    'out_okay' => $freeswitch['OutTotal'] - $freeswitch['OutFailed']
 | 
						|
);
 | 
						|
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
 | 
						|
data_update($device, 'app', $tags, $fields);
 | 
						|
update_application($app, $rawdata, $fields);
 | 
						|
 | 
						|
unset($lines, $freeswitch, $rrd_name, $rrd_def, $fields, $tags);
 |