Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media definition in zabbix and log trace for debug #3

Closed
pizzulicchio opened this issue Jul 23, 2015 · 14 comments
Closed

Media definition in zabbix and log trace for debug #3

pizzulicchio opened this issue Jul 23, 2015 · 14 comments

Comments

@pizzulicchio
Copy link

zabbixmedia
Hi,
What have i to insert into media configuration settings of zabbix, into "send to" field ?

The telephone number of recipient or what ?
Can you post a screenshot or improve the documentation ?

and.... should be possible implement a sort of debug output of your script ?
thank you very much! your idea to use telegram for notification is fantastic!

@ableev
Copy link
Owner

ableev commented Jul 23, 2015

You should use nickname without "@" symbol.
If your login is "@ableev" -> "ableev".
Once you send something to bot, alert script will save your chatid.

Ok, I will improve the documentation and will try to add debug. But. You can test notification right in command line on zabbix server. I should give you an example :) I will.

@pizzulicchio
Copy link
Author

have you got some tips for me?
i have used my nickname in "send to" field but no notification arrive.
how it's possible to debug?

@ableev
Copy link
Owner

ableev commented Jul 28, 2015

Here my part of step-by-step solution on pure VPS.

Clone repo

git clone git@github.com:ableev/Zabbix-in-Telegram.git
cd Zabbix-in-Telegram/

create zabbix user

and give him read-only access for all hosts / groups

create telegram bot, get token for it

I think you can do it if you are using the Telegram

fill in tg_vars.cfg

Clone tg_vars.cfg.example and change it. Use your TG api key and login/password for zabbix user, i.e.:

TG_KEY="101740052:AAEY2T_R7IJD_eYYPMDmoz80GKdqyyL8DCY"
ZBX_TG_PREFIX="zbxtg" 
ZBX_SERVER="http://zabbix.r1.zabbix.pro"
ZBX_API_USER="zbxapiusr886f4ec8dfefb88a94f40beaa88b26fa" 
ZBX_API_PASS="886f4ec8dfefb88a94f40beaa88b26fa886f4ec8dfefb88a94f40beaa88b26fa"
CURL="curl -s" 

Write something to bot

anything, literally.

Use your username without "@" symbol for test message

$ ./zbxtg.sh ableev test
{"ok":true,"result":{"message_id":4154,"from":{"id":321,"first_name":"Zabbix Bot","username":"Bot"},"chat":{"id":123,"first_name":"Ilya","last_name":"A","username":"ableev"},"date":1438123297,"text":"test\n\n--"}}

If it fails, you will see telegram api errors.


And if you didn't get any errors, maybe there are some mistakes in media/actions configuration in Zabbix.

@pizzulicchio
Copy link
Author

ok, i'm going ahead... now i'm be able to receive telegram message with correct format data but i have no picture of the graph.

I receive an image with written : ERROR: No items definied.

screenshot_2015-07-29-01-18-28

Why ?

( thank you very much for your patience )

@ableev
Copy link
Owner

ableev commented Jul 29, 2015

Could you please show me configuration of your action?

@pizzulicchio
Copy link
Author

Sure:
action
Here a screen of Event in zabbix
( graph id seems to not been fetched )
event

ableev pushed a commit that referenced this issue Jul 29, 2015
@ableev
Copy link
Owner

ableev commented Jul 29, 2015

I added new branch, could you, please, pull the latest code and checkout branch to "issues-3".
Run zbxtg.sh with your data,

./zbxtg.sh "pizzulicchio" "PROBLEM test test test" "Last  value
zbxtg;graphs
zbxtg;graphs_period=10800
zbxtg;itemid:23924
zbxtg;title:Test test"

Note that zbxtg; strings must be on separate lines.
It will print URL for zabbix web interface, you can open it in your browser. Is it valid or not?

@pizzulicchio
Copy link
Author

Sure it's valid url, and itìs browseable.
Here for you the output.
debug

ableev pushed a commit that referenced this issue Jul 29, 2015
@ableev
Copy link
Owner

ableev commented Jul 29, 2015

Looks like your zabbix's URL is different from config.
I've just added -L option for curl. Could you pull the latest code and test again?

@ableev
Copy link
Owner

ableev commented Jul 30, 2015

@pizzulicchio did that help?

@pizzulicchio
Copy link
Author

Something is wrong.
the output is:

debug2

@nuved
Copy link

nuved commented Aug 9, 2015

I get this error, when I change method to image:

<!doctype html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
        <title>Zabbix</title>
        <meta name="Author" content="Zabbix SIA" />
        <meta charset="utf-8" />
        <link rel="shortcut icon" href="images/general/zabbix.ico" />
<link rel="stylesheet" type="text/css" href="styles/default.css" />
<link rel="stylesheet" type="text/css" href="styles/color.css" />
<link rel="stylesheet" type="text/css" href="styles/icon.css" />
<link rel="stylesheet" type="text/css" href="styles/blocks.css" />
<link rel="stylesheet" type="text/css" href="styles/pages.css" />
<link rel="stylesheet" type="text/css" href="styles/themes/originalblue/main.css" />
<script>var PHP_TZ_OFFSET = 16200;</script><script src="js/browsers.js"></script>
<script src="jsLoader.php?ver=2.4.5&amp;lang=en_GB&showGuiMessaging=1"></script>
</head>
<body class="originalblue">
<div id="message-global-wrap"><div id="message-global"></div></div>
<div class="login">
    <div id="glow">
        <div class="loginForm">
            <div style="position: relative; color: #FFF; height: 100%;">
                <!-- Help & Support -->
                <div style="position: absolute; top: 0px; right: 10px;">
                    <a class="highlight" href="http://www.zabbix.com/documentation">Help</a>
                    &nbsp;|&nbsp;
                    <a class="highlight" href="https://support.zabbix.com">Support</a>
                </div>

                <!-- Copyright -->
                <div style="float: left; width: 250px; height: 100%;">
                    <div style="position: absolute; top: 39%; left: 30px;" class="loginLogo"></div>
                    <div style="position: absolute; bottom: 2px;">
                            <span class="bold textwhite" style="margin: 0 0 4px 4px; font-size: 0.9em;">
                                Zabbix 2.4.5 Copyright 2001-2015 by Zabbix SIA                          </span>
                    </div>
                </div>

                <!-- Login Form -->
                <div style="height: 100%; padding-top: 58px; padding-right: 40px; margin-left: 275px;">
                    <div style="float: right;">
                        <form action="index.php" method="post">
                            <input type="hidden" name="request" class="input hidden" value="" />
                            <ul style="list-style-type: none;">
                                <li style="padding-right: 6px; height: 22px;">
                                    <div class="ui-corner-all textwhite bold" style="padding: 2px 4px; float: right; background-color: #D60900; visibility: visible" >
                                        <span class="nowrap">Account is blocked for 18 seconds</span>
                                    </div>
                                </li>
                                <li style="margin-top: 10px; padding-top: 1px; height: 22px; width: 265px; white-space: nowrap;" >
                                    <div class="label">Username</div><input type="text" id="name" name="name" class="input" />
                                </li>
                                <li style="margin-top: 10px; padding-top: 1px; height: 22px; width: 265px; white-space: nowrap;" >
                                    <div class="label">Password</div><input type="password" id="password" name="password" class="input"/>
                                </li>
                                <li style="margin-top: 8px; text-align: center;">
                                    <input type="checkbox" id="autologin" name="autologin" value="1"  />
                                    <label for="autologin" class="bold" style="line-height: 20px; vertical-align: top;">
                                        Remember me for 30 days                                 </label>
                                    <div style="height: 8px;"></div>
                                    <input type="submit" class="input jqueryinput" name="enter" id="enter" value="Sign in" />
                                                                            <span style="margin-left: 14px;">
                                                <a class="highlight underline" href="dashboard.php">Login as Guest</a>
                                            </span>
                                                                    </li>
                            </ul>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery('body').css('background-color', '#E8EAEF');
        jQuery('#enter').button();
        jQuery('#name').focus();
    });
</script>
<script type="text/javascript">
    jQuery(document).ready(function() {



        // the chkbxRange.init() method must be called after the inserted post scripts and initializing cookies
        cookie.init();
        chkbxRange.init();
    });
</script>
</body>
</html>
{"ok":false,"error_code":400,"description":"Error: PHOTO_INVALID_DIMENSIONS"}%      

from terminal i ran this command for testing it...

./zbxtg.sh "nuved" "PROBLEM test test test" "Last  value
zbxtg;graphs
zbxtg;graphs_period=10800
zbxtg;itemid:65440
zbxtg;title:Test test"

@nuved
Copy link

nuved commented Aug 10, 2015

i find the problem...
my password is so complicated and then it cant login to api zabbix suscessfully! i change my password and now everything is ok:D thx man

@ableev ableev closed this as completed in aab0a75 Dec 16, 2015
@ableev
Copy link
Owner

ableev commented Dec 16, 2015

Probably that commit will fix the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants