# Telegraf - Error in plugin \[inputs.exec\]

**URL:** <https://community.influxdata.com/t/telegraf-error-in-plugin-inputs-exec/5071>\
**Category:** Telegraf\
**Tags:** telegraf\
**Created:** [May 8, 2018, 7:33pm UTC](https://community.influxdata.com/t/telegraf-error-in-plugin-inputs-exec/5071 "2018-05-08T19:33:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![v4vamsee](https://avatars.discourse-cdn.com/v4/letter/v/d2c977/32.png) [@v4vamsee](https://community.influxdata.com/u/v4vamsee)\
**Post date:** [May 8, 2018, 7:33pm UTC](https://community.influxdata.com/t/telegraf-error-in-plugin-inputs-exec/5071/1 "2018-05-08T19:33:35Z")

</div>

Hello,

I am trying to gather stats via a python script which generates the data in JSON format. I get following error:

2018-05-08T19:25:20Z E! Error in plugin [inputs.exec]: exec: exit status 1 for command ‘/opt/web/vmware\_inventory/vmware\_inventory.py --host server1’: Traceback (most recent call last):…  
2018-05-08T19:25:30Z E! Error in plugin [inputs.exec]: exec: exit status 1 for command ‘/opt/web/vmware\_inventory/vmware\_inventory.py --host serve1’: Traceback (most recent call last):…

Here is my telegraf configuration:

[[inputs.exec]]  
commands = [“/opt/web/vmware\_inventory/vmware\_inventory.py --host server1”]

## Timeout for each command to complete.

timeout = “5s”

## measurement name suffix (for separating different commands)

name\_suffix = “\_vminven”

## Used by the templating engine to join matched values when cardinality is \> 1

separator = “\_”

## Data format to consume.

## Each data format has its own unique set of configuration options, read

## more about them here:

## [telegraf/docs/DATA\_FORMATS\_INPUT.md at master · influxdata/telegraf · GitHub](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md)

#data\_format = “influx”  
data\_format = “json”  
#data\_format = “Value”  
#data\_format = “nagios”  
#data\_format = “dropwizard”  
name\_override = “vm\_inven”

Here is the actual JSON output:  
[root@xxxx]# /opt/web/vmware\_inventory/vmware\_inventory.py --host server1  
{  
“resourcepool”: {  
“\_moId”: “xxx”,  
“name”: “xxx”  
},  
“alarmactionsenabled”: true,  
“configissue”: ,  
“tag”: ,  
“datastore”: [  
{  
“\_moId”: “xxxx”,  
“name”: “xxxx”  
}  
],  
“triggeredalarmstate”: ,  
“layout”: {  
“disk”: ,  
“swapfile”: “[Store165] xxx”,  
“dynamictype”: null,  
“dynamicproperty”: ,  
“configfile”: ,  
“snapshot”: ,  
“logfile”:   
},  
“network”: ,  
“effectiverole”: [  
1  
],  
“storage”: {  
“dynamictype”: null,  
“timestamp”: {},  
“dynamicproperty”: ,  
“perdatastoreusage”:   
},  
“ansible\_ssh\_host”: “xxxx”,  
“ansible\_uuid”: “xxx”,  
“layoutex”: {  
“dynamictype”: null,  
“timestamp”: {},  
“dynamicproperty”: ,  
“snapshot”: ,  
“file”: ,  
“disk”:   
},  
“config”: {  
“alternateguestname”: “”,  
“firmware”: “bios”,  
“instanceuuid”: “xxxx”,  
“cpuaffinity”: null,  
“repconfig”: null,  
“npivdesirednodewwns”: null,  
“memoryhotaddenabled”: false,  
“nestedhvenabled”: false,  
“hardware”: {},  
“vappconfig”: null,  
“tools”: {},  
“migrateencryption”: “opportunistic”,  
“guestfullname”: “Microsoft Windows Server 2012 (64-bit)”,  
“changeversion”: “2018-05-04T19:25:47.325721Z”,  
“npivportworldwidename”: ,  
“uuid”: “xxx”,  
“messagebustunnelenabled”: false,  
“consolepreferences”: null,  
“forkconfiginfo”: {},  
“cpuhotremoveenabled”: false,  
“vpmcenabled”: false,  
“npivonnonrdmdisks”: null,  
“npivworldwidenametype”: null,  
“swapstorageobjectid”: null,  
“managedby”: null,  
“version”: “vmx-11”,  
“locationid”: “xxx”,  
“maxmksconnections”: 40,  
“template”: false,  
“guestid”: “windows8Server64Guest”,  
“bootoptions”: {},  
“cpufeaturemask”: ,  
“hotplugmemorylimit”: 32768,  
“npivnodeworldwidename”: ,  
“cpuallocation”: {},  
“files”: {},  
“memoryreservationlockedtomax”: false,  
“scheduledhardwareupgradeinfo”: {},  
“dynamictype”: null,  
“createdate”: null,  
“dynamicproperty”: ,  
“initialoverhead”: {},  
“datastoreurl”: ,  
“memoryaffinity”: null,  
“vmxconfigchecksum”: " xxxx",  
“latencysensitivity”: {},  
“changetrackingenabled”: false,  
“npivtemporarydisabled”: true,  
“memoryallocation”: {},  
“ftinfo”: null,  
“guestautolockenabled”: false,  
“annotation”: “”,  
“defaultpowerops”: {},  
“vassertsenabled”: false,  
“hotplugmemoryincrementsize”: 128,  
“keyid”: null,  
“name”: “xxx”,  
“npivdesiredportwwns”: null,  
“vflashcachereservation”: 0,  
“extraconfig”: ,  
“networkshaper”: null,  
“modified”: {},  
“vmstorageobjectid”: null,  
“swapplacement”: “inherit”,  
“flags”: {},  
“guestintegrityinfo”: null,  
“cpuhotaddenabled”: false  
},  
“customvalue”: ,  
“permission”: ,  
“parentvapp”: null,  
“recenttask”: ,  
“availablefield”: ,  
“overallstatus”: “green”,  
“ansible\_host”: “xxx”,  
“guest”: {  
“hostname”: “xxxx”,  
“toolsversionstatus”: “guestToolsNeedUpgrade”,  
“generationinfo”: ,  
“toolsversion”: “xxx”,  
“guestfullname”: “Microsoft Windows Server 2012 (64-bit)”,  
“disk”: ,  
“appstate”: “none”,  
“guestoperationsready”: true,  
“toolsrunningstatus”: “guestToolsRunning”,  
“guestfamily”: “windowsGuest”,  
“toolsinstalltype”: null,  
“guestid”: “windows8Server64Guest”,  
“net”: ,  
“appheartbeatstatus”: “appStatusGray”,  
“guestkernelcrashed”: null,  
“dynamictype”: null,  
“screen”: {},  
“dynamicproperty”: ,  
“interactiveguestoperationsready”: true,  
“powerpolicy”: null,  
“ipaddress”: “xxx”,  
“gueststate”: “running”,  
“toolsversionstatus2”: “guestToolsSupportedOld”,  
“toolsstatus”: “toolsOld”,  
“ipstack”: ,  
“gueststatechangesupported”: true,  
“toolsupdatestatus”: null  
},  
“guestheartbeatstatus”: “green”,  
“name”: “rich-msql-22-pv”,  
“rootsnapshot”: ,  
“configstatus”: “green”,  
“value”: ,  
“summary”: {  
“customvalue”: ,  
“guest”: {},  
“dynamictype”: null,  
“overallstatus”: “green”,  
“dynamicproperty”: ,  
“storage”: {},  
“vm”: {},  
“quickstats”: {},  
“runtime”: {},  
“config”: {}  
},  
“capability”: {  
“quiescedsnapshotssupported”: true,  
“cpufeaturemasksupported”: true,  
“consolepreferencessupported”: false,  
“vpmcsupported”: true,  
“vmnpivwwnupdatesupported”: true,  
“featurerequirementsupported”: true,  
“diskonlysnapshotonsuspendedvmsupported”: null,  
“snapshotconfigsupported”: true,  
“bootoptionssupported”: true,  
“poweredonmonitortypechangesupported”: true,  
“virtualmmuusageignored”: null,  
“changetrackingsupported”: true,  
“nestedhvsupported”: true,  
“settingdisplaytopologymodessupported”: false,  
“reverttosnapshotsupported”: true,  
“settingvideoramsizesupported”: true,  
“settingscreenresolutionsupported”: true,  
“virtualmmuusagesupported”: true,  
“sesparsedisksupported”: true,  
“s1acpimanagementsupported”: true,  
“virtualexecusageignored”: null,  
“poweredoffsnapshotssupported”: true,  
“disksharessupported”: true,  
“dynamictype”: null,  
“vmnpivwwndisablesupported”: true,  
“disablesnapshotssupported”: false,  
“canconnectusbdevices”: null,  
“pervmevcsupported”: null,  
“swapplacementsupported”: true,  
“bootretryoptionssupported”: true,  
“memoryreservationlocksupported”: true,  
“toolsrebootpredictsupported”: null,  
“dynamicproperty”: ,  
“recordreplaysupported”: true,  
“settingdisplaytopologysupported”: true,  
“locksnapshotssupported”: true,  
“npivwwnonnonrdmvmsupported”: true,  
“guestautolocksupported”: true,  
“toolsautoupdatesupported”: true,  
“multiplecorespersocketsupported”: true,  
“securebootsupported”: null,  
“multiplesnapshotssupported”: true,  
“snapshotoperationssupported”: true,  
“toolssynctimesupported”: true,  
“hostbasedreplicationsupported”: true,  
“messagebussupported”: false,  
“vmnpivwwnsupported”: true,  
“memorysnapshotssupported”: true,  
“vmfsnativesnapshotsupported”: false  
},  
“snapshot”: null,  
“runtime”: {  
“powerstate”: “poweredOn”,  
“paused”: false,  
“featuremask”: ,  
“instantclonefrozen”: null,  
“onlinestandby”: false,  
“snapshotinbackground”: false,  
“cleanpoweroff”: null,  
“featurerequirement”: ,  
“question”: null,  
“boottime”: {},  
“maxmemoryusage”: 32768,  
“offlinefeaturerequirement”: ,  
“minrequiredevcmodekey”: “intel-merom”,  
“suspendinterval”: 0,  
“dynamicproperty”: ,  
“quiescedforkparent”: null,  
“dynamictype”: null,  
“memoryoverhead”: null,  
“vflashcacheallocation”: 0,  
“cryptostate”: null,  
“host”: {  
“\_moId”: “host-xxxx”,  
“name”: “xxxxx”  
},  
“maxcpuusage”: 37188,  
“device”: ,  
“suspendtime”: null,  
“recordreplaystate”: “inactive”,  
“toolsinstallermounted”: false,  
“consolidationneeded”: false,  
“connectionstate”: “connected”,  
“needsecondaryreason”: null,  
“dasvmprotection”: {},  
“faulttolerancestate”: “notConfigured”,  
“nummksconnections”: 0  
}  
}

What is the best way to parse above data?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [May 8, 2018, 10:27pm UTC](https://community.influxdata.com/t/telegraf-error-in-plugin-inputs-exec/5071/2 "2018-05-08T22:27:13Z")

</div>

Usually this means the `telegraf` user, which the service runs as, does’'t have permission to run the script. You can try a command like this to debug:

```auto
sudo -u telegraf /opt/web/vmware_inventory/vmware_inventory.py --host server1

```

---

<div class="post-metadata">

**Author:** ![v4vamsee](https://avatars.discourse-cdn.com/v4/letter/v/d2c977/32.png) [@v4vamsee](https://community.influxdata.com/u/v4vamsee)\
**Post date:** [May 11, 2018, 5:07pm UTC](https://community.influxdata.com/t/telegraf-error-in-plugin-inputs-exec/5071/3 "2018-05-11T17:07:54Z")

</div>

Thank you Daniel. That worked.

On a side note, can you please help me with parsing the JSON output? How can it be best done via telegraf?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/daniel/32/142_2.png) [@daniel](https://community.influxdata.com/u/daniel)\
**Post date:** [May 11, 2018, 5:48pm UTC](https://community.influxdata.com/t/telegraf-error-in-plugin-inputs-exec/5071/4 "2018-05-11T17:48:36Z")

</div>

Due to how complex this JSON is, I suggest processing it in a script that wraps this command and passing either line protocol or a simplified JSON structure to Telegraf.

---

<div class="post-metadata">

**Author:** ![v4vamsee](https://avatars.discourse-cdn.com/v4/letter/v/d2c977/32.png) [@v4vamsee](https://community.influxdata.com/u/v4vamsee)\
**Post date:** [May 11, 2018, 6:02pm UTC](https://community.influxdata.com/t/telegraf-error-in-plugin-inputs-exec/5071/5 "2018-05-11T18:02:22Z")

</div>

Can u please provide an example?
