nucleusv / zabbix Goto Github PK
View Code? Open in Web Editor NEWTemplates and LLD rules for Zabbix
Templates and LLD rules for Zabbix
Hi nucleusv,
I'm using below code to connect to DSN for fetching oracle tablespaces details. This is working without any issue for single DSN but if we've multiple DSN (reading from array separated by '|') it's failing ... It's not coming under a single JSON root element, rather multiple root elements.
#!/usr/bin/php
<?php
if(!isset($argv[1]) && !isset($argv[2])) exit("ZBX_NOTSUPPORTED");
$argv[1] = (explode("|", $argv[1] ));
foreach ($argv[1] as $value) {
$arry['data'][]=array('{#DSN}'=>"$value",);
$connected_dsn = odbc_connect($value,"","");
if(!$connected_dsn) exit('SQL connection erorr | ZBX_NOTSUPPORTED');
switch ($argv[2]) {
case "tablespaces":
$result=odbc_exec($connected_dsn,"SELECT tablespace_name FROM dba_tablespaces;");
$tablespaces = array("data"=>array());
while(odbc_fetch_row($result)){
$tablespaces['data'][]=array('{#TBSNAME}'=>odbc_result($result,1),'{#DSN}'=>$value);
}
echo json_encode($tablespaces);
break;
case "jobs":
$result=odbc_exec($connected_dsn,"SELECT job_name, owner FROM dba_scheduler_jobs WHERE state != 'DISABLED';");
$jobs = array("data"=>array());
while(odbc_fetch_row($result)){
$jobs['data'][]=array(
'{#JOBNAME}'=>odbc_result($result,1),
'{#JOBOWNER}'=>odbc_result($result,2));
}
echo json_encode($jobs);
# break;
}
#exit();
}
?>
[root@tets_server externalscripts]# ./test_oracle.odbc.discovery "KCEPCPRDDB1V-EPCPRDDB|KCEPCPRDDB1V-EPCPVMDB" tablespaces
{"data":[{"{#TBSNAME}":"SYSTEM"},{"{#TBSNAME}":"SYSAUX"},{"{#TBSNAME}":"UNDOTBS1"},{"{#TBSNAME}":"TEMP"},{"{#TBSNAME}":"XDB"},{"{#TBSNAME}":"USERS"},{"{#TBSNAME}":"STATSPACK_DATA"},{"{#TBSNAME}":"WWFDATA"},{"{#TBSNAME}":"IGPDATA"},{"{#TBSNAME}":"EMADATA"},{"{#TBSNAME}":"CRNDATA"},{"{#TBSNAME}":"BATCHDATA"},{"{#TBSNAME}":"NTWKSDATA"},{"{#TBSNAME}":"NWMDATA"},{"{#TBSNAME}":"COMMUSR"},{"{#TBSNAME}":"REPORTSDATA"}]}{"data":[{"{#TBSNAME}":"SYSTEM"},{"{#TBSNAME}":"SYSAUX"},{"{#TBSNAME}":"UNDOTBS1"},{"{#TBSNAME}":"TEMP"},{"{#TBSNAME}":"XDB"},{"{#TBSNAME}":"USERS"},{"{#TBSNAME}":"STATSPACK_DATA"},{"{#TBSNAME}":"WWFDATA"},{"{#TBSNAME}":"IGPDATA"},{"{#TBSNAME}":"EMADATA"},{"{#TBSNAME}":"CRNDATA"},{"{#TBSNAME}":"COMMUSR"},{"{#TBSNAME}":"NTWKSDATA"}]}
> [root@ets_server externalscripts]#
Kindly suggest how can this be fixed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.