This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 163
Host
John E. Vincent edited this page Jan 23, 2011
·
5 revisions
In the Noah world a Host
is fairly similar to that of a Nagios host. A host has the following attributes
- Name string, unique
- Status string, one of "up","down" or "pending"
- Services - set of Service ids
You can see the draft API specifications for each object type here: Draft Host API
curl -d '{"name":"fraggle", "status":"pending"}' -X PUT http://localhost:9292/h/fraggle
{"result":"success","id":"7","status":"pending","name":"fraggle"}
You can use the irbstub.rb
file to load the models (irb -r ./irbstub.rb
)
>> h = Host.create(:name => 'myhost', :status => 'up')
=> #<Host:1 created_at="2011-01-23 11:19:56 UTC" updated_at="2011-01-23 11:19:56 UTC" name="myhost" status="up">
>> h.valid?
=> true
>> h.save
=> #<Host:1 created_at="2011-01-23 11:19:56 UTC" updated_at="2011-01-23 11:20:01 UTC" name="myhost" status="up">
>>
You can also add services at the time you create the Host:
>> h = Host.create(:name => 'myotherserver', :status => 'up')
=> #<Host:2 created_at="2011-01-23 11:21:08 UTC" updated_at="2011-01-23 11:21:08 UTC" name="myotherserver" status="up">
>> if h.save
>> h.services << Service.create(:name => 'myservice', :status => 'up', :host => h)
>> end
=> false
>> h.valid?
=> true
>> h
=> #<Host:2 created_at="2011-01-23 11:21:08 UTC" updated_at="2011-01-23 11:22:14 UTC" name="myotherserver" status="up">
>> h.services
=> #<Set (Service): ["1"]>
>> h.services[1]
=> #<Service:1 created_at="2011-01-23 11:22:14 UTC" updated_at="2011-01-23 11:22:14 UTC" name="myservice" status="up" host_id="2">