Skip to content

Instantly share code, notes, and snippets.

@ujuc
Last active August 29, 2015 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ujuc/31505cb649ee8712db99 to your computer and use it in GitHub Desktop.
Save ujuc/31505cb649ee8712db99 to your computer and use it in GitHub Desktop.
zabbix FC host check
UserParameter=fchost.discovery, /etc/zabbix/fchost_discovery.py
UserParameter=fchost.status[*], /etc/zabbix/fchost_status.py $1
#!/usr/bin/env python
# coding: utf-8
import os
import json
pwd = '/sys/class/fc_host/'
hosts = list()
get_hosts = os.listdir(pwd)
for host in get_hosts:
dc = {"{#FCHOST}": host}
hosts.append(dc)
data = {'data': hosts}
print json.dumps(data)
#!/usr/bin/env python
# coding: utf-8
import sys
import subprocess as sub
host_name = sys.argv[1]
pwd = '/sys/class/fc_host/'
get_host_state = sub.Popen(['cat', '{0}{1}/port_state'.format(pwd, host_name)], stdout=sub.PIPE).communicate()
host_state = get_host_state[0].split['\n'][0]
print host_state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment