Fetching host availability to external webpage in Nagios - linux

Is there any possible way to fetch the live availability of host/host group from Nagios monitoring tool (where host/hostgroups are already configured) which can be redirected/captured to an external webpage.
are there any exposed API's to do that, couldn't found a way.
Nagios is on a Linux host.
Any help or info is appreciated.
EDIT1:
I have a hostgroup say for example 'All_prod' in this hostgroup I will be having around 20 linux hosts for all the host there would be some metrics/checks defined (example availability, cpu load, free memory ..etc). Here I want the report of only availability metrics of all the host(example : lets say if in 24 hours if the availability is down for 10 minutes then it should provide me with the report as it was down for 10 minutes in 24 hours or just give me any related info which i can evaluate using data evaluation).
it would be great if there are any API's to fetch that information, which will return the data as json/xml.

You can use the Nagios JSON API. You can use the query builder here http://NAGIOSURL/jsonquery.html.
But, to answer your specific question, the queries for hosts would look like this:
http://NAGIOSURL/cgi-bin/statusjson.cgi?query=host&hostname=localhost
Which will output something similar to the following:
{
"format_version": 0,
"result": {
"query_time": 1497384499000,
"cgi": "statusjson.cgi",
"user": "nagiosadmin",
"query": "host",
"query_status": "released",
"program_start": 1497368240000,
"last_data_update": 1497384489000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"host": {
"name": "localhost",
"plugin_output": "egsdda",
"long_plugin_output": "",
"perf_data": "",
"status": 8,
"last_update": 1497384489000,
"has_been_checked": true,
"should_be_scheduled": false,
"current_attempt": 10,
"max_attempts": 10,
"last_check": 1496158536000,
"next_check": 0,
"check_options": 0,
"check_type": 1,
"last_state_change": 1496158536000,
"last_hard_state_change": 1496158536000,
"last_hard_state": 1,
"last_time_up": 1496158009000,
"last_time_down": 1496158536000,
"last_time_unreachable": 1480459504000,
"state_type": 1,
"last_notification": 1496158536000,
"next_notification": 1496165736000,
"no_more_notifications": false,
"notifications_enabled": true,
"problem_has_been_acknowledged": false,
"acknowledgement_type": 0,
"current_notification_number": 2,
"accept_passive_checks": true,
"event_handler_enabled": true,
"checks_enabled": false,
"flap_detection_enabled": true,
"is_flapping": false,
"percent_state_change": 0,
"latency": 0.49,
"execution_time": 0,
"scheduled_downtime_depth": 0,
"process_performance_data": true,
"obsess": true
}
}
}
And for hostgroups:
http://NAGIOSURL/nagios/cgi-bin/statusjson.cgi?query=hostlist&hostgroup=linux-servers
Which will output something similar to the following:
{
"format_version": 0,
"result": {
"query_time": 1497384613000,
"cgi": "statusjson.cgi",
"user": "nagiosadmin",
"query": "hostlist",
"query_status": "released",
"program_start": 1497368240000,
"last_data_update": 1497384609000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"selectors": {
"hostgroup": "linux-servers"
},
"hostlist": {
"localhost": 8
}
}
}
Hope this helps!
EDIT 1 (To correspond with the question's EDIT 1):
What you're asking for isn't built in by default. You can use the above methods to grab the data for each host (but it sounds like you want it for each service), so again we will use the JSON API found at http://YOURNAGIOSURL/jsonquery.html to grab service data..
http://YOURNAGIOSURL/nagios/cgi-bin/statusjson.cgi?query=service&hostname=localhost&servicedescription=Current+Load
We'll get the following output (something similar, anyway):
{
"format_version": 0,
"result": {
"query_time": 1497875258000,
"cgi": "statusjson.cgi",
"user": "nagiosadmin",
"query": "service",
"query_status": "released",
"program_start": 1497800686000,
"last_data_update": 1497875255000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"service": {
"host_name": "localhost",
"description": "Current Load",
"plugin_output": "OK - load average: 0.00, 0.00, 0.00",
"long_plugin_output": "",
"perf_data": "load1=0.000;5.000;10.000;0; load5=0.000;4.000;6.000;0; load15=0.000;3.000;4.000;0;",
"max_attempts": 4,
"current_attempt": 1,
"status": 2,
"last_update": 1497875255000,
"has_been_checked": true,
"should_be_scheduled": true,
"last_check": 1497875014000,
"check_options": 0,
"check_type": 0,
"checks_enabled": true,
"last_state_change": 1497019191000,
"last_hard_state_change": 1497019191000,
"last_hard_state": 0,
"last_time_ok": 1497875014000,
"last_time_warning": 1497019191000,
"last_time_unknown": 0,
"last_time_critical": 1497018891000,
"state_type": 1,
"last_notification": 0,
"next_notification": 0,
"next_check": 1497875314000,
"no_more_notifications": false,
"notifications_enabled": true,
"problem_has_been_acknowledged": false,
"acknowledgement_type": 0,
"current_notification_number": 0,
"accept_passive_checks": true,
"event_handler_enabled": true,
"flap_detection_enabled": true,
"is_flapping": false,
"percent_state_change": 0,
"latency": 0,
"execution_time": 0,
"scheduled_downtime_depth": 0,
"process_performance_data": true,
"obsess": true
}
}
}
The most important line for what you're trying to do (as far as I understand it) is the perfdata line:
"perf_data": "load1=0.000;5.000;10.000;0; load5=0.000;4.000;6.000;0; load15=0.000;3.000;4.000;0;",
This is the data you'd use to generate whatever custom metrics report you're trying to generate.
Keep in mind this is something that is sort of built in to Nagios XI (not in an exportable format like you're requesting) but the metrics component does allow you to easily drill down and take a look at some metric specific data.
Hope this helps!

Related

How to get catalog search results by keywords via Amazon SP API that like Amazon website search results?

First method "listCatalogItems" produces correct results but limits max 10 ASINs. And now this method is deprecated.
Other method "searchCatalogItems" produces INcorrect random results.
fyi listCatalogItems says it's deprecated but it still works
I am getting correct results when I use searchCatalogItems. Here is my postman call: https://sellingpartnerapi-na.amazon.com/catalog/2022-04-01/items?marketplaceIds=ATVPDKIKX0DER&keywords=samsung
and part of my results:
{
"numberOfResults": 54592886,
"pagination": {
"nextToken": "9HkIVcuuPmX_bm51o3-igBfN45pxW4Ru7ElIM6GCECYCuXJKzT26f-3Tfs1Ro3IhelNA74VxDMJwt_JvE7qiRh0loZTzTpEBWUbZ8HB0T4ttV8cFw4xYQ4RMUzdY_udbnvAHOHCcZcycn0nW8RotZh1l1vj7KQoFIa7pWiOPHyaYWP7sBE9Fg7cGN2wE0an5ePw96h6ZL7m6olRxFOcqTWNanEVRjipq"
},
...
"items": [
{
"asin": "B09YN4W5C1",
"summaries": [
{
"marketplaceId": "ATVPDKIKX0DER",
"adultProduct": false,
"autographed": false,
"brand": "SAMSUNG",
"itemClassification": "VARIATION_PARENT",
"itemName": "SAMSUNG Jet Bot Robot Vacuum Cleaner",
"manufacturer": "SAMSUNG",
"memorabilia": false,
"packageQuantity": 1,
"tradeInEligible": false,
"websiteDisplayGroup": "home_display_on_website",
"websiteDisplayGroupName": "Home"
}
]
},
{
"asin": "B01AQ6OWAG",
"summaries": [
{
"marketplaceId": "ATVPDKIKX0DER",
"adultProduct": false,
"autographed": false,
"brand": "SAMSUNG",
"browseClassification": {
"displayName": "Remote Controls",
"classificationId": "10967581"
},
"itemClassification": "BASE_PRODUCT",
"itemName": "SAMSUNG TV Remote Control BN59-01199F by Samsung",
"manufacturer": "Samsung",
"memorabilia": false,
"modelNumber": "BN59-01199F",
"packageQuantity": 1,
"partNumber": "BN59-01199F",
"tradeInEligible": false,
"websiteDisplayGroup": "ce_display_on_website",
"websiteDisplayGroupName": "CE"
}
]
},

Imgur seems to be letting me search private images, have they screwed up?

According the imgur website:
When you upload a post to Imgur, you have two post privacy options: Hidden and Public.
A hidden post means that your post is not shared with the general Imgur community and can only be accessed via the URL. Hidden posts cannot be searched,...
Using only my client id (no OAuth), I hit the gallery search endpoint using the tag '#wow' (ie GET https://api.imgur.com/3/gallery/t/wow/). I get the same results as when visiting this publicly accessible page: https://imgur.com/t/wow.
Viewing the metadata for these images that I get from my api request, almost all (56 / 60) have a privacy value of "hidden"
Could be concerning, though wondered if an imgur expert could explain this before I try contact imgur about it.
Portion of the API json response:
{"data":
{"name": "wow",
"display_name": "wow",
"followers": 29719,
"total_items": 17077,
"following": false,
"is_whitelisted": true,
"background_hash": "QL9pTeJ",
"thumbnail_hash": nil,
"accent": "159559",
"background_is_animated": false,
"thumbnail_is_animated": false,
"is_promoted": false,
"description": "",
"logo_hash": nil,
"logo_destination_url": nil,
"description_annotations": {},
"items":
[{"id": "yWPI5rf",
"title": "Lake basement.",
"description": nil,
"datetime": 1656844974,
"cover": "IrUShgg",
"cover_width": 720,
"cover_height": 960,
"account_url": "DacianFalx",
"account_id": 64529075,
"privacy": "hidden", // 56 / 60 items have the same privacy value
"layout": "blog",
"views": 50557,
"link": "https://imgur.com/a/yWPI5rf",
"ups": 481,
"downs": 6,
"points": 475,
"score": 499,
"is_album": true,
"vote": nil,
"favorite": false,
"nsfw": false,
"section": "",
"comment_count": 116,
"favorite_count": 40,
"topic": nil,
"topic_id": nil,
"images_count": 1,
"in_gallery": true,
"is_ad": false,
"tags":
[{"name": "wow",
"display_name": "wow",
"followers": 29719,
"total_items": 17076,
"following": false,
"is_whitelisted": false,
"background_hash": "QL9pTeJ",
...omitted...

LLRP for Zebra FX7500 with llrpjs doesn't read tags

Using the llrpjs library for Node.js, we are attempting to read tags from the Zebra FX7500 (Motorola?). This discussion points to the RFID Reader Software Interface Control Guide pages 142-144, but does not indicate potential values to set up the device.
From what we can gather, we should issue a SET_READER_CONFIG with a custom parameter (MotoDefaultSpec = VendorIdentifier: 161, ParameterSubtype: 102, UseDefaultSpecForAutoMode: true). Do we need to include the ROSpec and/or AccessSpec values as well (are they required)? After sending the SET_READER_CONFIG message, do we still need to send the regular LLRP messages (ADD_ROSPEC, ENABLE_ROSPEC, START_ROSPEC)? Without the MotoDefaultSpec, even after sending the regular LLRP messages, sending a GET_REPORT does not retrieve tags nor does a custom message with MOTO_GET_TAG_EVENT_REPORT. They both trigger a RO_ACCESS_REPORT event message, but the tagReportData is null.
The README file for llrpjs lists "Vendor definitions support" as a TODO item. While that is somewhat vague, is it possible that the library just hasn't implemented custom LLRP extension (messages/parameters) support, which is why none of our attempts are working? The MotoDefaultSpec parameter and MOTO_GET_TAG_EVENT_REPORT are custom to the vendor/chipset. The MOTO_GET_TAG_EVENT_REPORT custom message seems to trigger a RO_ACCESS_REPORT similar to the base LLRP GET_REPORT message, so we assume that part is working.
It is worth noting that Zebra's 123RFID Desktop setup and optimization tool connects and reads tags as expected, so the device and antenna are working (reading tags).
Could these issues be related to the ROSPEC file we are using (see below)?
{
"$schema": "https://llrpjs.github.io/schema/core/encoding/json/1.0/llrp-1x0.schema.json",
"id": 1,
"type": "ADD_ROSPEC",
"data": {
"ROSpec": {
"ROSpecID": 123,
"Priority": 1,
"CurrentState": "Disabled",
"ROBoundarySpec": {
"ROSpecStartTrigger": {
"ROSpecStartTriggerType": "Immediate"
},
"ROSpecStopTrigger": {
"ROSpecStopTriggerType": "Null",
"DurationTriggerValue": 0
}
},
"AISpec": {
"AntennaIDs": [1, 2, 3, 4],
"AISpecStopTrigger": {
"AISpecStopTriggerType": "Null",
"DurationTrigger": 0
},
"InventoryParameterSpec": {
"InventoryParameterSpecID": 1234,
"ProtocolID": "EPCGlobalClass1Gen2"
}
},
"ROReportSpec": {
"ROReportTrigger": "Upon_N_Tags_Or_End_Of_ROSpec",
"N": 1,
"TagReportContentSelector": {
"EnableROSpecID": true,
"EnableAntennaID": true,
"EnableFirstSeenTimestamp": true,
"EnableLastSeenTimestamp": true,
"EnableSpecIndex": false,
"EnableInventoryParameterSpecID": false,
"EnableChannelIndex": false,
"EnablePeakRSSI": false,
"EnableTagSeenCount": true,
"EnableAccessSpecID": false
}
}
}
}
}
For anyone having a similar issue, we found that attempting to configure more antennas than the Zebra device has connected caused the entire spec to fail. In our case, we had two antennas connected, so including antennas 3 and 4 in the spec was causing the problem.
See below for the working ROSPEC. The extra antennas in the data.AISpec.AntennaIDs property were removed and allowed our application to connect and read tags.
We are still having some issues with llrpjs when trying to STOP_ROSPEC because it sends an RO_ACCESS_REPORT response without a resName value. See the issue on GitHub for more information.
That said, our application works without sending the STOP_ROSPEC command.
{
"$schema": "https://llrpjs.github.io/schema/core/encoding/json/1.0/llrp-1x0.schema.json",
"id": 1,
"type": "ADD_ROSPEC",
"data": {
"ROSpec": {
"ROSpecID": 123,
"Priority": 1,
"CurrentState": "Disabled",
"ROBoundarySpec": {
"ROSpecStartTrigger": {
"ROSpecStartTriggerType": "Null"
},
"ROSpecStopTrigger": {
"ROSpecStopTriggerType": "Null",
"DurationTriggerValue": 0
}
},
"AISpec": {
"AntennaIDs": [1, 2],
"AISpecStopTrigger": {
"AISpecStopTriggerType": "Null",
"DurationTrigger": 0
},
"InventoryParameterSpec": {
"InventoryParameterSpecID": 1234,
"ProtocolID": "EPCGlobalClass1Gen2",
"AntennaConfiguration": {
"AntennaID": 1,
"RFReceiver": {
"ReceiverSensitivity": 0
},
"RFTransmitter": {
"HopTableID": 1,
"ChannelIndex": 1,
"TransmitPower": 170
},
"C1G2InventoryCommand": {
"TagInventoryStateAware": false,
"C1G2RFControl": {
"ModeIndex": 23,
"Tari": 0
},
"C1G2SingulationControl": {
"Session": 1,
"TagPopulation": 32,
"TagTransitTime": 0,
"C1G2TagInventoryStateAwareSingulationAction": {
"I": "State_A",
"S": "SL"
}
}
}
}
}
},
"ROReportSpec": {
"ROReportTrigger": "Upon_N_Tags_Or_End_Of_AISpec",
"N": 1,
"TagReportContentSelector": {
"EnableROSpecID": true,
"EnableAntennaID": true,
"EnableFirstSeenTimestamp": true,
"EnableLastSeenTimestamp": true,
"EnableTagSeenCount": true,
"EnableSpecIndex": false,
"EnableInventoryParameterSpecID": false,
"EnableChannelIndex": false,
"EnablePeakRSSI": false,
"EnableAccessSpecID": false
}
}
}
}
}

Cant find reference in Mongo DB documentation

I have been struggling with MongoDB documentation for some time now. I want to know what will method returns and their definitions for each field. It's just that it's not on their documentation
For example I want to know what will db.collection.deleteMany() returns
The documentation does not tell you what will it return when it succeeded.
To overcome this I thought I can just know it by myself by just returning trying it and return the raw result from the db.collection.deleteMany() method
and I there you got the result
{
"result": {
"n": 32,
"ok": 1
},
"connection": {
"_events": {},
"_eventsCount": 4,
"id": 1,
"address": "127.0.0.1:27017",
"bson": {},
"socketTimeout": 360000,
"monitorCommands": false,
"closed": false,
"destroyed": false,
"lastIsMasterMS": 2
},
"deletedCount": 32,
"n": 32,
"ok": 1
}
But then I realized I don't know what those fields definition
What's result.n? What's result.ok ? What's connection._events?
Am I doing it wrong how will I find those definitions please help thanks
I just had to go to the API reference for the particular driver I was using and not to the method references.
For Node.js here is the documentation for API references.

Remove properties related to Sharepoint from raw odata response

I am using Sharepoint REST API to get/modify data in Sharepoint from NodeJS.
I am getting odata response from Sharepoint REST API and everything is working as expected.
Except one thing.
Currently I am getting response from Sharepoint REST API as below
{
"odata.metadata": "https://test.sharepoint.com/_api/$metadata#SP.ApiData.Lists",
"value": [
{
"odata.type": "SP.List",
"odata.id": "https://test.sharepoint.com/_api/Web/Lists(guid'sample-guid')",
"odata.etag": "\"6\"",
"odata.editLink": "Web/Lists(guid'sample-guid')",
"AllowContentTypes": true,
"BaseTemplate": 160,
"BaseType": 0,
"ContentTypesEnabled": true,
"CrawlNonDefaultViews": false,
"Created": "2015-05-19T11:13:46Z",
"DefaultContentApprovalWorkflowId": "00000000-0000-0000-0000-000000000000",
"Description": "Use this list to track access requests to a site or uniquely permissioned items in the site.",
"Direction": "none",
"DocumentTemplateUrl": null,
"DraftVersionVisibility": 0,
"EnableAttachments": false,
"EnableFolderCreation": false,
"EnableMinorVersions": false,
"EnableModeration": false,
"EnableVersioning": true,
"EntityTypeName": "AccessRequests",
"FileSavePostProcessingEnabled": false,
"ForceCheckout": false,
"HasExternalDataSource": false,
"Hidden": true,
"Id": "sample-id",
"IrmEnabled": false,
"IrmExpire": false,
"IrmReject": false,
"IsApplicationList": false,
"IsCatalog": false,
"IsPrivate": false,
"ItemCount": 1,
"LastItemDeletedDate": "2015-05-19T11:13:46Z",
"LastItemModifiedDate": "2015-08-04T06:57:22Z",
"ListItemEntityTypeFullName": "SP.Data.AccessRequestsItem",
"MajorVersionLimit": 0,
"MajorWithMinorVersionsLimit": 0,
"MultipleDataList": false,
"NoCrawl": true,
"ParentWebUrl": "/",
"ParserDisabled": false,
"ServerTemplateCanCreateFolders": true,
"TemplateFeatureId: "sample-id",
"Title": "Test Title"
}, {
........
}]
}
In the above response I am getting fields which are related to Sharepoint System along with fields I want.
for ex: odata.type, odata.id, AllowContentTypes, BaseTemplate etc.
How do I get the fields which I required but not the other Sharepoint related fields.
Can anybody help ?
Thanks
For that purpose you could utilize $select query option (follow OData Version 2.0 for a more details).
Regarding odata.type and odata.id properties, since they are part
of metadata properties, you just need to specify the proper Accept
header in order to request them (eg: accept:
application/json;odata=minimalmetadata). For a more details follow JSON
Light support
in REST SharePoint API released article.
The following example returns a specific set of List resource properties such as AllowContentTypes and BaseTemplate:
Endpoint URI: https://contoso.sharepoint.com/_api/web/lists?$select=AllowContentTypes,BaseTemplate
Accept: application/json; odata=minimalmetadata
Method: GET
Result
{
"d": {
"results": [
{
"__metadata": {
"id": "https://contoso.sharepoint.com/_api/Web/Lists(guid'82dcfcc5-e58c-4610-b4c3-589a7228e912')",
"uri": "https://contoso.sharepoint.com/_api/Web/Lists(guid'82dcfcc5-e58c-4610-b4c3-589a7228e912')",
"etag": "\"0\"",
"type": "SP.List"
},
"AllowContentTypes": true,
"BaseTemplate": 125
},
//...
]
}
}

Resources