I2Mobile: Difference between revisions

From Coolscript
Jump to navigation Jump to search
(Created page with "'''Welcome to Coolscript''' These are just a few scripts which you may use for your IT-System purposes. This site is new and more scripts will follow soon. {| | Logrotation...")
 
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Welcome to Coolscript'''


i2Mobile (beta) is a lightweight web interface for Icinga2, designed for mobile clients, running on Apache, this is based on the API (Rest) interface of [https://www.icinga.org/ Icinga2].<br>
The aim of this is to have a simple, easy and fast client for mobile phones.<br><br>
{|align=right
|__TOC__
|}
'''Features'''
*Use the Icinga2 API to retrieve the status - no more use of status.cgi (nagios/icinga1)
*Fast and bandwidth friendly (less data)
*Display hosts and services with the state of error, warning and ok
*Mobile silence
**Hide hosts and services whenever they have been acknowledged
**Hide hosts and services which state is unknown
**Hide host and services by custom attributes (optional)


These are just a few scripts which you may use for your IT-System purposes. This site is new and more scripts will follow soon.
<br>
=Requirements=
<br>
* Linux, Apache and Perl
* Access to the already existing Icinga2 API Host
<br>


{|
=Screenshots=
| Logrotation and file archive management script: || '''[[Logd]]'''
<br><br>
|-
{| style="width: 50%;"
| Eventlog to Firewall script for Windows 2008: || '''[[Eventlog to Firewall]]'''
|style="width:40%; vertical-align: top;"|
|-
*'''All hosts and services are running'''
| Authentication and Syslog to Firewall script for Linux: || '''[[Syslog_to_Firewall]]'''
[[image:I2mobile-allgood.png|320px|left]]
|-
|style="width:40%; vertical-align: top;"|
| PSAD to Iptables: || '''[[psad2ipt]]'''
*'''Warnings present'''
|-
[[image:I2mobile-srvwarn.png|320px|left]]
| Scheduled Task for Windows: || '''[[Scheduled Task for Windows]]'''
|}
|-
| Spamassassin Plugin for Geo purposes: || '''[[GeoMailSearch]]'''
|-
| Icinga2 Web Interface for Smartphones || '''[[i2Mobile]]'''
|-
| Autoresponse for Sendmail || '''[[Autoresponse]]'''
|-
| Raspberry Projects || '''[[RaspberryProjects]]'''
|-


<br><br>
{| style="width: 50%;"
|style="width:40%; vertical-align: top;"|
*'''Critical Errors'''
[[image:I2mobile-srvandhosterror.png|320px|left]]
|style="width:40%; vertical-align: top;"|
*'''Warnings and Crticals'''
[[image:I2mobile-srvandhostwarnanderror.png|320px|left]]
|}


<br><br>
{| style="width: 50%;"
|style="width:40%; vertical-align: top;"|
*'''Service List'''
[[image:I2mobile-srvlist.png|320px|left]]
|style="width:40%; vertical-align: top;"|
*'''Service Detail'''
[[image:I2mobile-srvdetail.png|320px|left]]
|}
|}


<br><br>
<br><br>
=Installation=
'''Note: The scripts has been tested on Debian 8 with Apache 2.4'''
*Get the tar file from the link below
*Copy the entire web directory to your www root, in this example /var/www/i2mobile
*Make your Apache user (eg www-data) owner of the new www directory and files
*Copy the configuration example to /etc/i2mobile.xml
*Copy the web config template to /etc/apache2/sites-available/i2mobile.domain.com.conf
**Configure and rename the web config to your requriements
<br>
*Setup Apache, enable the web site and switch on the cgi module, example:
a2ensite i2mobile.domain.com
a2enmod cgi
*Install the required perl modules using MCPAN:
# perl -MCPAN -e 'install REST::Client'
# perl -MCPAN -e 'install JSON'
# perl -MCPAN -e 'install MIME::Base64'
# perl -MCPAN -e 'install Data::Dumper'
# perl -MCPAN -e 'install Data::GUID'
=Configure i2Mobile=
Configuration is done in /etc/i2mobile.xml. These are the minimum settings:


*'''IcingaHost='''URL and Port to the Icinga2 Host
*'''Password='''The password
*'''CookieAuthentication='''Optional authentication using a session cookie
*'''Contact='''Optional contact information
*'''URL='''=Optional Site URL


'''Example:'''
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
  <System
  IcingaHost="https://your.ip.here:5665"
  Password="user:123456789"
  CookieAuthentication="0"
  Contact="you@domain.com"
  URL="http://i2mobile.domain.com"></System>
</CONFIG>


*See [[Mail redirect hacks]]


Questions, feedback or recommendations are welcome, please use the
'''Thats it, setup is finsihed.'''
[[Special:Contact|Contact]] page to do this.
<br>
 
=Display options=
Services and hosts can be hided in i2Mobile, the idea is to show only important information and hide services and hosts which are not interested for the mobile user
*Service sample
apply Service "Something" {
  ...
  //this will hide the service from i2Mobile
  vars.is_ignore = "1"
}
*Host sample
apply Host "Something" {
  ...
  //this will hide the host from i2Mobile
  vars.is_ignore = "1"
}
 
=Authentication options=
Authentication can be established using the Apache htaccess options, however, there is the alternative option to work with session cookies which is '''less secure''' but<br>
allows the i2Mobile user to access the web quickly without prompting for authentication.<br>
The idea of session cookies is to create a GUID and then keep them local in i2mobile.xml and use it as reference for each web user.<br>
A helper page is available to add the session cookie to the client mobile browser, the mobile client should then receive a email or sms including the link to add the session cookie.<br>
'''Sample'''
*CookieID="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
*Link to add the session cookie to the client browser:
**http://i2mobile.domain.com/setsessioncookie.pl?id=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
**Client can now access the page without additional authentication
'''Full configuration sample'''
*i2mobile.xml
<Authentication
  Enabled="1"
  CookieID="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
  Name="John Public"
  MailTo="jp@domain.com"
  Expire="20180701"
</Authentication>
From the above sample it is possible to immediate disable the web access by setting Enabled to 0 or set the Expire to yesterday.<br>
You may also use a small helper tool called addsc.pl which is available within the web directory, this tool creates the GUID and Link for the mobile client.<br>
'''Debugging'''<br>
See the status page which is available to obtain the validly of the session cookie
*http://i2mobile.domain.com/env.pl
<br>
 
=Download=
<br>
{| style="width: 70%;"
|style="width:30%; vertical-align: top;"|
'''Download the script'''<br>
Version 1.0 - 16KB<br>
[[File:Download.png|60px|link=https://coolscript.org/download/scripts/i2mobile.1.0.tar.gz|Download]]
<br>
|style="width:70%; vertical-align: top;"|
<br>
|}




<br><hr><br>


''''PROJECT RECOMMENDATION:'''Add  a script to automatic white ip a dyndns address from iptables
'''Feedbacks or comments are very welcome, no matter which direction. Please drop a email to postmaster at coolscript.org'''

Latest revision as of 13:07, 4 March 2022

i2Mobile (beta) is a lightweight web interface for Icinga2, designed for mobile clients, running on Apache, this is based on the API (Rest) interface of Icinga2.
The aim of this is to have a simple, easy and fast client for mobile phones.

Features

  • Use the Icinga2 API to retrieve the status - no more use of status.cgi (nagios/icinga1)
  • Fast and bandwidth friendly (less data)
  • Display hosts and services with the state of error, warning and ok
  • Mobile silence
    • Hide hosts and services whenever they have been acknowledged
    • Hide hosts and services which state is unknown
    • Hide host and services by custom attributes (optional)


Requirements


  • Linux, Apache and Perl
  • Access to the already existing Icinga2 API Host


Screenshots



  • All hosts and services are running
  • Warnings present



  • Critical Errors
  • Warnings and Crticals



  • Service List
  • Service Detail





Installation

Note: The scripts has been tested on Debian 8 with Apache 2.4

  • Get the tar file from the link below
  • Copy the entire web directory to your www root, in this example /var/www/i2mobile
  • Make your Apache user (eg www-data) owner of the new www directory and files
  • Copy the configuration example to /etc/i2mobile.xml
  • Copy the web config template to /etc/apache2/sites-available/i2mobile.domain.com.conf
    • Configure and rename the web config to your requriements


  • Setup Apache, enable the web site and switch on the cgi module, example:
a2ensite i2mobile.domain.com
a2enmod cgi
  • Install the required perl modules using MCPAN:
# perl -MCPAN -e 'install REST::Client'
# perl -MCPAN -e 'install JSON'
# perl -MCPAN -e 'install MIME::Base64'
# perl -MCPAN -e 'install Data::Dumper'
# perl -MCPAN -e 'install Data::GUID'

Configure i2Mobile

Configuration is done in /etc/i2mobile.xml. These are the minimum settings:

  • IcingaHost=URL and Port to the Icinga2 Host
  • Password=The password
  • CookieAuthentication=Optional authentication using a session cookie
  • Contact=Optional contact information
  • URL==Optional Site URL

Example:

<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
 <System 
  IcingaHost="https://your.ip.here:5665" 
  Password="user:123456789" 
  CookieAuthentication="0" 
  Contact="you@domain.com" 
  URL="http://i2mobile.domain.com"></System>
</CONFIG>


Thats it, setup is finsihed.

Display options

Services and hosts can be hided in i2Mobile, the idea is to show only important information and hide services and hosts which are not interested for the mobile user

  • Service sample
apply Service "Something" {
 ...
 //this will hide the service from i2Mobile
 vars.is_ignore = "1"
}
  • Host sample
apply Host "Something" {
 ...
 //this will hide the host from i2Mobile
 vars.is_ignore = "1"
}

Authentication options

Authentication can be established using the Apache htaccess options, however, there is the alternative option to work with session cookies which is less secure but
allows the i2Mobile user to access the web quickly without prompting for authentication.
The idea of session cookies is to create a GUID and then keep them local in i2mobile.xml and use it as reference for each web user.
A helper page is available to add the session cookie to the client mobile browser, the mobile client should then receive a email or sms including the link to add the session cookie.
Sample

Full configuration sample

  • i2mobile.xml
<Authentication 
 Enabled="1" 
 CookieID="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" 
 Name="John Public" 
 MailTo="jp@domain.com" 
 Expire="20180701"
</Authentication>

From the above sample it is possible to immediate disable the web access by setting Enabled to 0 or set the Expire to yesterday.
You may also use a small helper tool called addsc.pl which is available within the web directory, this tool creates the GUID and Link for the mobile client.
Debugging
See the status page which is available to obtain the validly of the session cookie


Download


Download the script
Version 1.0 - 16KB
Download






Feedbacks or comments are very welcome, no matter which direction. Please drop a email to postmaster at coolscript.org