0

Here is how I would send data to our hobbit/xymon server in a bash script:

$BB $BBDISP "status server.host.com.$TEST $COLOR `date` $LINE"

$BB and $BBDISP are environmental variables set by hobbit. I can't find a python equivalent anywhere here or in the docs. Should be simple but sadly, no.

a ekandem
  • 99
  • 1
  • 10

1 Answers1

2

I assume all variables comes from environment. You could do

import os
import subprocess
import datetime

BB = os.environ["BB"]
BBDISP = os.environ["BBDISP"]
TEST = os.environ["TEST"]
COLOR = os.environ["COLOR"]
LINE = os.environ["LINE"]

dat = dat = datetime.datetime.ctime(datetime.datetime.now())

subprocess.call((BB, BBDISP, "server.host.com." + TEST, COLOR, dat, LINE))

That's the general idea, that you still have to adapt if :

  • you want to process the output of command
  • some variable do not come from environment
  • ...
Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252